Skip to main content

Qxide

한국어 · 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.5.0 is an early experiment introducing Java-style syntax, and 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.

$ qxide run examples/qx/bell.qx
a=1 b=1
$ qxide run examples/qx/bell.qx --shots 1000
[0, 0]  0b00 = 0  ×504
  a=0 b=0
[1, 1]  0b11 = 3  ×496
  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()

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

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.5.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.5.0
File Size Uploaded Provenance Actions
qxide-0.5.0.tar.gz 200.2 kB Without provenance Details for qxide-0.5.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for qxide 0.5.0
File Actions
qxide-0.5.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for qxide-0.5.0-py3-none-win_amd64.whl
qxide-0.5.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.5.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
qxide-0.5.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for qxide-0.5.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
qxide-0.5.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for qxide-0.5.0-py3-none-macosx_11_0_arm64.whl
qxide-0.5.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for qxide-0.5.0-py3-none-macosx_10_12_x86_64.whl

Total release size: 1.9 MB

Release files / qxide-0.5.0.tar.gz

Download URL qxide-0.5.0.tar.gz
Size 200.2 kB
Tags Source
SHA-256 checksum
How to use checksums
acfd49378475d8045d65995af2cd9bdfa7a5e03db23e3a7e81e68a37ac7514f5
BLAKE2b-256 checksum
How to use checksums
278cf27399af84432073aa77f6fbd791bd53189733e146d2c5c029beccc57aab
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.5.0-py3-none-win_amd64.whl

Download URL qxide-0.5.0-py3-none-win_amd64.whl
Size 247.2 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
75ad04fba93a1f9e6a838bda82f76d26f3ca949a66baea5ebb827a782f5a6986
BLAKE2b-256 checksum
How to use checksums
a8bd52dc34ac10c8e6305d0980a1f59689fd2a96e76cb69aba85aff61a7f640f
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.5.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL qxide-0.5.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 385.2 kB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
f21eb6f0985088d0292760fbf068767b240492f55ead787bb28023316877ed51
BLAKE2b-256 checksum
How to use checksums
55e306b52597fdc53ec2be582e60a918b7e96dbb824563062a0b4ef9e9c89d18
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.5.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL qxide-0.5.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 379.3 kB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
2d684cb66a97c8ea7209e0499d384eaaa6d99d3cd32d86eef6465723942a70c3
BLAKE2b-256 checksum
How to use checksums
dff65034302df6820cca08aef9b2ef7a4109851e1faf16c8fb841677117aa8c5
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.5.0-py3-none-macosx_11_0_arm64.whl

Download URL qxide-0.5.0-py3-none-macosx_11_0_arm64.whl
Size 350.0 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d87b1f93fb8bacd1815f281cd7bb4e3dc08118ac7356770ba162548e1fd3cdde
BLAKE2b-256 checksum
How to use checksums
cdcd70edb22370ba75072b52cb50e74b5567b572f38ea4b74b0e255b014683e7
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.5.0-py3-none-macosx_10_12_x86_64.whl

Download URL qxide-0.5.0-py3-none-macosx_10_12_x86_64.whl
Size 359.4 kB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
94f70a11ed13cf98e6f6b59176cf959a6d40c864275cdfa800087e62328bbcea
BLAKE2b-256 checksum
How to use checksums
c003259ba4f26dd2e25a46dbd0a4ca5a23fb18aac4e6e812cf06cd7ab13db170
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.5.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