Skip to main content
KetQat

Appearance

QAOA for MaxCut (statevector)

Run QAOA on a small graph with an exhaustive angle grid and compare the expected cut with the exact MaxCut optimum.

Officially provided by KetQat — method by Farhi et al. (2014), Karp (1972) and others. KetQat prepares, verifies and maintains this product; it does not claim to have invented the method. Read the origin statement.

What it does and who it is for

Runs the Quantum Approximate Optimization Algorithm for MaxCut as a statevector simulation on your machine. The graph is a ring, a path, a complete graph or your own edge list; the product prepares the uniform superposition, applies the cost and mixer layers as operators for one or two layers, searches the angles on an exhaustive grid, and reports the best expected cut against the exact optimum found by enumerating every assignment. The final state is sampled with a seed so you also get an observed cut distribution.

On a triangle-free regular graph at one layer, the Farhi-Goldstone-Gutmann closed form for the expected cut is evaluated at the chosen angles and reported beside the simulation, so the two can be compared directly.

The optimiser is a grid rather than a gradient method on purpose: a grid is exhaustive at its resolution, so the reported expectation is a lower bound on what QAOA can reach at that depth, not where a local optimiser happened to stop.

Use cases

  • Check the approximation ratio of one- or two-layer QAOA against the true MaxCut optimum of a small graph
  • Compare a simulated expected cut with the Farhi-Goldstone-Gutmann p=1 closed form on a ring
  • Produce a reproducible QAOA baseline (angles, expectation, sampled cuts) to compare another implementation against

Use it on your computer

This page never runs anything. Copy the commands into your own terminal; the product runs locally with no account and no telemetry.
  1. Install

    Installs the KetQat SDK from commit 2cedabbd814f, the exact version whose product definition this page shows. The SDK is not on PyPI yet, so pip install ketqat alone will not work.

    Terminal
    pip install "ketqat[algorithms] @ git+https://github.com/ketqat/ketqat-sdk@2cedabbd814fd199b1989c8ceb1e9efa1744c2c0#subdirectory=python"
  2. Run the example

    Save it as example.py and run python example.py. Or use the CLI: ketqat catalog run [email protected].

    Python
    import json
    from ketqat_runner import catalog
    
    record = catalog.run("[email protected]", seed=7, graph="ring", n_vertices=6, layers=1, shots=1000)
    result = record.result
    print(json.dumps({
        "status": record.status,
        "max_cut": result["max_cut"],
        "best_expectation": round(result["best_expectation"], 9),
        "approximation_ratio": round(result["approximation_ratio"], 9),
        "analytic_p1_expectation": round(result["analytic_p1_expectation"], 9),
    }))
    
    Expected output (fields the example must print)
    {
      "status": "succeeded",
      "max_cut": 6,
      "best_expectation": 4.5,
      "approximation_ratio": 0.75,
      "analytic_p1_expectation": 4.5
    }

    Verified with

    SDK
    0.3.0
    Python
    3.12.12
    Platform
    macOS-27.0.1-arm64 Python 3.12.12 (maintainer run in a clean virtualenv, test_catalog_examples.py)
    Date
    1 Nov 2026
  3. Optional: tell us it ran

    ketqat report RUN_ID sends an opt-in usage report: product, version, succeeded/failed, time and SDK version only. It shows you the exact payload first and needs an API token from Settings. Nothing is sent unless you run it.

Inputs and outputs

Inputs

Inputs of QAOA for MaxCut (statevector)
NameTypeDefaultAllowed valuesDescription
graphstringringenum: ring, path, complete, customring (cycle on n vertices), path, complete, or custom (give edges).
n_verticesinteger6maximum: 12; minimum: 2Number of vertices n, one qubit each; the state vector has 2^n amplitudes.
edgesstring[]nullminItems: 1; uniqueItems: trueFor graph=custom: edges as 'u-v' strings with vertices in 0..n-1, no self-loops, no repeats. null otherwise.
layersinteger1maximum: 2; minimum: 1QAOA depth p: 1 or 2. Each layer adds one beta and one gamma to the grid search.
gridinteger24maximum: 64; minimum: 4Grid points per angle: beta in [0, pi) and gamma in [0, 2 pi), so grid^(2p) expectation evaluations. Requests estimated above ~24 s are refused with the estimate.
shotsinteger1000maximum: 1000000; minimum: 1Measurement samples drawn from the optimised QAOA state.

