Initializing quantum devices
Each Device in QoolQit wraps a Pulser device and defines the hardware characteristics that the program will be compiled to and later executed on.
from qoolqit import MockDevice, AnalogDevice, DigitalAnalogDevice
# An example of an mock device with no hardware constrainsdevice_ideal = MockDevice()
# An example of a real devicedevice_real = AnalogDevice()
# An example of a real device with digital-analog capabilities.device_real_digital = DigitalAnalogDevice()Besides available default devices, relevant for QPU emulation, new QPU devices can be: - imported remotely - created from custom Pulser devices
Fetching a QoolQit device from a connection
Section titled “Fetching a QoolQit device from a connection”Depending on your provider you might have different QPUs available to launch your quantum program to.
The list of available ones can be fetched through the specific connection handler object, with the generic connection.fetch_available_devices() method.
For the Pasqal Cloud service, for example, creating a QoolQit device from a connection object, simply reads as:
from pulser_pasqal import PasqalCloudfrom qoolqit import Device
connection = PasqalCloud()print(connection.fetch_available_devices())
# fetch QoolQit devicefresnel_device = Device.from_connection(connection=connection, name="FRESNEL"){'FRESNEL': FRESNEL}FRESNEL: └── max_duration: 67.85840131753953 └── max_amplitude: 1.0 └── max_detuning: 5.555555555555555 └── min_distance: 0.7673301077365813Create a QoolQit device from a Pulser device
Section titled “Create a QoolQit device from a Pulser device”A custom QoolQit device can be also built straight from any Pulser device, with any desired specification. Please, refer to Pulser documentation (external) to learn how to make a custom 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)AnalogDevice: └── max_duration: 87.96459430051421 └── max_amplitude: 1.0 └── max_detuning: 10.0 └── min_distance: 0.7809234915702248Unit conversion
Section titled “Unit conversion”Each device has a default unit converter. These are the unit values used when converting an adimensional program in the Rydberg analog model to the physical units of Pulser devices for hardware execution.
device_real.converterUnitConverter(time = 79.577, energy = 12.566, distance = 6.403)The converter handles the logic of converting the adimensional QoolQit model to Pulser units. For theoretical details on how this conversion works between the Rydberg analog model and the implementation that Pulser uses you can check the Rydberg analog model page.
By default, each device creates a default converter where the energy unit is set as that device’s maximum amplitude. If you make no changes to the device’s converter, this means that amplitude values in the range will be converted to values in the range .
Customizing units
Section titled “Customizing units”For advanced users, customizing the unit conversion factors is possible.
device_real.set_time_unit(50.0)
device_real.set_energy_unit(10.0)
device_real.set_distance_unit(6.0)UnitConverter(time = 50.000, energy = 20.000, distance = 5.925)UnitConverter(time = 100.000, energy = 10.000, distance = 6.651)UnitConverter(time = 53.893, energy = 18.555, distance = 6.000)Restoring defaults
Section titled “Restoring defaults”You can always restore the default converter:
device_real.reset_converter()UnitConverter(time = 79.577, energy = 12.566, distance = 6.403)Notes
Advanced users may also pass a prebuiltdefault_converterto the constructor to start in a custom unit system:from qoolqit import UnitConvertercustom_default = UnitConverter.from_energy(C6=device_from_pulser._C6, upper_amp=2.0)device_custom = Device(pulser_device=devices.AnalogDevice, default_converter=custom_default)