Skip to content

Schema

CZ

Bases: Operation

A CZ gate operation.

Fields

op_type (str): The type of operation (Literal["CZ"]). participants (Tuple[Union[Tuple[int], Tuple[int, int]], ...]): The qubit indices that are participating in the CZ gate.

CZError

Bases: ErrorOperation[ErrorModelType]

CZError operation.

Fields

survival_prob (Tuple[float, ...]): The survival probabilities for each qubit. error_type (str): The type of error (Literal["CZError"]). storage_error (ErrorModelType): The error model for storage. entangled_error (ErrorModelType): The error model for entangled qubits. single_error (ErrorModelType): The error model for single qubits.

ErrorModel

Bases: BaseModel

Base class for error models.

ErrorOperation

Bases: BaseModel, Generic[ErrorModelType]

Base class for error operations.

GateEvent

Bases: BaseModel, Generic[ErrorModelType]

A gate event.

Fields

error (Union[SingleQubitError[ErrorModelType], CZError[ErrorModelType]]): The error model for the gate event. operation (OperationType): The operation for the gate event.

GlobalRz

Bases: Operation

GlobalRz operation.

Fields

op_type (str): The type of operation (Literal["GlobalRz"]). phi (float): The angle of rotation.

GlobalW

Bases: Operation

GlobalW operation.

Fields

op_type (str): The type of operation (Literal["GlobalW"]). theta (float): The angle of rotation. phi (float): The angle of rotation.

LocalRz

Bases: Operation

LocalRz operation.

Fields

op_type (str): The type of operation (Literal["LocalRz"]). participants (Tuple[int, ...]): The qubit indices that are participating in the local Rz gate. phi (float): The angle of rotation.

LocalW

Bases: Operation

LocalW operation.

Fields

op_type (str): The type of operation (Literal["LocalW"]). participants (Tuple[int, ...]): The qubit indices that are participating in the local W gate. theta (float): The angle of rotation. phi (float): The angle of rotation.

Measurement

Bases: Operation

Measurement operation.

Fields

op_type (str): The type of operation (Literal["Measurement"]). measure_tag (str): The tag to use for the measurement. participants (Tuple[int, ...]): The qubit indices that are participating in the measurement.

NoiseModel

Bases: BaseModel, Generic[ErrorModelType]

Noise model for a circuit.

Fields

all_qubits (Tuple[int, ...]): The qubit indices for the noise model. gate_events (List[GateEvent[ErrorModelType]]): The gate events for the noise model.

num_qubits property

num_qubits: int

Return the number of qubits in the noise model.

decompiled_circuit

decompiled_circuit() -> str

Clean the circuit of noise.

Returns:

Name Type Description
str str

The decompiled circuit from hardware execution.

Source code in .venv/lib/python3.12/site-packages/bloqade/qbraid/schema.py
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
def decompiled_circuit(self) -> str:
    """Clean the circuit of noise.

    Returns:
        str: The decompiled circuit from hardware execution.

    """
    from bloqade.noise import native
    from bloqade.qasm2.emit import QASM2
    from bloqade.qasm2.passes import glob, parallel

    mt = self.lower_noise_model("method")

    native.RemoveNoisePass(mt.dialects)(mt)
    parallel.ParallelToUOp(mt.dialects)(mt)
    glob.GlobalToUOP(mt.dialects)(mt)
    return QASM2(qelib1=True).emit_str(mt)

lower_noise_model

lower_noise_model(sym_name: str, return_qreg: bool = False)

Lower the noise model to a method.

Parameters:

Name Type Description Default
sym_name str

The name of the method to generate.

required
return_qreg bool

Whether to return the quantum register after the method has completed execution. Useful for obtaining the full state vector.

False

Returns:

Name Type Description
Method

The generated kirin method.

Source code in .venv/lib/python3.12/site-packages/bloqade/qbraid/schema.py
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
def lower_noise_model(self, sym_name: str, return_qreg: bool = False):
    """Lower the noise model to a method.

    Args:
        sym_name (str): The name of the method to generate.
        return_qreg (bool): Whether to return the quantum register after the method
            has completed execution. Useful for obtaining the full state vector.

    Returns:
        Method: The generated kirin method.

    """
    from bloqade.qbraid.lowering import Lowering

    return Lowering().lower(sym_name, self, return_qreg)

Operation

Bases: BaseModel

Base class for operations.

PauliErrorModel

Bases: ErrorModel

Pauli error model.

Fields

error_model_type (str): The type of error model (Literal["PauliNoise"]). errors (Tuple[Tuple[int, Tuple[float, float, float]], ...]): The qubit indices and the error rates for each qubit.

SingleQubitError

Bases: ErrorOperation[ErrorModelType]

SingleQubitError operation.

Fields

survival_prob (Tuple[float, ...]): The survival probabilities for each qubit. error_type (str): The type of error (Literal["SingleQubitError"]). operator_error (ErrorModelType): The error model for the single qubit.