1
$\begingroup$

If I have a line in a DEM e.g.

error(0.001) D0

is there an easy way to see which circuit faults in the original circuit contributed to that error mechanism?

$\endgroup$

1 Answer 1

3
$\begingroup$

Use stim.Circuit.explain_detector_error_model_errors, like this:

circuit = ...
dem_errors_to_explain = stim.DetectorErrorModel("""
    error(1) D0
""")

circuit_errors = circuit.explain_detector_error_model_errors(
    dem_filter=dem_errors_to_explain,
    reduce_to_one_representative_error=True,
)

The result is a list of stim.ExplainedError objects (in this case the list only has one item, since we only asked to explain one error).

Note that these circuit error describing objects have a lot of fields. The easiest way to understand them is to start by just printing them out and see what's listed. The reduce_to_one_representative_error argument simplifies things by making each explained error only contain the simplest stim.CircuitErrorLocation, instead of all of them. You'll then get something like:

>>> print(circuit_errors[0])

Explained Error {
    dem_error_terms D0[coords 1,2,3]
    CircuitErrorLocation {
        flipped_pauli_product: Y0[coords 0,0]
        Circuit location stack trace:
            (after 10 TICKs)
            at instruction #3 (DEPOLARIZE1) in the circuit
            at target #1 of the instruction
            resolving to DEPOLARIZE1(0.01) 0[coords 0,0]
    }
}

Note that if you get something like this:

Explained Error {
    dem_error_terms D0[coords 1,2,3]
    [no single circuit error had these exact symptoms]
}

you may have accidentally used a version of your circuit that had no noise in it.

$\endgroup$
1
  • $\begingroup$ In the same spirit I am wondering if there is a way to check which errors triggered for a specific shot For instance in this part in the example notebook <code> sampler = circuit.compile_sampler() one_sample = sampler.sample(shots=1)[0] for k in range(0, len(one_sample), 8): timeslice = one_sample[k:k+8] print("".join("1" if e else "_" for e in timeslice)) <\code> would there be a way to see that let's say it's the error on qubit 2 at timestep 3 that triggered the measurements observed ? Thanks in advance ! $\endgroup$
    – Diego
    Commented Apr 11 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.