Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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.8.2
  • PyPI
  • Socket score

Maintainers
1

Bartiq

What is bartiq

Bartiq is a library that allows one to analyze quantum algorithms 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 https://github.com/PsiQ/bartiq.git and then run pip install . from the main directory.

# Clone bartiq repo (you can use SSH link as well)
git clone https://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 its 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 compile_routine, evaluate
from qref import SchemaV1

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

uncompiled_routine = SchemaV1(**routine_dict)
compiled_routine = compile_routine(uncompiled_routine).routine

assignments = {"L": 100, "mu": 10}

evaluated_routine = evaluate(compiled_routine, assignments).routine

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 example.

Documentation

Documentation for bartiq can be found here.

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc