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.load_program(secret_key)
print(algo)
from qbraid_algorithms import qft
algo = qft.load_program(4)
print(algo)
from qbraid_algorithms import iqft
algo = iqft.load_program(4)
print(algo)
from qbraid_algorithms import qpe
"""
Path to a qasm file defining the unitary gate U.
Eg. -
OPENQASM 3.0;
include "stdgates.inc";
gate custom_t q {
p(pi/4) q;
}
"""
unitary_filepath = "gate.qasm"
"""
Path to a qasm file defining the eigenstate preparation gate.
Eg. -
OPENQASM 3.0;
include "stdgates.inc";
gate prep q {
x q;
}
"""
eigen_state_filepath = "eigen_state.qasm"
algo = qpe.load_program(num_qubits = 4, unitary_filepath=unitary_filepath,
psi_filepath=eigen_state_filepath)
print(algo)
See API Reference for complete functionality of each algorithm module.