Skip to main content

Quantinuum's tool for converting HUGR to QIR

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-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(main.compile().to_bytes())
        # Or to compile a non-main guppy function:
        sys.stdout.buffer.write(guppy_func.compile_function().to_bytes())
    
  2. 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 -n auto

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.21rc1.tar.gz (799.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.21rc1-cp310-abi3-win_amd64.whl (29.4 MB view details)

Uploaded CPython 3.10+Windows x86-64

hugr_qir-0.0.21rc1-cp310-abi3-manylinux_2_34_x86_64.whl (34.4 MB view details)

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

hugr_qir-0.0.21rc1-cp310-abi3-macosx_13_0_x86_64.whl (32.3 MB view details)

Uploaded CPython 3.10+macOS 13.0+ x86-64

hugr_qir-0.0.21rc1-cp310-abi3-macosx_13_0_arm64.whl (29.7 MB view details)

Uploaded CPython 3.10+macOS 13.0+ ARM64

File details

Details for the file hugr_qir-0.0.21rc1.tar.gz.

File metadata

  • Download URL: hugr_qir-0.0.21rc1.tar.gz
  • Upload date:
  • Size: 799.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.12.3

File hashes

Hashes for hugr_qir-0.0.21rc1.tar.gz
Algorithm Hash digest
SHA256 551a967f6f78e91e47b81503f179dfe8f15a9b91144ef769da9cc970b47017cd
MD5 77adb1922cedf887cc3123d15c5b3ece
BLAKE2b-256 39e5aa147cfe071b73ce6adb390843461184e49c91a826a8c108b5ab857189a7

See more details on using hashes here.

File details

Details for the file hugr_qir-0.0.21rc1-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for hugr_qir-0.0.21rc1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8ac8f37af30387f34963b50a7351d22508d9a882a62f8d548cfd86c7bc3482ce
MD5 34f404fcfa1afa22e1202b3117bfe2f0
BLAKE2b-256 e34c2d2271fb9b6284b4f1e59136b72cc489564960791f59cab516a407259e6d

See more details on using hashes here.

File details

Details for the file hugr_qir-0.0.21rc1-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for hugr_qir-0.0.21rc1-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5f55c6f8ed79562afdc1ea349f91e4f512b529b28236d641f06aadf6c9cb1daa
MD5 64ca65253da6330fe0fa7dea70f15f09
BLAKE2b-256 90bc1606eb171c6e37ed217aabc5b5a6a8d2cc9231f3ac8960c34880aeda84ed

See more details on using hashes here.

File details

Details for the file hugr_qir-0.0.21rc1-cp310-abi3-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for hugr_qir-0.0.21rc1-cp310-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 001c9a1da8bcd4bdc227e81bc242a9602539da3b62fe193f0cbbbfc1b21948e5
MD5 9637aba25769ce82ae6bf3bf14377cd4
BLAKE2b-256 f22e6da6dc05d7522edbf877939f2f6296ac74043da48b76bf79c52cc3abcea2

See more details on using hashes here.

File details

Details for the file hugr_qir-0.0.21rc1-cp310-abi3-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for hugr_qir-0.0.21rc1-cp310-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 953e71d8ac654a87bc48460011a779573c3d196d258243fde8bcda09425535a7
MD5 704d73148dccf368e755f44e97d58047
BLAKE2b-256 90e79c65bc2647fd121b304429e44a4a440850975d33e57f7cee1a09592e0e19

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