Skip to content

Results are limited to the current section : Qoolqit

qoolqit.devices

Modules:

  • device
  • unit_converter

Classes:

  • AnalogDevice

    A realistic device 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:

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)

Return the device specification constraints.

from_connection(connection: RemoteConnection, name: str) -> Device classmethod

Section titled “ from_connection(connection: RemoteConnection, name: str) -> Device classmethod ”

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.

Parameters:

(RemoteConnection) –

connection object to fetch the available devices.

(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 PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
@classmethod
def 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)

Show 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)

Resets 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

Changes 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)

Changes 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(pulser_device: BaseDevice, default_converter: Optional[UnitConverter] = None)

Section titled “ Device(pulser_device: BaseDevice, default_converter: Optional[UnitConverter] = None) ”

QoolQit Device wrapper around a Pulser BaseDevice.

Parameters:

(BaseDevice) –

a BaseDevice to build the QoolQit device from.

(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 PasqalCloud
from qoolqit import Device
# Fetch the remote device from the connection
connection = PasqalCloud()
pulser_fresnel_device = connection.fetch_available_devices()["FRESNEL"]
# Wrap a Pulser device object into a QoolQit Device
fresnel_device = Device(pulser_device=PulserFresnelDevice)

From custom Pulser device:

from dataclasses import replace
from pulser import AnalogDevice
from qoolqit import Device
# Converting the pulser Device object in a VirtualDevice object
VirtualAnalog = AnalogDevice.to_virtual()
# Replacing desired values
ModdedAnalogDevice = replace(
VirtualAnalog,
max_radial_distance=100,
max_sequence_duration=7000
)
# Wrap a Pulser device object into a QoolQit Device
mod_analog_device = Device(pulser_device=ModdedAnalogDevice)

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()

Return the device specification constraints.

from_connection(connection: RemoteConnection, name: str) -> Device classmethod

Section titled “ from_connection(connection: RemoteConnection, name: str) -> Device classmethod ”

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.

Parameters:

(RemoteConnection) –

connection object to fetch the available devices.

(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 PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
@classmethod
def 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)

Show 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)

Resets 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

Changes 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)

Changes 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)

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)

Return the device specification constraints.

from_connection(connection: RemoteConnection, name: str) -> Device classmethod

Section titled “ from_connection(connection: RemoteConnection, name: str) -> Device classmethod ”

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.

Parameters:

(RemoteConnection) –

connection object to fetch the available devices.

(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 PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
@classmethod
def 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)

Show 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)

Resets 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

Changes 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)

Changes 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)

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)

Return the device specification constraints.

from_connection(connection: RemoteConnection, name: str) -> Device classmethod

Section titled “ from_connection(connection: RemoteConnection, name: str) -> Device classmethod ”

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.

Parameters:

(RemoteConnection) –

connection object to fetch the available devices.

(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 PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
@classmethod
def 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)

Show 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)

Resets 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

Changes 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)

Changes 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)

Show 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(), DigitalAnalogDevice(), MockDevice()):
dev.info()