Skip to main content

PyQIR

The pyqir package provides the ability to generate QIR as well as an easy way to parse and analyze QIR.

QIR generation is intended to be used by code automating translation processes enabling the conversion in some format to QIR via Python; i.e., this is a low-level API intended to be used as a bridge to existing Python frameworks enabling the generation of QIR rather than directly consumed by an end-user. It is not intended to be used as a framework for algorithm and application development.

Installation

The package is released on PyPI and can be installed via pip:

pip install pyqir

Examples

PyQIR examples can be found in this repository's examples folder.

Generation

The following code creates QIR for a Bell pair before measuring each qubit and returning the result. The unoptimized QIR is displayed in the terminal when executed:

from pyqir import BasicQisBuilder, SimpleModule

module = SimpleModule("Bell", num_qubits=2, num_results=2)
qis = BasicQisBuilder(module.builder)

qis.h(module.qubits[0])
qis.cx(module.qubits[0], module.qubits[1])

qis.mz(module.qubits[0], module.results[0])
qis.mz(module.qubits[1], module.results[1])

print(module.ir())

The QIR output will look like:

; ModuleID = 'Bell'
source_filename = "Bell"




define void @main() #0 {
entry:
  call void @__quantum__qis__h__body(ptr null)
  call void @__quantum__qis__cnot__body(ptr null, ptr inttoptr (i64 1 to ptr))
  call void @__quantum__qis__mz__body(ptr null, ptr null)
  call void @__quantum__qis__mz__body(ptr inttoptr (i64 1 to ptr), ptr inttoptr (i64 1 to ptr))
  ret void
}

declare void @__quantum__qis__h__body(ptr)

declare void @__quantum__qis__cnot__body(ptr, ptr)

declare void @__quantum__qis__mz__body(ptr, ptr writeonly) #1

attributes #0 = { "entry_point" "output_labeling_schema" "qir_profiles"="custom" "required_num_qubits"="2" "required_num_results"="2" }
attributes #1 = { "irreversible" }

!llvm.module.flags = !{!0, !1, !2, !3}

!0 = !{i32 1, !"qir_major_version", i32 2}
!1 = !{i32 7, !"qir_minor_version", i32 0}
!2 = !{i32 1, !"dynamic_qubit_management", i1 false}
!3 = !{i32 1, !"dynamic_result_management", i1 false}

LLVM Opaque Pointers

Starting in PyQIR 0.12, we support LLVM opaque pointers via dependency on LLVM version 18 or higher. These newer version of PyQIR can parse IR or bitcode (.ll or .bc) with either style of pointers, but will always produce opaque pointers in any QIR output. Given that, PyQIR 0.12 also produces QIR with major version 2 by default. If you have need to produce QIR output with major version 1 that uses typed pointers, use PyQIR 0.11 or earlier.

The following table describes the compatibility of PyQIR versions:

Input Output Tooling
Typed Pointer QIR Typed Pointer QIR Use PyQIR 0.11 or earlier
Typed Pointer QIR Opaque Pointer QIR Use PyQIR 0.12 or later
Opaque Pointer QIR Opaque Pointer QIR Use PyQIR 0.12 or later
Opaque Pointer QIR Typed Pointer QIR NOT SUPPORTED

For more information on QIR major version compatibility, see the QIR 2.0 Specification.

Contributing

There are many ways in which you can contribute to PyQIR, whether by contributing a feature or by engaging in discussions; we value contributions in all shapes and sizes! We refer to this document for guidelines and ideas for how you can get involved.

Contributing a pull request to this repo requires to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. A CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately. Simply follow the instructions provided by the bot. You will only need to do this once.

Metadata

