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

Uploaded CPython 3.10+Windows x86-64

selene_hugr_qis_compiler-0.3.0-cp310-abi3-manylinux_2_28_x86_64.whl (80.2 MB view details)

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

selene_hugr_qis_compiler-0.3.0-cp310-abi3-manylinux_2_28_aarch64.whl (73.4 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

selene_hugr_qis_compiler-0.3.0-cp310-abi3-macosx_15_0_x86_64.whl (30.0 MB view details)

Uploaded CPython 3.10+macOS 15.0+ x86-64

selene_hugr_qis_compiler-0.3.0-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.0-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.3.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1362aabc66755a78eef424368f18c56705e4ce535c935b1dc7ec92d54996afa4
MD5 24e376096f9afd55222016d3ab660e09
BLAKE2b-256 46f1eeb98c080b29c36b451ade1f045282128d0f0004ae377046cba4d408ef63

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.3.0-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5404be32bab0f9ec71119db5bf4721b0adebfb63070bc13101b5eb23619eadf5
MD5 29fa4882d31abfb8a77bd740840bc86c
BLAKE2b-256 cc5c65f84eed3ebf87edb94e7453b4c2d22af8e21d590a9d5bbfb91c78cbd024

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.3.0-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e2cbbd4c75cd81571b977234d94af46817b80e58abce57e44b94563c920c6b1f
MD5 0119fa9bbee955fb522364dbbfde99d3
BLAKE2b-256 7372b2381139d89fe85a8b20bc89ae519a1574a1b7eef583ff30b1ae3e89f137

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.3.0-cp310-abi3-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 950e5f646fc82b708d42b9dd80dc208b1ca001ad4c3da07ebadc523715cd7c36
MD5 0613d648aa5a5ed87b3238b87bfe014e
BLAKE2b-256 fa3b52643ceeded41078a58bb34c14ff2cbc2db37c828a5b92ab7d6b00dda755

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.3.0-cp310-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 4829e879393df97d0d5b29a9dbae1eb87ab1a86ccd427d7f49d1d3f331f1a982
MD5 a7aff8205ec3cf9d0d4a83444c4ad7e2
BLAKE2b-256 a43eaf15e05af810a10d5245f676fe2ffdaeba1bd6ac27aa7c451549aead4061

See more details on using hashes here.

Provenance

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