bloqade.pyqrack.task.PyQrackSimulatorTask
classPyQrackSimulatorTask¶source
bloqade.pyqrack.task.PyQrackSimulatorTask
Bases: AbstractSimulatorTask[Param, RetType, MemoryType]
PyQrack simulator task for Bloqade.
Signature
class PyQrackSimulatorTask(kernel: ir.Method[Params, RetType], args: tuple[Any, ...], kwargs: dict[str, Any], pyqrack_interp: PyQrackInterpreter[MemoryType])Parameters
| Name | Type | Description |
|---|---|---|
kernel | ir.Method[Params, RetType] | |
args | tuple[Any, ...] | |
kwargs | dict[str, Any] | |
pyqrack_interp | PyQrackInterpreter[MemoryType] |
Attributes
| Name | Type | Description |
|---|---|---|
pyqrack_interp | PyQrackInterpreter[MemoryType] |
methodrun¶source
bloqade.pyqrack.task.PyQrackSimulatorTask.run
propertystate¶source
bloqade.pyqrack.task.PyQrackSimulatorTask.state
state: MemoryTypemethodstate_vector¶source
bloqade.pyqrack.task.PyQrackSimulatorTask.state_vector
def state_vector() -> list[complex]Returns the state vector of the simulator.
Returns
list[complex]
methodqubits¶source
bloqade.pyqrack.task.PyQrackSimulatorTask.qubits
def qubits() -> list[PyQrackQubit]Returns the qubits in the simulator.
Returns
list[PyQrackQubit]
methodbatch_run¶source
bloqade.pyqrack.task.PyQrackSimulatorTask.batch_run
def batch_run(shots: int = 1) -> dict[RetType, float]Repeatedly run the task to collect statistics on the shot outcomes. The average is done over [shots] repetitions and thus is frequentist and converges to exact only in the shots -> infinity limit.
Returns: dict[RetType, float]: a dictionary mapping outcomes to their probabilities, as estimated from counting the shot outcomes. RetType must be hashable.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
shots | int | 1 | the number of repetitions of the task |
Returns
dict[RetType, float]
methodbatch_state¶source
bloqade.pyqrack.task.PyQrackSimulatorTask.batch_state
def batch_state(shots: int = 1, qubit_map: None = None) -> QuantumStateRepeatedly run the task to extract the averaged quantum state. The average is done over [shots] repetitions and thus is frequentist and converges to exact only in the shots -> infinity limit.
Returns: QuantumState: the averaged quantum state as a density matrix, represented in its eigenbasis.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
shots | int | 1 | the number of repetitions of the task |
qubit_map | None | None | an optional callable that takes the output of self.run() and extract the [returned] qubits to be used for the quantum state. If None, all qubits in the simulator are used, in the order set by the simulator. If callable, qubit_map must have the signature > qubit_map(output:RetType) -> list[PyQrackQubit] and the averaged state is > quantum_state(qubit_map(self.run())). If qubit_map is not None, self.run() must return qubit(s). Two common patterns here are: > qubit_map = lambda qubits: qubits for the case where self.run() returns a list of qubits, or > qubit_map = lambda qubit: [qubits] for the case where self.run() returns a single qubit. |
Returns
QuantumState