Skip to content

Noise model

generate_logical_noise_model

generate_logical_noise_model(
    noise_model: GeminiNoiseModelABC | None = None,
    loss: bool = True,
) -> SimpleLogicalNoiseModel

Generate a logical noise model with initialization kernels.

Creates a physical noise model and adds Steane [[7,1,3]] clean and noisy initialization kernels, all derived from the same source parameters.

Parameters:

Name Type Description Default
noise_model GeminiNoiseModelABC | None

The bloqade-circuit noise model to use. Defaults to None.

None
loss bool

Whether to include loss channels. Defaults to True.

True

Returns:

Type Description
SimpleLogicalNoiseModel

A logical noise model with gate/move noise and both initialization kernels.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/noise_model.py
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
def generate_logical_noise_model(
    noise_model: "GeminiNoiseModelABC | None" = None,
    loss: bool = True,
) -> SimpleLogicalNoiseModel:
    """Generate a logical noise model with initialization kernels.

    Creates a physical noise model and adds Steane [[7,1,3]] clean and noisy
    initialization kernels, all derived from the same source parameters.

    Args:
        noise_model: The bloqade-circuit noise model to use. Defaults to None.
        loss: Whether to include loss channels. Defaults to True.

    Returns:
        A logical noise model with gate/move noise and both initialization kernels.
    """
    from bloqade.cirq_utils.noise.model import GeminiOneZoneNoiseModel

    if noise_model is None:
        noise_model = GeminiOneZoneNoiseModel()

    physical = generate_simple_noise_model(noise_model, loss=loss)

    from bloqade.lanes.arch.gemini.logical.upstream import steane7_initialize_with_noise

    clean_init, noisy_init = steane7_initialize_with_noise(
        local_px=noise_model.local_px,
        local_py=noise_model.local_py,
        local_pz=noise_model.local_pz,
        local_loss_prob=noise_model.local_loss_prob,
        mover_px=noise_model.mover_px,
        mover_py=noise_model.mover_py,
        mover_pz=noise_model.mover_pz,
        move_loss_prob=noise_model.move_loss_prob,
        sitter_px=noise_model.sitter_px,
        sitter_py=noise_model.sitter_py,
        sitter_pz=noise_model.sitter_pz,
        sit_loss_prob=noise_model.sit_loss_prob,
        loss=loss,
    )

    return SimpleLogicalNoiseModel.from_simple(
        physical,
        logical_initialize_clean=clean_init,
        logical_initialize_noisy=noisy_init,
    )

generate_simple_noise_model

generate_simple_noise_model(
    noise_model: GeminiNoiseModelABC | None = None,
    loss: bool = True,
) -> SimpleNoiseModel

Generate a physical noise model from a bloqade-circuit noise model.

Parameters:

Name Type Description Default
noise_model GeminiNoiseModelABC | None

The bloqade-circuit noise model to use. Defaults to None.

None
loss bool

Whether to include loss in the noise model. Defaults to True.

True

Returns:

Type Description
SimpleNoiseModel

