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

Uploaded CPython 3.10+Windows x86-64

selene_hugr_qis_compiler-0.3.1-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.1-cp310-abi3-manylinux_2_28_aarch64.whl (73.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

selene_hugr_qis_compiler-0.3.1-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.1-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.1-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.3.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 cfc4212cf70f025576900bc70f3ed9b45310f7b541ccc98177f464d313cce4bb
MD5 991d917e945d4e58774dd55f5659c36a
BLAKE2b-256 6b1be1e5707c09eb3d75be5fbd308eb41370c15516f069abbb2b47d6b013a696

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.3.1-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1928520a4e213e6d4814d82d58ebed9f7a0ea6650600be0fa547816259b86d8f
MD5 c4c0f4400630e6b465839bf83b318820
BLAKE2b-256 48fdca716bc66ca2998e81b0b02797fd67681757c70c1049919574df20a02042

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.3.1-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8d5560eb748ed42928c4874f3b62279ebca168e57fcdec2be8d28d2b5fb277ee
MD5 bf0272248a70ee00915273b1a10fb67f
BLAKE2b-256 e564d4b90a92e10ebbecdc9e3f44c7eb03d7736df902bee00b5ab83d80f8234d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.3.1-cp310-abi3-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 b91d61fdf48c48749941cb7bf877856c9cecc73d19f03b2bbecd8a1ce549705c
MD5 bced7181be3332509ae4ce4516ec7815
BLAKE2b-256 0fbe1b1e51b25db14e34d4c73b1a4ea98d01f8584e77430d1a9c2c80bd4007fe

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for selene_hugr_qis_compiler-0.3.1-cp310-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 cbf1bbea651cbeec351336b0d1f35f266f6e2d56ac6973f19966604c445e1529
MD5 8f011de992bb41f631caeb40ce8aba00
BLAKE2b-256 8cd687521c00d4697461ee2ab3f1fb7e65f2ac8fe6dc542ebffed094cf32b39c

See more details on using hashes here.

Provenance

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