A Toolkit for Reproducible Study, Application and Verification of QAOA
Project description
QAOAKit
: A Toolkit for Reproducible Application and Verification of QAOA
Installation
Recommended: create an Anaconda environment
conda create -n qaoa python=3
conda activate qaoa
Note that current implementation requires significant amounts of RAM (~5GB) as it loads the entire dataset into memory.
pip install QAOAKit
python -m QAOAKit.build_tables
Example
import networkx as nx
from qiskit.providers.aer import AerSimulator
from QAOAKit import opt_angles_for_graph, angles_to_qaoa_format
from QAOAKit.qaoa import get_maxcut_qaoa_circuit
# build graph
G = nx.star_graph(5)
# grab optimal angles
p = 3
angles = angles_to_qaoa_format(opt_angles_for_graph(G,p))
# build circuit
qc = get_maxcut_qaoa_circuit(G, angles['beta'], angles['gamma'])
qc.measure_all()
# run circuit
backend = AerSimulator()
print(backend.run(qc).result().get_counts())
Almost all counts you get should correspond to one of the two optimal MaxCut solutions for star graph: 000001
or 111110
.
Advanced usage
More advanced examples are available in examples
folder:
- Using optimal parameters in state-of-the-art tensor network QAOA simulator QTensor:
examples/qtensor_get_energy.py
- Transfering parameters to large unseen instances:
examples/Transferability to unseen instances.ipynb
- Tackling open problems in quantum optimization:
examples/Tackling open problems.ipynb
Install from source
git clone https://github.com/QAOAKit/QAOAKit.git
cd QAOAKit
pip install -e .
python -m QAOAKit.build_tables
pytest
If you have an issue like "Illegal Instruction (core dumped)", you may have to force pip to recompile Nauty binaries (pip install --no-binary pynauty pynauty
) or install Nauty separately: https://pallini.di.uniroma1.it/
You can set up the linter to run before every commit.
pip install pre-commit
pre-commit install
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
Built Distribution
File details
Details for the file QAOAKit-0.1.9.tar.gz
.
File metadata
- Download URL: QAOAKit-0.1.9.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/3.8.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c053c76c9037ca9e05c58b64d911262b84b57dd8a04a0fc50e384887cf8395c |
|
MD5 | f36936e50adefd7c0114eec9b98a6651 |
|
BLAKE2b-256 | 64c02fdf3795006676c6b91ffe44d51ffb06438a5d297fbd7b147683758a62a0 |
File details
Details for the file QAOAKit-0.1.9-py3-none-any.whl
.
File metadata
- Download URL: QAOAKit-0.1.9-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/3.8.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3231e88d06e9ea36b6c72eaa9c0439e329212a24ca26e9471ed614018c738a71 |
|
MD5 | d502f669913364182a45680f95962253 |
|
BLAKE2b-256 | 19e9e033ab72f8b6e8943ac1735854d4e5d759724b3d8168de92375deabc3dc5 |