Skip to main content

QProgram

Tests Code Quality Python License

QProgram is a Python DSL for describing pulse-level quantum experiments. You write what you want the chip to do; the platform decides how to run it.

The core package knows nothing about any particular instrument. It defines the language, the AST, a text file format, a capability protocol platforms validate programs against, and the extension hooks vendor packages plug into. Its only runtime dependencies are numpy and xarray.

Installation

pip install qprogram

Optional extras: qprogram[viz] adds Waveform.plot(), and qprogram[lsp] adds the language server used by editor integrations.

A first program

import qprogram as qp

schema = qp.BusSchema.transmon()
q = schema.q

program = qp.QProgram(label="rabi", schema=schema)
gain = program.variable("gain", units="V")

with program.average(shots=1000):
    with program.sweep(gain).from_range(0.0, 1.0, 0.01):
        program.set_gain(q[0].drive, gain)
        program.play(q[0].drive, "pi_pulse")
        program.sync()
        m0 = program.measure(q[0].readout, "readout", "weights")

# Plug in calibrated waveforms at the very end.
resolved = program.with_waveforms(
    {
        "pi_pulse": qp.waveforms.IQDrag(amplitude=0.5, duration=40, sigma=8, beta=0.1),
        "readout": qp.waveforms.IQPair(qp.waveforms.Square(1.0, 2000), qp.waveforms.Square(0.0, 2000)),
        "weights": qp.waveforms.IQPair(qp.waveforms.Square(1.0, 2000), qp.waveforms.Square(1.0, 2000)),
    }
)

# Run it. `qp.simulate` is the reference software executor that ships with the
# package; hardware platforms implement the same `PlatformProtocol` interface.
result = qp.simulate(resolved)
data = result.get(m0)  # xarray.DataArray with named dimensions

data comes back with dimensions ("gain", "IQ") and shape (101, 2): dimensions are named after the enclosing loops, outermost first, and the 1000 shots of the average block are reduced rather than kept. The reference executor is the executable definition of the language's semantics.

What the package does

Nothing in the package reaches an instrument. A program is a description: it is built, checked, and handed over. Turning it into instrument code, placing it on a timeline, and calibrating its pulses all happen behind qp.PlatformProtocol, which is why the same program runs wherever that protocol is implemented. The core stays small for that reason: it holds only what any platform could be asked to do. Instrument-specific work (markers, active reset, triggers, slow-control parameters) comes from optional vendor packages that register themselves on import, and a .qp file that uses one records the dependency as a require line and refuses to load without it.

Documentation

Full documentation, including the user guide, the .qp format reference, and the generated API reference, lives at https://qilimanjaro-tech.github.io/qprogram/.

Development

The project uses uv.

uv sync --all-extras          # create .venv and install everything
uv run pytest                 # run the test suite
uv run ruff check .           # lint
uv run ruff format .          # format
uv run ty check               # type-check
uv run --group docs zensical serve   # preview the documentation

Reference

The design is described in "QProgram: A Hardware-Agnostic DSL for Portable Pulse-Level Quantum Programming" by Vyron Vasileiadis, Flavie Le Bars, and David Arcos (Qilimanjaro Quantum Tech, Barcelona, Spain).

License

Apache License 2.0. See LICENSE.

Metadata

Release files for qprogram 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qprogram 0.2.0
File Size Uploaded
qprogram-0.2.0.tar.gz 1.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for qprogram 0.2.0
File Interpreter ABI Platform
qprogram-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 2.2 MB

Release files / qprogram-0.2.0.tar.gz

Download URL qprogram-0.2.0.tar.gz
Size 1.9 MB
Tags Source
SHA-256 checksum
How to use checksums
461209b290639c1ca14c1ea92b798aeb034e7045e2d5966f1f8d61f9a10d3020
BLAKE2b-256 checksum
How to use checksums
03f804bb68c0e39dbdea6dfab59d89cf1f9ca653f1887a58aa835b6b3b3aa89d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / qprogram-0.2.0-py3-none-any.whl

Download URL qprogram-0.2.0-py3-none-any.whl
Size 317.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16135be36d26e417fdab7b9b603845e93f13337363d5d30eb41ce683588a984f
BLAKE2b-256 checksum
How to use checksums
b9fba24fbf743f969c747df4a8a42ebef2b09cad5340aeda872115d1feeb8950
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page