Skip to main content

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:

Alias Sampling

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.

Metadata

Release files for bartiq 0.17.0

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

Source distribution (sdist)

Source distribution for bartiq 0.17.0
File Size Uploaded Provenance Actions
bartiq-0.17.0.tar.gz 58.9 kB With provenance Details for bartiq-0.17.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bartiq 0.17.0
File Interpreter ABI Platform Actions
bartiq-0.17.0-py3-none-any.whl Python 3 none any Details for bartiq-0.17.0-py3-none-any.whl

Total release size: 140.8 kB

Release files / bartiq-0.17.0.tar.gz

Download URL bartiq-0.17.0.tar.gz
Size 58.9 kB
Tags Source
SHA-256 checksum
How to use checksums
59e383401072a486cf786476ee9da0213a777b95d7c5f50bfe45711519f6c0d8
BLAKE2b-256 checksum
How to use checksums
0bdcf9cb4df107f5b834dfd752d7e068c80a70c79427da65356564cfd61b025f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 20, 2026.

Transparency log

Release files / bartiq-0.17.0-py3-none-any.whl

Download URL bartiq-0.17.0-py3-none-any.whl
Size 82.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e8c042ced19246deac468edd0029aa2bf816ebbbb7e34a2c4d04e81bfc4b090
BLAKE2b-256 checksum
How to use checksums
c15a4454d7c7b8af513b390cb54f0b1c66ba84666bfd3f1e87f7665ad77c8f28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 20, 2026.

Transparency log

Security for bartiq 0.17.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bartiq-0.17.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.17.0 This release

2 release files Full provenance

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