We're trying to simulate whether some initialization strings are preferable to others. For example, would initializing all qubits to $|0\rangle$ lead to a lower error rate?

Is it possible to further tune the error model to allow for, for example, a higher probability of a bit-flip when the qubit is in $|1\rangle$ rather than $|0\rangle$?


1 Answer 1


Stim circuits don't have a native option for this kind of error model, because it's incompatible with some of the key performance optimizations used for high speed bulk sampling.

However, you can do this sort of thing by directly driving stim.TableauSimulator. For example, after telling the tableau simulator to do a layer of operations, you could roll dice to decide whether or not to apply resets:

from typing import Sequence
import random
import stim

def apply_decay_error(sim: stim.TableauSimulator,
                      decay_probability: float,
                      affected_qubits: Sequence[int]):
    decayed_qubits = [
        for q in affected_qubits
        if random.random() < decay_probability

    # Note: much more efficient to reset all in one call

Directly using stim.TableauSimulator produces samples orders of magnitude slower than stim.Circuit.compile_sampler would, but it's much more flexible.

  • $\begingroup$ Thank you, Craig! This is very detailed and helpful. $\endgroup$
    – xilinzhou
    Commented Jul 7, 2022 at 23:30

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.