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.5.tar.gz (179.8 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.5-cp310-abi3-win_amd64.whl (8.5 MB view details)

Uploaded CPython 3.10+Windows x86-64

hugr_qir-0.0.5-cp310-abi3-manylinux_2_28_x86_64.whl (10.2 MB view details)

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

hugr_qir-0.0.5-cp310-abi3-macosx_13_0_x86_64.whl (9.7 MB view details)

Uploaded CPython 3.10+macOS 13.0+ x86-64

hugr_qir-0.0.5-cp310-abi3-macosx_13_0_arm64.whl (8.9 MB view details)

Uploaded CPython 3.10+macOS 13.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for hugr_qir-0.0.5.tar.gz
Algorithm Hash digest
SHA256 021592435aaa49c64ed5aaebd6cda05f69c474660ec4737eec7c8e3592da740c
MD5 cd598a3922e5f3c4d96f63fb88622c95
BLAKE2b-256 6924e45bf5b32927638abe2b2b60ff7a56baeef36b3fdbf0da6e826261e83baa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hugr_qir-0.0.5-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 8.5 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.5-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3ea967e490be361eef814ca527f18488f67d59e8386f193b5c25d84b98e29aff
MD5 9f27ded25aef38fbb87552a09544e04f
BLAKE2b-256 16a8036687b5d58d26cd9e6e6f8f5cdac9b10b3aff39cca100ae4ea306eaa8bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.5-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6bf8dc7a5e7f4f2dbec2949b0594455ab5018795e9e7e174fb90d9c5afbfb5f2
MD5 2eb1d460b951960cdcbb29438401e0eb
BLAKE2b-256 8320277966fdbb1e18741f51ffa79f191e2401cf48fc555d64237ec4231c1f29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.5-cp310-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 0822378278ede34ecb820d9fc204dd0fb74078ac0e2c0f8ebeb50d5ad156cf3a
MD5 3e77abf6801948e0d38d8fae9c5df64a
BLAKE2b-256 a15e5e716cc795246ca305cc8d0e9a5d3fcb6779662307f0364b8796809bc910

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.5-cp310-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 db883ed247d45e5febee73f69448ce30d0b27dbda7e0bc01b8b446f0235d657f
MD5 22fbafd5f71cd3fada454756b92b0c8c
BLAKE2b-256 7403a36b29d25655ce47e3b27fd3c5a70cd1ab39060e6455225ac8d6f8738fe3

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