Skip to main content

JIT compiles and executes programs written in QIR (Quantum Intermediate Representation).

Project description

QIR Runner

This project implements a basic QIR runtime and execution tool. Once installed, qir-runner will be available via the command line in your python environment as well as the qirrunner module which can be imported into a Python program.

Usage

Command line

Usage: qir-runner [OPTIONS] --file <PATH>

Options:
  -f, --file <PATH>        (Required) Path to the QIR file to run
  -e, --entrypoint <NAME>  Name of the entry point function to execute
  -s, --shots <NUM>        The number of times to repeat the execution of the chosen entry point in the program [default: 1]
  -r, --rngseed <NUM>      The value to use when seeding the random number generator used for quantum simulation
  -h, --help               Print help
  -V, --version            Print version

Python module

From a Python program, qirrunner provides a run function and two output helpers Output and OutputHandler. If the output_fn parameter of run is not specified, output will be written to stdout. Supplying the parameter allows the output of the execution to be captured.

from qirrunner import run, OutputHandler

path = "./runner/tests/resources/bv.bc"

handler = OutputHandler()
run(path, shots=2, output_fn=handler.handle)

print(handler.get_output())

Installation

pip install qirrunner

Installing from sdist

Platforms for which qirrunner doesn't have pre-built wheels (such as aarch64 macos), installation is available via sdist. Before installing qirrunner via pip:

  • Install a usable LLVM distribution which has llvm-config available.
  • Set the LLVM_SYS_201_PREFIX environment variable to the LLVM installation directory
    • example: export LLVM_SYS_201_PREFIX=/Users/sample/llvm
  • Install: python -m pip install qirrunner
    • This will build qirrunner from source. You will need a working Rust installation in order for this to compile.

Implemented APIs

