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.0.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.0-cp39-abi3-win_amd64.whl (17.4 MB view details)

Uploaded CPython 3.9+Windows x86-64

qirrunner-0.9.0-cp39-abi3-manylinux_2_35_x86_64.whl (32.4 MB view details)

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

qirrunner-0.9.0-cp39-abi3-manylinux_2_35_aarch64.whl (30.8 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.35+ ARM64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: qirrunner-0.9.0.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.0.tar.gz
Algorithm Hash digest
SHA256 7f7899426dc87544a126a324bb169e84b101eff45336c930f99e9c46626eb60e
MD5 da2bdad9b6ecfc8f36743a018a810298
BLAKE2b-256 fadce31d0675dfd849ff56ad40a31114cfe16c8198ceb0d4b00876fcc495390d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qirrunner-0.9.0-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.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d2997379ac8f8af27a3212186b8f21a3dff5364dadb40c5afed0af19634eda59
MD5 7823af5411f3271e08230da44c973164
BLAKE2b-256 2d89ed2418503ef1c095305a514dd56edcfc33ed8568714166dfa86b6e3bf53d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qirrunner-0.9.0-cp39-abi3-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 93326a086af1aff72fdf7f78a13174ca79b3576b50308a9f20031a811cc5165b
MD5 3553805b3ae28b6671133bf823300f58
BLAKE2b-256 ef420312f9258d67f78426ab30ae616bd6e8740644c75d1029dbb6465abfcf13

See more details on using hashes here.

File details

Details for the file qirrunner-0.9.0-cp39-abi3-manylinux_2_35_aarch64.whl.

File metadata

File hashes

Hashes for qirrunner-0.9.0-cp39-abi3-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 7b87a50454551863cfe24daa1c82e153dba8184f8b2452e2931710a64ed678ff
MD5 b3b79ae9c94e5776b579315858ae7ca0
BLAKE2b-256 a4735c2fa6c6797c113d7ce23126c4662935b2cfaffc560b6258c77ef0ecd800

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qirrunner-0.9.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d033bdcd368dd4370d871c96a358367808eb7dd64899a31604570d0ccf33f860
MD5 3d099bf7e620c46bcde7949ac20f6432
BLAKE2b-256 81c14d3f82f8bec636af59cb04a497deb16a231a5e93bbf991e09e963991ec66

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