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-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(main.compile().to_bytes())
    # Or to compile a non-main guppy function:
    sys.stdout.buffer.write(guppy_func.compile_function().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.19.tar.gz (269.4 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.19-cp310-abi3-win_amd64.whl (29.3 MB view details)

Uploaded CPython 3.10+Windows x86-64

hugr_qir-0.0.19-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.19-cp310-abi3-macosx_13_0_x86_64.whl (32.2 MB view details)

Uploaded CPython 3.10+macOS 13.0+ x86-64

hugr_qir-0.0.19-cp310-abi3-macosx_13_0_arm64.whl (29.5 MB view details)

Uploaded CPython 3.10+macOS 13.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for hugr_qir-0.0.19.tar.gz
Algorithm Hash digest
SHA256 d31a4c11cb0d67dea91c74d3066b99602572d6e53072b62e35a1de2bc897ccad
MD5 5a616b86b7deee4033b9bb49cd9f485d
BLAKE2b-256 307f64607db841ec7745e895bcfccdf8e168b1fe7148e35abe3050e72ec7fc61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.19-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a539cb47bf0a88741bd3aaf5bf3cc01028033b936a309b42b506492e40c7ccb2
MD5 723b2bb856d3d81824cb9277d80a71b7
BLAKE2b-256 707bdcfaba042a845a5164fac082ed669160a0fbdcf3181d16389704fa9d158e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.19-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 43c7300329475a0ff738bebcf0baa7daf5b6f07ac7b2a8a08c5321db138d53ae
MD5 2705f04af9c3d3605ce8245e28e7cbf2
BLAKE2b-256 72a85b9e2a2088bae95e9b34e1b1368beabb9e34628a66ff9fff9a3349145e5c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.19-cp310-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 fdd156e10614d068e7689dc4e75d1dcf7bb1a96a2c2fd729aae68cb5d40f1cf5
MD5 dc35767ab6e8da06eef63b0242b2d402
BLAKE2b-256 67e354950f0f415dbb14d6a51a122fcaafddf563ca85948bf3c9e61dc90ddad7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.19-cp310-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 ee8d51fd35e9dbe32c969108ea15bb52aedd684e6ebb29e544a030eb1f89d12f
MD5 027afd25b419fecaad15f7c52397c801
BLAKE2b-256 a5488bde86a5d51da2cf6372f4a25d2cea64e353cd08400f3f0493d63ec5af06

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