Skip to main content

Python based QIR Evaluation (JIT) library.

Project description

pyqir-evaluator

The pyqir-evaluator package provides an easy way to execute generated QIR for the purpose of:

  1. easily testing and experimenting with QIR code
  2. connecting it to low-level Python-based lab software such as e.g. QCoDeS

It contains the necessary just-in-time compilation infrastructure as well as an extensibility mechanism to define what actions to perform when a gate is applied in Python. Right now the evaluator does not have a full runtime environment and can JIT QIR produced by the pyqir-generator, but cannot use any external function calls.

Installation

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

pip install pyqir-evaluator

Examples

There are evaluator examples in the repository.

Let's look at how to log the gate sequence for the Bernstein-Vazirani example.

We can evaluate the generated bitcode with NonadaptiveEvaluator and GateLogger to print out a simple log of the quantum application:

from pyqir.evaluator import NonadaptiveEvaluator, GateLogger

from pathlib import Path
import os

path = Path(__file__).parent
file = os.path.join(path, "bernstein_vazirani.bc")

evaluator = NonadaptiveEvaluator()
logger = GateLogger()

evaluator.eval(file, logger)

print("# output from GateLogger")
logger.print()

This would generate the following output:

# output from GateLogger
qubits[9]
out[9]
x qubit[8]
h qubit[0]
h qubit[1]
h qubit[2]
h qubit[3]
h qubit[4]
h qubit[5]
h qubit[6]
h qubit[7]
h qubit[8]
cx qubit[2], qubit[8]
cx qubit[3], qubit[8]
h qubit[0]
h qubit[1]
h qubit[2]
h qubit[3]
h qubit[4]
h qubit[5]
h qubit[6]
h qubit[7]
measure qubits[0] -> out[0]
measure qubits[1] -> out[1]
measure qubits[2] -> out[2]
measure qubits[3] -> out[3]
measure qubits[4] -> out[4]
measure qubits[5] -> out[5]
measure qubits[6] -> out[6]
measure qubits[7] -> out[7]
measure qubits[8] -> out[8]

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.

Building and Testing

See Building.

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_evaluator-0.6.1-cp36-abi3-win_amd64.whl (9.5 MB view details)

Uploaded CPython 3.6+ Windows x86-64

pyqir_evaluator-0.6.1-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.9 MB view details)

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

pyqir_evaluator-0.6.1-cp36-abi3-macosx_10_7_x86_64.whl (9.9 MB view details)

Uploaded CPython 3.6+ macOS 10.7+ x86-64

File details

Details for the file pyqir_evaluator-0.6.1-cp36-abi3-win_amd64.whl.

File metadata

  • Download URL: pyqir_evaluator-0.6.1-cp36-abi3-win_amd64.whl
  • Upload date:
  • Size: 9.5 MB
  • Tags: CPython 3.6+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6

File hashes

Hashes for pyqir_evaluator-0.6.1-cp36-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6300ad7b3022feb65ebc904966f8a1418e6c8291ab6386eab63cc577806217e3
MD5 56e3daf431290769b2b918fbf7c9d55d
BLAKE2b-256 3ad29e0cd758169ce3c42738104f7a9291bc1e15d6b543a0124054baac1be5f4

See more details on using hashes here.

File details

Details for the file pyqir_evaluator-0.6.1-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: pyqir_evaluator-0.6.1-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 11.9 MB
  • Tags: CPython 3.6+, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6

File hashes

Hashes for pyqir_evaluator-0.6.1-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cd780ae7895a11152a13056470651b65142dd5ab5984917bd282acf812c406cd
MD5 96d1499fcaad3e955af9d9ca292391a5
BLAKE2b-256 00940f96eb93829ca55b024ed34d2060a619d2f23ce7f83a9cad75e5b1ac53b8

See more details on using hashes here.

File details

Details for the file pyqir_evaluator-0.6.1-cp36-abi3-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: pyqir_evaluator-0.6.1-cp36-abi3-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 9.9 MB
  • Tags: CPython 3.6+, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6

File hashes

Hashes for pyqir_evaluator-0.6.1-cp36-abi3-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 2cdbb2c02d8c96c97622681648058ea8f984a7333ebe5f77f4d8afe45c2c31ce
MD5 57153005373b5fd96080722dc29700d2
BLAKE2b-256 b49d5e0b0ad497d968ecb6bdfb5e9d7c1501b719a8bf4d002ceab2183e406a26

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