View on GitHub
Open this notebook in GitHub to run it yourself
- Get a logical noise model (a ready-made public one, or initialize your own).
- Model a quantum program in Qmod (a small Quantum Phase Estimation).
- Synthesize it to a quantum program.
- Export it to a Clifford+T circuit.
- Route the circuit onto a 3-D surface-code lattice.
- Visualize the routed program.
- Summarize resources, fidelity, and runtime across code distances.
The FT-engine steps (logical-noise initialization, routing, visualization, and total-error estimation) run on the Classiq backend and require an account with FT-engine access. For a conceptual overview see the Error Correction user guide; for the full API surface see the SDK reference.
Setup
- Get a logical noise model
- Use a ready-made public model (what we do here) — retrieve it by name with
get_logical_noise, no simulation required. - Initialize your own from a
PhysicalNoiseModelwithinitialize_logical_noise.
INITIALIZE_OWN_NOISE to True to run it once (the result is stored under your chosen name and reused afterwards).
See the Logical Noise user guide for more detail on public models, custom noise, and plotting.
logical_noise exposes the fitted logical error rates.
For example, plot the 1-qubit Clifford logical error as a function of the code distance — it drops exponentially, which is the whole point of error correction.



- Build the circuit in Qmod
T gate (eigenphase 1/8) into a 3-qubit register. QPE is a good FT example because it is naturally expressed in the Clifford+T gate set the surface code implements.
- Synthesize
Output:
Tip: You can also feed an externally prepared QASM string directly into the FT engine — see qasm_to_qmod in the SDK reference.
- Export to a Clifford+T circuit
export with a FaultTolerantTranspilationConfig decomposes the program into Clifford+T, approximating any rotations to within clifford_t_approximation_error.
- Route onto the surface-code lattice
route_circuit lowers the Clifford+T circuit onto a 3-D surface-code lattice — two spatial axes for the grid of surface-code patches and a third (z) axis for time, in error-correction cycles. It returns a TopologicalProgram describing where and when every operation happens.
See the Routing user guide for more information.
Output:
- Visualize the routed program
view_program renders the routed lattice as an interactive 3-D scene.
With show=True it is embedded directly in the notebook output, so you can orbit, zoom, and toggle between the surface-code and logical views inline.
For a tall circuit, restrict the rendered cycle range along the z (time) axis with start_cycle / end_cycle.
Tip: The viewer supports orbit, zoom, pan, toggling between surface-code and logical views, camera presets, cycle-range filtering, and saving to an HTML file. See the Visualization user guide for the full set of options.
- Resources, fidelity, and runtime
TopologicalProgram carries everything we need for a combined summary.
For each code distance we report the physical-qubit count (a distance-d surface-code patch uses a (d + 1) x (d + 1) qubit footprint, times the patch-grid footprint) and the estimated total logical error and fidelity from estimate_total_errors.
Larger distances suppress the error further, at the cost of more physical qubits. We also record how long the FT-engine steps took.
See the Total Error user guide for more on how the error estimate is computed.
Cleanup and next steps
If you initialized your own logical noise, remove it when you no longer need it. (Shared public models such aspublic/depolarize_1e-3 cannot be removed this way.)
From here you can scale up the circuit, sweep clifford_t_approximation_error to trade T-count against accuracy, or compare code distances to pick the smallest one that meets your target fidelity.
For the full API details see the SDK reference; for conceptual background and more examples see the Error Correction user guide.