Symbolic Quantum Resource Estimation compilation
Project description
Bartiq
What is bartiq
Bartiq allows for the compilation and analysis of fault tolerant quantum algorithms, in order to better understand what resources they require to run on a quantum computer. Quantum resource estimation (QRE) focuses on key logical-level resources like $T$-gates, Toffolis, circuit active volume, and qubit count. In bartiq, quantum algorithms are expressed as a collection of subroutines, each of which can have its local resource cost expressed symbolically. The compilation engine in bartiq creates global resource costs from these local definitions.
Installation
To install bartiq run:
pip install bartiq
Documentation
Complete documentation for bartiq can be found here.
Quick start
In bartiq we can express a quantum algorithm as a collection of subroutines, each of which has a respective symbolic resource cost, and compile it to get a global symbolic resource cost for the whole algorithm.
As an example we consider the following circuit, from Encoding Electronic Spectra in Quantum Circuits with Linear T Complexity. This circuit prepares an arbitrary state with $L$ unique amplitudes, and is equivalent to classical alias sampling. From Fig. 11 in the paper:
In order to quickly get started with bartiq, you can load this as an example routine and use it as follows (click here to download alias_sampling_basic.json):
import json
from bartiq import compile_routine, evaluate
from qref import SchemaV1
with open("alias_sampling_basic.json", "r") as f:
routine_dict = json.load(f)
uncompiled_routine = SchemaV1(**routine_dict)
compiled_routine = compile_routine(uncompiled_routine).routine
After loading the alias sampling JSON file we cast it to the qref.SchemaV1 type, our data format for representing quantum algorithms for the purposes for resource estimation. This provides us with an uncompiled_routine, which we can then compile with bartiq. The compilation engine will propagate the resource costs from low-level subroutines up, to create aggregated global costs for the whole circuit.
To see, for example, the symbolic $T$-gate count for this circuit:
print(compiled_routine.resources["T_gates"].value)
>>> 4*L + 8*L/multiplicity(2, L) + 4*mu + O(log2(L)) - 8
To obtain numeric resource costs we can assign values to our variables $L$ and $\mu$ and then evaluate the routine
assignments = {"L": 100, "mu": 10}
evaluated_routine = evaluate(compiled_routine, assignments).routine
print(evaluated_routine.resources["T_gates"].value)
>>> O(log2(100)) + 832
To go step by step through the process and see how you can use bartiq for your algorithms please take a look at our tutorials, starting with a basic example.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bartiq-0.16.1.tar.gz.
File metadata
- Download URL: bartiq-0.16.1.tar.gz
- Upload date:
- Size: 58.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6330143358433917ef04e2e36577aefec6efb59e3442497162e736cceab8887
|
|
| MD5 |
7b321f5458de32459e365241b3a08916
|
|
| BLAKE2b-256 |
1df9bed13b6665282782a2c8960451b24afed953372c7eb37e45bad7ead13ddb
|
Provenance
The following attestation bundles were made for bartiq-0.16.1.tar.gz:
Publisher:
build.yaml on PsiQ/bartiq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bartiq-0.16.1.tar.gz -
Subject digest:
e6330143358433917ef04e2e36577aefec6efb59e3442497162e736cceab8887 - Sigstore transparency entry: 906694061
- Sigstore integration time:
-
Permalink:
PsiQ/bartiq@3d6f5685d48bc7d24418419e075b27e80dcf1994 -
Branch / Tag:
refs/tags/v0.16.1 - Owner: https://github.com/PsiQ
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yaml@3d6f5685d48bc7d24418419e075b27e80dcf1994 -
Trigger Event:
release
-
Statement type:
File details
Details for the file bartiq-0.16.1-py3-none-any.whl.
File metadata
- Download URL: bartiq-0.16.1-py3-none-any.whl
- Upload date:
- Size: 81.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e848a55fcc8c0f5a685c36c9d0a576df6ccb3cb6082144e8cb11602a5307a8ff
|
|
| MD5 |
0f49ebdfb7297de3dbf5a86ae51afc93
|
|
| BLAKE2b-256 |
39a41486aa7df7288567c2a6dbc874f57a6c643cf20ced169b774ac3ae72ee87
|
Provenance
The following attestation bundles were made for bartiq-0.16.1-py3-none-any.whl:
Publisher:
build.yaml on PsiQ/bartiq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bartiq-0.16.1-py3-none-any.whl -
Subject digest:
e848a55fcc8c0f5a685c36c9d0a576df6ccb3cb6082144e8cb11602a5307a8ff - Sigstore transparency entry: 906694115
- Sigstore integration time:
-
Permalink:
PsiQ/bartiq@3d6f5685d48bc7d24418419e075b27e80dcf1994 -
Branch / Tag:
refs/tags/v0.16.1 - Owner: https://github.com/PsiQ
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yaml@3d6f5685d48bc7d24418419e075b27e80dcf1994 -
Trigger Event:
release
-
Statement type: