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.

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
from qprogram.buses import BusSchema
from qprogram.waveforms import IQDrag, IQPair, Square

schema = 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")

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

result = qp.simulate(resolved)
data = result.get(m0)  # xarray.DataArray with named dimensions

qp.simulate runs the reference software executor that ships with the package, which is also the executable definition of the language's semantics. Hardware platforms implement the same PlatformProtocol interface.

What you get

  • One program, many backends. The same QProgram runs on any platform that speaks the protocol. Vendor-specific extras — markers, active reset, triggers, slow-control parameters — live in optional vendor packages and stay out of the core.
  • Real Python. Loops, variables, function arguments, and comprehensions all work. Pulses are objects you can pass around, inspect, and serialize.
  • A text file format. qp.save(program, "exp.qp") writes a readable .qp file that diffs cleanly, plays back identically, and survives version upgrades through explicit require lines.
  • Typed bus references. A BusSchema gives tab-completion and validation for drives, readouts, fluxes, and couplers without locking you into a naming convention.
  • Capability-checked programs. Platforms declare what they support per bus and domain, and qp.explain(program, capabilities) shows exactly which part of a program a backend cannot run and why.

How a program travels

A pulse experiment passes through six steps — Define → Serialize → Explain → Optimize → Execute → Results. QProgram owns all of them but Execute, which the platform you supply carries out. Results come back shaped by the program that produced them: labelled xarray arrays whose axes are named by the sweeps that generated them, rather than unlabelled buffers.

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qprogram-0.1.0.tar.gz (405.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qprogram-0.1.0-py3-none-any.whl (272.9 kB view details)

Uploaded Python 3

File details

Details for the file qprogram-0.1.0.tar.gz.

File metadata

  • Download URL: qprogram-0.1.0.tar.gz
  • Upload date:
  • Size: 405.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","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}

File hashes

Hashes for qprogram-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c91c1ccee667d3519f54756319f869979dd57b0e911ce811904ec03eb3bceaae
MD5 8d0f310b8c829fba4974f64369cac818
BLAKE2b-256 6a0595940bb40c18f3d6c5dc39360ae4938991cff2a6fa0eeac5c74f8007528d

See more details on using hashes here.

File details

Details for the file qprogram-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: qprogram-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 272.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","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}

File hashes

Hashes for qprogram-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a59fcb279394146696ea2287671edd09004e56027881745bca055d31b0b34d3b
MD5 e5fc0ccbea44ee014ab44ddf253246ef
BLAKE2b-256 0d234f97d6602da280da3652acac945ec961928e227a8ae8f80a1d4487260384

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 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