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.

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

QAOAKit-0.1.8.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

QAOAKit-0.1.8-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: QAOAKit-0.1.8.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

Hashes for QAOAKit-0.1.8.tar.gz
Algorithm Hash digest
SHA256 9bf5f6c82a29cf08d0e03cf32d21c4ec1cb28c4d6a51b806340313c5723718a6
MD5 06fe117f6682c3ed95f9baa7e90ef801
BLAKE2b-256 dc79f26da39773019347c82e17b620e6563f76e722af69af290c502cb49e2632

See more details on using hashes here.

File details

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

File metadata

  • Download URL: QAOAKit-0.1.8-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

Hashes for QAOAKit-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 ecb548d6e5ff97a05fa1256c4fb1298512fe84ea612fc3dbf5d0dbfa6122d1b4
MD5 d654b456b4cc35ebfda5f2ec66279dd3
BLAKE2b-256 e82446425801366480698b32223e4d7c4b16ee07359c1148e5444da8ddb34187

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