Skip to content

Schema

CZ

Bases: Operation


              flowchart TD
              bloqade.qbraid.schema.CZ[CZ]
              bloqade.qbraid.schema.Operation[Operation]

                              bloqade.qbraid.schema.Operation --> bloqade.qbraid.schema.CZ
                


              click bloqade.qbraid.schema.CZ href "" "bloqade.qbraid.schema.CZ"
              click bloqade.qbraid.schema.Operation href "" "bloqade.qbraid.schema.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]


              flowchart TD
              bloqade.qbraid.schema.CZError[CZError]
              bloqade.qbraid.schema.ErrorOperation[ErrorOperation]

                              bloqade.qbraid.schema.ErrorOperation --> bloqade.qbraid.schema.CZError
                


              click bloqade.qbraid.schema.CZError href "" "bloqade.qbraid.schema.CZError"
              click bloqade.qbraid.schema.ErrorOperation href "" "bloqade.qbraid.schema.ErrorOperation"
            

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


              flowchart TD
              bloqade.qbraid.schema.ErrorModel[ErrorModel]

              

              click bloqade.qbraid.schema.ErrorModel href "" "bloqade.qbraid.schema.ErrorModel"
            

Base class for error models.

ErrorOperation

Bases: BaseModel, Generic[ErrorModelType]


              flowchart TD
              bloqade.qbraid.schema.ErrorOperation[ErrorOperation]

              

              click bloqade.qbraid.schema.ErrorOperation href "" "bloqade.qbraid.schema.ErrorOperation"
            

Base class for error operations.

GateEvent

Bases: BaseModel, Generic[ErrorModelType]


              flowchart TD
              bloqade.qbraid.schema.GateEvent[GateEvent]

              

              click bloqade.qbraid.schema.GateEvent href "" "bloqade.qbraid.schema.GateEvent"
            

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


              flowchart TD
              bloqade.qbraid.schema.GlobalRz[GlobalRz]
              bloqade.qbraid.schema.Operation[Operation]

                              bloqade.qbraid.schema.Operation --> bloqade.qbraid.schema.GlobalRz
                


              click bloqade.qbraid.schema.GlobalRz href "" "bloqade.qbraid.schema.GlobalRz"
              click bloqade.qbraid.schema.Operation href "" "bloqade.qbraid.schema.Operation"
            

GlobalRz operation.

Fields

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

GlobalW

Bases: Operation


              flowchart TD
              bloqade.qbraid.schema.GlobalW[GlobalW]
              bloqade.qbraid.schema.Operation[Operation]

                              bloqade.qbraid.schema.Operation --> bloqade.qbraid.schema.GlobalW
                


              click bloqade.qbraid.schema.GlobalW href "" "bloqade.qbraid.schema.GlobalW"
              click bloqade.qbraid.schema.Operation href "" "bloqade.qbraid.schema.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


              flowchart TD
              bloqade.qbraid.schema.LocalRz[LocalRz]
              bloqade.qbraid.schema.Operation[Operation]

                              bloqade.qbraid.schema.Operation --> bloqade.qbraid.schema.LocalRz
                


              click bloqade.qbraid.schema.LocalRz href "" "bloqade.qbraid.schema.LocalRz"
              click bloqade.qbraid.schema.Operation href "" "bloqade.qbraid.schema.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


              flowchart TD
              bloqade.qbraid.schema.LocalW[LocalW]
              bloqade.qbraid.schema.Operation[Operation]

                              bloqade.qbraid.schema.Operation --> bloqade.qbraid.schema.LocalW
                


              click bloqade.qbraid.schema.LocalW href "" "bloqade.qbraid.schema.LocalW"
              click bloqade.qbraid.schema.Operation href "" "bloqade.qbraid.schema.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


              flowchart TD
              bloqade.qbraid.schema.Measurement[Measurement]
              bloqade.qbraid.schema.Operation[Operation]

                              bloqade.qbraid.schema.Operation --> bloqade.qbraid.schema.Measurement
                


              click bloqade.qbraid.schema.Measurement href "" "bloqade.qbraid.schema.Measurement"
              click bloqade.qbraid.schema.Operation href "" "bloqade.qbraid.schema.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]


              flowchart TD
              bloqade.qbraid.schema.NoiseModel[NoiseModel]

              

              click bloqade.qbraid.schema.NoiseModel href "" "bloqade.qbraid.schema.NoiseModel"
            

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.qasm2.emit import QASM2
    from bloqade.qasm2.passes import glob, parallel
    from bloqade.qasm2.rewrite.noise import remove_noise

    mt = self.lower_noise_model("method")

    remove_noise.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


              flowchart TD
              bloqade.qbraid.schema.Operation[Operation]

              

              click bloqade.qbraid.schema.Operation href "" "bloqade.qbraid.schema.Operation"
            

Base class for operations.

PauliErrorModel

Bases: ErrorModel


              flowchart TD
              bloqade.qbraid.schema.PauliErrorModel[PauliErrorModel]
              bloqade.qbraid.schema.ErrorModel[ErrorModel]

                              bloqade.qbraid.schema.ErrorModel --> bloqade.qbraid.schema.PauliErrorModel
                


              click bloqade.qbraid.schema.PauliErrorModel href "" "bloqade.qbraid.schema.PauliErrorModel"
              click bloqade.qbraid.schema.ErrorModel href "" "bloqade.qbraid.schema.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]


              flowchart TD
              bloqade.qbraid.schema.SingleQubitError[SingleQubitError]
              bloqade.qbraid.schema.ErrorOperation[ErrorOperation]

                              bloqade.qbraid.schema.ErrorOperation --> bloqade.qbraid.schema.SingleQubitError
                


              click bloqade.qbraid.schema.SingleQubitError href "" "bloqade.qbraid.schema.SingleQubitError"
              click bloqade.qbraid.schema.ErrorOperation href "" "bloqade.qbraid.schema.ErrorOperation"
            

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.