Skip to content

bloqade.pyqrack.task.PyQrackSimulatorTask

← Module overview

classPyQrackSimulatorTasksource

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

NameTypeDescription
kernelir.Method[Params, RetType]
argstuple[Any, ...]
kwargsdict[str, Any]
pyqrack_interpPyQrackInterpreter[MemoryType]

Attributes

NameTypeDescription
pyqrack_interpPyQrackInterpreter[MemoryType]

methodrunsource

bloqade.pyqrack.task.PyQrackSimulatorTask.run

def run() -> RetType

Returns

RetType

source

propertystatesource

bloqade.pyqrack.task.PyQrackSimulatorTask.state

state: MemoryType
source

methodstate_vectorsource

bloqade.pyqrack.task.PyQrackSimulatorTask.state_vector

def state_vector() -> list[complex]

Returns the state vector of the simulator.

Returns

list[complex]

source

methodqubitssource

bloqade.pyqrack.task.PyQrackSimulatorTask.qubits

def qubits() -> list[PyQrackQubit]

Returns the qubits in the simulator.

Returns

list[PyQrackQubit]

source

methodbatch_runsource

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

NameTypeDefaultDescription
shotsint1the number of repetitions of the task

Returns

dict[RetType, float]

source

methodbatch_statesource

bloqade.pyqrack.task.PyQrackSimulatorTask.batch_state

def batch_state(shots: int = 1, qubit_map: None = None) -> QuantumState

Repeatedly 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

NameTypeDefaultDescription
shotsint1the number of repetitions of the task
qubit_mapNoneNonean 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

source