Simulating Noisy Circuits
Every real quantum processor is coupled to its environment. Gates are imperfect, qubits leak energy, and stray fields shift phases. A noise model is a mathematical prescription that augments an ideal circuit with probabilistic error operations so that simulated statistics match measured hardware data.
From ideal to noisy: the insertion picture
The simplest simulation strategy is error insertion: after each ideal gate draw from the noise distribution and, if an error occurs, append the corresponding error gate. For a bit-flip channel with error probability this means appending with probability and doing nothing with probability .
Concretely, one simulation trajectory (or "shot") proceeds as:
- Initialise all qubits to .
- Apply each ideal gate in order.
- After each gate, sample whether an error occurred and, if so, insert the error gate.
- Measure and record the outcome bit-string.
Repeating for many shots produces a sampled distribution whose histogram approximates the true noisy output probabilities.
A worked example: bit-flip noise on a Bell-adjacent circuit
Consider a two-qubit circuit whose ideal action is
Measuring this ideal state yields the outcomes and each with probability .
Now suppose qubit 1 suffers a certain bit-flip error () after the gates. Inserting the Pauli on qubit 1 gives the noisy state
The measurement distribution shifts from to , each still with probability . The error is detectable: a classically expected distribution has no weight on or , so any observation in those bins signals a bit-flip on qubit 1.
Reading the sampled histogram
After running the noisy circuit for many shots the histogram shows:
| Outcome | Ideal probability | Noisy probability () | |---------|-------------------|---------------------------| | | | | | | | | | | | | | | | |
The error has shifted every outcome bit-string by flipping qubit 1. In a probabilistic noise model () all four bars would be non-zero, and a syndrome measurement (not a destructive readout) could diagnose the error without collapsing the encoded information.
From Kraus operators to circuit insertion
The bit-flip channel studied in an earlier lesson has Kraus operators
Each shot samples one of these operators: with probability the identity acts (no error), and with probability the Pauli acts (bit flip). The circuit-insertion picture is a direct Monte Carlo realisation of this Kraus decomposition.
For more complex noise models — such as depolarizing or amplitude-damping — the same principle applies: each Kraus operator is mapped to a circuit fragment, and the stochastic choice between fragments is sampled at run time.
Try it
Build the two-qubit noisy circuit described above. Apply to qubit 0, then inject a certain bit-flip error on qubit 1 by applying to qubit 1, then measure. The grader checks that the output distribution places equal weight on and .
Open the Probabilities tab: the bars for and should be absent, and the bars for and should each reach . That is the signature of a certain bit-flip error on qubit 1.
Sign in on the full site to ask questions and join the discussion.