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

DEPOLARIZE1

Single qubit depolarizing noise. This channel applies one of the Pauli errors X, Y, Z with probability \(p/3\).

DEPOLARIZE2

Two qubit depolarizing noise. This channel applies one of the 15 non-identity two-qubit Pauli errors (IX, IY, …, ZZ) with probability \(p/15\).

X_ERROR

Single qubit Pauli-X error (Bit flip). Applies X with probability \(p\).

Y_ERROR

Single qubit Pauli-Y error. Applies Y with probability \(p\).

Z_ERROR

Single qubit Pauli-Z error (Phase flip). Applies Z with probability \(p\).

PAULI_CHANNEL_1

Custom single qubit Pauli channel. Takes 3 arguments (px, py, pz) specifying the probabilities of applying X, Y, and Z errors respectively.

PAULI_CHANNEL_2

Custom two qubit Pauli channel. Takes 15 arguments specifying the probabilities of applying each of the 15 non-identity two-qubit Pauli errors.

E (or CORRELATED_ERROR)

Correlated Pauli error on multiple qubits (requires pauli_string argument). Applies the specified Pauli string with probability \(p\).

ELSE_CORRELATED_ERROR

Similar to CORRELATED_ERROR but 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