Skip to content

Results are limited to the current section: Qoolqit

Product news

Quick Run Guide

QoolQit requires Python 3.10 or later. Install it from PyPI (external) in a virtual environment:

python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install qoolqit

Run your first experiment on a local emulator. No account or credentials are needed.

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 register
register = Register.from_coordinates([(0, 1), (0, -1), (2, 0)])
# Define the drive parameters
omega = 0.8
delta_i = -2.0 * omega
delta_f = -delta_i
T = 25.0
# Define the drive
drive = Drive(
amplitude=ConstantWaveform(T, omega),
detuning=RampWaveform(T, delta_i, delta_f),
)
# Create and compile the program
program = QuantumProgram(register, drive)
program.compile_to(MockDevice())

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

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 the emu-sv (external) package.
  • MPSBackend: PyTorch-based Matrix Product State emulator, best for 25 to ~80 qubits. Requires the emu-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)

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, ...})

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), RemoteSVBackend or RemoteMPSBackend. Availability depends on your provider.
  • emulation_config: same as for local emulators. See Emulation configuration.
  • num_shots: number of bitstring samples to collect.

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 retrieval
job_id = job.job_id()
batch_id = get_batch_id(job)
# reconnect to the job later
job = retrieve_remote_job(connection, job_id, batch_id=batch_id)

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 devices
connection.fetch_available_devices()
# {'FRESNEL': FRESNEL, ...}
# compile the program to the FRESNEL device
device = Device.from_connection(connection, "FRESNEL")
program.compile_to(device=device, profile="max_energy")

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 retrieval
job_id = job.job_id()
batch_id = get_batch_id(job)