qoolqit.execution
execution
QoolQit module to execute quantum programs on QPUs or local/remote emulators.
Modules:
-
backends– -
compilation_functions– -
job– -
sequence_compiler–
Classes:
-
LocalEmulator–Run QoolQit
QuantumPrograms on a Pasqal local emulator backends. -
QPU–Execute QoolQit QuantumPrograms on Pasqal quantum processing units.
-
RemoteEmulator–Run QoolQit
QuantumPrograms on a Pasqal remote emulator backends. -
SequenceCompiler–Compiles a QoolQit Register and Drive to a Device.
Functions:
-
get_batch_id–Return the batch ID associated with a remote job.
-
retrieve_remote_job–Retrieve a previously submitted remote job by its identifiers.
Attributes:
-
JobStatus(TypeAlias) –Alias for :class:
~pulser.backend.remote.JobStatus.
JobStatus: TypeAlias = remote.JobStatus
module-attribute
Alias for :class:~pulser.backend.remote.JobStatus.
Terminal states (where :meth:Job.has_ended returns True):
- :attr:
~remote.JobStatus.DONE - :attr:
~remote.JobStatus.ERROR - :attr:
~remote.JobStatus.CANCELED
LocalEmulator(*, backend_type: type[EmulatorBackend] = QutipBackendV2, emulation_config: EmulationConfig | None = None, num_shots: int | None = None)
Run QoolQit QuantumPrograms on a Pasqal local emulator backends.
This class serves as a primary interface between tools written using QoolQit (including solvers) and local emulator backends.
Parameters:
-
(backend_typetype, default:QutipBackendV2) –backend type. Must be a subtype of
pulser.backend.EmulatorBackend. -
(emulation_configEmulationConfig, default:None) –optional configuration object emulators.
-
(num_shotsint, default:None) –number of bitstring samples to collect from the final quantum state.
Examples:
from qoolqit.execution import LocalEmulator, BackendType
backend = LocalEmulator(backend_type=BackendType.QutipBackendV2)
result = backend.run(program)
Methods:
-
default_emulation_config–Return a unique emulation config for all emulators.
-
run–Run a compiled QuantumProgram and return the results.
-
validate_emulation_config–Returns a valid config for emulator backends, if needed.
Source code in qoolqit/execution/backends.py
default_emulation_config() -> EmulationConfig
Return a unique emulation config for all emulators.
Defaults to a configuration that asks for the final bitstring, sampled num_shots times.
Source code in qoolqit/execution/backends.py
run(program: QuantumProgram) -> job.Job[Results]
Run a compiled QuantumProgram and return the results.
Source code in qoolqit/execution/backends.py
validate_emulation_config(emulation_config: EmulationConfig | None) -> EmulationConfig
Returns a valid config for emulator backends, if needed.
Parameters:
-
(emulation_configEmulationConfig | None) –optional base configuration class for all emulators backends. If no config is provided to an emulator backend, the backend default will used.
Source code in qoolqit/execution/backends.py
QPU(*, connection: RemoteConnection, num_shots: int | None = None)
Execute QoolQit QuantumPrograms on Pasqal quantum processing units.
This class provides the primary interface for running quantum programs on actual QPU hardware. It requires authenticated credentials through a connection object to submit and execute programs on remote quantum processors.
Parameters:
-
(connectionRemoteConnection) –Authenticated connection to the remote QPU backend.
-
(num_shotsint | None, default:None) –Number of bitstring samples to collect from the final quantum state.
Examples:
Using Pasqal Cloud:
from pulser_pasqal import PasqalCloud
from qoolqit.execution import QPU
connection = PasqalCloud(
username="your_username",
password="your_password",
project_id="your_project_id"
)
backend = QPU(connection=connection)
remote_results = backend.submit(program)
Using Atos MyQML:
from pulser_myqlm import PulserQLMConnection
from qoolqit.execution import QPU
connection = PulserQLMConnection()
backend = QPU(connection=connection)
results = backend.run(program)
Note
Contact your quantum computing provider for credentials and connection setup: - Pasqal Cloud Documentation - Atos MyQML Framework
Methods:
-
run–Run a compiled QuantumProgram and return a job handler.
-
validate_connection–Validate the required connection to instantiate a RemoteBackend.
Source code in qoolqit/execution/backends.py
run(program: QuantumProgram) -> job.Job[Results]
Run a compiled QuantumProgram and return a job handler.
The returned handler Job can be used to retrieve results with job.results()
Parameters:
-
(programQuantumProgram) –the compiled quantum program to run.
Source code in qoolqit/execution/backends.py
validate_connection(connection: RemoteConnection) -> RemoteConnection
staticmethod
Validate the required connection to instantiate a RemoteBackend.
Remote emulators and QPUs require a pulser.backend.remote.RemoteConnection or derived
to send jobs. Validation also happens inside the backend. Early validation just makes the
error easier to understand.
Source code in qoolqit/execution/backends.py
RemoteEmulator(*, backend_type: type[RemoteEmulatorBackend] = EmuFreeBackendV2, connection: RemoteConnection, emulation_config: EmulationConfig | None = None, num_shots: int | None = None)
Run QoolQit QuantumPrograms on a Pasqal remote emulator backends.
This class serves as a primary interface between tools written using QoolQit (including solvers)
and remote emulator backends.
The behavior is similar to LocalEmulator, but here, requires credentials through
a connection to submit/run a program.
To get your credentials and to create a connection object, please refer to the Pasqal Cloud
interface documentation.
Parameters:
-
(backend_typetype, default:EmuFreeBackendV2) –backend type. Must be a subtype of
pulser_pasqal.backends.RemoteEmulatorBackend. -
(connectionRemoteConnection) –connection to execute the program on remote backends.
-
(emulation_configEmulationConfig, default:None) –optional configuration object emulators.
-
(num_shotsint, default:None) –number of bitstring samples to collect from the final quantum state.
Examples:
from pulser_pasqal import PasqalCloud
from qoolqit.execution import RemoteEmulator, BackendType
connection = PasqalCloud(username=..., password=..., project_id=...)
backend = RemoteEmulator(backend_type=BackendType.EmuFreeBackendV2, connection=connection)
Methods:
-
default_emulation_config–Return a unique emulation config for all emulators.
-
run–Run a compiled QuantumProgram and return a job handler.
-
validate_connection–Validate the required connection to instantiate a RemoteBackend.
-
validate_emulation_config–Returns a valid config for emulator backends, if needed.
Source code in qoolqit/execution/backends.py
default_emulation_config() -> EmulationConfig
Return a unique emulation config for all emulators.
Defaults to a configuration that asks for the final bitstring, sampled num_shots times.
Source code in qoolqit/execution/backends.py
run(program: QuantumProgram) -> job.Job[Results]
Run a compiled QuantumProgram and return a job handler.
The returned handler Job can be used to retrieve results with job.results()
Parameters:
-
(programQuantumProgram) –the compiled quantum program to run.
Source code in qoolqit/execution/backends.py
validate_connection(connection: RemoteConnection) -> RemoteConnection
staticmethod
Validate the required connection to instantiate a RemoteBackend.
Remote emulators and QPUs require a pulser.backend.remote.RemoteConnection or derived
to send jobs. Validation also happens inside the backend. Early validation just makes the
error easier to understand.
Source code in qoolqit/execution/backends.py
validate_emulation_config(emulation_config: EmulationConfig | None) -> EmulationConfig
Returns a valid config for emulator backends, if needed.
Parameters:
-
(emulation_configEmulationConfig | None) –optional base configuration class for all emulators backends. If no config is provided to an emulator backend, the backend default will used.
Source code in qoolqit/execution/backends.py
SequenceCompiler(register: Register, drive: Drive, device: Device, profile: CompilerProfile, device_max_duration_ratio: float | None = None)
Compiles a QoolQit Register and Drive to a Device.
Parameters:
-
(registerRegister) –the QoolQit Register.
-
(driveDrive) –the QoolQit Drive.
-
(deviceDevice) –the QoolQit Device.
-
(profileCompilerProfile) –the CompilerProfile to use.
-
(device_max_duration_ratiofloat | None, default:None) –optionally set the program duration to a fraction of the device's maximum allowed duration.
Source code in qoolqit/execution/sequence_compiler.py
get_batch_id(job: Job[Results]) -> str
Return the batch ID associated with a remote job.
Temporary utility for cases where batch_id must be persisted
and later passed to :func:retrieve_remote_job. Will be
deprecated once RemoteConnection supports direct job lookup
by job ID alone.
Parameters:
-
(jobJob[Results]) –Any :class:
Jobinstance.
Returns:
-
str(str) –The batch ID if job is a :class:
_RemoteJob, -
str–otherwise an empty string.
Source code in qoolqit/execution/job.py
retrieve_remote_job(connection: remote.RemoteConnection, job_id: str, *, batch_id: str = '') -> Job[Results]
Retrieve a previously submitted remote job by its identifiers.
Use this to reconnect to a job in a new session, or to monitor a job submitted outside the current context.
Note
The batch_id argument is required by some
RemoteConnection implementations (e.g.
PasqalCloudConnection) to query job progress. Use
:func:get_batch_id to recover the batch ID from an existing
:class:Job if needed.
This dependency on batch_id is temporary and will be removed
once RemoteConnection supports direct lookup by job ID
alone.
Parameters:
-
(connectionRemoteConnection) –The remote connection through which to query the job.
-
(job_idstr) –The UUID of the job to retrieve.
-
(batch_idstr, default:'') –The batch identifier the job belongs to. Defaults to an empty string.
Returns:
-
Job[Results]–Job[Results]: A :class:
_RemoteJobconnected to the -
Job[Results]–specified job.