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.8.tar.gz (191.2 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.8-cp310-abi3-win_amd64.whl (29.6 MB view details)

Uploaded CPython 3.10+Windows x86-64

hugr_qir-0.0.8-cp310-abi3-manylinux_2_34_x86_64.whl (34.2 MB view details)

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

hugr_qir-0.0.8-cp310-abi3-macosx_13_0_x86_64.whl (32.6 MB view details)

Uploaded CPython 3.10+macOS 13.0+ x86-64

hugr_qir-0.0.8-cp310-abi3-macosx_13_0_arm64.whl (29.8 MB view details)

Uploaded CPython 3.10+macOS 13.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for hugr_qir-0.0.8.tar.gz
Algorithm Hash digest
SHA256 f385a020c821010486521cac77c8a55dad523076b73d2c21d8a5f3ab9cc383c0
MD5 2d435033cb90332cdab88542ba498e51
BLAKE2b-256 6fc2aaa1d808b5258293186d0c178222dcbbb9a92cf8da22c19395767d1369bb

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for hugr_qir-0.0.8-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f2b8d345abf2be73a6476ac0389e10147ef63c6daa1690e7a52d37296a2784d6
MD5 798f3d6d904c46622d03df7e3e820dfa
BLAKE2b-256 505de9a2b0714ebc922ee0d600c32b35579b0db0ae6a06a9fb566b09caeb9db8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.8-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8fd5deb644971f1cb5daa8eaf9f510ea08607639843513b53e1bb8db5325ffe1
MD5 d2b9a0dc19e2e8697b119caf67e16c8e
BLAKE2b-256 84bd812064d7a25df48d905ec13137ec7d3dcc7f85d4daea44cd9a15cc5cf9bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.8-cp310-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 496d694eb5695c3b11e50489011be627fa9bc728bd6b5007aa57ac0f492be6e7
MD5 23e2f803d0a952e838fe4c180fb8d7dd
BLAKE2b-256 24ac3077aca3a7e2a4fbbbdf97f12bb0164895854c440984ed7bd880d2918ba6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.8-cp310-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 f6a77c23bca2f976ed0c4a23ecdde275856d8f08311b636ae9511aa30fd075e6
MD5 bb18a7dcd4b20df2445b1e21a9ae1150
BLAKE2b-256 7adc00ac6a653282a0eed898023802fad3fa12575676248b98183aee24251b32

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