Skip to main content

Quantinuum's tool for converting HUGR to QIR

Reason this release was yanked:

release bug

Project description

hugr-qir

build_status codecov

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

Warning: Not all hugr/guppy programs can be converted to QIR

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/general/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.13.tar.gz (227.5 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.13-cp310-abi3-win_amd64.whl (29.7 MB view details)

Uploaded CPython 3.10+Windows x86-64

hugr_qir-0.0.13-cp310-abi3-manylinux_2_34_x86_64.whl (34.6 MB view details)

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

hugr_qir-0.0.13-cp310-abi3-macosx_13_0_x86_64.whl (32.7 MB view details)

Uploaded CPython 3.10+macOS 13.0+ x86-64

hugr_qir-0.0.13-cp310-abi3-macosx_13_0_arm64.whl (30.0 MB view details)

Uploaded CPython 3.10+macOS 13.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for hugr_qir-0.0.13.tar.gz
Algorithm Hash digest
SHA256 1851d87fe11dd51ef0aad2fd2518d39313b67d5edaaad0d459878e7367293ccc
MD5 885ef72b90a82af9e6de9c5b722dedb5
BLAKE2b-256 fae62352c6d145463fc8465b698a4a9d7747d1c67baa5726c47a3d504e55ba8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.13-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8cfc5bc10c9f7f919befcdd96f56e5d266bbfc92c01218bbc515418abc86afed
MD5 38ea9d7358f44a5171f1569450512b20
BLAKE2b-256 d119aff941ca95b7c4a5a18f952a0df32f437ef29fe3fc918c3080f014385cf6

See more details on using hashes here.

File details

Details for the file hugr_qir-0.0.13-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for hugr_qir-0.0.13-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 939d9f642e219515e4dbe2fb354937b7a4e833d1a2ee4440e4d66e1511bddba1
MD5 62218e0d0f0344f18d2e70037cd95bba
BLAKE2b-256 06ad2978d22616d2f5308ffa058cf20362b90fbc55856ab6b311ee01491c219d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.13-cp310-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 7ae685432a4dc579ec4f83524cc353b9a1f4c3e1a81557431c3c626443b9e83e
MD5 467ac620d92d39d1d2297a4c5c0555d1
BLAKE2b-256 9df5091a634d0007b90af3a8867d6e6ef91ce94db6a759f4e3591b16c1d9c0e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.13-cp310-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 62be0654a3e7ed0fea9e24a8248e2c17455392e1100e8b00a1a14c2a7513d76b
MD5 6e1a7b9833cf6ca70a1a1e7334395f33
BLAKE2b-256 089af1f5b73ad96b339b2086f3c044b34158d1ad11e6103d474e4ca516fa2e64

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