Repository navigation
✨ Add error correction module with Shor and Steane logical circuit transpilers - #930
Felix-Gundlach wants to merge 279 commits into
Conversation
….com/emilkanic0909/MQT_Bench_ErrorCorrectionCodes into feature/ErrorCorrection_Verification # Conflicts: # tests/test_error_correction.py
…rection_SubMain # Conflicts: # src/mqt/bench/benchmark_generation.py
…lkanic0909/MQT_Bench_ErrorCorrectionCodes into feature/ErrorCorrection_Verification
…rCorrection_SubMain
…emilkanic0909/MQT_Bench_ErrorCorrectionCodes into feature/ErrorCorrection_SubMain
…c0909/MQT_Bench_ErrorCorrectionCodes into feature/ErrorCorrection_SubMain
…c0909/MQT_Bench_ErrorCorrectionCodes into feature/ErrorCorrection_SubMain
…c0909/MQT_Bench_ErrorCorrectionCodes into feature/ErrorCorrection_SubMain
+ early gate_counts.json, counts for steane are not yet correct
…nic0909/MQT_Bench_ErrorCorrectionCodes into feature/ErrorCorrection_MergePrep
simon1hofmann
left a comment
There was a problem hiding this comment.
The early return in get_benchmark_alg() now skips encoding when generate_mirror_circuit=True. A two-qubit GHZ mirror stays at 2 qubits with either encoding, instead of 26 for Steane or 34 for Shor. Please assign the mirror to qc rather than returning, then continue through the encoding block. A small regression test combining mirroring and encoding would catch this.
My bad. Good catch. |
…nic0909/MQT_Bench_ErrorCorrectionCodes into feature/ErrorCorrection_MergePrep
5091caf to
c6e296f
Compare
|
We fixed the problems with Clifford+T synthesis in #1081 and #1093. |
Thanks for info, We will try |
Signed-off-by: Felix Gundlach <67263641+Felix-Gundlach@users.noreply.github.com>
The EC transpiler now checks the Qiskit version, so the minimum stays at 2.2.3. - Qiskit 2.5.0 and newer: Qiskit's Clifford+T compilation with `approximation_degree=0.95` (unchanged output). - Older versions: each RZ rotation is replaced by Solovay-Kitaev at recursion degree 0 (at most 12 H/T/Tdg gates), with only RZ gates changed. The threshold is 2.5.0 instead of 2.4.2 because gridsynth in Qiskit 2.4.0–2.4.2 panics for about a third of rotation angles at this approximation degree. Only its default precision works there, and that makes encoded circuits 40–80x larger. The EC tests pass on every Qiskit release from 2.2.3 to 2.6.1.
|
Because I should've put this as a comment, not a commit message, in the first place: 🤖 AI text below 🤖 The EC transpiler now checks the Qiskit version, so the minimum stays at 2.2.3.
The threshold is 2.5.0 instead of 2.4.2 because gridsynth in Qiskit 2.4.0–2.4.2 panics for about a third of rotation angles at this approximation degree. Only its default precision works there, and that makes encoded circuits 40–80x larger. The EC tests pass on every Qiskit release from 2.2.3 to 2.6.1. |
…spiler_circuit_structure
…nic0909/MQT_Bench_ErrorCorrectionCodes into feature/ErrorCorrection_MergePrep
Signed-off-by: Felix Gundlach <67263641+Felix-Gundlach@users.noreply.github.com>
|
@simon1hofmann We no use different transpilation passes depending on qiskit version as requested. While not quite the same as the switch quoted in #930 now on main, they work well with the tests. Some oddities may remain™. Apart from the currently failing test case ("changes can be cleanly merged"...), is there anything else we can still help with? |
|
Hey @Felix-Gundlach A few things still need fixing before merging:
Please also finish the documentation cleanup:
|
Description
Adds an error correction module that encodes benchmark circuits into logical circuits using the 7-qubit Steane code or the 9-qubit Shor code. Encoding is exposed via a new
encodingparameter onget_benchmark()andget_benchmark_alg(), accepting"","steane", or"shor":error_correction/ec_transpiler.pyholds the code-agnosticECTranspilerbase class. It decomposes the circuit into the code's basis, replaces every logical qubit with a data register plus syndrome ancillas, substitutes each gate by its logical equivalent, and appends a syndrome extraction and correction cycle after every logical operation.SteaneTranspilerandShorTranspileronly declare their code parameters and supply the encoding, decoding, and syndrome circuits.Since MQT Bench targets circuit structure rather than exact behaviour, gates without a fault-tolerant transversal realization (
t/tdgfor both codes, plushfor Shor) are emitted as opaque placeholder instructions named{code}_ideal_logical_{gate}rather than as full magic-state constructions.The encoding, decoding, syndrome, and correction circuits shared with the existing
seven_qubit_steane_codeandshors_nine_qubit_codebenchmarks moved into a newcomponentsmodule.Dependencies: requires Qiskit >= 2.4.0 (up from 2.0.0) for the transpilation to the Clifford+T basis. Noted in the changelog and the upgrade guide.
Limitations: encoding is only applied at
BenchmarkLevel.ALG(aUserWarningis raised otherwise), control-flow operations are rejected with aValueError, and basis decomposition usesapproximation_degree=0.95, so encoded circuits are approximations.AI assistance: this description was drafted by an LLM from the current diff and reviewed by us. Various docstrings were generated by an LLM and reviewed & edited by us.
Checklist
If PR contains AI-assisted content:
🤖 *AI text below* 🤖(titles are exempt).