Release files for pyqir 0.12.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pyqir 0.12.9
File Actions
pyqir-0.12.9-cp315-abi3.abi3t-win_arm64.whl CPython 3.15 abi3t, abi3 Windows ARM64 Details for pyqir-0.12.9-cp315-abi3.abi3t-win_arm64.whl
pyqir-0.12.9-cp315-abi3.abi3t-win_amd64.whl CPython 3.15 abi3t, abi3 Windows x86-64 Details for pyqir-0.12.9-cp315-abi3.abi3t-win_amd64.whl
pyqir-0.12.9-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl CPython 3.15 abi3t, abi3 Linux glibc 2.28+ x86-64 Details for pyqir-0.12.9-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl
pyqir-0.12.9-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl CPython 3.15 abi3t, abi3 Linux glibc 2.28+ ARM64 Details for pyqir-0.12.9-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl
pyqir-0.12.9-cp315-abi3.abi3t-macosx_11_0_arm64.whl CPython 3.15 abi3, abi3t macOS 11.0+ ARM64 Details for pyqir-0.12.9-cp315-abi3.abi3t-macosx_11_0_arm64.whl
pyqir-0.12.9-cp315-abi3.abi3t-macosx_10_12_x86_64.whl CPython 3.15 abi3t, abi3 macOS 10.12+ x86-64 Details for pyqir-0.12.9-cp315-abi3.abi3t-macosx_10_12_x86_64.whl
pyqir-0.12.9-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for pyqir-0.12.9-cp310-abi3-win_arm64.whl
pyqir-0.12.9-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for pyqir-0.12.9-cp310-abi3-win_amd64.whl
pyqir-0.12.9-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details for pyqir-0.12.9-cp310-abi3-manylinux_2_28_x86_64.whl
pyqir-0.12.9-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for pyqir-0.12.9-cp310-abi3-manylinux_2_28_aarch64.whl
pyqir-0.12.9-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for pyqir-0.12.9-cp310-abi3-macosx_11_0_arm64.whl
pyqir-0.12.9-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for pyqir-0.12.9-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 25.0 MB

Release files / pyqir-0.12.9-cp315-abi3.abi3t-win_arm64.whl

Download URL pyqir-0.12.9-cp315-abi3.abi3t-win_arm64.whl
Size 1.9 MB
Tags CPython 3.15 Windows ARM64 abi3 abi3t
SHA-256 checksum
How to use checksums
e57746bd3c085941e24516dab5c275ae7a748ecfa52eb86f6499017e6a0bde28
BLAKE2b-256 checksum
How to use checksums
114d9ae45d5e8985214ca0af6882d4757cab5ecea15ff10e9b05014e4b11843a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / pyqir-0.12.9-cp315-abi3.abi3t-win_amd64.whl

Download URL pyqir-0.12.9-cp315-abi3.abi3t-win_amd64.whl
Size 2.0 MB
Tags CPython 3.15 Windows x86-64 abi3 abi3t
SHA-256 checksum
How to use checksums
899dce9e9aeb38b20ae878f5a6b820b28b5ba4e7c76dc6882b01d4be5223ac6c
BLAKE2b-256 checksum
How to use checksums
8c8cf07f6c2cdf4732dead8d36f09993add839b6734cb79b5dff2e9c7ca739e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / pyqir-0.12.9-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl

Download URL pyqir-0.12.9-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl
Size 2.2 MB
Tags CPython 3.15 Linux glibc 2.28+ x86-64 abi3 abi3t
SHA-256 checksum
How to use checksums
df5455eea0ae5d0faadf77ab05f52e88783736ccbf8f9a6b71b643fc89823dad
BLAKE2b-256 checksum
How to use checksums
627527eb431a20d2c81ebe54e3c942edff0012065bd1ec1078f670641c522519
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / pyqir-0.12.9-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl

Download URL pyqir-0.12.9-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl
Size 2.2 MB
Tags CPython 3.15 Linux glibc 2.28+ ARM64 abi3 abi3t
SHA-256 checksum
How to use checksums
f99506811766fa8931f5bedc03e241a0fa7f425bc2c7b8d491ec2bcfba6e3d64
BLAKE2b-256 checksum
How to use checksums
3d20ff6c48ca0af47f32699abf9129987d9dfa885c3522fc7f8fa793096b5f92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / pyqir-0.12.9-cp315-abi3.abi3t-macosx_11_0_arm64.whl

