Code
qcr:2606.48636.1

QAOA for MaxCut with PennyLane

This PennyLane demo applies the Quantum Approximate Optimization Algorithm (QAOA) to the Maximum Cut (MaxCut) problem, the canonical benchmark for quantum optimization, following the original formulation by Farhi, Goldstone, and Gutmann. MaxCut asks for the partition of a graph's vertices into two sets that maximizes the number of edges crossing between them, an NP-hard problem with many practical analogues. The tutorial encodes MaxCut as a cost Hamiltonian whose ground state corresponds to the optimal cut, then builds the QAOA circuit, alternating cost-Hamiltonian and mixer-Hamiltonian layers parameterized by angles, in PennyLane. It defines the expected cut value as the objective, optimizes the layer angles with gradient-based optimization using PennyLane's automatic differentiation, and reads out the most probable bitstring as the proposed partition. The demo walks through defining the graph, constructing the circuit from first principles (rather than the high-level module), running the optimization, and interpreting the resulting cut, and discusses how circuit depth affects solution quality. As a from-scratch, end-to-end MaxCut solver, it is a foundational, widely-referenced example of quantum combinatorial optimization in PennyLane.
Optimization
Qubit
Circuit-based
Uploaded 1 day ago
15
Views
Citing this entry? Use this QCR ID
Uploaded by
QL
QCR Librarian

Overview

https://github.com/PennyLaneAI/demos/blob/c52c0abeb5122218aa96b38eea848864cce7323f/demonstrations_v2/tutorial_qaoa_maxcut/demo.py
README.md

QAOA for MaxCut with PennyLane

This PennyLane demo applies the Quantum Approximate Optimization Algorithm (QAOA) to the Maximum Cut (MaxCut) problem, the canonical benchmark for quantum optimization, following the original formulation by Farhi, Goldstone, and Gutmann. MaxCut asks for the partition of a graph's vertices into two sets that maximizes the number of edges crossing between them, an NP-hard problem with many practical analogues. The tutorial encodes MaxCut as a cost Hamiltonian whose ground state corresponds to the optimal cut, then builds the QAOA circuit, alternating cost-Hamiltonian and mixer-Hamiltonian layers parameterized by angles, in PennyLane. It defines the expected cut value as the objective, optimizes the layer angles with gradient-based optimization using PennyLane's automatic differentiation, and reads out the most probable bitstring as the proposed partition. The demo walks through defining the graph, constructing the circuit from first principles (rather than the high-level module), running the optimization, and interpreting the resulting cut, and discusses how circuit depth affects solution quality. As a from-scratch, end-to-end MaxCut solver, it is a foundational, widely-referenced example of quantum combinatorial optimization in PennyLane.

Run it

pip install -r requirements.txt
python demo.py

Source and license

Imported from demonstrations_v2/tutorial_qaoa_maxcut/demo.py in PennyLaneAI/demos at c52c0abeb5122218aa96b38eea848864cce7323f, under the Apache License 2.0. Original authors: Xanadu and the PennyLane community. The upstream LICENSE is included alongside this example.

Join the Discussion

Comments (0)

No comments yet. Be the first to share your thoughts!

Indexed by QCR Librarian

This entry was created automatically from publicly available records. QCR links to public sources and only stores repository content where the license permits redistribution.

Publication

doi:10.48550/arxiv.1411.4028
A Quantum Approximate Optimization Algorithm

Edward Farhi, Jeffrey Goldstone, Sam Gutmann

Versions

v1 Latest
Jun 17, 2026
qcr:2606.48636.1

Cite all versions? Use the base QCR ID to always reference the latest version of this entry.

Tools used

PennyLane

Keywords

qaoa
maxcut
optimization
variational
pennylane

You may also like5