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

Uploaded CPython 3.10+Windows x86-64

hugr_qir-0.0.9-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.9-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.9-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.9.tar.gz.

File metadata

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

File hashes

Hashes for hugr_qir-0.0.9.tar.gz
Algorithm Hash digest
SHA256 a685590a6ce7808adfe11a1ccb0e9aed96802d92e5a55a010ddcf64468883d26
MD5 afddecc3a22282f11424efb8b337c74b
BLAKE2b-256 2d89e12988505325789311bd0b4777a4e9851d02ee58976c101514a142dbfae9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hugr_qir-0.0.9-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.9-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1bd915bf9d7006361d56d8bd292f5172d7de42ec22eab970d78c9938a20ca735
MD5 4ba4b32dae1ac8eacfcfe3121afb22e7
BLAKE2b-256 57af81ba97fafde6b9678324d56e4eb151627e1a21664d2d27f014c944f6ff36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.9-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5741cdd74c61cc92316418b644e524130289b86d26c2403e126515586f131ba9
MD5 267014fef8938cfd9061bc837f6f3d08
BLAKE2b-256 6ff91e9d89ed1f34a075b94275e71c3a1571f288cc62198b9a012ca84e95f223

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.9-cp310-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 2b2071e87c9154df93c3ea1d97e407832c57cafd897e282d960311e21786233c
MD5 c1be7e3b19b5cde9d5ad81b3c176246d
BLAKE2b-256 ed726624c4b353da4bf5751a9d096178d397d30a4ba2cf755a10c159f6be174e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.9-cp310-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 8ffbf38995c69315acc6053b63441058667e8c17bdf2f151dca3c33c56761a01
MD5 0fbe1e338c28abe11401b15127382f72
BLAKE2b-256 85ef8c7680e85877f45dd5de8f6789cd681b93773667cb25b9e3f770d18fb7af

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