Skip to content

Noise

bit_flip

bit_flip(p: float, qubits: IList[Qubit, Any]) -> None

Apply a bit flip error channel to the qubits in the given list with probability p.

Parameters:

Name Type Description Default
p float

Probability of a bit flip error being applied.

required
qubits IList[Qubit, Any]

The list of qubits to which the noise channel is applied.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/squin/stdlib/broadcast/noise.py
135
136
137
138
139
140
141
142
143
144
@kernel
def bit_flip(p: float, qubits: ilist.IList[Qubit, Any]) -> None:
    """
    Apply a bit flip error channel to the qubits in the given list with probability `p`.

    Args:
        p (float): Probability of a bit flip error being applied.
        qubits (IList[Qubit, Any]): The list of qubits to which the noise channel is applied.
    """
    single_qubit_pauli_channel(p, 0, 0, qubits)

correlated_qubit_loss

correlated_qubit_loss(
    p: float, qubits: IList[IList[Qubit, N], Any]
) -> None

Apply correlated qubit loss channels to groups of qubits.

For each group of qubits, applies a correlated loss channel where all qubits within the group are lost together with probability p. Loss events are independent between different groups.

Parameters:

Name Type Description Default
p float

Loss probability for each group.

required
qubits IList[IList[Qubit, N], Any]

List of qubit groups. Each sublist represents a group of qubits to which a correlated loss channel is applied.

required
Example

q1 = squin.qalloc(3) # First group: qubits 0, 1, 2 q2 = squin.qalloc(3) # Second group: qubits 3, 4, 5 squin.broadcast.correlated_qubit_loss(0.5, [q1, q2])

Each group has 50% chance: either all qubits lost or none lost.

Group 1 and Group 2 outcomes are independent.

Source code in .venv/lib/python3.12/site-packages/bloqade/squin/stdlib/broadcast/noise.py
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
@kernel
def correlated_qubit_loss(
    p: float, qubits: ilist.IList[ilist.IList[Qubit, N], Any]
) -> None:
    """
    Apply correlated qubit loss channels to groups of qubits.

    For each group of qubits, applies a correlated loss channel where all qubits
    within the group are lost together with probability `p`. Loss events are independent
    between different groups.

    Args:
        p (float): Loss probability for each group.
        qubits (IList[IList[Qubit, N], Any]): List of qubit groups. Each sublist
            represents a group of qubits to which a correlated loss channel is applied.

    Example:
        >>> q1 = squin.qalloc(3) # First group: qubits 0, 1, 2
        >>> q2 = squin.qalloc(3) # Second group: qubits 3, 4, 5
        >>> squin.broadcast.correlated_qubit_loss(0.5, [q1, q2])
        # Each group has 50% chance: either all qubits lost or none lost.
        # Group 1 and Group 2 outcomes are independent.
    """
    noise.correlated_qubit_loss(p, qubits)

depolarize

depolarize(p: float, qubits: IList[Qubit, Any]) -> None

Apply a depolarizing noise channel to a list of qubits with probability p.

For each qubit, this will randomly select one of the Pauli operators X, Y, Z with a probability p / 3 and apply it to the qubit. No operator is applied with a probability of 1 - p.

Parameters:

Name Type Description Default
p float

The probability with which a Pauli operator is applied.

required
qubits IList[Qubit, Any]

The list of qubits to which the noise channel is applied.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/squin/stdlib/broadcast/noise.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@kernel
def depolarize(p: float, qubits: ilist.IList[Qubit, Any]) -> None:
    """
    Apply a depolarizing noise channel to a list of qubits with probability `p`.

    For each qubit, this will randomly select one of the Pauli operators X, Y, Z
    with a probability `p / 3` and apply it to the qubit. No operator is applied
    with a probability of `1 - p`.

    Args:
        p (float): The probability with which a Pauli operator is applied.
        qubits (IList[Qubit, Any]): The list of qubits to which the noise channel is applied.
    """
    noise.depolarize(p, qubits)

depolarize2

depolarize2(
    p: float,
    controls: IList[Qubit, N],
    targets: IList[Qubit, N],
) -> None

Symmetric two-qubit depolarization channel applied to a set of control and target qubits.

For each pair of qubits from the controls and targets lists, this will randomly select one of the pauli products

{IX, IY, IZ, XI, XX, XY, XZ, YI, YX, YY, YZ, ZI, ZX, ZY, ZZ}

each with a probability p / 15. No noise is applied with a probability of 1 - p.

Parameters:

Name Type Description Default
p float

The probability with which a Pauli product is applied.

required
controls IList[Qubit, N]

The list of control qubits.

required
targets IList[Qubit, N]

