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

Uploaded CPython 3.10+Windows x86-64

selene_hugr_qis_compiler-0.4.0-cp310-abi3-manylinux_2_28_x86_64.whl (82.0 MB view details)

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

selene_hugr_qis_compiler-0.4.0-cp310-abi3-manylinux_2_28_aarch64.whl (75.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

selene_hugr_qis_compiler-0.4.0-cp310-abi3-macosx_15_0_x86_64.whl (30.5 MB view details)

Uploaded CPython 3.10+macOS 15.0+ x86-64

selene_hugr_qis_compiler-0.4.0-cp310-abi3-macosx_15_0_arm64.whl (29.8 MB view details)

Uploaded CPython 3.10+macOS 15.0+ ARM64

File details

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

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.4.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f1e4320d715a43c891dc5351074fac349e02698eb1a6803185192e3ba18e4775
MD5 30439edc72a1a8cee3b211819fd3b541
BLAKE2b-256 f35c5797977a7099296e7c9fe764a78580db751d18036e599d95298cd7eabdb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for selene_hugr_qis_compiler-0.4.0-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.4.0-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.4.0-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 67ecbe7b475fb22c928dd14dfd70ca59066e179b4e05ba75439360e2dd0f3130
MD5 3a6654c4fd1cf71627aba5a04b9e4c9b
BLAKE2b-256 d19c30b597fba339196dbc102c8a08af5510811569191097f2c270b7f66922cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for selene_hugr_qis_compiler-0.4.0-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.4.0-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.4.0-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 53e13bb5e9f581b1d3416c3e0f2ae0939fddceca690aeefb6d830fe7eb6347ad
MD5 d5e9eae29e009946ac0dbce6b8f4014c
BLAKE2b-256 2625940ce18b47faf845a45a64cb1bc6d4b3aa583454f3dea2c006012c5a118d

See more details on using hashes here.

Provenance

The following attestation bundles were made for selene_hugr_qis_compiler-0.4.0-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.4.0-cp310-abi3-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.4.0-cp310-abi3-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 98924dcd69c315c2903a62cfdad2d5c542f80b2cb924579e91748580b7525123
MD5 94aba64cadb33e1fe3de5b98c0961479
BLAKE2b-256 53c592bd9dc84355414b2023fb24ddea80527492ac22370b9713cb3d7c53d5e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for selene_hugr_qis_compiler-0.4.0-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.4.0-cp310-abi3-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.4.0-cp310-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9a1f1a6125d9d65d8dbd72b4a5912a0f4b9152dc0586bffb208139f7627baab5
MD5 aa18d20a6378a6567fca2acd8e3b5571
BLAKE2b-256 261ae519e6c88ed4c4ab2614a0336e23ebc978d985081ff180154d7ac78d0d98

See more details on using hashes here.

Provenance

The following attestation bundles were made for selene_hugr_qis_compiler-0.4.0-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