Quick Run Guide
Installation
Section titled “Installation”QoolQit requires Python 3.10 or later. Install it from PyPI (external) in a virtual environment:
python -m venv .venvsource .venv/bin/activate # Windows: .venv\Scripts\activatepip install qoolqitLocal Execution
Section titled “Local Execution”Run your first experiment on a local emulator. No account or credentials are needed.
1. Define a quantum program
Section titled “1. Define a quantum program”Create a register and a drive, then compile the program to a device. MockDevice is a test device for local runs.
from qoolqit import ( ConstantWaveform, Drive, MockDevice, QuantumProgram, RampWaveform, Register,)
# Create the registerregister = Register.from_coordinates([(0, 1), (0, -1), (2, 0)])
# Define the drive parametersomega = 0.8delta_i = -2.0 * omegadelta_f = -delta_iT = 25.0
# Define the drivedrive = Drive( amplitude=ConstantWaveform(T, omega), detuning=RampWaveform(T, delta_i, delta_f),)
# Create and compile the programprogram = QuantumProgram(register, drive)program.compile_to(MockDevice())2. Run on the local emulator
Section titled “2. Run on the local emulator”LocalEmulator runs the program on your machine. run() returns a Job, and job.results() gives you the results.
from qoolqit.execution import LocalEmulator
emulator = LocalEmulator()job = emulator.run(program)results = job.results()3. Choose a backend
Section titled “3. Choose a backend”LocalEmulator supports several Pasqal emulators (external):
QutipBackendV2(default): based on QuTiP, best for up to ~15 qubits.SVBackend: PyTorch-based state-vector emulator, best for up to ~25 qubits. Requires theemu-sv(external) package.MPSBackend: PyTorch-based Matrix Product State emulator, best for 25 to ~80 qubits. Requires theemu-mps(external) package.
Install emu-sv and emu-mps with pip install "qoolqit[extras]", then pick a backend with backend_type:
from qoolqit.execution import BackendType, LocalEmulator
emulator = LocalEmulator(backend_type=BackendType.QutipBackendV2)4. Inspect results
Section titled “4. Inspect results”job.results() returns a Results object. get_result_tags() lists what it contains, and final_bitstrings gives the sampled bitstrings:
results.get_result_tags() # ['bitstrings']results.final_bitstrings # Counter({'111': 807, '101': 68, '110': 60, ...})Remote Execution
Section titled “Remote Execution”Connection
Section titled “Connection”Remote Execution on Cloud Emulators
Section titled “Remote Execution on Cloud Emulators”1. Create a connection
Section titled “1. Create a connection”This example uses Pasqal Cloud: create a PasqalCloudConnection with your username, password and project ID from the portal.
from pasqal_cloud import PasqalCloudConnection
connection = PasqalCloudConnection( username=USERNAME, # your user/email for the Pasqal Cloud Platform password=PASSWORD, # your Pasqal Cloud Platform password project_id=PROJECT_ID, # the ID of the project associated with your account)Replace USERNAME, PASSWORD and PROJECT_ID with your own values. Avoid hardcoding your password in code you share.
2. Initialize a remote emulator and submit
Section titled “2. Initialize a remote emulator and submit”RemoteEmulator uses RemoteEmuFreeBackend by default, which is free for all Pasqal Cloud accounts and needs no credits. run() submits the program and returns a Job without waiting for the results.
from qoolqit.execution import BackendType, RemoteEmulator
remote_emulator = RemoteEmulator( backend_type=BackendType.RemoteEmuFreeBackend, connection=connection, num_shots=1000,)job = remote_emulator.run(program)RemoteEmulator accepts the following arguments:
backend_type:RemoteEmuFreeBackend(default),RemoteSVBackendorRemoteMPSBackend. Availability depends on your provider.emulation_config: same as for local emulators. See Emulation configuration.num_shots: number of bitstring samples to collect.
3. Check status and retrieve results
Section titled “3. Check status and retrieve results”Remote jobs run asynchronously, so you can check their status and fetch the results once they are done. Save the job and batch IDs to retrieve the job later, for example from a new session.
from qoolqit.execution import get_batch_id, retrieve_remote_job
# query status: PENDING, RUNNING, DONE, etc.status = job.get_status()
# fetch the results (blocks until the job is done)results = job.results()results.final_bitstrings
# save the identifiers for later retrievaljob_id = job.job_id()batch_id = get_batch_id(job)
# reconnect to the job laterjob = retrieve_remote_job(connection, job_id, batch_id=batch_id)Remote Execution on a QPU
Section titled “Remote Execution on a QPU”The same connection lets you run the program on a QPU.
1. List available devices and compile to the QPU
Section titled “1. List available devices and compile to the QPU”List the devices available through your connection, then compile the program to the target QPU. You must compile to the QPU device before submitting.
from qoolqit.devices import Device
# list available devicesconnection.fetch_available_devices()# {'FRESNEL': FRESNEL, ...}
# compile the program to the FRESNEL devicedevice = Device.from_connection(connection, "FRESNEL")program.compile_to(device=device, profile="max_energy")2. Submit to the QPU
Section titled “2. Submit to the QPU”Create a QPU backend with your connection and number of shots, then submit. Status checks and result retrieval work the same as for remote emulators.
from qoolqit.execution import QPU, get_batch_id
qpu = QPU(connection=connection, num_shots=500)job = qpu.run(program)
# save the identifiers for later retrievaljob_id = job.job_id()batch_id = get_batch_id(job)