Skip to main content

QIR to Quantinuum QIS (Quantum Instruction Set) compiler

Project description

QIR-QIS

Crates.io PyPI

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 14
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 Rust dependencies and build
cargo build

# Install Python dependencies
uv sync

Building

# Build Rust binary
cargo build --release

# Build Python package
uv run maturin build --release

Testing

Running Tests

Tests require cargo-nextest:

# Run all tests
make test

# Or directly with cargo
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:

  1. Compile the QIR to QIS
  2. Run it on the Selene/Quest simulator
  3. 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


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

qir_qis-0.1.2-cp310-abi3-win_amd64.whl (15.7 MB view details)

Uploaded CPython 3.10+Windows x86-64

qir_qis-0.1.2-cp310-abi3-manylinux_2_28_x86_64.whl (18.8 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

qir_qis-0.1.2-cp310-abi3-manylinux_2_28_aarch64.whl (17.5 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

qir_qis-0.1.2-cp310-abi3-macosx_13_0_x86_64.whl (17.5 MB view details)

Uploaded CPython 3.10+macOS 13.0+ x86-64

qir_qis-0.1.2-cp310-abi3-macosx_13_0_arm64.whl (15.9 MB view details)

Uploaded CPython 3.10+macOS 13.0+ ARM64

File details

Details for the file qir_qis-0.1.2-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: qir_qis-0.1.2-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 15.7 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

Hashes for qir_qis-0.1.2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9bbe962c5660a77a8dddfc7d7ac8b9361c533c146e0069f4500b23d62457e582
MD5 335a0e5509153db28120aee3919c6a49
BLAKE2b-256 683b2448c23b2528ba41b17c6e20424a586e76507d8b63333ea6e2e04d8c97db

See more details on using hashes here.

Provenance

The following attestation bundles were made for qir_qis-0.1.2-cp310-abi3-win_amd64.whl:

Publisher: wheels-release.yml on Quantinuum/qir-qis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qir_qis-0.1.2-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for qir_qis-0.1.2-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 12fa517ffd305200ee231035bf0b59f7fce20f92347e6b93892b18a9601923fa
MD5 7d56938e8a865efd46787c093f3f7d52
BLAKE2b-256 a5974f6f53c4ad4ef151c008ed7e390d73a46feaf656cb4da0db00cb3a116830

See more details on using hashes here.

Provenance

The following attestation bundles were made for qir_qis-0.1.2-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: wheels-release.yml on Quantinuum/qir-qis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qir_qis-0.1.2-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for qir_qis-0.1.2-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 01aae87bdf4c42ef2daf324ab1bfad6b6fc97eb98964de7b51c4bc8be0460f33
MD5 15bc30f9880ff88d938b7e04b8605077
BLAKE2b-256 bcf5f1447c8d03cfd1ec7cb209eae86a514ba4b54e2a4c165cb857ad59b89a20

See more details on using hashes here.

Provenance

The following attestation bundles were made for qir_qis-0.1.2-cp310-abi3-manylinux_2_28_aarch64.whl:

Publisher: wheels-release.yml on Quantinuum/qir-qis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qir_qis-0.1.2-cp310-abi3-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for qir_qis-0.1.2-cp310-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 1cdab8c9250dfb783cb6d3d43f719c2a540292b41d9076a84fd03254229323a0
MD5 123f6129b2bdeeb78f7ae5cfebf032f6
BLAKE2b-256 0c0b4e606a3af3fcfbe99c92e6d933458d0df407bab8d0b2bb701a75eadf6913

See more details on using hashes here.

Provenance

The following attestation bundles were made for qir_qis-0.1.2-cp310-abi3-macosx_13_0_x86_64.whl:

Publisher: wheels-release.yml on Quantinuum/qir-qis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qir_qis-0.1.2-cp310-abi3-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for qir_qis-0.1.2-cp310-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 6c81bbe95ec61c241d9aba5d5ad9e457b96bc4e7642c12b19bff7882a84d1183
MD5 44034a3c2a588ea643c9d10bd489d25a
BLAKE2b-256 65cedd353987e9ca6e3f51ce134ad9d30e4d7559c4a9791fec5d347995380ead

See more details on using hashes here.

Provenance

The following attestation bundles were made for qir_qis-0.1.2-cp310-abi3-macosx_13_0_arm64.whl:

Publisher: wheels-release.yml on Quantinuum/qir-qis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page