The list of target qubits.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/squin/stdlib/broadcast/noise.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
@kernel
def depolarize2(
    p: float, controls: ilist.IList[Qubit, N], targets: ilist.IList[Qubit, N]
) -> None:
    """
    Symmetric two-qubit depolarization channel applied to a set of control and target qubits.

    For each pair of qubits from the `controls` and `targets` lists, this will randomly select one
    of the pauli products

    `{IX, IY, IZ, XI, XX, XY, XZ, YI, YX, YY, YZ, ZI, ZX, ZY, ZZ}`

    each with a probability `p / 15`. No noise is applied with a probability of `1 - p`.

    Args:
        p (float): The probability with which a Pauli product is applied.
        controls (IList[Qubit, N]): The list of control qubits.
        targets (IList[Qubit, N]): The list of target qubits.
    """
    noise.depolarize2(p, controls, targets)

qubit_loss

qubit_loss(p: float, qubits: IList[Qubit, Any]) -> None

Apply a qubit loss channel to each of the qubits in the given list.

Each qubit in the list is lost with a probability p.

Parameters:

Name Type Description Default
p float

Probability of the atom being lost.

required
qubits IList[Qubit, Any]

The list of qubits to which the noise channel is applied.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/squin/stdlib/broadcast/noise.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
@kernel
def qubit_loss(p: float, qubits: ilist.IList[Qubit, Any]) -> None:
    """
    Apply a qubit loss channel to each of the qubits in the given list.

    Each qubit in the list is lost with a probability `p`.

    Args:
        p (float): Probability of the atom being lost.
        qubits (IList[Qubit, Any]): The list of qubits to which the noise channel is applied.
    """
    noise.qubit_loss(p, qubits)

single_qubit_pauli_channel

single_qubit_pauli_channel(
    px: float,
    py: float,
    pz: float,
    qubits: IList[Qubit, Any],
) -> None

Apply a Pauli error channel with weighted px, py, pz. No error is applied with a probability 1 - (px + py + pz).

This randomly selects one of the three Pauli operators X, Y, Z, weighted with the given probabilities in that order.

Parameters:

Name Type Description Default
probabilities IList[float, Literal[3]]

A list of 3 probabilities corresponding to the probabilities (p_x, p_y, p_z) in that order.

required
qubits IList[Qubit, Any]

The list of qubits to which the noise channel is applied.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/squin/stdlib/broadcast/noise.py
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
@kernel
def single_qubit_pauli_channel(
    px: float, py: float, pz: float, qubits: ilist.IList[Qubit, Any]
) -> None:
    """
    Apply a Pauli error channel with weighted `px, py, pz`. No error is applied with a probability
    `1 - (px + py + pz)`.

    This randomly selects one of the three Pauli operators X, Y, Z, weighted with the given probabilities in that order.

    Args:
        probabilities (IList[float, Literal[3]]): A list of 3 probabilities corresponding to the probabilities `(p_x, p_y, p_z)` in that order.
        qubits (IList[Qubit, Any]): The list of qubits to which the noise channel is applied.
    """
    noise.single_qubit_pauli_channel(px, py, pz, qubits)

two_qubit_pauli_channel

two_qubit_pauli_channel(
    probabilities: IList[float, Literal[15]],
    controls: IList[Qubit, N],
    targets: IList[Qubit, N],
) -> None

Apply a Pauli product error with weighted probabilities to the set of control and target qubits.

No error is applied with the probability 1 - sum(probabilities).

For each pair of qubits from the controls and targets lists, this will randomly select one of the pauli products

{IX, IY, IZ, XI, XX, XY, XZ, YI, YX, YY, YZ, ZI, ZX, ZY, ZZ}

weighted with the corresponding list of probabilities.

NOTE: The order of the given probabilities must match the order of the list of Pauli products above!

Source code in .venv/lib/python3.12/site-packages/bloqade/squin/stdlib/broadcast/noise.py
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
@kernel
def two_qubit_pauli_channel(
    probabilities: ilist.IList[float, Literal[15]],
    controls: ilist.IList[Qubit, N],
    targets: ilist.IList[Qubit, N],
) -> None:
    """
    Apply a Pauli product error with weighted `probabilities` to the set of control and target qubits.

    No error is applied with the probability `1 - sum(probabilities)`.

    For each pair of qubits from the `controls` and `targets` lists, this will randomly select one
    of the pauli products

    `{IX, IY, IZ, XI, XX, XY, XZ, YI, YX, YY, YZ, ZI, ZX, ZY, ZZ}`

    weighted with the corresponding list of probabilities.

    **NOTE**: The order of the given probabilities must match the order of the list of Pauli products above!
    """
    noise.two_qubit_pauli_channel(probabilities, controls, targets)