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.get_module().compile().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.3.tar.gz (176.1 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.3-cp310-abi3-win_amd64.whl (6.8 MB view details)

Uploaded CPython 3.10+Windows x86-64

hugr_qir-0.0.3-cp310-abi3-manylinux_2_28_x86_64.whl (8.0 MB view details)

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

hugr_qir-0.0.3-cp310-abi3-macosx_13_0_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.10+macOS 13.0+ x86-64

hugr_qir-0.0.3-cp310-abi3-macosx_13_0_arm64.whl (7.1 MB view details)

Uploaded CPython 3.10+macOS 13.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for hugr_qir-0.0.3.tar.gz
Algorithm Hash digest
SHA256 c7d59f230af63031c951b499c9163e70b16c0e2e79e19f3b1fda3473c9257ad6
MD5 3415e5cf079202924006916a755dd7aa
BLAKE2b-256 49a3d35d8cead44650aa292ab00b66ea9b89f1ac3ae80d4e1e743f0f309710c5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for hugr_qir-0.0.3-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 33f8e2abb2a34a4101b817612fe1a9d80319102c9ff94685e2050828d085135a
MD5 d36aa98376d80bc46887a7e210b69672
BLAKE2b-256 63324b7693a033a2f4d3ea4cd424ef6851291cb3c9824b0aacce82b8710f2a3c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.3-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 41366ff87568a4e19ec795ef1cb91a56b4fe37d50213e982b7608c29215186df
MD5 1a4bfb4110afd18e34e1c07ba91e1fd6
BLAKE2b-256 7395f0a084edfa3b4d9b1bec9a521e72130737ff96168756fe06e19b6e6fd7c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.3-cp310-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 5fc029f9aa0c31cad0af6a062e9db406fbd422a6e8c2ca802fb129214c74b280
MD5 fe3f34585ffa5070c38cc6194a07534d
BLAKE2b-256 3f496b5a404a3ac142c12fb19d4471992929bb5fa7a04d0c19855d9aa3ec7fa4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.3-cp310-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 7ba7c5e8f83fd869b520b8c397e4eab6d624f4c60a37db5c8797a919051d009b
MD5 d609151a5dab019893464ddfe030bc38
BLAKE2b-256 7e7d8e749a4af1793ff737d8e53d5b3b18dccefe9f86d3a453ba28263b345a7c

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