🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

bartiq

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bartiq

Symbolic Quantum Resource Estimation compilation

0.13.1
PyPI
Maintainers
1

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.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts