Skip to main content

Quantinuum's tool for converting HUGR to QIR

Project description

hugr-qir

WARNING: this is a beta version, still under development and not all hugr/guppy programs can be converted

build_status codecov

A tool for converting Hierarchical Unified Graph Representation (HUGR, pronounced hugger) formatted quantum programs into QIR format.

Installation

You can install from pypi via pip install hugr-qir.

Usage

Python

Use the function hugr_to_qir from the hugr_to_qir module to convert hugr to qir. By default, some basic validity checks will be run on the generated QIR. These checks can be turned off by passing validate_qir = False.

You can find an example notebook at examples/submit-guppy-h1-h2-via-qir.ipynb showing the conversion and the submission to H1/H2.

CLI

You can use the available cli after installing the python package.

This will generate qir for a given hugr file:

hugr-qir test-file.hugr

Run hugr-qir --help to see the available options.

If you want to generate a hugr file from guppy, you can do this in two steps:

  1. add this to the end of your guppy file:
if __name__ == "__main__":
    sys.stdout.buffer.write(guppy.compile(main).package.to_bytes())
  1. Generate the hugr file with:
python guppy_examples/quantum-classical-1.py > test-guppy.hugr

Development

#️⃣ Setting up the development environment

The easiest way to setup the development environment is to use the provided devenv.nix file. This will setup a development shell with all the required dependencies.

To use this, you will need to install devenv. Once you have it running, open a shell with:

devenv shell

All the required dependencies should be available. You can automate loading the shell by setting up direnv.

Run tests

You can run the rust test with:

cargo test

You can run the Python test with:

pytest

If you want to update the snapshots you can do that via:

pytest --snapshot-update

License

This project is licensed under Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0).

Project details


Download files

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

Source Distribution

hugr_qir-0.0.6.tar.gz (179.6 kB view details)

Uploaded Source

Built Distributions

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

hugr_qir-0.0.6-cp310-abi3-win_amd64.whl (8.5 MB view details)

Uploaded CPython 3.10+Windows x86-64

hugr_qir-0.0.6-cp310-abi3-manylinux_2_28_x86_64.whl (10.2 MB view details)

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

hugr_qir-0.0.6-cp310-abi3-macosx_13_0_x86_64.whl (9.7 MB view details)

Uploaded CPython 3.10+macOS 13.0+ x86-64

hugr_qir-0.0.6-cp310-abi3-macosx_13_0_arm64.whl (8.9 MB view details)

Uploaded CPython 3.10+macOS 13.0+ ARM64

File details

Details for the file hugr_qir-0.0.6.tar.gz.

File metadata

  • Download URL: hugr_qir-0.0.6.tar.gz
  • Upload date:
  • Size: 179.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.0

File hashes

Hashes for hugr_qir-0.0.6.tar.gz
Algorithm Hash digest
SHA256 cf076e43d1119e5ff9fa67c5f2d70ec54ce4de5399f31f1d3feac032e816255c
MD5 725727f3e08ae9130591dca8d7c5e65d
BLAKE2b-256 ac7dc066ec9670bdb214ee1b59cd456312e79bd6c9ae9de18e5b9aaa00750bc1

See more details on using hashes here.

File details

Details for the file hugr_qir-0.0.6-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: hugr_qir-0.0.6-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 8.5 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.0

File hashes

Hashes for hugr_qir-0.0.6-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 81edd99a1e55932fabe670358ac885c0e6959b64adc1b82e7c7fa3b893f8222f
MD5 0c4ee334a3f18a95f23b54a54c700eec
BLAKE2b-256 1d2849345df212915bee274f2b669beeb6ac9637a6dabc9983fca362cadcc696

See more details on using hashes here.

File details

Details for the file hugr_qir-0.0.6-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hugr_qir-0.0.6-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 137eb9523c9d3e602c4471f2a03a93ffd5e498a820a7597ae581c2011067d7aa
MD5 a5705be17ca7c8fe6a15b11ff296a366
BLAKE2b-256 62a106bb9d73c31907fdaef3fed5098fb29b449a48cb7517aa7ec2536305e288

See more details on using hashes here.

File details

Details for the file hugr_qir-0.0.6-cp310-abi3-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for hugr_qir-0.0.6-cp310-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 5517f33a560a60e6bc09134efe1cb6238d9084bba0e8316dff00972f7d01e1e9
MD5 745c463e7275a541346e869f6d4b697c
BLAKE2b-256 e74d0b03b350b9d32332b594835e523a6dcb796cc2c8930c8b239dfda4800513

See more details on using hashes here.

File details

Details for the file hugr_qir-0.0.6-cp310-abi3-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for hugr_qir-0.0.6-cp310-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 2d1fb2f41e512a5f7abe400ff694440a18464a78111f9101643d58c9edc9e7e9
MD5 7f1f33f5152a82306a9deb16d42d454a
BLAKE2b-256 b14a921b107af46ac9a8de2be874aa657ba6535485f8e0558a1f38dea1111953

See more details on using hashes here.

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