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.17.0.tar.gz (58.9 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.17.0-py3-none-any.whl (82.0 kB view details)

Uploaded Python 3

File details

Details for the file bartiq-0.17.0.tar.gz.

File metadata

  • Download URL: bartiq-0.17.0.tar.gz
  • Upload date:
  • Size: 58.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bartiq-0.17.0.tar.gz
Algorithm Hash digest
SHA256 59e383401072a486cf786476ee9da0213a777b95d7c5f50bfe45711519f6c0d8
MD5 2a996cb53b0aa8002975184380d93776
BLAKE2b-256 0bdcf9cb4df107f5b834dfd752d7e068c80a70c79427da65356564cfd61b025f

See more details on using hashes here.

Provenance

The following attestation bundles were made for bartiq-0.17.0.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.17.0-py3-none-any.whl.

File metadata

  • Download URL: bartiq-0.17.0-py3-none-any.whl
  • Upload date:
  • Size: 82.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bartiq-0.17.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e8c042ced19246deac468edd0029aa2bf816ebbbb7e34a2c4d04e81bfc4b090
MD5 89b139fdfd99e433d1843d95286c3c0b
BLAKE2b-256 c15a4454d7c7b8af513b390cb54f0b1c66ba84666bfd3f1e87f7665ad77c8f28

See more details on using hashes here.

Provenance

The following attestation bundles were made for bartiq-0.17.0-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