Outputs

Outputs of QAOA for MaxCut (statevector)
NameTypeDescription
best_expectationnumberLargest expected cut <C> found on the grid, from the simulated state.
max_cutintegerExact MaxCut value from enumerating all 2^n assignments, with the optimal assignments listed.
approximation_rationumberbest_expectation / max_cut.
best_betanumber[]Mixer angles of the best grid point (one per layer); best_gamma holds the cost angles.
analytic_p1_expectationnumberFarhi-Goldstone-Gutmann closed form at the chosen angles when layers=1 and the graph is triangle-free and regular; null otherwise.
probability_of_optimal_cutnumberExact probability that measuring the optimised state yields an optimal assignment.
countsobjectSeeded measurement counts by assignment string (vertex 0 is the rightmost character), with the sampled mean cut and the best sampled cut.

Sample result

Ring of 6 vertices, one layer, 24x24 grid: best expected cut 4.5 of the exact maximum 6 (ratio 0.75, the known p=1 ceiling), equal to the Farhi-Goldstone-Gutmann closed form at the chosen angles; an optimal assignment has probability 0.285 and 276 of 1000 seeded shots hit one.

Generated with

Product version
1.0.0
Seed
7
Parameters
{"grid":24,"edges":null,"graph":"ring","shots":1000,"layers":1,"n_vertices":6}
SDK
0.3.0
Python
3.12.12
Platform
macOS-27.0.1-arm64-arm-64bit
Result data (JSON)
{
  "grid": 24,
  "note": "Ratio is against the exact optimum from enumerating all 64 assignments, not a bound. Angles come from an exhaustive 24x24 grid per layer; a finer grid can only improve the expectation, so this is a lower bound on QAOA's best.",
  "graph": {
    "kind": "ring",
    "edges": [
      [
        0,
        1
      ],
      [
        1,
        2
      ],
      [
        2,
        3
      ],
      [
        3,
        4
      ],
      [
        4,
        5
      ],
      [
        5,
        0
      ]
    ],
    "n_vertices": 6,
    "triangle_free": true,
    "regular_degree": 2
  },
  "shots": 1000,
  "counts": {
    "100010": 12,
    "100011": 2,
    "100100": 31,
    "100101": 35,
    "100110": 32,
    "101000": 6,
    "101001": 38,
    "101010": 138,
    "101011": 7,
    "101100": 43,
    "101101": 21,
    "101110": 9,
    "101111": 3,
    "110001": 1,
    "110010": 31,
    "110100": 36,
    "110101": 9,
    "110110": 31,
    "111010": 8,
    "111011": 2,
    "111101": 2,
    "111110": 1,
    "000010": 2,
    "000100": 4,
    "000101": 4,
    "000111": 5,
    "001001": 36,
    "001010": 6,
    "001011": 36,
    "001101": 26,
    "001110": 5,
    "010000": 2,
    "010001": 12,
    "010010": 36,
    "010011": 38,
    "010100": 11,
    "010101": 138,
    "010110": 33,
    "010111": 6,
    "011001": 30,
    "011010": 35,
    "011011": 30,
    "011100": 1,
    "011101": 6
  },
  "layers": 1,
  "max_cut": 6,
  "best_beta": [
    2.748893571891
  ],
  "bit_order": "vertex 0 is the rightmost character of each assignment string",
  "execution": "statevector simulation of the QAOA layers; angles from an exhaustive grid; optimum by enumeration",
  "best_gamma": [
    2.356194490192
  ],
  "analytic_p1_note": "Farhi-Goldstone-Gutmann p=1 closed form |E| (1/2 + 1/2 sin(4 beta) sin(gamma) cos(gamma)^(d-1)) evaluated at the chosen angles; it holds for triangle-free d-regular graphs.",
  "best_expectation": 4.5,
  "best_sampled_cut": 6,
  "sampled_cut_mean": 4.492,
  "analytic_p1_applies": true,
  "approximation_ratio": 0.75,
  "optimal_assignments": [
    "010101",
    "101010"
  ],
  "beats_random_guessing": true,
  "analytic_p1_expectation": 4.5,
  "random_guess_expectation": 3,
  "observed_optimal_fraction": 0.276,
  "probability_of_optimal_cut": 0.28515625
}