Download URL pyqir-0.12.9-cp315-abi3.abi3t-macosx_11_0_arm64.whl
Size 2.2 MB
Tags CPython 3.15 abi3 abi3t macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
08f83cbb3be4903450df1c58fee5e972ddd4d2f53148089bebdcb0c15bf574f7
BLAKE2b-256 checksum
How to use checksums
727ab1944602664fe45396ad0fc9cf2b600b4e5dbcd5506a1aeb715f20864730
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / pyqir-0.12.9-cp315-abi3.abi3t-macosx_10_12_x86_64.whl

Download URL pyqir-0.12.9-cp315-abi3.abi3t-macosx_10_12_x86_64.whl
Size 2.3 MB
Tags CPython 3.15 abi3 abi3t macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3989442b6eb7c77b4365dc707c47724650270e433041e86e8d07be8f63f9c3fb
BLAKE2b-256 checksum
How to use checksums
50546d1ca1ed6f4ff73711cf8448f0f4190d67a47d3ad6c1d3244b2825420c2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / pyqir-0.12.9-cp310-abi3-win_arm64.whl

Download URL pyqir-0.12.9-cp310-abi3-win_arm64.whl
Size 1.9 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
2eba0d21dcb683afd718018bdad20a024905c4d2260e8a457dde2251357e1e7f
BLAKE2b-256 checksum
How to use checksums
f5fef0a60972124ce02bf84bfac8f78b26c13037a203251aa8364ca90f1e4590
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / pyqir-0.12.9-cp310-abi3-win_amd64.whl

Download URL pyqir-0.12.9-cp310-abi3-win_amd64.whl
Size 2.0 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
3b40efdd5139f9750800d96d1f0a11025d9f25f53580d03b5077d8f306a4fba4
BLAKE2b-256 checksum
How to use checksums
f0b44f39760397ee42a7e9506dd34242541f91ec74406d9f661c0f391823f852
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / pyqir-0.12.9-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL pyqir-0.12.9-cp310-abi3-manylinux_2_28_x86_64.whl
Size 2.1 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
9d1f33b73878301c6a487a3292f1e4319dd891a77327c0c51e8004e967dab831
BLAKE2b-256 checksum
How to use checksums
1104f42c473b545e91a80b546190a55031403dea67bc97feefa3686a29e7c5ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / pyqir-0.12.9-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL pyqir-0.12.9-cp310-abi3-manylinux_2_28_aarch64.whl
Size 2.1 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
d1ba12a1dd1c1ea113df2d0c5423bf9d4f3ccdde36bb20b872da16a2bad223ce
BLAKE2b-256 checksum
How to use checksums
d8f84e6c1ce9cd11ef23777e5d59f93e9984632c00614977334f5f6b0c7f174c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / pyqir-0.12.9-cp310-abi3-macosx_11_0_arm64.whl

Download URL pyqir-0.12.9-cp310-abi3-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
79d95e0f82ef7ab89529384721a99a46925f57796241639898ca5e98240d45a7
BLAKE2b-256 checksum
How to use checksums
3a725db0b8c68011580016f5e87f4e0c3b20db7283ed706c230aae646c68e6ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / pyqir-0.12.9-cp310-abi3-macosx_10_12_x86_64.whl

Download URL pyqir-0.12.9-cp310-abi3-macosx_10_12_x86_64.whl
Size 2.2 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
bc7abb40fcbcdc996485eb21985bb8fc2a109533aada2ec217e28980116e376f
BLAKE2b-256 checksum
How to use checksums
eca8b430e77ce9674fe8a198e50258e620c801fa808e564992a613b22236b4d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Security for pyqir 0.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.12.9 This release

12 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page