Skip to main content

Python based QIR generator library.

Reason this release was yanked:

Please upgrade to 0.3.2a1 or newer.

Project description

pyqir-generator

The pyqir-generator package provides the ability to generate QIR using a Python API.

It 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.

Examples

There are generator examples in the repository.

Let's look at a short example. The following code creates QIR for an create Bell pair before measuring each qubit and returning the result. The unoptimized QIR is displayed in the terminal when executed:

from pyqir.generator 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.m(module.qubits[0], module.results[0])
qis.m(module.qubits[1], module.results[1])

print(module.ir())

The QIR output will look like:

; ModuleID = 'Bell'
source_filename = "Bell"

%Qubit = type opaque
%Result = type opaque

define void @main() #0 {
entry:
  call void @__quantum__qis__h__body(%Qubit* null)
  call void @__quantum__qis__cnot__body(%Qubit* null, %Qubit* inttoptr (i64 1 to %Qubit*))
  %result0 = call %Result* @__quantum__qis__m__body(%Qubit* null)
  %result1 = call %Result* @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*))
  ret void
}

declare void @__quantum__qis__h__body(%Qubit*)

declare void @__quantum__qis__cnot__body(%Qubit*, %Qubit*)

declare %Result* @__quantum__qis__m__body(%Qubit*)

attributes #0 = { "EntryPoint" "requiredQubits"="2" }

Building and Testing

See Building

Current Limitations

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

pyqir_generator-0.3.0a1-cp36-abi3-win_amd64.whl (8.8 MB view details)

Uploaded CPython 3.6+ Windows x86-64

pyqir_generator-0.3.0a1-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.6+ manylinux: glibc 2.17+ x86-64

pyqir_generator-0.3.0a1-cp36-abi3-macosx_10_7_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.6+ macOS 10.7+ x86-64

File details

Details for the file pyqir_generator-0.3.0a1-cp36-abi3-win_amd64.whl.

File metadata

  • Download URL: pyqir_generator-0.3.0a1-cp36-abi3-win_amd64.whl
  • Upload date:
  • Size: 8.8 MB
  • Tags: CPython 3.6+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.4 tqdm/4.59.0 importlib-metadata/3.10.0 keyring/22.3.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.8

File hashes

Hashes for pyqir_generator-0.3.0a1-cp36-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b95b3bba107d6fe1685ea6c24d0b3d1b92a65aa1377b15e4cd7f3ba16fcf2464
MD5 5f0c3ce44d5dec896f9f4e6564daef88
BLAKE2b-256 7086cb25d5dbeb025cd894ebdee3b10b03a5b5c295394178c5f8a067aaebe392

See more details on using hashes here.

File details

Details for the file pyqir_generator-0.3.0a1-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: pyqir_generator-0.3.0a1-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 6.1 MB
  • Tags: CPython 3.6+, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.4 tqdm/4.59.0 importlib-metadata/3.10.0 keyring/22.3.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.8

File hashes

Hashes for pyqir_generator-0.3.0a1-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 34e98a813491ef8df068948673f167d5fd6cad8d111999b2cf8374d064339982
MD5 e8dafa17dd51469450f340d59e8d632b
BLAKE2b-256 d3126be2c8d1bb27e5e7b25a92d88f77f40366428b63ffaba9403bee84a01a9a

See more details on using hashes here.

File details

Details for the file pyqir_generator-0.3.0a1-cp36-abi3-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: pyqir_generator-0.3.0a1-cp36-abi3-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 4.8 MB
  • Tags: CPython 3.6+, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.4 tqdm/4.59.0 importlib-metadata/3.10.0 keyring/22.3.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.8

File hashes

Hashes for pyqir_generator-0.3.0a1-cp36-abi3-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 170bab899f1c97855592cd137c528c8c1632187601810eadcf0f739c840bb92f
MD5 4349a855f3bb5fbc4d67575df5ef6fa8
BLAKE2b-256 76d2b8485ccc61800c0f68215560ba940094df7a45e48dbd7880e405af97fe32

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page