✨ Add error correction module with Shor and Steane logical circuit transpilers - #930
Conversation
small formatting changes
…de' into feature/ErrorCorrection_Verification
+ Added logging functionality
Signed-off-by: Felix Gundlach <67263641+Felix-Gundlach@users.noreply.github.com>
@Felix-Gundlach Hi Felix, are you implementing lastest Patrick's notes or general quality improvements? |
Both commented features are general quality improvements. I've also quitely fixed and resolved some of the requested changes, like reverting our .gitignore changes. |
…m/emilkanic0909/MQT_Bench_ErrorCorrectionCodes into feature/ErrorCorrection_MergePrep
…m/emilkanic0909/MQT_Bench_ErrorCorrectionCodes into feature/ErrorCorrection_MergePrep
Good point, lets raise an error for now. Since (measurement-based classical) control flow is already unsupported and regular benchmarks only use terminal measurements, re-encoding is not that necessary for now (only exception could be bv(dynamic=True)). |
|
@flowerthrower Hi, I have fixed some issues because of gadget name in order to fix pipeline, But I have noticed that some synthesis for QFT in different qiskit version is different, therefore amount of instructions grouped by types isnt exhaustive anymore. What should we do? I am trying to made another structure for our tests for qft |
|
@flowerthrower So for QFT we have made that it simple checks existence of some gate types and not exact amount. So all pipelines (excepting the codecov/patch) are green now. E.g. Y gates and Z logical gates arent tested anywhere, and also generation without syndrome isnt tested. So we can add them when you confirm. Since our current tests are based on your project description, that we take bv, graphstate and qft. Maybe we could add more tests, for another circuits and parameters. Which new tests do you recommend to add? to make codecov happy |
|
Hi @emilkanic0909, thanks for your observation, the updated QFT test looks fine; checking gate presence instead of version-dependent counts resolves that issue. For the remaining coverage, please do not add more benchmark circuits just for Codecov. Instead:
This should cover the meaningful functionality without introducing artificial tests. |
Summary
This PR introduces a dedicated Error Correction Module for MQT Bench. It adds two high-level transpilers that encode standard benchmark circuits into fault-tolerant logical circuits using the 7-qubit Steane code and the 9-qubit Shor code, respectively. The module is designed to integrate cleanly with the existing
benchmark_generationAPI.Changes
New files
src/mqt/bench/error_correction/steane_transpiler.py—SteaneTranspilerclass: encodes logical qubits into 7-qubit Steane blocks, applies transversal Clifford gates (H, X, Z, S, CX, CZ), and handles T-gates via magic state injection with ancilla teleportation.src/mqt/bench/error_correction/shor_transpiler.py—ShorTranspilerclass: encodes logical qubits into 9-qubit Shor blocks, implements the full logical Clifford gate set (including the non-transversal H via bit-swap), and supports S- and T-gates via magic state teleportation gadgets.tests/test_error_correction.py— pytest suite covering gate-level equivalence (via MQT QCEC), correctness under injected bit- and phase-flip errors (via Hellinger fidelity with Aer), and circuit structure validation against pre-computed gate counts for GHZ, Bernstein–Vazirani, graph state, and QFT benchmarks.How it works
Both transpilers follow the same three-phase pipeline:
QFTGate) are first decomposed into the supported basis set{H, X, Z, S, T, CX, CZ}.if_testfeature.T-gates, which are non-transversal, are handled via a teleportation gadget: a magic state ancilla block is prepared, a logical CNOT is applied from the data qubit to the ancilla, the ancilla is decoded and measured, and a conditional logical S correction is applied on outcome 1.
Testing
mqt.qcecfor all single- and two-qubit Clifford gates.gate_counts.jsonfor qubit counts ranging from 3 to 9 across all supported algorithms.Notes
add_syndromes=Falsefor lightweight structural or equivalence checks.Checklist
If PR contains AI-assisted content:
Assisted-by: [Model Name] via [Tool Name]footer.