Skip to main content

A Toolkit for Reproducible Study, Application and Verification of QAOA

Project description

QAOAKit: A Toolkit for Reproducible Application and Verification of QAOA

Code style: black Tests

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:

Citation

Please cite the following paper when using QAOAKit:

@inproceedings{Shaydulin2021,
  doi = {10.1109/qcs54837.2021.00011},
  url = {https://doi.org/10.1109/qcs54837.2021.00011},
  year = {2021},
  month = nov,
  publisher = {{IEEE}},
  author = {Ruslan Shaydulin and Kunal Marwaha and Jonathan Wurtz and Phillip C. Lotshaw},
  title = {{QAOAKit}: A Toolkit for Reproducible Study,  Application,  and Verification of the {QAOA}},
  booktitle = {2021 {IEEE}/{ACM} Second International Workshop on Quantum Computing Software ({QCS})}
}

Consider citing relevant papers for the particular dataset you use as well.

Install from source

git clone https://github.com/QAOAKit/QAOAKit.git
cd QAOAKit
pip install -e .
python -m QAOAKit.build_tables
pytest

Nauty installation issues

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), use conda (conda install -c conda-forge 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.

We are in the process of moving the codebase to numpy-style docstrings. See documentation here: https://numpydoc.readthedocs.io/en/latest/format.html

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

QAOAKit-0.1.13.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

QAOAKit-0.1.13-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file QAOAKit-0.1.13.tar.gz.

File metadata

  • Download URL: QAOAKit-0.1.13.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for QAOAKit-0.1.13.tar.gz
Algorithm Hash digest
SHA256 f33f3b8d0135e1fbd6b097891fd4e04ea17bb4727126a66ae47508292d8d9c6b
MD5 fadc0fbdde8ed55ac028315c96df690a
BLAKE2b-256 2bb137f9d2260f75de5b0b3fce2629b1c3016e53569a33133430eb06f6606cfe

See more details on using hashes here.

File details

Details for the file QAOAKit-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: QAOAKit-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for QAOAKit-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 0bd598e0ea8c2efc663c6242534c157a0c7a9562cb9f98fde36159f3cad803cb
MD5 e0b1d193154d8464601a56fa8eb8eee9
BLAKE2b-256 db9b7aba566a67b9eb6eb1c779dc5d7231e0cc04077d746086d43233a37d2830

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page