4

An erasure error is a heralded error that completely destroys a qubit (e.g. resets it or maximally mixes it). The qubit is gone but you are told it's gone. How do I simulate this kind of error using stim?

Craig Gidney
  • 44,299
  • 1
  • 41
  • 116

3 Answers3

6

I'm also recently trying to find QEC decoders that supports the heralded errors in stim, but unfortunately I couldn't find any (as of Feb 2025). Since this feature is commonly desired in stim simulation and the workaround is usually too slow (e.g., constructing a new decoder in every repetition), I implemented support of efficient heralded errors in the MWPF decoder in version 0.2.8. Please see the README file of how to use it in stim: https://github.com/yuewuo/mwpf

Please note that you have to put in the circuit when constructing the decoder, like SinterMWPFDecoder().with_circuit(...your_circuit) because the standard stim simulation workflow only gives the decoder a DEM (detector error model) which already wipes out the heralded error information.

To play with erasure decoding, I also implemented a CLI tool that allows you to convert certain percentage of the noise into heralded noise. For example, use pip install mwpf[stim]>=0.2.8 qec-lego-bench>=0.0.4.

# rotated surface code with 90% of the Pauli noise converted into heralded errors
python3 -m qec_lego_bench logical-error-rate 'rsc(d=3,p=0.01)' --noise2 'erasure_conversion(rate=0.9)' --num-workers=10 --max-shots=1_000_000_000 --decoder 'mwpf(pass_circuit=1)'

this still works, but much slower and less accuracy, because the heralded detector are treated like normal syndrome detector

python3 -m qec_lego_bench logical-error-rate 'rsc(d=3,p=0.01)' --noise2 'erasure_conversion(rate=0.9)' --num-workers=10 --max-shots=1_000_000_000 --decoder 'mwpf'

this will first add the erasure converted heralded noise, and then remove all the detectors so the decoder won't know any information about the heralded detectors

python3 -m qec_lego_bench logical-error-rate 'rsc(d=3,p=0.01)' --noise2 'erasure_conversion(rate=0.9)' --noise3 'remove_all_herald_detectors' --num-workers=1 --max-shots=1_000_000_000 --decoder 'mwpf(pass_circuit=1)'

If you already have a stim Circuit that you would like to try erasure conversion on, you can also pass in the circuit with

python3 -m qec_lego_bench logical-error-rate 'file(filepath=./some_noisy_circuit.stim)' ...
Yue Wu
  • 61
  • 1
  • 4
5

Since stim v1.12, you can use the HERALDED_ERASE gate or the HERALDED_PAULI_CHANNEL_1 gate to get heralded erasures.

Note that you will still need to find a decoder that understands the erasures. For example, as of this writing, pymatching will just ignore the heralds and do normal decoding instead of erasure-informed decoding.


For more complex erasure errors, you can sort of emulate erasures by combining CORRELATED_ERROR, ELSE_CORRELATED_ERROR, and an ancilla. This ancilla qubit is not physical; it's just a way of explaining what you want in terms of a circuit. Each heralded error should flip the ancilla qubit in addition to applying its normal error effects. In this way, measuring the ancilla will reveal the herald. Then you can declare detectors and etc on this measurement result, like with any other measurement.

Craig Gidney
  • 44,299
  • 1
  • 41
  • 116
4

Adding my two cents on "finding a decoder that understands the erasures" - here are slides I made in the past, which seems to be valid for the newly updated HERALDED_ERASE feature in Stim as well. Thanks for adding this feature!

enter image description here

enter image description here