Skip to main content

Qxide logo

Qxide

Korean · qxide.dev

Qxide is a programming language for classical and quantum computers with Java/C-style syntax and compile-time qubit safety that compiles quantum code to OpenQASM 3.

The qxide command-line tool simulates .qx programs with built-in state-vector and stabilizer simulators (qxide run), checks them (qxide check), and exports them to OpenQASM 3 (qxide qasm). The same qxide crate can also be used directly as a Rust library. Version 0.8.0 is still an early experiment adding a typed IR engine and optional Cranelift JIT (--engine ir|jit), submission to IBM Quantum devices (qxide run --backend ibm:<device>), String and the std library, desktop apps, and a language server with a VS Code extension; both the language and APIs may still change.

Install

There are three ways to install the qxide command; all of them install the same binary.

Install a prebuilt binary from GitHub Releases using the install script at qxide.dev:

# Linux / macOS
curl --proto '=https' --tlsv1.2 -LsSf https://qxide.dev/install.sh | sh
# Windows
powershell -ExecutionPolicy Bypass -c "irm https://qxide.dev/install.ps1 | iex"

Install from crates.io (requires a Rust toolchain):

cargo install qxide

Install from PyPI (the wheel bundles the same command-line binary, not a Python API):

pip install qxide

Verify the installation with:

qxide --version

Quick start with .qx

The following .qx program entangles two qubits into a Bell pair using Java/C-style declarations. Additional examples (bell.qx, ghz.qx, teleport.qx) are in examples/qx/.

// examples/qx/bell.qx
void main() {
    Qubit a = qubit();
    Qubit b = qubit();
    h(a);
    cx(a, b);
    Bit ma = measure(a);
    Bit mb = measure(b);
    println("a={} b={}", ma, mb);
}

Run the program with qxide run: a single shot prints the program's output, while --shots N executes N shots. Without --seed, each qxide run picks a fresh random seed so counts differ from run to run and prints the seed used to stderr as a single seed: S (pass --seed S to reproduce) line; passing --seed S reproduces the exact same output and prints no seed line. When nothing printed depends on measurement outcomes (for example, a single shot that prints no measured bit or a program with no measurements), no simulation runs and no seed is printed.

$ qxide run examples/qx/bell.qx
seed: 12059043656824605579 (pass --seed 12059043656824605579 to reproduce)
a=0 b=0
$ qxide run examples/qx/bell.qx --shots 1000
seed: 15940593722917789681 (pass --seed 15940593722917789681 to reproduce)
[0, 0]  0b00 = 0  ×521
  a=0 b=0
[1, 1]  0b11 = 3  ×479
  a=1 b=1

In the multi-shot table, each row represents one measurement record followed by its count: shown as an array with c[0] first ([0, 1, 1]), in binary with the highest bit first (0b110), and as an integer with c[0] as the least significant bit (= 6). The program's own output for that outcome is indented below the row. Use qxide check to validate a program without running it, or qxide qasm to emit OpenQASM 3.

$ qxide check examples/qx/bell.qx
examples/qx/bell.qx: ok
$ qxide qasm examples/qx/bell.qx
OPENQASM 3.0;
include "stdgates.inc";
qubit[2] q;
bit[2] c;
h q[0];
cx q[0], q[1];
c[0] = measure q[0];
c[1] = measure q[1];

Qubits are linear values: they cannot be copied, reused after measurement, or passed twice to the same gate, and every qubit must be measured or explicitly discarded (with discard) before it goes out of scope. In the example below, using a qubit after measuring it produces a compile-time error with line and column numbers, caught by qxide check before anything runs.

void main() {
    Qubit q = qubit();
    Bit m = measure(q);
    h(q);
}
$ qxide check use_after_measure.qx
error[Q0301]: use of consumed qubit `q`
 --> use_after_measure.qx:4:7
  |
4 |     h(q);
  |       ^
note: qubit consumed here
 --> use_after_measure.qx:3:13
  |
3 |     Bit m = measure(q);
  |             ^^^^^^^^^^
  • Types: int (64-bit), double, boolean, Qubit, QReg, Bit, BitReg, and final declarations
  • Gates and operations: h, x, z, s, sdg, t, tdg, rx, ry, rz, cx, ccx, reset, measure, discard
  • Control flow: if on a measured Bit lowers to a classical feed-forward branch in OpenQASM 3
  • Register output: r.to_binary() and r.as_int()
  • Qubit functions: parameters borrowed by default or moved with consume, Qubit/QReg return values, and gate-only calls inside if on a measured Bit (see examples/qx/functions.qx, examples/qx/teleport_fn.qx)
  • Type inference, casts, and constants: var for int/double/boolean locals, Java-style (int) x and (double) n casts, and PI (see examples/qx/rotation.qx)

