bloqade.pyqrack.device.PyQrackSimulatorBase
classPyQrackSimulatorBase¶source
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
| Name | Type | Default | Description |
|---|---|---|---|
options | PyQrackOptions | _default_pyqrack_args() | |
loss_m_result | MeasurementResultValue | MeasurementResultValue.One | |
rng_state | np.random.Generator | np.random.default_rng() |
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
options | PyQrackOptions | field(default_factory=_default_pyqrack_args) | options (PyQrackOptions): options passed into the pyqrack simulator. |
loss_m_result | MeasurementResultValue | field(default=(MeasurementResultValue.One), kw_only=True) | |
rng_state | np.random.Generator | field(default_factory=(np.random.default_rng), kw_only=True) | |
MemoryType | — | TypeVar('MemoryType', bound=MemoryABC) |
methodnew_task¶source
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
| Name | Type | Description |
|---|---|---|
mt | ir.Method[Params, RetType] | |
args | tuple[Any, ...] | |
kwargs | dict[str, Any] | |
memory | MemoryType |
Returns
PyQrackSimulatorTask[Params, RetType, MemoryType]
methodstate_vector¶source
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
| Name | Type | Default | Description |
|---|---|---|---|
kernel | ir.Method[Params, RetType] | required | |
args | tuple[Any, ...] | () | |
kwargs | dict[str, Any] | None | None |
Returns
list[complex]
methodpauli_expectation¶source
bloqade.pyqrack.device.PyQrackSimulatorBase.pauli_expectation
Signature
def pauli_expectation(pauli: list[Pauli], qubits: list[PyQrackQubit]) -> floatReturns the expectation value of the given Pauli operator given a list of Pauli operators and qubits.
Parameters
| Name | Type | Description |
|---|---|---|
pauli | list[Pauli] | List of Pauli operators to compute the expectation value for. |
qubits | list[PyQrackQubit] | List of qubits corresponding to the Pauli operators. |
Returns
floatfloat: The expectation value of the Pauli operator.
methodquantum_state¶source
bloqade.pyqrack.device.PyQrackSimulatorBase.quantum_state
Signature
def quantum_state(qubits: list[PyQrackQubit] | IList[PyQrackQubit, Any], tol: float = 1e-12) -> QuantumStateExtract 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
| Name | Type | Default | Description |
|---|---|---|---|
qubits | list[PyQrackQubit] | IList[PyQrackQubit, Any] | required | |
tol | float | 1e-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.
sourcemethodreduced_density_matrix¶source
bloqade.pyqrack.device.PyQrackSimulatorBase.reduced_density_matrix
Signature
def reduced_density_matrix(qubits: list[PyQrackQubit] | IList[PyQrackQubit, Any], tol: float = 1e-12) -> np.ndarrayExtract 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
| Name | Type | Default | Description |
|---|---|---|---|
qubits | list[PyQrackQubit] | IList[PyQrackQubit, Any] | required | |
tol | float | 1e-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