Skip to main content

A Python frontend for compiling HUGR to Quantinuum's QIS.

Project description

The HUGR-QIS compiler for Selene

This package provides compilation from HUGR to LLVM adhering to the Quantinuum QIS.

Usage

Guppy can produce a HUGR Envelope with:

from guppylang.decorator import guppy

@guppy
def main() -> None:
    # ...

hugr = main.compile()
hugr_envelope = hugr.package.to_bytes()

This can then be compiled to LLVM IR or bitcode using this package:

from qis_compiler import (
    compile_to_llvm_ir,
    compile_to_bitcode,
)

# Compile to LLVM IR for the host system
# and receive it as a string
ir = compile_to_llvm_ir(hugr_envelope)

# Compile to LLVM bitcode for the host system
# and receive it as a bytes object
bitcode = compile_to_bitcode(hugr_envelope)

If you wish to target a specific architecture or platform, you can pass the triple as an argument to the compilation functions:

# Compile to LLVM IR for Apple Silicon
ir_apple_silicon = compile_to_llvm_ir(
    hugr_envelope,
    target_triple="aarch64-apple-darwin",
)
# Compile to LLVM bitcode for x86_64 MSVC
bitcode_apple_silicon = compile_to_bitcode(
    hugr_envelope,
    target_triple="x86_64-windows-msvc",
)

Development

Snapshot testing

This package uses snapshot testing for its compiler output. Sample programs are defined using guppy in the script python/tests/generate_hugrs.py. To add a new test case add a new function to generate the desired HUGR program and call it from the if __name__ == "__main__": block.

The script has self contained dependencies with a pinned guppy version defined in comments at the top of the file. uv will create a virtual environment and install the dependencies when you run the script with uv run python tests/generate_hugrs.py. This can also be done using just regenerate in the python/tests directory.

HUGR regeneration should not be done in conjunction with other changes to the compiler, to isolate possible changes to the snapshots. It should only be required if guppylang updates are required for testing the compiler.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

selene_hugr_qis_compiler-0.3.2-cp310-abi3-win_amd64.whl (27.9 MB view details)

Uploaded CPython 3.10+Windows x86-64

selene_hugr_qis_compiler-0.3.2-cp310-abi3-manylinux_2_28_x86_64.whl (80.4 MB view details)

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

selene_hugr_qis_compiler-0.3.2-cp310-abi3-manylinux_2_28_aarch64.whl (73.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

selene_hugr_qis_compiler-0.3.2-cp310-abi3-macosx_15_0_x86_64.whl (30.1 MB view details)

Uploaded CPython 3.10+macOS 15.0+ x86-64

selene_hugr_qis_compiler-0.3.2-cp310-abi3-macosx_15_0_arm64.whl (29.3 MB view details)

Uploaded CPython 3.10+macOS 15.0+ ARM64

File details

Details for the file selene_hugr_qis_compiler-0.3.2-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.3.2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1483c7804ae2c04a7d61faa789b4287562c8005f3208d08cb32de6e16fad304e
MD5 75c38ae0cf546dce31fc3785a14d6b9a
BLAKE2b-256 97847ff3cf0ca9782d52e7ef9637909dd7a29bdc95f0cedcb9ee15c4bb33312e

See more details on using hashes here.

Provenance

The following attestation bundles were made for selene_hugr_qis_compiler-0.3.2-cp310-abi3-win_amd64.whl:

Publisher: python-qis-wheels.yml on Quantinuum/tket2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file selene_hugr_qis_compiler-0.3.2-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.3.2-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b780b7add24417e0edc3863c3eb7534f97740a117fce2257d0da60c7dd2b519f
MD5 e7188d35ea427772123c738e6975b087
BLAKE2b-256 df58e487ed7e6e86b2caf8d436d5a0a92ad92050dccfcb0ed955b501f1603095

See more details on using hashes here.

Provenance

The following attestation bundles were made for selene_hugr_qis_compiler-0.3.2-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: python-qis-wheels.yml on Quantinuum/tket2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file selene_hugr_qis_compiler-0.3.2-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.3.2-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6a61882b108898ee35830c3a81acb63713734621a24e1d3d0494af0a372cd364
MD5 5cd189aa491cd6daf558d1b30167a306
BLAKE2b-256 52a4974b3e01ab8a1275aedf6a92ab885786255cacaeca9c532964ffec034950

See more details on using hashes here.

Provenance

The following attestation bundles were made for selene_hugr_qis_compiler-0.3.2-cp310-abi3-manylinux_2_28_aarch64.whl:

Publisher: python-qis-wheels.yml on Quantinuum/tket2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file selene_hugr_qis_compiler-0.3.2-cp310-abi3-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.3.2-cp310-abi3-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 12fe33d34cee7572253828ff59b2547f03836d16cc3705b10c1e43d1ed27164e
MD5 c53dcbd433d0e770b2ea926e0e819df6
BLAKE2b-256 60908c78417270a1f55a152f29adcbecc30e284838d8b901bcc2c21c78392f91

See more details on using hashes here.

Provenance

The following attestation bundles were made for selene_hugr_qis_compiler-0.3.2-cp310-abi3-macosx_15_0_x86_64.whl:

Publisher: python-qis-wheels.yml on Quantinuum/tket2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file selene_hugr_qis_compiler-0.3.2-cp310-abi3-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.3.2-cp310-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 dfc42ab54f7627f29d777c90e64377ea7cbb4527df838eed7939a0ea82e20ce7
MD5 8631b9939465b593b771f79d436d64f4
BLAKE2b-256 661c6aa814446d0a9a2a537eb1e18a7a233e067be8ef0b7d408d0aa1332d549d

See more details on using hashes here.

Provenance

The following attestation bundles were made for selene_hugr_qis_compiler-0.3.2-cp310-abi3-macosx_15_0_arm64.whl:

Publisher: python-qis-wheels.yml on Quantinuum/tket2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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