qoolqit.devices
devices
Section titled “
devices
”Modules:
-
device– -
unit_converter–
Classes:
-
AnalogDevice–A realistic device for analog sequence execution.
-
AnalogDeviceWithDMM–A realistic device with DMM for analog sequence execution.
-
Device–QoolQit Device wrapper around a Pulser BaseDevice.
-
DigitalAnalogDevice–A device with digital and analog capabilities.
-
MockDevice–A virtual device for unconstrained prototyping.
Functions:
-
available_default_devices–Show the default available devices in QooQit.
AnalogDevice
Section titled “
AnalogDevice
”AnalogDevice()A realistic device for analog sequence execution.
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
def __init__(self) -> None: super().__init__(pulser_device=pulser.AnalogDevice)
specs
property
Section titled “
specs
property
”specs: dict[str, float | None]Return the device specification constraints.
from_connection
classmethod
Section titled “
from_connection
classmethod
”from_connection( connection: RemoteConnection, name: str) -> Device (qoolqit.devices.device.Device)" href="#qoolqit.devices.Device">DeviceReturn the specified device from the selected device from a connection.
Available devices through the provided connection are can be seen with
the connection.fetch_available_devices() method.
Parameters:
-
connection(RemoteConnection) –connection object to fetch the available devices.
-
name(str) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloudfresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")Source code in qoolqit/devices/device.py
@classmethoddef from_connection(cls, connection: RemoteConnection, name: str) -> Device: """Return the specified device from the selected device from a connection.
Available devices through the provided connection are can be seen with the `connection.fetch_available_devices()` method.
Args: connection (RemoteConnection): connection object to fetch the available devices. name (str): The name of the desired device.
Returns: Device: The requested device.
Raises: ValueError: If the requested device is not available through the provided connection.
Example: ```python from pulser_pasqal import PasqalCloud fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL") ``` """ available_remote_devices = connection.fetch_available_devices() if name not in available_remote_devices: raise ValueError(f"Device {name} is not available through the provided connection.") pulser_device = available_remote_devices[name] return cls(pulser_device=pulser_device)info() -> NoneShow the device short description and constraints.
Source code in qoolqit/devices/device.py
def info(self) -> None: """Show the device short description and constraints.""" print(self)
reset_converter
Section titled “
reset_converter
”reset_converter() -> NoneResets the unit converter to the default one.
Source code in qoolqit/devices/device.py
def reset_converter(self) -> None: """Resets the unit converter to the default one.""" # Create a NEW converter so mutations don't persist. self._converter = self._default_converter
set_distance_unit
Section titled “
set_distance_unit
”set_distance_unit(distance: float) -> NoneChanges the unit converter according to a reference distance unit.
Source code in qoolqit/devices/device.py
def set_distance_unit(self, distance: float) -> None: """Changes the unit converter according to a reference distance unit.""" self.converter.factors = self.converter.factors_from_distance(distance)
set_energy_unit
Section titled “
set_energy_unit
”set_energy_unit(energy: float) -> NoneChanges the unit converter according to a reference energy unit.
Source code in qoolqit/devices/device.py
def set_energy_unit(self, energy: float) -> None: """Changes the unit converter according to a reference energy unit.""" self.converter.factors = self.converter.factors_from_energy(energy)
AnalogDeviceWithDMM
Section titled “
AnalogDeviceWithDMM
”AnalogDeviceWithDMM()A realistic device with DMM for analog sequence execution.
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
def __init__(self) -> None: dmm_channel = pulser.channels.dmm.DMM( clock_period=4, min_duration=16, max_duration=6000, mod_bandwidth=8, bottom_detuning=-2 * math.pi * 20, total_bottom_detuning=-2 * math.pi * 20, ) # Create a virtual device that can be modified to add a DMM channel. pulser_virtual_device = pulser.AnalogDevice.to_virtual() pulser_device = replace( pulser_virtual_device, dmm_objects=(dmm_channel,), name="AnalogDeviceWithDMM" ) super().__init__(pulser_device=pulser_device)
specs
property
Section titled “
specs
property
”specs: dict[str, float | None]Return the device specification constraints.
from_connection
classmethod
Section titled “
from_connection
classmethod
”from_connection( connection: RemoteConnection, name: str) -> Device (qoolqit.devices.device.Device)" href="#qoolqit.devices.Device">DeviceReturn the specified device from the selected device from a connection.
Available devices through the provided connection are can be seen with
the connection.fetch_available_devices() method.
Parameters:
-
connection(RemoteConnection) –connection object to fetch the available devices.
-
name(str) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloudfresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")Source code in qoolqit/devices/device.py
@classmethoddef from_connection(cls, connection: RemoteConnection, name: str) -> Device: """Return the specified device from the selected device from a connection.
Available devices through the provided connection are can be seen with the `connection.fetch_available_devices()` method.
Args: connection (RemoteConnection): connection object to fetch the available devices. name (str): The name of the desired device.
Returns: Device: The requested device.
Raises: ValueError: If the requested device is not available through the provided connection.
Example: ```python from pulser_pasqal import PasqalCloud fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL") ``` """ available_remote_devices = connection.fetch_available_devices() if name not in available_remote_devices: raise ValueError(f"Device {name} is not available through the provided connection.") pulser_device = available_remote_devices[name] return cls(pulser_device=pulser_device)info() -> NoneShow the device short description and constraints.
Source code in qoolqit/devices/device.py
def info(self) -> None: """Show the device short description and constraints.""" print(self)
reset_converter
Section titled “
reset_converter
”reset_converter() -> NoneResets the unit converter to the default one.
Source code in qoolqit/devices/device.py
def reset_converter(self) -> None: """Resets the unit converter to the default one.""" # Create a NEW converter so mutations don't persist. self._converter = self._default_converter
set_distance_unit
Section titled “
set_distance_unit
”set_distance_unit(distance: float) -> NoneChanges the unit converter according to a reference distance unit.
Source code in qoolqit/devices/device.py
def set_distance_unit(self, distance: float) -> None: """Changes the unit converter according to a reference distance unit.""" self.converter.factors = self.converter.factors_from_distance(distance)
set_energy_unit
Section titled “
set_energy_unit
”set_energy_unit(energy: float) -> NoneChanges the unit converter according to a reference energy unit.
Source code in qoolqit/devices/device.py
def set_energy_unit(self, energy: float) -> None: """Changes the unit converter according to a reference energy unit.""" self.converter.factors = self.converter.factors_from_energy(energy)
Device
Section titled “
Device
”Device( pulser_device: BaseDevice, default_converter: Optional[UnitConverter] = None,)QoolQit Device wrapper around a Pulser BaseDevice.
Parameters:
-
pulser_device(BaseDevice) –a
BaseDeviceto build the QoolQit device from. -
default_converter(Optional[UnitConverter], default:None) –optional unit converter to handle unit conversion.
Examples:
From Pulser device:
qoolqit_device = Device(pulser_device=pulser_device)From remote Pulser device:
from pulser_pasqal import PasqalCloudfrom qoolqit import Device
# Fetch the remote device from the connectionconnection = PasqalCloud()pulser_fresnel_device = connection.fetch_available_devices()["FRESNEL"]
# Wrap a Pulser device object into a QoolQit Devicefresnel_device = Device(pulser_device=PulserFresnelDevice)From custom Pulser device:
from dataclasses import replacefrom pulser import AnalogDevicefrom qoolqit import Device
# Converting the pulser Device object in a VirtualDevice objectVirtualAnalog = AnalogDevice.to_virtual()# Replacing desired valuesModdedAnalogDevice = replace( VirtualAnalog, max_radial_distance=100, max_sequence_duration=7000 )
# Wrap a Pulser device object into a QoolQit Devicemod_analog_device = Device(pulser_device=ModdedAnalogDevice)- API reference
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
def __init__( self, pulser_device: BaseDevice, default_converter: Optional[UnitConverter] = None,) -> None:
if not isinstance(pulser_device, BaseDevice): raise TypeError("`pulser_device` must be an instance of Pulser BaseDevice class.")
# Store it for all subsequent lookups self._pulser_device: BaseDevice = pulser_device self._name: str = self._pulser_device.name
# Physical constants / channel & limit lookups (assumes 'rydberg_global' channel) self._C6 = self._pulser_device.interaction_coeff self._clock_period = self._pulser_device.channels["rydberg_global"].clock_period # Relevant limits from the underlying device (float or None) self._max_duration = self._pulser_device.max_sequence_duration self._max_amp = self._pulser_device.channels["rydberg_global"].max_amp self._upper_amp = self._max_amp or 4 * math.pi self._max_abs_det = self._pulser_device.channels["rydberg_global"].max_abs_detuning self._min_distance = self._pulser_device.min_atom_distance self._lower_distance = self._min_distance or 5.0 self._max_radial_distance = self._pulser_device.max_radial_distance
# ratio between maximum amplitude and maximum interaction energy J_max = C6/r_min^6 self._energy_ratio: float = (self._upper_amp * self._lower_distance**6) / self._C6
# layouts self._requires_layout = self._pulser_device.requires_layout
if default_converter is not None: # Snapshot the caller-provided factors so reset() reproduces them exactly. t0, e0, d0 = default_converter.factors self._default_factory: Callable[[], UnitConverter] = lambda: UnitConverter( self._C6, t0, e0, d0 ) else: self._default_factory = lambda: UnitConverter.from_distance( self._C6, self._lower_distance )
self.reset_converter()
specs
property
Section titled “
specs
property
”specs: dict[str, float | None]Return the device specification constraints.
from_connection
classmethod
Section titled “
from_connection
classmethod
”from_connection( connection: RemoteConnection, name: str) -> Device (qoolqit.devices.device.Device)" href="#qoolqit.devices.Device">DeviceReturn the specified device from the selected device from a connection.
Available devices through the provided connection are can be seen with
the connection.fetch_available_devices() method.
Parameters:
-
connection(RemoteConnection) –connection object to fetch the available devices.
-
name(str) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloudfresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")Source code in qoolqit/devices/device.py
@classmethoddef from_connection(cls, connection: RemoteConnection, name: str) -> Device: """Return the specified device from the selected device from a connection.
Available devices through the provided connection are can be seen with the `connection.fetch_available_devices()` method.
Args: connection (RemoteConnection): connection object to fetch the available devices. name (str): The name of the desired device.
Returns: Device: The requested device.
Raises: ValueError: If the requested device is not available through the provided connection.
Example: ```python from pulser_pasqal import PasqalCloud fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL") ``` """ available_remote_devices = connection.fetch_available_devices() if name not in available_remote_devices: raise ValueError(f"Device {name} is not available through the provided connection.") pulser_device = available_remote_devices[name] return cls(pulser_device=pulser_device)info() -> NoneShow the device short description and constraints.
Source code in qoolqit/devices/device.py
def info(self) -> None: """Show the device short description and constraints.""" print(self)
reset_converter
Section titled “
reset_converter
”reset_converter() -> NoneResets the unit converter to the default one.
Source code in qoolqit/devices/device.py
def reset_converter(self) -> None: """Resets the unit converter to the default one.""" # Create a NEW converter so mutations don't persist. self._converter = self._default_converter
set_distance_unit
Section titled “
set_distance_unit
”set_distance_unit(distance: float) -> NoneChanges the unit converter according to a reference distance unit.
Source code in qoolqit/devices/device.py
def set_distance_unit(self, distance: float) -> None: """Changes the unit converter according to a reference distance unit.""" self.converter.factors = self.converter.factors_from_distance(distance)
set_energy_unit
Section titled “
set_energy_unit
”set_energy_unit(energy: float) -> NoneChanges the unit converter according to a reference energy unit.
Source code in qoolqit/devices/device.py
def set_energy_unit(self, energy: float) -> None: """Changes the unit converter according to a reference energy unit.""" self.converter.factors = self.converter.factors_from_energy(energy)
DigitalAnalogDevice
Section titled “
DigitalAnalogDevice
”DigitalAnalogDevice()A device with digital and analog capabilities.
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
def __init__(self) -> None: super().__init__(pulser_device=pulser.DigitalAnalogDevice)
specs
property
Section titled “
specs
property
”specs: dict[str, float | None]Return the device specification constraints.
from_connection
classmethod
Section titled “
from_connection
classmethod
”from_connection( connection: RemoteConnection, name: str) -> Device (qoolqit.devices.device.Device)" href="#qoolqit.devices.Device">DeviceReturn the specified device from the selected device from a connection.
Available devices through the provided connection are can be seen with
the connection.fetch_available_devices() method.
Parameters:
-
connection(RemoteConnection) –connection object to fetch the available devices.
-
name(str) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloudfresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")Source code in qoolqit/devices/device.py
@classmethoddef from_connection(cls, connection: RemoteConnection, name: str) -> Device: """Return the specified device from the selected device from a connection.
Available devices through the provided connection are can be seen with the `connection.fetch_available_devices()` method.
Args: connection (RemoteConnection): connection object to fetch the available devices. name (str): The name of the desired device.
Returns: Device: The requested device.
Raises: ValueError: If the requested device is not available through the provided connection.
Example: ```python from pulser_pasqal import PasqalCloud fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL") ``` """ available_remote_devices = connection.fetch_available_devices() if name not in available_remote_devices: raise ValueError(f"Device {name} is not available through the provided connection.") pulser_device = available_remote_devices[name] return cls(pulser_device=pulser_device)info() -> NoneShow the device short description and constraints.
Source code in qoolqit/devices/device.py
def info(self) -> None: """Show the device short description and constraints.""" print(self)
reset_converter
Section titled “
reset_converter
”reset_converter() -> NoneResets the unit converter to the default one.
Source code in qoolqit/devices/device.py
def reset_converter(self) -> None: """Resets the unit converter to the default one.""" # Create a NEW converter so mutations don't persist. self._converter = self._default_converter
set_distance_unit
Section titled “
set_distance_unit
”set_distance_unit(distance: float) -> NoneChanges the unit converter according to a reference distance unit.
Source code in qoolqit/devices/device.py
def set_distance_unit(self, distance: float) -> None: """Changes the unit converter according to a reference distance unit.""" self.converter.factors = self.converter.factors_from_distance(distance)
set_energy_unit
Section titled “
set_energy_unit
”set_energy_unit(energy: float) -> NoneChanges the unit converter according to a reference energy unit.
Source code in qoolqit/devices/device.py
def set_energy_unit(self, energy: float) -> None: """Changes the unit converter according to a reference energy unit.""" self.converter.factors = self.converter.factors_from_energy(energy)
MockDevice
Section titled “
MockDevice
”MockDevice()A virtual device for unconstrained prototyping.
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
def __init__(self) -> None: super().__init__(pulser_device=pulser.MockDevice)
specs
property
Section titled “
specs
property
”specs: dict[str, float | None]Return the device specification constraints.
from_connection
classmethod
Section titled “
from_connection
classmethod
”from_connection( connection: RemoteConnection, name: str) -> Device (qoolqit.devices.device.Device)" href="#qoolqit.devices.Device">DeviceReturn the specified device from the selected device from a connection.
Available devices through the provided connection are can be seen with
the connection.fetch_available_devices() method.
Parameters:
-
connection(RemoteConnection) –connection object to fetch the available devices.
-
name(str) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloudfresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")Source code in qoolqit/devices/device.py
@classmethoddef from_connection(cls, connection: RemoteConnection, name: str) -> Device: """Return the specified device from the selected device from a connection.
Available devices through the provided connection are can be seen with the `connection.fetch_available_devices()` method.
Args: connection (RemoteConnection): connection object to fetch the available devices. name (str): The name of the desired device.
Returns: Device: The requested device.
Raises: ValueError: If the requested device is not available through the provided connection.
Example: ```python from pulser_pasqal import PasqalCloud fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL") ``` """ available_remote_devices = connection.fetch_available_devices() if name not in available_remote_devices: raise ValueError(f"Device {name} is not available through the provided connection.") pulser_device = available_remote_devices[name] return cls(pulser_device=pulser_device)info() -> NoneShow the device short description and constraints.
Source code in qoolqit/devices/device.py
def info(self) -> None: """Show the device short description and constraints.""" print(self)
reset_converter
Section titled “
reset_converter
”reset_converter() -> NoneResets the unit converter to the default one.
Source code in qoolqit/devices/device.py
def reset_converter(self) -> None: """Resets the unit converter to the default one.""" # Create a NEW converter so mutations don't persist. self._converter = self._default_converter
set_distance_unit
Section titled “
set_distance_unit
”set_distance_unit(distance: float) -> NoneChanges the unit converter according to a reference distance unit.
Source code in qoolqit/devices/device.py
def set_distance_unit(self, distance: float) -> None: """Changes the unit converter according to a reference distance unit.""" self.converter.factors = self.converter.factors_from_distance(distance)
set_energy_unit
Section titled “
set_energy_unit
”set_energy_unit(energy: float) -> NoneChanges the unit converter according to a reference energy unit.
Source code in qoolqit/devices/device.py
def set_energy_unit(self, energy: float) -> None: """Changes the unit converter according to a reference energy unit.""" self.converter.factors = self.converter.factors_from_energy(energy)
available_default_devices
Section titled “
available_default_devices
”available_default_devices() -> NoneShow the default available devices in QooQit.
Source code in qoolqit/devices/device.py
def available_default_devices() -> None: """Show the default available devices in QooQit.""" for dev in (AnalogDevice(), AnalogDeviceWithDMM(), MockDevice()): dev.info()