double @__quantum__qis__arccos__body(double)
double @__quantum__qis__arcsin__body(double)
double @__quantum__qis__arctan__body(double)
double @__quantum__qis__arctan2__body(double)
void @__quantum__qis__assertmeasurementprobability__body(ptr, ptr, ptr, double, ptr, double)
void @__quantum__qis__assertmeasurementprobability__ctl(ptr, ptr)
void @__quantum__qis__barrier__body()
void @__quantum__qis__ccx__body(ptr, ptr)
void @__quantum__qis__cnot__body(ptr, ptr)
double @__quantum__qis__cos__body(double)
double @__quantum__qis__cosh__body(double)
void @__quantum__qis__cx__body(ptr, ptr)
void @__quantum__qis__cy__body(ptr, ptr)
void @__quantum__qis__cz__body(ptr, ptr)
double @__quantum__qis__drawrandomdouble__body()
i64 @__quantum__qis__drawrandomint__body()
void @__quantum__qis__dumpmachine__body()
void @__quantum__qis__exp__adj(ptr, double, ptr)
void @__quantum__qis__exp__body(ptr, double, ptr)
void @__quantum__qis__exp__ctl(ptr, ptr)
void @__quantum__qis__exp__ctladj(ptr, ptr)
void @__quantum__qis__exp__ctl(ptr, ptr)
void @__quantum__qis__h__body(ptr)
void @__quantum__qis__h__ctl(ptr, ptr)
double @__quantum__qis__ieeeremainder__body(double, double)
double @__quantum__qis__infinity__body()
i1 @__quantum__qis__isinf__body()
i1 @__quantum__qis__isnan__body()
i1 @__quantum__qis__isnegativeinfinity__body()
double @__quantum__qis__log__body(double)
ptr @__quantum__qis__m__body(ptr)
ptr @__quantum__qis__measure__body(ptr, ptr)
ptr @__quantum__qis__mresetz__body(ptr)
void @__quantum__qis__mz__body(ptr, ptr)
double @__quantum__qis__nan__body()
void @__quantum__qis__r__adj(i2, double, ptr)
void @__quantum__qis__r__body(i2, double, ptr)
void @__quantum__qis__r__ctl(ptr, ptr)
void @__quantum__qis__r__ctladj(ptr, ptr)
bool @__quantum__qis__read_result__body(ptr)
void @__quantum__qis__reset__body(ptr)
void @__quantum__qis__rx__body(double, ptr)
void @__quantum__qis__rx__ctl(ptr, ptr)
void @__quantum__qis__rxx__body(double, ptr, ptr)
void @__quantum__qis__ry__body(double, ptr)
void @__quantum__qis__ry__ctl(ptr, ptr)
void @__quantum__qis__ryy__body(double, ptr, ptr)
void @__quantum__qis__rz__body(double, ptr)
void @__quantum__qis__rz__ctl(ptr, ptr)
void @__quantum__qis__rzz__body(double, ptr, ptr)
void @__quantum__qis__s__adj(ptr)
void @__quantum__qis__s__body(ptr)
void @__quantum__qis__s__ctl(ptr, ptr)
void @__quantum__qis__s__ctladj(ptr, ptr)
void @__quantum__qis__sx__body(ptr)
double @__quantum__qis__sin__body(double)
double @__quantum__qis__sinh__body(double)
double @__quantum__qis__sqrt__body(double)
void @__quantum__qis__swap__body(ptr, ptr)
void @__quantum__qis__t__adj(ptr)
void @__quantum__qis__t__body(ptr)
void @__quantum__qis__t__ctl(ptr, ptr)
void @__quantum__qis__t__ctladj(ptr, ptr)
double @__quantum__qis__tan__body(double)
double @__quantum__qis__tanh__body(double)
void @__quantum__qis__x__body(ptr)
void @__quantum__qis__x__ctl(ptr, ptr)
void @__quantum__qis__y__body(ptr)
void @__quantum__qis__y__ctl(ptr, ptr)
void @__quantum__qis__z__body(ptr)
void @__quantum__qis__z__ctl(ptr, ptr)
ptr @__quantum__rt__array_concatenate(ptr, ptr)
ptr @__quantum__rt__array_copy(ptr, bool)
ptr @__quantum__rt__array_create_1d(i32, i64)
ptr @__quantum__rt__array_get_element_ptr_1d(ptr, i64)
i64 @__quantum__rt__array_get_size_1d(ptr)
void @__quantum__rt__array_record_output(i64, ptr)
void @__quantum__rt__array_update_alias_count(ptr, i32)
void @__quantum__rt__array_update_reference_count(ptr, i32)
ptr @__quantum__rt__bigint_add(ptr, ptr)
ptr @__quantum__rt__bigint_bitand(ptr, ptr)
ptr @__quantum__rt__bigint_bitnot(ptr)
ptr @__quantum__rt__bigint_bitor(ptr, ptr)
ptr @__quantum__rt__bigint_bitxor(ptr, ptr)
ptr @__quantum__rt__bigint_create_array(i32, ptr)
ptr @__quantum__rt__bigint_create_i64(i64)
ptr @__quantum__rt__bigint_divide(ptr, ptr)
bool @__quantum__rt__bigint_equal(ptr, ptr)
ptr @__quantum__rt__bigint_get_data(ptr)
i32 @__quantum__rt__bigint_get_length(ptr)
bool @__quantum__rt__bigint_greater(ptr, ptr)
bool @__quantum__rt__bigint_greater_eq(ptr, ptr)
ptr @__quantum__rt__bigint_modulus(ptr, ptr)
ptr @__quantum__rt__bigint_multiply(ptr, ptr)
ptr @__quantum__rt__bigint_negate(ptr)
ptr @__quantum__rt__bigint_power(ptr, i32)
ptr @__quantum__rt__bigint_shiftleft(ptr, i64)
ptr @__quantum__rt__bigint_shiftright(ptr, i64)
void @__quantum__rt__bigint_subtract(ptr, ptr)
ptr @__quantum__rt__bigint_to_string(ptr)
void @__quantum__rt__bigint_update_reference_count(ptr, i32)
void @__quantum__rt__bool_record_output(i1, ptr)
ptr @__quantum__rt__bool_to_string(i1)
ptr @__quantum__rt__callable_copy(ptr, bool)
ptr @__quantum__rt__callable_create(ptr, ptr, ptr)
void @__quantum__rt__callable_invoke(ptr, ptr, ptr)
void @__quantum__rt__callable_make_adjoint(ptr)
void @__quantum__rt__callable_make_controlled(ptr)
void @__quantum__rt__callable_update_alias_count(ptr, i32)
void @__quantum__rt__callable_update_reference_count(ptr, i32)
void @__quantum__rt__capture_update_alias_count(ptr, i32)
void @__quantum__rt__capture_update_reference_count(ptr, i32)
void @__quantum__rt__double_record_output(double, ptr)
ptr @__quantum__rt__double_to_string(double)
void @__quantum__rt__fail(ptr)
void @__quantum__rt__int_record_output(i64, ptr)
ptr @__quantum__rt__int_to_string(i64)
ptr @__quantum__rt__memory_allocate(i64)
void @__quantum__rt__message(ptr)
void @__quantum__rt__message_record_output(ptr)
ptr @__quantum__rt__pauli_to_string(i2)
ptr @__quantum__rt__qubit_allocate()
ptr @__quantum__rt__qubit_allocate_array(i64)
void @__quantum__rt__qubit_release(ptr)
void @__quantum__rt__qubit_release_array(ptr)
ptr @__quantum__rt__qubit_to_string(ptr)
bool @__quantum__rt__read_result(ptr)
bool @__quantum__rt__result_equal(ptr, ptr)
ptr @__quantum__rt__result_get_one()
ptr @__quantum__rt__result_get_zero()
void @__quantum__rt__result_record_output(ptr, ptr)
ptr @__quantum__rt__result_to_string(ptr)
void @__quantum__rt__result_update_reference_count(ptr, i32)
ptr @__quantum__rt__string_concatenate(ptr, ptr)
ptr @__quantum__rt__string_create(ptr)
bool @__quantum__rt__string_equal(ptr, ptr)
ptr @__quantum__rt__string_get_data(ptr)
i32 @__quantum__rt__string_get_length(ptr)
void @__quantum__rt__string_update_reference_count(ptr, i32)
ptr @__quantum__rt__tuple_copy(ptr, i1)
ptr @__quantum__rt__tuple_create(i64)
void @__quantum__rt__tuple_record_output(i64, ptr)
void @__quantum__rt__tuple_update_alias_count(ptr, i32)
void @__quantum__rt__tuple_update_reference_count(ptr, i32)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qirrunner-0.9.1.tar.gz (257.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

qirrunner-0.9.1-cp39-abi3-win_arm64.whl (15.0 MB view details)

Uploaded CPython 3.9+Windows ARM64

qirrunner-0.9.1-cp39-abi3-win_amd64.whl (17.4 MB view details)

Uploaded CPython 3.9+Windows x86-64

qirrunner-0.9.1-cp39-abi3-manylinux_2_38_aarch64.whl (31.7 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.38+ ARM64

qirrunner-0.9.1-cp39-abi3-manylinux_2_35_x86_64.whl (32.7 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.35+ x86-64

qirrunner-0.9.1-cp39-abi3-manylinux_2_34_x86_64.whl (33.4 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.34+ x86-64

qirrunner-0.9.1-cp39-abi3-macosx_11_0_arm64.whl (17.5 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

qirrunner-0.9.1-cp39-abi3-macosx_10_12_x86_64.whl (18.7 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file qirrunner-0.9.1.tar.gz.

File metadata

  • Download URL: qirrunner-0.9.1.tar.gz
  • Upload date:
  • Size: 257.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: RestSharp/106.13.0.0

File hashes

Hashes for qirrunner-0.9.1.tar.gz
Algorithm Hash digest
SHA256 0968d216db7ffafebb0fe2437135cafbf480fedfcad6da1161efd1924badf4d6
MD5 ed17dddfd205e29eed1159e5673ffe23
BLAKE2b-256 c4728f26429093c62f20e25436f1ae93451f9d0d7cc679aeab3cb88164df2f5f

See more details on using hashes here.

File details

Details for the file qirrunner-0.9.1-cp39-abi3-win_arm64.whl.

File metadata

  • Download URL: qirrunner-0.9.1-cp39-abi3-win_arm64.whl
  • Upload date:
  • Size: 15.0 MB
  • Tags: CPython 3.9+, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: RestSharp/106.13.0.0

File hashes

Hashes for qirrunner-0.9.1-cp39-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 85c8f7980f30c54790277c216c39c58b01376f4c5e2ec7bd3d9ebd63a8830a4e
MD5 e2ff3492131e1ed8bc2d151e1a8d43f1
BLAKE2b-256 2c1b670bed6be83ecab2e7a3b2316e85c6c301a8e6976afac242acdcf78845a6

See more details on using hashes here.

File details

Details for the file qirrunner-0.9.1-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: qirrunner-0.9.1-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 17.4 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: RestSharp/106.13.0.0

File hashes

Hashes for qirrunner-0.9.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b60cc5878eaa1b5ac1a302fb49b10432a328079241ac9a09ec7416c1c368ad6a
MD5 17fe951f83371b35d18d5e6bcd3165f3
BLAKE2b-256 47b69ecca2d908980bfe916fdc74bd9905947337cdbe75ee84552881b1b81a88

See more details on using hashes here.

File details

Details for the file qirrunner-0.9.1-cp39-abi3-manylinux_2_38_aarch64.whl.

File metadata

File hashes

Hashes for qirrunner-0.9.1-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 27262052345862f910e76daae2863966d0f98220030da91af0e9d2f01182b518
MD5 db2611e21953c09a169d570bed7ea99a
BLAKE2b-256 696f17cff25b25ab00482b7589252433b0f332a4edd063a636820558c9f17559

See more details on using hashes here.

File details

Details for the file qirrunner-0.9.1-cp39-abi3-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for qirrunner-0.9.1-cp39-abi3-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 2fb8efae9d243f00ad0be910cb4f31867653e5f0629b8aa98d130f29809ec846
MD5 5ae815c7adabc6602d116c55db978273
BLAKE2b-256 bfa33ea3a9ad5f309c769b04acb2985bb4bf744e36fee1c7c27bcbe7f32e9356

See more details on using hashes here.

File details

Details for the file qirrunner-0.9.1-cp39-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for qirrunner-0.9.1-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e5298313529caf191335fad6c93d75e6d69598e7f8d9e5102e102f69edb5ecf2
MD5 a4a607ccbf732647ad04e2cf1c2e32b3
BLAKE2b-256 18a8867d899fd15a7ef73dc17c043394f1d041c2d3de7c14e0998c1f8436f21e

See more details on using hashes here.

File details

Details for the file qirrunner-0.9.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qirrunner-0.9.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 33b544ef3a93d692f79d464ae3355f78e47260f6581974afedbd2bb37cf598b1
MD5 7dcc3aa1045a768bf959a01100791e1b
BLAKE2b-256 4d1fdc7d638ab263f613143032f4eb44777ca6b42e3ae4059b977a266c33305c

See more details on using hashes here.

File details

Details for the file qirrunner-0.9.1-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for qirrunner-0.9.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5d155fbb4186dd987d25e6aaccbec02ca2549330cdf9bda8f9dc9b91dbe1ee5a
MD5 00d1726f7ffd4ad18c0f61b7dae80bdc
BLAKE2b-256 f2e99a00b0e4ff7178ee0002009e4971b227bb761922632e4797970e4a100581

See more details on using hashes here.

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