StimNoiseGate#
- class StimNoiseGate(stim_name, *params, pauli_string=None)[source]#
Class for representing Stim errors in Qrisp circuits.
This class is used to wrap Stim instructions into Qrisp Operations. These operations are effectively identity gates (they have an empty definition) but carry the information about the Stim noise channel. When converted to Stim circuits, these operations are replaced by the corresponding Stim instruction.
Name
Description
DEPOLARIZE1Single qubit depolarizing noise. This channel applies one of the Pauli errors X, Y, Z with probability \(p/3\).
DEPOLARIZE2Two qubit depolarizing noise. This channel applies one of the 15 non-identity two-qubit Pauli errors (IX, IY, …, ZZ) with probability \(p/15\).
X_ERRORSingle qubit Pauli-X error (Bit flip). Applies X with probability \(p\).
Y_ERRORSingle qubit Pauli-Y error. Applies Y with probability \(p\).
Z_ERRORSingle qubit Pauli-Z error (Phase flip). Applies Z with probability \(p\).
PAULI_CHANNEL_1Custom single qubit Pauli channel. Takes 3 arguments (px, py, pz) specifying the probabilities of applying X, Y, and Z errors respectively.
PAULI_CHANNEL_2Custom two qubit Pauli channel. Takes 15 arguments specifying the probabilities of applying each of the 15 non-identity two-qubit Pauli errors.
E(orCORRELATED_ERROR)Correlated Pauli error on multiple qubits (requires
pauli_stringargument). Applies the specified Pauli string with probability \(p\).ELSE_CORRELATED_ERRORSimilar to
CORRELATED_ERRORbut only applies if the previous error instruction did NOT apply an error. This allows constructing more complex conditional error models.- Parameters:
- stim_namestr
The name of the Stim error gate (e.g.
DEPOLARIZE1).- *paramsfloat
The parameters of the error channel (e.g. error probability). Further details about the semantics of the parameters can be found in the Stims gate reference
- pauli_stringstr, optional
A string of Pauli operators (e.g.
XX) for correlated errors.
Examples
We construct a simple circuit that contains both: quantum gates and error instructions.
from qrisp import QuantumCircuit from qrisp.misc.stim_tools import StimNoiseGate qc = QuantumCircuit(1) qc.x(0) # Apply a depolarization error with probability 0.1 qc.append(StimNoiseGate("DEPOLARIZE1", 0.1), qc.qubits) print(qc) # Yields: # ┌───┐┌──────────────────┐ # qb_0: ┤ X ├┤ stim.DEPOLARIZE1 ├ # └───┘└──────────────────┘ print(qc.to_stim()) # Yields: # X 0 # DEPOLARIZE1(0.1) 0