Skip to main content

Symbolic Quantum Resource Estimation compilation

Project description

Bartiq

What is bartiq

Bartiq is a library that allows to analyze a quantum routines and calculate symbolic expressions for quantum resource estimates (QRE).

Installation

To install bartiq run: pip install bartiq.

In order to install it from source clone the repo by running git clone git@github.com:PsiQ/qref.git and then run pip install . from the main directory.

# Clone bartiq repo (you can use HTTP link as well)
git clone git@github.com:PsiQ/bartiq.git
cd bartiq
pip install .

Quick start

In bartiq we can take a quantum algorithm expressed as a collection of subroutines, each with it's costs expressed as symbolic expressions, and compile it to get cost expression for the whole algorithm.

As an example we can use Alias Sampling – an algorithm proposed by Babbush et al.. Here's how it's depicted in the paper:

Alias Sampling

In order to quickly get started with bartiq, you can load Alias Sampling as an example routine and use it as follows (click here to download alias_sampling_basic.json):

import json
from bartiq import Routine, compile_routine, evaluate
from bartiq.integrations import qref_to_bartiq

with open("alias_sampling_basic.json", "r") as f:
    routine_dict = json.load(f)

uncompiled_routine = qref_to_bartiq(routine_dict)
compiled_routine = compile_routine(uncompiled_routine)

assignments = ["L=100", "mu=10"]

evaluated_routine = evaluate(compiled_routine, assignments)

Now in order to inspect the results you can do:

print(compiled_routine.resources["T_gates"].value)
print(evaluated_routine.resources["T_gates"].value)

which returns both symbolic the expression for the T-count as well as result for specific values of L and mu:

4*L + 8*L/multiplicity(2, L) + 4*mu + swap.O(log2(L)) - 8
swap.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 basic_usage.

Documentation

Documentation for bartiq can be found here.

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.1.2.tar.gz (46.1 kB view hashes)

Uploaded Source

Built Distribution

bartiq-0.1.2-py3-none-any.whl (60.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page