Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

qbraid-qir-header

CI Documentation Status PyPI version PyPI version License Discord

qBraid-SDK extension providing support for QIR conversions.

Motivation

qir

This project aims to make QIR representations accessible via the qBraid-SDK transpiler, and by doing so, open the door to language-specific conversions from any and all high-level quantum languages supported by qbraid. See QIR Alliance: why do we need it?.

Installation

qBraid-QIR requires Python 3.8 or greater, and can be installed with pip as follows:

pip install qbraid-qir

Optional dependencies

qBraid-QIR offers integrations that require extra (optional) dependencies, which can be installed as follows:

For Cirq to QIR conversions, install the cirq extra:

pip install 'qbraid-qir[cirq]'

For OpenQASM 3 to QIR conversions, install the qasm3 extra:

pip install 'qbraid-qir[qasm3]'

Install from source

You can also install from source by cloning this repository and running a pip install command in the root directory of the repository:

git clone https://github.com/qBraid/qbraid-qir.git
cd qbraid-qir
pip install .

To include optional dependencies when installing from source, use the same "extras_require" format, e.g.

pip install '.[cirq,qasm3]'

Check version

You can view the version of qbraid-qir you have installed within a Python shell as follows:

In [1]: import qbraid_qir

In [2]: qbraid_qir.__version__

Resources

Usage examples

Cirq conversions

import cirq
from qbraid_qir.cirq import cirq_to_qir

q0, q1 = cirq.LineQubit.range(2)

circuit = cirq.Circuit(
  cirq.H(q0),
  cirq.CNOT(q0, q1),
  cirq.measure(q0, q1)
)

module = cirq_to_qir(circuit, name="my-circuit")

ir = str(module)

OpenQASM 3 conversions

from qbraid_qir.qasm3 import qasm3_to_qir

program = """
OPENQASM 3;
include "stdgates.inc";

qubit[2] q;
bit[2] c;

h q[0];
cx q[0], q[1];

measure q[0] -> c[0];
measure q[1] -> c[1];
"""

module = qasm3_to_qir(program, name="my-program")

ir = str(module)

Add QIR node to qBraid conversion graph

from qbraid_qir.cirq import cirq_to_qir
from qbraid.transpiler import Conversion, ConversionGraph

graph = ConversionGraph()

conversion = Conversion("cirq", "qir", cirq_to_qir)

graph.add_conversion(conversion)

graph.plot()

Architecture diagram

qBraid-SDK transpiler hub-and-spokes architecture with qbraid-qir integration (left) mapped to language specific conversion step in QIR abstraction layers (right).

architecture

Contributing

Citation

If you use qBraid-QIR in your research, we kindly request that you cite it appropriately. The BibTeX entry below is aligned with the latest stable release. For the most up-to-date citation details, please refer to CITATION.cff.

@software{Kushnir_qBraid-QIR_Python_package_2024,
author = {Kushnir, Samuel and Gupta, Harshit and Jain, Rohan and Parakh, Priyansh and Hill, Ryan James},
license = {GPL-3.0},
month = mar,
title = {{qBraid-QIR: Python package for QIR conversions, integrations, and utilities.}},
url = {https://github.com/qBraid/qbraid-qir},
version = {0.2.0},
year = {2024}
}

Acknowledgements

This project was conceived in cooperation with the Quantum Open Source Foundation (QOSF).

License

GNU General Public License v3.0

Metadata

Release files for qbraid-qir 0.2.0.dev20240404040722

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

Source distribution (sdist)

Source distribution for qbraid-qir 0.2.0.dev20240404040722
File Size Uploaded
qbraid-qir-0.2.0.dev20240404040722.tar.gz 340.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qbraid-qir 0.2.0.dev20240404040722
File Interpreter ABI Platform
qbraid_qir-0.2.0.dev20240404040722-py3-none-any.whl Python 3 none any Details

Total release size: 398.3 kB

Release files / qbraid-qir-0.2.0.dev20240404040722.tar.gz

Download URL qbraid-qir-0.2.0.dev20240404040722.tar.gz
Size 340.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5696c5e9a541d4c231cf77f111392bc6ad39d39ef4c25ab30c185b0eb9032e2e
BLAKE2b-256 checksum
How to use checksums
d9afd6051eb8abcb39128000122100200e7c0077a243448a01f3625bf643114b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / qbraid_qir-0.2.0.dev20240404040722-py3-none-any.whl

Download URL qbraid_qir-0.2.0.dev20240404040722-py3-none-any.whl
Size 58.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
630fc88cdc2b88b761487fc420ad6f644d7df2030c1d001b63d17139b535b92b
BLAKE2b-256 checksum
How to use checksums
08a77c75dbb8f2c643bfcf2ea385b8a7da90bfc6d5c047ddb87ab4655c20af49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2
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