Skip to content

Target

PyQrack dataclass

PyQrack(
    min_qubits: int = 0,
    dynamic_qubits: bool = False,
    pyqrack_options: PyQrackOptions = _default_pyqrack_args(),
)

PyQrack target runtime for Bloqade.

dynamic_qubits class-attribute instance-attribute

dynamic_qubits: bool = False

Whether to use dynamic qubit allocation. Cannot use with tensor network simulations.

min_qubits class-attribute instance-attribute

min_qubits: int = 0

Minimum number of qubits required for the PyQrack simulator. Useful when address analysis fails to determine the number of qubits.

pyqrack_options class-attribute instance-attribute

pyqrack_options: PyQrackOptions = field(
    default_factory=_default_pyqrack_args
)

Options to pass to the QrackSimulator object, node qubitCount will be overwritten.

multi_run

multi_run(
    mt: Method[Params, RetType],
    _shots: int,
    *args: args,
    **kwargs: kwargs
) -> List[RetType]

Run the given kernel method on the PyQrack _shots times, caching analysis results.

Args mt (Method): The kernel method to run. _shots (int): The number of times to run the kernel method.

Returns List of results of the kernel method, one for each shot.

Source code in .venv/lib/python3.12/site-packages/bloqade/pyqrack/target.py
 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
def multi_run(
    self,
    mt: ir.Method[Params, RetType],
    _shots: int,
    *args: Params.args,
    **kwargs: Params.kwargs,
) -> List[RetType]:
    """Run the given kernel method on the PyQrack `_shots` times, caching analysis results.

    Args
        mt (Method):
            The kernel method to run.
        _shots (int):
            The number of times to run the kernel method.

    Returns
        List of results of the kernel method, one for each shot.

    """
    fold = Fold(mt.dialects)
    fold(mt)

    interpreter = self._get_interp(mt)
    batched_results = []
    for _ in range(_shots):
        batched_results.append(interpreter.run(mt, args, kwargs))

    return batched_results

run

run(
    mt: Method[Params, RetType],
    *args: args,
    **kwargs: kwargs
) -> RetType

Run the given kernel method on the PyQrack simulator.

Args mt (Method): The kernel method to run.

Returns The result of the kernel method, if any.

Source code in .venv/lib/python3.12/site-packages/bloqade/pyqrack/target.py
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
def run(
    self,
    mt: ir.Method[Params, RetType],
    *args: Params.args,
    **kwargs: Params.kwargs,
) -> RetType:
    """Run the given kernel method on the PyQrack simulator.

    Args
        mt (Method):
            The kernel method to run.

    Returns
        The result of the kernel method, if any.

    """
    fold = Fold(mt.dialects)
    fold(mt)
    return self._get_interp(mt).run(mt, args, kwargs)