Skip to main content

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:

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.

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

bartiq-0.16.1.tar.gz (58.7 kB view details)

Uploaded Source

Built Distribution

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

bartiq-0.16.1-py3-none-any.whl (81.7 kB view details)

Uploaded Python 3

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

Hashes for bartiq-0.16.1.tar.gz
Algorithm Hash digest
SHA256 e6330143358433917ef04e2e36577aefec6efb59e3442497162e736cceab8887
MD5 7b321f5458de32459e365241b3a08916
BLAKE2b-256 1df9bed13b6665282782a2c8960451b24afed953372c7eb37e45bad7ead13ddb

See more details on using hashes here.

Provenance

The following attestation bundles were made for bartiq-0.16.1.tar.gz:

Publisher: build.yaml on PsiQ/bartiq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for bartiq-0.16.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e848a55fcc8c0f5a685c36c9d0a576df6ccb3cb6082144e8cb11602a5307a8ff
MD5 0f49ebdfb7297de3dbf5a86ae51afc93
BLAKE2b-256 39a41486aa7df7288567c2a6dbc874f57a6c643cf20ced169b774ac3ae72ee87

See more details on using hashes here.

Provenance

The following attestation bundles were made for bartiq-0.16.1-py3-none-any.whl:

Publisher: build.yaml on PsiQ/bartiq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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