Skip to main content

View on GitHub

Open this notebook in GitHub to run it yourself
This advanced tutorial walks a circuit through the full Classiq Fault-Tolerance (FT) Engine pipeline, end to end:
  1. Get a logical noise model (a ready-made public one, or initialize your own).
  2. Model a quantum program in Qmod (a small Quantum Phase Estimation).
  3. Synthesize it to a quantum program.
  4. Export it to a Clifford+T circuit.
  5. Route the circuit onto a 3-D surface-code lattice.
  6. Visualize the routed program.
  7. 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

  1. Get a logical noise model
On error-corrected hardware each logical qubit is a patch of many physical qubits protected by a surface code. A logical noise model captures how the logical error rate of each fundamental operation shrinks as the code distance grows, given the hardware’s physical noise. There are two ways to get one:
  • 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 PhysicalNoiseModel with initialize_logical_noise.
This runs a Monte-Carlo simulation on the backend and can take up to ~1 hour, so it is shown below but left off by default. Flip 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.
The retrieved 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.
output The 1-qubit Clifford logical error is essentially a memory experiment — it measures how well the surface code preserves a logical qubit over one round of stabilizer measurements under the given noise model. The exponential suppression with code distance is the hallmark of a well-below-threshold error-correcting code.
output A CNOT in the surface code is performed via lattice surgery — merging and splitting patches along a bus of ancilla patches. Of the six Pauli error channels (IX, XI, XX, IZ, ZI, ZZ), two — IX and ZI — have correlation surfaces that span the entire bus. Their error rate therefore grows with the number of patches between control and target: the longer the CNOT, the more physical qubits participate, and the more opportunities for error. The other four channels are bounded by the fixed-size towers at each endpoint and do not scale with bus length.
output

  1. Build the circuit in Qmod
Any circuit works; here we use a small Quantum Phase Estimation that reads the phase of a 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.

  1. 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.

  1. Export to a Clifford+T circuit
Routing expects a transpiled Clifford+T circuit. export with a FaultTolerantTranspilationConfig decomposes the program into Clifford+T, approximating any rotations to within clifford_t_approximation_error.

  1. 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:

  1. 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.

  1. Resources, fidelity, and runtime
The routed 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 as public/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.