QEC with atom loss in decoding (cosmiq.qec)#
cosmiq.qec simulates quantum error correction when atoms can be lost. On neutral-atom
hardware a lost atom can be detected, so the decoder can be told where it happened. This
package shows how much a decoder gains from that signal: you pick a code, a noise level and a
decoder, and memory_experiment returns the logical error rate.
It needs the extra, pip install "cosmiq[qec]" (Stim and networkx), and import cosmiq never
imports it.
from cosmiq import qec
r = qec.memory_experiment(
"surface", d=5, noise=qec.Noise(p=1e-3, p_loss=0.01), shots=20_000, decoder="loss_aware", seed=1
)
r.logical_error_rate, r.sigma, r.heralds_per_shot # rate, standard error, lost atoms per shot
Comparing the two decoders#
The same seed gives the same shots, so the two decoders can be compared shot by shot:
noise = qec.Noise(p=1e-3, p_loss=0.02)
blind = qec.memory_experiment(
"repetition", d=3, noise=noise, shots=100_000, decoder="loss_blind", seed=1
)
aware = qec.memory_experiment(
"repetition", d=3, noise=noise, shots=100_000, decoder="loss_aware", seed=1
)
print(blind.logical_error_rate, aware.logical_error_rate)
only_blind = int((blind.failures & ~aware.failures).sum()) # shots only the blind one got wrong
only_aware = int((aware.failures & ~blind.failures).sum())
Tutorial 6 runs this, with a statistical test of the difference.
Codes#
Built in: Stim’s rotated surface code (
"surface") and repetition code ("repetition"), as memory experiments with as many rounds as the distance, at distance 3 or 5: the tested sizes. Any other distance is refused (QEC_DISTANCE), and so is a code that isn’t built in or registered (QEC_CODE).qec.code(name, d)gives the code object: its Stim circuit for a noise level (circuit(noise, rounds)), where atoms can be lost (erasure_locations()) and itsdistance.
Noise#
qec.Noise(p, p_loss=0, p_measure=p, p_reset=p, p_idle=p), each a probability in [0, 0.5):
Field |
What it is |
|---|---|
|
depolarising noise after every gate |
|
depolarising noise on the data qubits at the start of each round |
|
a flipped measurement |
|
a flipped reset |
|
the chance that an atom is lost, on every qubit in every round |
A lost atom is replaced at once, and a herald bit in the measurement record says where it happened; the replaced qubit then carries a random Pauli error (I, X, Y or Z, each a quarter of the time). The loss-aware decoder reads those heralds, and the loss-blind one ignores them.
From a device: a modelling choice#
qec.noise_from_device("cosmiq-ref-1") takes the noise levels from a device’s calibration and
its digital profile (qec.DEVICE_MAPPING lists each mapping):
Field |
Source |
|---|---|
|
the digital profile’s CZ depolarising rate |
|
the digital profile’s single-qubit depolarising rate |
|
the mean of the digital profile’s two readout error rates |
|
the calibration’s preparation error |
|
the calibration’s loss per sequence, used as a loss per qubit and round |
This is a modelling choice, not cosmiq-ref-1’s QEC performance. A device that lacks a value
the mapping reads is refused by name (QEC_CALIBRATION), never taken as 0; for no noise, use
qec.Noise(0). A device with no digital profile is refused (DIGITAL_DEVICE).
Decoders#
Both decoders are minimum-weight perfect matching, written in cosmiq: "loss_blind" weighs
each possible error by how likely it is, and "loss_aware" also makes the errors at a lost
atom free to choose in that shot, since an error there is expected. The decoder is pure Python
on one core: fine for studies, slow next to compiled decoders.
The methods are published: Dennis et al., J. Math. Phys. 43, 4452 (2002); Delfosse and Zémor, Phys. Rev. Research 2, 033042 (2020); Wu, Kolkowitz, Puri and Thompson, Nat. Commun. 13, 4657 (2022), on erasure conversion in neutral atoms.
Your own codes and decoders#
A code is any object with distance, circuit(noise, rounds) and erasure_locations()
(qec.Code); a decoder is any object with decode(problem, detectors, erased) and
weight(problem, detectors, erased) (qec.Decoder). Register them by name, and
memory_experiment runs them like the built-in ones:
qec.register_code("mine", lambda d: MyCode(d)) # memory_experiment("mine", d=...)
qec.register_decoder("mine", MyDecoder) # memory_experiment(..., decoder="mine")
Codes beyond the built-in ones, such as qLDPC codes and their decoders, can plug in this way later.
Limits#
The same seed gives identical results only on the same Stim version and machine. There’s no persistent loss, no leakage, no qLDPC code, no compiled decoder and no QEC on the virtual QPU, and loss-aware matching is published work, not a new method. What was tested is in Claims and limits.