See docs/design/qx-language.md for the full language design document.

More qxide commands

Besides run, check, and qasm, the qxide command can start a project with qxide new, format code with qxide fmt, run an interactive session with qxide repl, and explain error codes with qxide explain.

qxide new <NAME> creates a new package project containing qxide.toml (with a package name derived from the folder name, version 0.1.0, and the required qxide version), a Bell-pair src/main.qx, a short README.md, and a .gitignore that ignores target/; inside the folder, qxide run with no file runs src/main.qx. It fails with exit code 1 without creating or overwriting anything if the path already exists, and removes the folder again if writing a file fails. qxide fmt <FILE> rewrites a file in place to use standard 4-space indentation, brace placement, spacing, and blank-line rules while preserving comments and exact literal spelling; if the file does not parse, it prints the diagnostic and leaves the file untouched (type and ownership errors do not block formatting). Passing --check never writes to the file, exiting with 1 if the file would change and 0 if it is already formatted.

$ qxide new hello
Created project `hello` in `hello` with `qxide.toml`, `src/main.qx`, `README.md`, and `.gitignore`
Next:
  qxide run hello/src/main.qx
  qxide fmt hello/src/main.qx
$ cat messy.qx
void main(){
Qubit q=qubit();h( q );
Bit m=measure(q);println("{}",m);}
$ qxide fmt --check messy.qx
qxide: `messy.qx` is not formatted; run `qxide fmt messy.qx` to format it
$ qxide fmt messy.qx
$ cat messy.qx
void main() {
    Qubit q = qubit();
    h(q);
    Bit m = measure(q);
    println("{}", m);
}

qxide repl starts an interactive session where you can enter statements, function definitions, or bare expressions whose values are printed, with variables, functions, and qubits persisting across inputs. Each entry is checked under the same rules as qxide run, so errors such as reusing a measured qubit (Q0301) are reported and the rejected input is not kept; qubits may stay live while you work, and any left unmeasured or undiscarded when the session ends are reported as Q0302 with exit code 1. Built-in commands include :help for a summary, :qasm to print the OpenQASM 3 circuit built so far, :reset to clear the session, and :quit to exit. Like qxide run, qxide repl uses a random seed unless --seed S is given, printing the seed once to stderr as seed: S (pass --seed S to reproduce) when an input first prints a measured bit; qxide repl --seed S replays the same outcomes.

$ qxide repl
qxide 0.8.0 interactive .qx session; type :help for commands and :quit to exit.
qx> Qubit q = qubit();
qx> h(q);
qx> Bit m = measure(q);
qx> m
seed: 10159202627767585087 (pass --seed 10159202627767585087 to reproduce)
1
qx> h(q);
error[Q0301]: use of consumed qubit `q`
 --> <repl>:5:3
  |
5 | h(q);
  |   ^
note: qubit consumed here
 --> <repl>:3:9
  |
3 | Bit m = measure(q);
  |         ^^^^^^^^^^
qx> :quit

qxide explain <CODE> prints what triggers an error code and why the rule exists, along with an erroneous example, how to fix it, and the corrected program (codes are case-insensitive). The text comes from docs/error-codes.md, which lists every error code and can also be read directly on GitHub.

$ qxide explain Q0301
Q0301: use of a consumed qubit

A `Qubit` was used after it had already been consumed by being measured, discarded, or moved. In `.qx`, qubits have linear types checked at compile time, so once a qubit is consumed it is no longer available for further operations. This prevents a program from applying gates or other operations to a qubit whose quantum state has already been measured, discarded, or transferred.

Erroneous code example:

```qx
void main() {
    Qubit q = qubit();
    Bit b = measure(q);
    h(q);  // error[Q0301]
    println("{}", b);
}
```
...

Rust library

The same linear-qubit rules are available in the qxide Rust library, where the Rust compiler enforces ownership directly. Qubit does not implement Clone, measure consumes the qubit by value, and cx(&mut a, &mut b) prevents passing the same qubit twice.

