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. Linux and macOS are currently supported.
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
.
For graphs where no pre-optimized angles are available, the angles from "The fixed angle conjecture for QAOA on regular MaxCut graphs" (arXiv:2107.00677) will be returned.
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
- Transferring parameters to large unseen instances:
examples/Transferability to unseen instances.ipynb
- Tackling open problems in quantum optimization:
examples/Tackling open problems.ipynb
- Exploring the performance of QAOA on small graphs as a function of average degree:
examples/performance.ipynb
- Comparing QAOA with classical algorithms for MaxCut:
examples/classical_algorithms.py
- Clustering degenerate QAOA angles:
examples/degenerate_optima_in_angle_space.py
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/
Contributing
You should set up the linter to run before every commit.
pip install pre-commit
pre-commit install
Note that linter checks passing is a necessary condition for your contribution to be reviewed.
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.11.tar.gz
.
File metadata
- Download URL: QAOAKit-0.1.11.tar.gz
- Upload date:
- Size: 16.7 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 | 5b93603c7fbe62c929112a0b581f4ad10e153b1aa90372bf5eed4f9878a2dcc1 |
|
MD5 | f0daf042d9d9a36452c45c228f608272 |
|
BLAKE2b-256 | de8423a7ae7cb4b541d1d2b188f300249121efe8e3cb8f20c0647c99374c66e4 |
File details
Details for the file QAOAKit-0.1.11-py3-none-any.whl
.
File metadata
- Download URL: QAOAKit-0.1.11-py3-none-any.whl
- Upload date:
- Size: 15.1 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 | ef0183e839ea86c9cd31f0155eaa09cab95416251bf414620d702b9a9c4c0450 |
|
MD5 | 4744a30e21630b5f3ccae46d0334b32d |
|
BLAKE2b-256 | dd9b8d6b29e6335954d175d44baa9884b091d871ed8237cb9ee7493326bb446f |