qoqo_qryd.SimulatorBackend
- class qoqo_qryd.SimulatorBackend(device, number_qubits, /)
Local simulator backend for Rydberg devices.
The QRyd simulator backend applies each operation in a circuit to a quantum register. The underlying simulator uses the QuEST library. Although the underlying simulator supports arbitrary unitary gates, the QRyd simulator only allows operations that are available on a device model of a QRyd device. This limitation is introduced by design to check the compatibility of circuits with a model of the QRyd hardware. For unrestricted simulations use the backend simulator of the roqoqo-quest crate.
The simulator backend implements the qoqo EvaluatingBackend interface and is compatible with running single circuits, running and evaluating measurements and running QuantumPrograms on simulated QRyd devices.
- Parameters:
device (Union[QRydDevice,TweezerDevice]) -- The device providing information about the available operations.
- Raises:
TypeError -- Device Parameter is not QRydDevice or TweezerDevice
- __init__()
Methods
__init__
()Convert the bincode representation of the SimulatorBackend to a SimulatorBackend using the bincode crate.
Convert the json representation of a SimulatorBackend to a SimulatorBackend.
run_circuit
(circuit)Run a circuit with the QRyd backend.
Evaluates expectation values of a measurement with the backend.
Run all circuits corresponding to one measurement with the QRyd backend.
Return the bincode representation of the SimulatorBackend using the bincode crate.
to_json
()Return the json representation of the SimulatorBackend.
- from_bincode()
Convert the bincode representation of the SimulatorBackend to a SimulatorBackend using the bincode crate.
- Parameters:
input (ByteArray) -- The serialized SimulatorBackend (in bincode form).
- Returns:
The deserialized SimulatorBackend.
- Return type:
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to SimulatorBackend.
- from_json()
Convert the json representation of a SimulatorBackend to a SimulatorBackend.
- Parameters:
input (str) -- The serialized SimulatorBackend in json form.
- Returns:
The deserialized SimulatorBackend.
- Return type:
- Raises:
ValueError -- Input cannot be deserialized to SimulatorBackend.
- run_circuit(circuit)
Run a circuit with the QRyd backend.
A circuit is passed to the backend and executed. During execution values are written to and read from classical registers (List[bool], List[float], List[complex]). To produce sufficient statistics for evaluating expectation values, circuits have to be run multiple times. The results of each repetition are concatenated in OutputRegisters (List[List[bool]], List[List[float]], List[List[complex]]).
- Parameters:
circuit (Circuit) -- The circuit that is run on the backend.
- Returns:
The output registers written by the evaluated circuits.
- Return type:
Tuple[Dict[str, List[List[bool]]], Dict[str, List[List[float]]], Dict[str, List[List[complex]]]]
- Raises:
TypeError -- Circuit argument cannot be converted to qoqo Circuit
RuntimeError -- Running Circuit failed
- run_measurement()
Evaluates expectation values of a measurement with the backend.
- Parameters:
measurement (Measurement) -- The measurement that is run on the backend.
- Returns:
The dictionary of expectation values.
- Return type:
Optional[Dict[str, float]]
- Raises:
TypeError -- Measurement evaluate function could not be used
RuntimeError -- Internal error measurement.evaluation returned unknown type
- run_measurement_registers()
Run all circuits corresponding to one measurement with the QRyd backend.
An expectation value measurement in general involves several circuits. Each circuit is passed to the backend and executed separately. During execution values are written to and read from classical registers (List[bool], List[float], List[complex]). To produce sufficient statistics for evaluating expectation values, circuits have to be run multiple times. The results of each repetition are concatenated in OutputRegisters (List[List[bool]], List[List[float]], List[List[complex]]).
- Parameters:
measurement (Measurement) -- The measurement that is run on the backend.
- Returns:
The output registers written by the evaluated circuits.
- Return type:
Tuple[Dict[str, List[List[bool]]], Dict[str, List[List[float]]], Dict[str, List[List[complex]]]]
- Raises:
TypeError -- Circuit argument cannot be converted to qoqo Circuit
RuntimeError -- Running Circuit failed
- to_bincode()
Return the bincode representation of the SimulatorBackend using the bincode crate.
- Returns:
The serialized SimulatorBackend (in bincode form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize SimulatorBackend to bytes.
- to_json()
Return the json representation of the SimulatorBackend.
- Returns:
The serialized form of SimulatorBackend.
- Return type:
str
- Raises:
ValueError -- Cannot serialize SimulatorBackend to json.