Assumptions, scope and limitations

Assumptions

  • Ideal, noiseless gates: the cost layer exp(-i gamma C) and the mixer exp(-i beta sum X) are applied as exact operators on amplitudes.
  • Unweighted MaxCut: every edge counts 1 when cut.
  • Angles are restricted to a uniform grid; the reported expectation is the best grid point, a lower bound on QAOA's best at that depth.

Scope

  • Graphs on 2 to 12 vertices, one or two QAOA layers, grids of 4 to 64 points per angle.
  • Exact expected cut, exact optimum by enumeration, exact probability of an optimal assignment, and seeded sampling of the final state.
  • The p=1 closed form is evaluated only where it holds (triangle-free regular graphs); elsewhere it is reported as not applicable.

Limitations

  • Grid search costs grid^(2p) state preparations and is exhaustive only for p <= 2; deeper circuits are not offered.
  • No noise model, no gate decomposition and no circuit depth: the layers are applied as operators, so this says nothing about hardware cost.
  • The approximation ratio is for the specific small instance; it is not a guarantee for larger graphs of the same family.
  • Sampled counts are reproducible for the same seed with the same NumPy version; NumPy does not guarantee identical random streams across versions.
  • Tested on macOS and Linux only; Windows is untested.

Environment and resources

Runs
Locally, on your computer
Type
Simulation
Python
>=3.10
Operating systems
Linux, macOS
Resources
Ring of 6 at one layer with the default 24x24 grid: ~0.1 s; 10 vertices: ~3 s; 12 vertices: ~12 s. Two layers with a 12-point grid on 6 vertices: ~6 s. Pure-Python amplitudes, under 50 MB. Requests estimated above ~24 s are refused.
SDK extras
algorithms
Minimum SDK
0.3.0

Validation

Verified: the example was executed by CI, validation tests exist and limitations are recorded.

Versions and changelog

  1. 1.0.01 Nov 2026currentShown on this page

    • First catalog release, wrapping the SDK's existing QAOA MaxCut simulation with graph presets, seeded sampling and the p=1 closed-form cross-check.

    Needs SDK 0.3.0 or later with extras: algorithms.

All product changelogs

Origin, license and credits

KetQat implementation of published methods

The Quantum Approximate Optimization Algorithm and the p=1 closed form for triangle-free regular graphs are due to Farhi, Goldstone and Gutmann (2014); MaxCut is the classical NP-hard problem of Karp (1972). KetQat wrote this pure-Python statevector implementation (qaoa.py), the grid search, the brute-force reference, the seeded sampling, the validation tests and this catalog entry. KetQat did not invent the method.

Upstream software

License of what you receive

Apache-2.0 — see Licensing.

Contributors

People credited for this product. KetQat publishes and maintains it; contributors are credited for their work and are not sellers.

  • dorakingx · KetQat maintainer: implementation, validation and catalog entry

How to contribute

References

  1. Edward Farhi, Jeffrey Goldstone, Sam Gutmann (2014). A Quantum Approximate Optimization Algorithm. arXiv preprint.arXiv:1411.4028
  2. Richard M. Karp (1972). Reducibility among combinatorial problems. Complexity of Computer Computations, Plenum Press, 85-103.
  3. Michael A. Nielsen, Isaac L. Chuang (2010). Quantum Computation and Quantum Information: 10th Anniversary Edition. Cambridge University Press.DOI 10.1017/CBO9780511976667

Usage

No usage reports yet

Distinct signed-in accounts that chose to send at least one usage report (ketqat report) for this product in the last 90 days. KetQat staff, test and bot accounts are excluded. Reports are opt-in, so this is not a count of all users.

Computed 10 Nov 2026, 17:10 UTC.

Reviews

Not yet rated

Be the first to rate this product after you run it.

Mean of visible reviews. Hidden reviews and reviews by KetQat staff, test and bot accounts are excluded. Pro status gives no extra weight.

Sign in to review this product. One review per person; you can edit it later.

No reviews yet.