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

Uploaded CPython 3.10+Windows x86-64

hugr_qir-0.0.7-cp310-abi3-manylinux_2_28_x86_64.whl (33.6 MB view details)

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

hugr_qir-0.0.7-cp310-abi3-macosx_13_0_x86_64.whl (32.0 MB view details)

Uploaded CPython 3.10+macOS 13.0+ x86-64

hugr_qir-0.0.7-cp310-abi3-macosx_13_0_arm64.whl (29.3 MB view details)

Uploaded CPython 3.10+macOS 13.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for hugr_qir-0.0.7.tar.gz
Algorithm Hash digest
SHA256 c77b49aa76e280b2ddf8054ff50fa2a2a70e256465b091c1126a3fc157135ab2
MD5 0a7c4df181d62aa32ff62b870e4404f0
BLAKE2b-256 43bb2433e0c33bde0754e8327056c475973e45e3f366c7daeabe81c2d01253fe

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for hugr_qir-0.0.7-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 11bb8404cc826ead9f90f0400bbf76450bc5eb8438e6441f767c596ed2721c9b
MD5 f40acfbe93af85b205afe6efb9822d2a
BLAKE2b-256 ff8d4bef436f76e9ea7aa380b973f0b003f942b277fd5d1a87c10aa2fb796291

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.7-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 72fa779c2f5ed2c07ea0d4ecef764d5705ce5dc1420556da9186870c4656f67a
MD5 04a83d4ecbbfe82f88a93dfc2e665ee0
BLAKE2b-256 cf26ece2446d520f0d8ceb53dbdd21ec77d2f1c5a0d85fa3092477a9156f0d97

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.7-cp310-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 93ea2a308ca2173caff5dc4e9d55fad38410c66e2d923f38cbde7230c07b5c31
MD5 f1674e0c0cafb9bb5b0cddda5c92a6c7
BLAKE2b-256 da732254d96f218212d9271aec87e5336eaaed7c988711d34b9d79a312d94eec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hugr_qir-0.0.7-cp310-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 036219e80f7c1e353aa48df176334c4e158742a00104fd2f3017d8bcb13b38e7
MD5 6fb7ae71ba428b432179f29f84065ac0
BLAKE2b-256 5a627f1c8625a3cd81d5f7172f682431eb14471ed384ef893534eca552528f3d

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