Skip to main content
qBraid-ALGOS
Quantum Algorithms Library.
Python package for building, simulating, and benchmarking hybrid quantum-classical algorithms.

Installation

qbraid-algorithms requires Python 3.11 or greater, and can be installed with pip as follows:
pip install qbraid-algorithms

Install from source

You can also install from source by cloning this repository and running a pip install command in the root directory of the repository:
git clone https://github.com/qBraid/qbraid-algorithms.git
cd qbraid-algorithms
pip3 install .

Check version

You can view the version of qbraid-algorithms you have installed within a Python shell as follows:
import qbraid_algorithms

qbraid_algorithms.__version__

Supported Algorithms

from qbraid_algorithms import bernstein_vazirani
secret_key = '01001'
algo = bernstein_vazirani.generate_program(secret_key)
print(algo)
 OPENQASM 3.0;
 include "stdgates.inc";
 def bernvaz(qubit[5] q, qubit[1] ancilla) {
   int[32] s = 18;
   int[16] n = 5;
   for int i in [0:n - 1] {
     h q[i];
   }
   x ancilla[0];
   h ancilla[0];
   for int i in [0:n - 1] {
     if (s >> i & 1) {
       cx q[i], ancilla[0];
     }
   }
   for int i in [0:n - 1] {
     h q[i];
   }
 }
 qubit[5] q;
 qubit[1] ancilla;
 bit[5] b;
 bernvaz(q, ancilla);
 b = measure q;
See API Reference for complete functionality of each algorithm module.