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(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.14.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.14-cp310-abi3-win_amd64.whl (29.7 MB view details)

Uploaded CPython 3.10+Windows x86-64

hugr_qir-0.0.14-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.14-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.14-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.14.tar.gz.

File metadata

  • Download URL: hugr_qir-0.0.14.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.14.tar.gz
Algorithm Hash digest
SHA256 015f425b67170b4b889b087d3fdf24fc3a3826e8a3ddf25efac2ce76d03ff352
MD5 276d1c7f86bf77fef06533da3af7f3b8
BLAKE2b-256 771c2c899d97df75e03abeaf93a4835d5e0bb4c94bc867fc7d4c61efb09b713e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.14-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0d9d67d7980b3f04bd6123bdee9f682672c70de57015b8564c284cb0002cf2c1
MD5 df3136406e703913ef26f6e9d353e721
BLAKE2b-256 204157b9e33d43f5f2fe35a17f065e5982885df6cda721d8bf5cfc92fb872f2a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.14-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 81ee89a7f723dc2821323dcf125c9f5dd8a47a4e7ddd37209b7924fad7015bbd
MD5 2523549afaa8f208625e2d995653ba27
BLAKE2b-256 a271330f7114a356f896ce9a32afad43b71cc5c314930e34cf95153e34d182bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.14-cp310-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 45d6c14f35a5dac3babe9a47491b0a6f16f514121d015b8cd5a042d973005912
MD5 71a2deabf010f236b291514ea64baedf
BLAKE2b-256 812fc79004be126af7bd3f83f1766b44c61bf6c15fdd95834f1d8e331129688a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.14-cp310-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 2532ae9b261cdbaba520e83b64a7af149ff31908aeff2c2cfdfa0c2e1ca898fd
MD5 98643f6fa116bbb461cdb8a9e9cf6f89
BLAKE2b-256 9c2b13fa166f640de68db2d44fa28636210a91c87fd560e79f26bea800067c3d

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