No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Notice: This is research code that will not necessarily be maintained to support further releases of Forest and other Rigetti Software. We welcome bug reports and PRs but make no guarantee about fixes or responses.

QuantumFlow-QAOA: Optimize QAOA circuits for graph maxcut using tensorflow

TensorFlow open source implementation for training Quantum Approximate Optimization Algorithm (QAOA) circuits on the graph MaxCut problem, from the paper:

Performance of the Quantum Approximate Optimization Algorithm on the Maximum Cut Problem

by Gavin E. Crooks


Code author: Gavin E. Crooks

Pull requests and issues: @gecrooks


This code relies upon QuantumFlow: A Quantum Algorithms Development Toolkit

git clone
cd quantumflow-qaoa
pip install -r requirements.txt

Train a QAOA circuit of N qubits and P steps to find good solutions to the MaxCut problem. We train on randomly sampled graphs, and validate against a fixed set of pregenerated graphs provided by qauntumflow.

> ./ --help
usage: [-h] [--version] [-v] [-i FILE] [-o FILE]
                                [-N NODES] [-P STEPS] [--epochs EPOCHS]
                                [--lr LEARNING_RATE] [-T FILE] [-V FILE]

QAOA graph maxcut using tensorflow gradient descent

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -v, --verbose
  -i FILE, --fin FILE   Read model from file
  -o FILE, --fout FILE  Write model to file
  -N NODES, --nodes NODES
  -P STEPS, --steps STEPS
  --epochs EPOCHS
  -T FILE, --train FILE
                        Collection of graphs to train on
  -V FILE, --validation FILE
                        Validation graph dataset

E.g. train 10 epoces on a batch of 100 8 node graphs, with 12 QAOA steps.

./ -N 8 -P 12 --verbose --epochs 10


If you use this code, please cite our paper:

  title={Performance of the Quantum Approximate Optimization Algorithm
on the Maximum Cut Problem},
  author={Crooks, Gavin E},