cargo add qxide
use qxide::Circuit;

let mut c = Circuit::new();
let mut a = c.qubit();
let mut b = c.qubit();
c.h(&mut a);           // superposition
c.cx(&mut a, &mut b);  // entanglement
let ma = c.measure(a); // `a` is consumed; only a classical bit remains
let mb = c.measure(b);

println!("{}", c.to_qasm());   // OpenQASM 3 for real quantum hardware
let shot = c.simulate(42);     // simulate on an ordinary computer
assert_eq!(shot.get(ma), shot.get(mb));

The library also provides registers, mid-circuit measurement with if_one/if_zero, reset, scoped uncomputation with with_ancilla, automatic backend selection, and an optional GPU state-vector prototype behind the gpu feature; API documentation is available on docs.rs.

Status

  • .qx programs currently run in a tree-walking interpreter.
  • A typed IR and native code generation (Cranelift first, LLVM optional) are planned; no performance claims are made before benchmarks exist.
  • Submitting jobs to physical quantum hardware is not implemented yet.
  • See ROADMAP.md (Korean) and docs/design/qx-language.md for current plans and design details.

License

Licensed under either of MIT (LICENSE-MIT) or Apache-2.0 (LICENSE-APACHE) at your option.

Metadata

Release files for qxide 0.8.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 qxide 0.8.0
File Size Uploaded Provenance Actions
qxide-0.8.0.tar.gz 436.9 kB Without provenance Details for qxide-0.8.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for qxide 0.8.0
File Actions
qxide-0.8.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for qxide-0.8.0-py3-none-win_amd64.whl
qxide-0.8.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for qxide-0.8.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
qxide-0.8.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for qxide-0.8.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
qxide-0.8.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for qxide-0.8.0-py3-none-macosx_11_0_arm64.whl
qxide-0.8.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for qxide-0.8.0-py3-none-macosx_10_12_x86_64.whl

Total release size: 7.5 MB

Release files / qxide-0.8.0.tar.gz

Download URL qxide-0.8.0.tar.gz
Size 436.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9cf4e16b32055618373e47c5657f6ac769bc06a4e44806027fbead397e2f39a6
BLAKE2b-256 checksum
How to use checksums
dab86388c6ec138311249854666abe3055cbf532c49aeb327dedaceaf3d4b67e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / qxide-0.8.0-py3-none-win_amd64.whl

Download URL qxide-0.8.0-py3-none-win_amd64.whl
Size 1.3 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
c0a18b6c8e78a1cdb179cef0dcc092963d2970af56fc3da4a447cf3779e242ca
BLAKE2b-256 checksum
How to use checksums
01c7e8e753082d139fa1836c4ca9f4b5b28003d6151befdf6e9af0ba721f0c51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / qxide-0.8.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL qxide-0.8.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.5 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
d264f131b3b7914e602b85a68cf45d82eca7871a66ee7d328a38d1d6b7670cb8
BLAKE2b-256 checksum
How to use checksums
c1a28af67eb95aecb0bde4599a82479d326f316f5c47448fc11142532c853ec3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / qxide-0.8.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL qxide-0.8.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.5 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
65f4a610640747922c209af690b0ead1ff0d83e019406346d2b944b4637f6798
BLAKE2b-256 checksum
How to use checksums
9ea989e308849bacd793edbf90876140cf49ad9013f597fc8758caf58fe2b4ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / qxide-0.8.0-py3-none-macosx_11_0_arm64.whl

Download URL qxide-0.8.0-py3-none-macosx_11_0_arm64.whl
Size 1.4 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2e548fc2844def1d4a7242b89fe8cab0b97eb8e107bfa4860892491699e5e755
BLAKE2b-256 checksum
How to use checksums
befff8f2e81b7a8ba8b7fbfe4889caba8072a866eb703b90ca34dfa81cf40a64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / qxide-0.8.0-py3-none-macosx_10_12_x86_64.whl

Download URL qxide-0.8.0-py3-none-macosx_10_12_x86_64.whl
Size 1.4 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
ec89c58ec297e78f25d25a5eeb7eba0aded7c777e82c10cf526590e661283f6f
BLAKE2b-256 checksum
How to use checksums
a61f0e5bd7f4b2adb1e6fd47cb77daa91b1a9964e7d65f5d24173cbd11b16d73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for qxide 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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