Skip to content

bloqade.pyqrack.device.PyQrackSimulatorBase

← Module overview

classPyQrackSimulatorBasesource

bloqade.pyqrack.device.PyQrackSimulatorBase

Bases: AbstractSimulatorDevice[PyQrackSimulatorTask]

PyQrack simulation device base class.

Signature
class PyQrackSimulatorBase(options: PyQrackOptions = _default_pyqrack_args(), *, loss_m_result: MeasurementResultValue = MeasurementResultValue.One, rng_state: np.random.Generator = np.random.default_rng())

Parameters

NameTypeDefaultDescription
optionsPyQrackOptions_default_pyqrack_args()
loss_m_resultMeasurementResultValueMeasurementResultValue.One
rng_statenp.random.Generatornp.random.default_rng()

Attributes

NameTypeDefaultDescription
optionsPyQrackOptionsfield(default_factory=_default_pyqrack_args)options (PyQrackOptions): options passed into the pyqrack simulator.
loss_m_resultMeasurementResultValuefield(default=(MeasurementResultValue.One), kw_only=True)
rng_statenp.random.Generatorfield(default_factory=(np.random.default_rng), kw_only=True)
MemoryType—TypeVar('MemoryType', bound=MemoryABC)

methodnew_tasksource

bloqade.pyqrack.device.PyQrackSimulatorBase.new_task

Signature
def new_task(mt: ir.Method[Params, RetType], args: tuple[Any, ...], kwargs: dict[str, Any], memory: MemoryType) -> PyQrackSimulatorTask[Params, RetType, MemoryType]

Parameters

NameTypeDescription
mtir.Method[Params, RetType]
argstuple[Any, ...]
kwargsdict[str, Any]
memoryMemoryType

Returns

PyQrackSimulatorTask[Params, RetType, MemoryType]

source

methodstate_vectorsource

bloqade.pyqrack.device.PyQrackSimulatorBase.state_vector

Signature
def state_vector(kernel: ir.Method[Params, RetType], args: tuple[Any, ...] = (), kwargs: dict[str, Any] | None = None) -> list[complex]

Runs task and returns the state vector.

Parameters

NameTypeDefaultDescription
kernelir.Method[Params, RetType]required
argstuple[Any, ...]()
kwargsdict[str, Any] | NoneNone

Returns

list[complex]

source

methodpauli_expectationsource

bloqade.pyqrack.device.PyQrackSimulatorBase.pauli_expectation

Signature
def pauli_expectation(pauli: list[Pauli], qubits: list[PyQrackQubit]) -> float

Returns the expectation value of the given Pauli operator given a list of Pauli operators and qubits.

Parameters

NameTypeDescription
paulilist[Pauli]List of Pauli operators to compute the expectation value for.
qubitslist[PyQrackQubit]List of qubits corresponding to the Pauli operators.

Returns

floatfloat: The expectation value of the Pauli operator.

source

methodquantum_statesource

bloqade.pyqrack.device.PyQrackSimulatorBase.quantum_state

Signature
def quantum_state(qubits: list[PyQrackQubit] | IList[PyQrackQubit, Any], tol: float = 1e-12) -> QuantumState

Extract the reduced density matrix representing the state of a list of qubits from a PyQRack simulator register.

Outputs: An eigh result containing the eigenvalues and eigenvectors of the reduced density matrix.

Parameters

NameTypeDefaultDescription
qubitslist[PyQrackQubit] | IList[PyQrackQubit, Any]required
tolfloat1e-12

Returns

QuantumState

Inputs

qubits: A list of PyQRack qubits to extract the reduced density matrix for tol: The tolerance for density matrix eigenvalues to be considered non-zero.

source

methodreduced_density_matrixsource

bloqade.pyqrack.device.PyQrackSimulatorBase.reduced_density_matrix

Signature
def reduced_density_matrix(qubits: list[PyQrackQubit] | IList[PyQrackQubit, Any], tol: float = 1e-12) -> np.ndarray

Extract the reduced density matrix representing the state of a list of qubits from a PyQRack simulator register.

Outputs: A dense 2^n x 2^n numpy array representing the reduced density matrix.

Parameters

NameTypeDefaultDescription
qubitslist[PyQrackQubit] | IList[PyQrackQubit, Any]required
tolfloat1e-12

Returns

np.ndarray

Inputs

qubits: A list of PyQRack qubits to extract the reduced density matrix for tol: The tolerance for density matrix eigenvalues to be considered non-zero.

source