Repository navigation
✨ Add error correction module with Shor and Steane logical circuit transpilers - #930
Felix-Gundlach wants to merge 293 commits into
Conversation
…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
…c0909/MQT_Bench_ErrorCorrectionCodes into feature/ErrorCorrection_SubMain
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:
|
Signed-off-by: Felix Gundlach <67263641+Felix-Gundlach@users.noreply.github.com>
Added various new tests regarding metadata generation and pass-through on encoded circuits
|
Alright. The PR description has been updated and the requested changes from #930 (comment) implemented by 46394a0. The tests also seem to be passing. @simon1hofmann Because I felt like the number of tests had grown a bit bloated, I had claude consolidate them a little. Same thing goes for the docstrings, which had grown inconsistent and needlessly precise over the different iterations. I hope that's fine? Next up is porting changes in the components from main to their new location in this branch and maybe going over the PR description again. Anything else I can help with? |
…pers and applied the same to steane helpers
|
🤖 AI text below 🤖 Synced the moved Shor's code and Steane code components with
|
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.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).