A simple noise model for physical gate/move noise insertion.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/noise_model.py
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
def generate_simple_noise_model(
    noise_model: "GeminiNoiseModelABC | None" = None,
    loss: bool = True,
) -> SimpleNoiseModel:
    """Generate a physical noise model from a bloqade-circuit noise model.

    Args:
        noise_model: The bloqade-circuit noise model to use. Defaults to None.
        loss: Whether to include loss in the noise model. Defaults to True.

    Returns:
        A simple noise model for physical gate/move noise insertion.
    """
    from bloqade.cirq_utils.noise.model import GeminiOneZoneNoiseModel

    if noise_model is None:
        noise_model = GeminiOneZoneNoiseModel()

    cz_unpaired_loss_prob = noise_model.cz_unpaired_loss_prob
    cz_unpaired_gate_px = noise_model.cz_unpaired_gate_px
    cz_unpaired_gate_py = noise_model.cz_unpaired_gate_py
    cz_unpaired_gate_pz = noise_model.cz_unpaired_gate_pz

    @squin.kernel
    def cz_unpaired_noise(qubits: ilist.IList[qubit.Qubit, Any]):
        debug.info("CZ Unpaired Noise")
        squin.broadcast.single_qubit_pauli_channel(
            cz_unpaired_gate_px, cz_unpaired_gate_py, cz_unpaired_gate_pz, qubits
        )
        if loss:
            squin.broadcast.qubit_loss(cz_unpaired_loss_prob, qubits)

    mover_px = noise_model.mover_px
    mover_py = noise_model.mover_py
    mover_pz = noise_model.mover_pz
    move_lost_prob = noise_model.move_loss_prob

    @squin.kernel
    def lane_noise(qubit: qubit.Qubit):
        debug.info("Lane Noise")
        squin.single_qubit_pauli_channel(mover_px, mover_py, mover_pz, qubit)
        if loss:
            squin.qubit_loss(move_lost_prob, qubit)

    sitter_px = noise_model.sitter_px
    sitter_py = noise_model.sitter_py
    sitter_pz = noise_model.sitter_pz
    sit_loss_prob = noise_model.sit_loss_prob

    @squin.kernel
    def idle_noise(qubits: ilist.IList[qubit.Qubit, Any]):
        debug.info("Idle Noise")
        squin.broadcast.single_qubit_pauli_channel(
            sitter_px, sitter_py, sitter_pz, qubits
        )
        if loss:
            squin.broadcast.qubit_loss(sit_loss_prob, qubits)

    cz_paired_error_dict = noise_model.cz_paired_error_probabilities
    if cz_paired_error_dict is None:
        raise ValueError("CZ paired error probabilities must be provided.")

    cz_paired_error_probabilities = ilist.IList(
        [cz_paired_error_dict[k] for k in PAIRED_KEYS]
    )

    cz_unpaired_loss_prob = noise_model.cz_gate_loss_prob

    @squin.kernel
    def cz_paired_noise(
        controls: ilist.IList[qubit.Qubit, Any], targets: ilist.IList[qubit.Qubit, Any]
    ):
        debug.info("CZ Paired Noise")
        squin.broadcast.two_qubit_pauli_channel(
            cz_paired_error_probabilities, controls, targets
        )

        def pair_qubit(i: int):
            return ilist.IList([controls[i], targets[i]])

        if loss:
            groups = ilist.map(pair_qubit, ilist.range(len(controls)))
            squin.broadcast.correlated_qubit_loss(cz_unpaired_loss_prob, groups)

    local_px = noise_model.local_px
    local_py = noise_model.local_py
    local_pz = noise_model.local_pz
    local_loss_prob = noise_model.local_loss_prob

    @squin.kernel
    def local_r_noise(
        qubits: ilist.IList[qubit.Qubit, Any], axis_angle: float, rotation_angle: float
    ):
        debug.info("Local Gate Noise")
        squin.broadcast.single_qubit_pauli_channel(local_px, local_py, local_pz, qubits)
        if loss:
            squin.broadcast.qubit_loss(local_loss_prob, qubits)

    @squin.kernel
    def local_rz_noise(qubits: ilist.IList[qubit.Qubit, Any], rotation_angle: float):
        debug.info("Local Rz Noise")
        squin.broadcast.single_qubit_pauli_channel(local_px, local_py, local_pz, qubits)
        if loss:
            squin.broadcast.qubit_loss(local_loss_prob, qubits)

    global_px = noise_model.global_px
    global_py = noise_model.global_py
    global_pz = noise_model.global_pz
    global_loss_prob = noise_model.global_loss_prob

    @squin.kernel
    def global_r_noise(
        qubits: ilist.IList[qubit.Qubit, Any], axis_angle: float, rotation_angle: float
    ):
        debug.info("Global Gate Noise")
        squin.broadcast.single_qubit_pauli_channel(
            global_px, global_py, global_pz, qubits
        )
        if loss:
            squin.broadcast.qubit_loss(global_loss_prob, qubits)

    @squin.kernel
    def global_rz_noise(qubits: ilist.IList[qubit.Qubit, Any], rotation_angle: float):
        debug.info("Global Rz Noise")
        squin.broadcast.single_qubit_pauli_channel(
            global_px, global_py, global_pz, qubits
        )
        if loss:
            squin.broadcast.qubit_loss(global_loss_prob, qubits)

    return SimpleNoiseModel(
        lane_noise=lane_noise,
        idle_noise=idle_noise,
        cz_unpaired_noise=cz_unpaired_noise,
        cz_paired_noise=cz_paired_noise,
        global_rz_noise=global_rz_noise,
        local_rz_noise=local_rz_noise,
        global_r_noise=global_r_noise,
        local_r_noise=local_r_noise,
    )