QIR to Quantinuum QIS (Quantum Instruction Set) compiler
Project description
QIR-QIS
A compiler that validates and translates QIR (Quantum Intermediate Representation) to Quantinuum QIS (Quantum Instruction Set). This tool enables quantum programs written in QIR to run on Quantinuum's quantum computing systems.
Features
- QIR Validation: Validates QIR bitcode for correctness and spec compliance
- QIS Translation: Compiles QIR to Quantinuum's native QIS instruction set
- Python & Rust API: Use as a Rust library or Python package
- CLI Tool: Command-line interface for quick compilation
See qtm-qir-reference.md for details on supported QIR features and their mapping to Quantinuum QIS.
Installation
From Source (Rust)
Requirements:
- Rust >= 1.91.0
- LLVM 21
# Point llvm-sys to your LLVM 21 installation
export LLVM_SYS_211_PREFIX=/path/to/llvm21
cargo build --release
The compiled binary will be available at target/release/qir-qis.
Python Package
Requirements:
- Python >= 3.10, < 3.15
- uv (recommended) or pip
Available pre-built wheels:
- Linux: x86_64 (manylinux_2_28), aarch64 (manylinux_2_28)
- macOS: x86_64, arm64 (Apple Silicon)
- Windows: x86_64
All wheels support Python 3.10+ using the stable ABI (abi3).
# Using uv (recommended)
uv pip install qir-qis
# Using pip
pip install qir-qis
For development installation:
uv sync
Usage
Command Line
Compile a QIR LLVM IR file to QIS bitcode:
# Basic usage
qir-qis input.ll
# With custom optimization level
qir-qis -O 3 input.ll
# Specify target architecture
qir-qis -t x86-64 input.ll
# Or using cargo
cargo run -- input.ll
This generates input.qis.bc containing the compiled QIS bitcode.
Python API
See examples/python_api.py for a complete working example.
uv run examples/python_api.py
For a more comprehensive example with quantum simulation, see main.py.
Rust API
See examples/rust_api.rs for a complete working example.
cargo run --example rust_api
Development
Setting Up Development Environment
# Clone the repository
git clone https://github.com/quantinuum/qir-qis.git
cd qir-qis
# Install LLVM 21 (macOS/Homebrew example)
brew install llvm@21
export LLVM_SYS_211_PREFIX=/opt/homebrew/opt/llvm@21
# Install Rust dependencies and build
cargo build
# Install Python dependencies
uv sync
Building
# Build Rust binary
LLVM_SYS_211_PREFIX=${LLVM_SYS_211_PREFIX:-/opt/homebrew/opt/llvm@21} \
cargo build --release
# Build Python package
LLVM_SYS_211_PREFIX=${LLVM_SYS_211_PREFIX:-/opt/homebrew/opt/llvm@21} \
uv run maturin build --release
Testing
Running Tests
Tests require cargo-nextest:
# Run all tests
LLVM_SYS_211_PREFIX=${LLVM_SYS_211_PREFIX:-/opt/homebrew/opt/llvm@21} \
make test
# Or directly with cargo
LLVM_SYS_211_PREFIX=${LLVM_SYS_211_PREFIX:-/opt/homebrew/opt/llvm@21} \
cargo nextest run --all-targets --all-features
Testing Individual Files
# Compile a single QIR file
make compile FILE=tests/data/adaptive.ll
# Compile all test files
make allcompile
Simulation Testing with Selene
Test the compiled QIS using Selene quantum simulator:
# Simulate a single file (runs 5 shots by default)
make sim FILE=tests/data/adaptive.ll
# Simulate all test files
make allsim
This will:
- Compile the QIR to QIS
- Run it on the Selene/Quest simulator
- Display measurement results
Code Quality
# Run linters
make lint
# This runs:
# - prek (pre-commit checks, https://prek.j178.dev/)
# - typos checker
# - cargo clippy
Regenerating Python Stubs
After modifying the Python API:
make stubs
This updates qir_qis.pyi with the latest type signatures.
Project Structure
qir-qis/
├── src/
│ ├── main.rs # CLI entry point
│ ├── lib.rs # Library and Python bindings
│ ├── convert.rs # QIR to QIS conversion logic
│ ├── decompose.rs # Gate decomposition
│ ├── opt.rs # LLVM optimization passes
│ └── utils.rs # Helper utilities
├── tests/
│ ├── data/ # Test QIR files
│ └── snaps/ # Snapshot test results
├── main.py # Example Python usage with simulation
├── Cargo.toml # Rust package configuration
├── pyproject.toml # Python package configuration
└── Makefile # Common development tasks
Common Makefile Targets
| Command | Description |
|---|---|
make test |
Run all unit and integration tests |
make compile FILE=<path> |
Compile a single QIR file |
make sim FILE=<path> |
Compile and simulate a QIR file |
make lint |
Run code quality checks |
make stubs |
Regenerate Python type stubs |
make allcompile |
Compile all test files |
make allsim |
Simulate all test files |
Contributing
Contributions are welcome! Please read CONTRIBUTING.md for:
- How to report issues and submit pull requests
- Coding standards and commit message format
- Development workflow and testing requirements
Quick checklist before submitting:
- Tests pass:
make test - Linters pass:
make lint - Documentation updated
License
Apache-2.0
Copyright Quantinuum
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qir_qis-0.1.4-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: qir_qis-0.1.4-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 20.3 MB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b596b3f6c644c6d519c97747d18c6df599098a6ea18b1545e295deaf6f756e71
|
|
| MD5 |
43a80abc718f322f60855c306028f029
|
|
| BLAKE2b-256 |
e181f25de0a11e190dce0c7e5e53785fc998ead74c9666d87272cc37c1bb0ef4
|
Provenance
The following attestation bundles were made for qir_qis-0.1.4-cp310-abi3-win_amd64.whl:
Publisher:
wheels-release.yml on Quantinuum/qir-qis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qir_qis-0.1.4-cp310-abi3-win_amd64.whl -
Subject digest:
b596b3f6c644c6d519c97747d18c6df599098a6ea18b1545e295deaf6f756e71 - Sigstore transparency entry: 1117437662
- Sigstore integration time:
-
Permalink:
Quantinuum/qir-qis@22f8c57d038402e9c0e7eca46abb68959fba73ac -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Quantinuum
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels-release.yml@22f8c57d038402e9c0e7eca46abb68959fba73ac -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file qir_qis-0.1.4-cp310-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: qir_qis-0.1.4-cp310-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 26.0 MB
- Tags: CPython 3.10+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
390b5abc1be0154f9b623e75528ffc9cbf41aac4cd6173bfec6088db50777d8e
|
|
| MD5 |
b46d9c134d15e990e2dfdb79ccceaa22
|
|
| BLAKE2b-256 |
1cadf89d038322062fa35881932ab0828ce73db7ea06aa54df356c411928ed02
|
Provenance
The following attestation bundles were made for qir_qis-0.1.4-cp310-abi3-manylinux_2_34_x86_64.whl:
Publisher:
wheels-release.yml on Quantinuum/qir-qis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qir_qis-0.1.4-cp310-abi3-manylinux_2_34_x86_64.whl -
Subject digest:
390b5abc1be0154f9b623e75528ffc9cbf41aac4cd6173bfec6088db50777d8e - Sigstore transparency entry: 1117437725
- Sigstore integration time:
-
Permalink:
Quantinuum/qir-qis@22f8c57d038402e9c0e7eca46abb68959fba73ac -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Quantinuum
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels-release.yml@22f8c57d038402e9c0e7eca46abb68959fba73ac -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file qir_qis-0.1.4-cp310-abi3-manylinux_2_34_aarch64.whl.
File metadata
- Download URL: qir_qis-0.1.4-cp310-abi3-manylinux_2_34_aarch64.whl
- Upload date:
- Size: 28.7 MB
- Tags: CPython 3.10+, manylinux: glibc 2.34+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7bdd4cd5c98c42ffbbb790279708fd871c09b5f52cfee36a25aaed608eedcc1
|
|
| MD5 |
adf90dbbeebdea79f36d2b2b66bd6345
|
|
| BLAKE2b-256 |
e0691ee1d966b4703988c066d4bfabc56e338ac285dc61654198110310882ba8
|
Provenance
The following attestation bundles were made for qir_qis-0.1.4-cp310-abi3-manylinux_2_34_aarch64.whl:
Publisher:
wheels-release.yml on Quantinuum/qir-qis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qir_qis-0.1.4-cp310-abi3-manylinux_2_34_aarch64.whl -
Subject digest:
a7bdd4cd5c98c42ffbbb790279708fd871c09b5f52cfee36a25aaed608eedcc1 - Sigstore transparency entry: 1117437688
- Sigstore integration time:
-
Permalink:
Quantinuum/qir-qis@22f8c57d038402e9c0e7eca46abb68959fba73ac -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Quantinuum
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels-release.yml@22f8c57d038402e9c0e7eca46abb68959fba73ac -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file qir_qis-0.1.4-cp310-abi3-macosx_15_0_x86_64.whl.
File metadata
- Download URL: qir_qis-0.1.4-cp310-abi3-macosx_15_0_x86_64.whl
- Upload date:
- Size: 23.2 MB
- Tags: CPython 3.10+, macOS 15.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
373c5c258605648bee53b00fc0f1acda9c40543242b93ce25982eba5f034e136
|
|
| MD5 |
fea635efc7503eef022e01f47e5dfac5
|
|
| BLAKE2b-256 |
a007c40232233d5d831927020d1f634ca815cc172726aa7635cd245810c05f19
|
Provenance
The following attestation bundles were made for qir_qis-0.1.4-cp310-abi3-macosx_15_0_x86_64.whl:
Publisher:
wheels-release.yml on Quantinuum/qir-qis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qir_qis-0.1.4-cp310-abi3-macosx_15_0_x86_64.whl -
Subject digest:
373c5c258605648bee53b00fc0f1acda9c40543242b93ce25982eba5f034e136 - Sigstore transparency entry: 1117437762
- Sigstore integration time:
-
Permalink:
Quantinuum/qir-qis@22f8c57d038402e9c0e7eca46abb68959fba73ac -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Quantinuum
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels-release.yml@22f8c57d038402e9c0e7eca46abb68959fba73ac -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file qir_qis-0.1.4-cp310-abi3-macosx_15_0_arm64.whl.
File metadata
- Download URL: qir_qis-0.1.4-cp310-abi3-macosx_15_0_arm64.whl
- Upload date:
- Size: 21.9 MB
- Tags: CPython 3.10+, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5889f93960216f1f66f7e05d37873edcbf21a1f5c6f24cdb667a16cc90bef202
|
|
| MD5 |
c0b8b79ecdfeb2a8bb67d9e35de4a068
|
|
| BLAKE2b-256 |
43980ff34bb2016bf67d4ec708067df4c083bba41c6b616334866b19027989fc
|
Provenance
The following attestation bundles were made for qir_qis-0.1.4-cp310-abi3-macosx_15_0_arm64.whl:
Publisher:
wheels-release.yml on Quantinuum/qir-qis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qir_qis-0.1.4-cp310-abi3-macosx_15_0_arm64.whl -
Subject digest:
5889f93960216f1f66f7e05d37873edcbf21a1f5c6f24cdb667a16cc90bef202 - Sigstore transparency entry: 1117437638
- Sigstore integration time:
-
Permalink:
Quantinuum/qir-qis@22f8c57d038402e9c0e7eca46abb68959fba73ac -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Quantinuum
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels-release.yml@22f8c57d038402e9c0e7eca46abb68959fba73ac -
Trigger Event:
workflow_dispatch
-
Statement type: