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:

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

QAOAKit-0.1.11.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

QAOAKit-0.1.11-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

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

Hashes for QAOAKit-0.1.11.tar.gz
Algorithm Hash digest
SHA256 5b93603c7fbe62c929112a0b581f4ad10e153b1aa90372bf5eed4f9878a2dcc1
MD5 f0daf042d9d9a36452c45c228f608272
BLAKE2b-256 de8423a7ae7cb4b541d1d2b188f300249121efe8e3cb8f20c0647c99374c66e4

See more details on using hashes here.

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

Hashes for QAOAKit-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 ef0183e839ea86c9cd31f0155eaa09cab95416251bf414620d702b9a9c4c0450
MD5 4744a30e21630b5f3ccae46d0334b32d
BLAKE2b-256 dd9b8d6b29e6335954d175d44baa9884b091d871ed8237cb9ee7493326bb446f

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