device_model¶
Model for quantum devices with given connectivity and native gate set.
- class parityos.devices.device_model.DeviceQubit(qubit: QubitT_co, properties: QubitPropertiesT_co = None)¶
Bases:
Generic[QubitT_co,QubitPropertiesT_co]A qubit on a quantum device, including property metadata such as state preparation and measurement errors or coherence times.
- properties: QubitPropertiesT_co¶
The properties of this qubit. Optional.
- class parityos.devices.device_model.DeviceGate(operator: Operator[QubitT_co], properties: GatePropertiesT_co = None)¶
Bases:
Generic[QubitT_co,GatePropertiesT_co]An operator on a quantum device, including properties such as such as gate error or duration.
- operator: Operator[QubitT_co]¶
The gate that is native on this device as an operator acting on specific device qubits.
- properties: GatePropertiesT_co¶
Properties of this gate on the device. Optional.
- class parityos.devices.device_model.DeviceModel(device_qubits: DeviceQubit[QubitT_co, QubitPropertiesT_co] | Iterable[DeviceQubit[QubitT_co, QubitPropertiesT_co]], device_gates: DeviceGate[QubitT_co, QubitPropertiesT_co] | Iterable[DeviceGate[QubitT_co, QubitPropertiesT_co]])¶
Bases:
Generic[QubitT_co,QubitPropertiesT_co,GatePropertiesT_co]Represents a quantum device with its native operators and qubits including device specific per-qubit and per-gate properties.
Caution
The set of qubits that
device_qubitsrepresents and alldevice_gatesact on must be the same.- Raises:
ParityOSException – If the set of qubits that
device_qubitsrepresents and alldevice_gatesact on are different.
- device_qubits: frozenset[DeviceQubit[QubitT_co, QubitPropertiesT_co]]¶
The (potentially noisy) qubits of the device.
- device_gates: frozenset[DeviceGate[QubitT_co, GatePropertiesT_co]]¶
Operators that are natively available on the device, including single qubit operators and measurements.
- connectivity: DeviceConnectivity[QubitT_co]¶
Underlying connectivity of this device, derived from the native operators.
- native_operator_types: frozenset[type[Operator[QubitT_co]]]¶
The set of gate types that exist in this device model.
- operators_with_n_qubits(n_qubits: int) frozenset[DeviceGate[QubitT_co, GatePropertiesT_co]]¶
Get all native device gates acting on a certain number of qubits.
- Parameters:
n_qubits – integer number of qubits.
- Returns:
All native gates on the device acting on
n_qubitsqubits.
- qubit_to_operators(qubit: Qubit) frozenset[DeviceGate[QubitT_co, GatePropertiesT_co]]¶
Get all gates acting on a given qubit.
- Parameters:
qubit – A qubit in the device model.
- Returns:
All operators that act on
qubit.
- parityos.devices.device_model.uniform_noiseless_device_from_connectivity(connectivity: DeviceConnectivity[QubitT], gate_types: Iterable[type[Operator[QubitT]]]) DeviceModel[QubitT, None, None]¶
Create a noiseless device model from the given connectivity, by adding the specified
gate_typeson all suitable connections in the connectivity.- This function currently supports adding the following gate types:
SingleQubitOperatorsuch asXorRZ.UnorderedMultiQubitOperatorsuch asSwaporISwap.ConcreteControlledOperatorsuch asCXorCZ.
- Parameters:
connectivity – Device connectivity to use.
gate_types – Iterable of gate types that will be added to all suitable connections of the device.
- Raises:
ParityOSNotSupportedError – If one of the given
gate_typesis not supported by this function.
Example
>>> from parityos.operators.controlled_operator import CNOT >>> from parityos.operators.elementary_operator import X, Z >>> from parityos.operators.rotation_operator import RX, RZ >>> from parityos.devices.device_connectivity import get_rectangular_nearest_neighbor_connectivity >>> from parityos.devices.device_model import uniform_noiseless_device_from_connectivity >>> connectivity = get_rectangular_nearest_neighbor_connectivity(3, 3) >>> d = uniform_noiseless_device_from_connectivity(connectivity, [CNOT, RZ, RX, X, Z])
- parityos.devices.device_model.make_single_qubit_device_operators(operator_type: type[SingleQubitOperator[QubitT]], connectivity: DeviceConnectivity[QubitT]) set[DeviceGate[QubitT, None]]¶
Make native single qubit operators of
operator_typeon all suitable connections inconnectivity.- Parameters:
operator_type – Type of single qubit operator to generate.
connectivity – Device connectivity on which to generate native operators.
- Returns:
Set of operators of type
operator_typethatconnectivitycan support.
- parityos.devices.device_model.make_multi_qubit_device_operators(operator_type: type[UnorderedMultiQubitOperator[QubitT]], connectivity: DeviceConnectivity[QubitT]) set[DeviceGate[QubitT, None]]¶
Make native multi qubit operators of
operator_typeon all suitable connections inconnectivity.- Parameters:
operator_type – Type of multi qubit operator to generate.
connectivity – Device connectivity on which to generate native operators.
- Returns:
Set of operators of type
operator_typethatconnectivitycan support.
- parityos.devices.device_model.make_controlled_device_operators(operator_type: type[ConcreteControlledOperator[QubitT, TargetT_co]], connectivity: DeviceConnectivity[QubitT]) set[DeviceGate[QubitT, None]]¶
Make native concrete controlled operators of
operator_typeon all suitable connections inconnectivity.On each suitable connection, all operators for all possible permutations of control and target qubits are generated.
- Parameters:
operator_type – Type of controlled operator to generate.
connectivity – Device connectivity on which to generate native operators.
- Returns:
Set of operators of type
operator_typethatconnectivitycan support.