Quantum annealing is a different model of quantum computing from everything else on this site. There's no circuit, no gates, no Grover or Shor's algorithm running on the hardware. An annealer solves exactly one shape of problem, optimization, by encoding the problem directly into the physics of the hardware and letting the system settle into a low-energy answer.
This guide formulates the same Max-Cut problem from our QAOA tutorial as an annealing challenge, solves the problem for free with D-Wave's Ocean SDK, and covers the practical mistake almost everyone hits moving from a toy example to real hardware.
The Physics Idea
An optimization problem is mapped onto a system of qubits so the system's lowest-energy configuration, its ground state, corresponds to the best solution. The qubits start in an easy-to-prepare state and evolve slowly toward the issue's energy profile. The adiabatic theorem is what makes this work: a quantum system starting in its ground state stays in the ground state through the evolution, provided the evolution is slow enough relative to the system's energy gaps. Read the qubits at the end, and you obtain a low-energy, hopefully optimal, solution.
This differs from gate-model computing in a fundamental way. A gate-model QPU executes an arbitrary sequence of operations you specify. An annealer executes one fixed process, physically relaxing toward a minimum, and your only input is how the problem gets encoded into this energy profile.
Formulating Max-Cut as a QUBO
Annealers solve problems expressed as a QUBO (Quadratic Unconstrained Binary Optimization): minimize an expression of binary variables x_i ∈ {0, 1} with only linear and pairwise quadratic terms, no higher-order interactions.
For Max-Cut, each edge (i, j) contributes 2·x_i·x_j − x_i − x_j to the objective. Work through the four cases: when x_i and x_j match (both on the same side), this term is 0. When they differ (the edge is cut), the term is −1. Minimizing the sum over all edges therefore maximizes the number of cut edges, exactly the Max-Cut objective, restated as a minimization.
Using the same four-node cycle graph as the QAOA guide:
import dimod
from neal import SimulatedAnnealingSampler
edges = [(0, 1), (1, 2), (2, 3), (3, 0)]
Q = {}
for i, j in edges:
Q[(i, i)] = Q.get((i, i), 0) - 1
Q[(j, j)] = Q.get((j, j), 0) - 1
Q[(i, j)] = Q.get((i, j), 0) + 2
bqm = dimod.BinaryQuadraticModel.from_qubo(Q)
Every edge in this graph gets cut simultaneously, the graph is bipartite: {0, 2} against {1, 3}, so the ground-state energy works out to exactly −4, one −1 contribution per edge. This figure comes directly from the QUBO's construction, not from running anything yet, and this is the goal the sampler below is trying to reach.
Solving This for Free with Simulated Annealing
D-Wave's Ocean SDK ships neal, a classical simulated-annealing sampler running entirely on your own machine, no QPU account, no queue, no cost. This is also the standard first step for developing an annealing problem before ever touching real hardware, the same role AerSimulator plays for gate-model circuits elsewhere on this site.
sampler = SimulatedAnnealingSampler()
sampleset = sampler.sample(bqm, num_reads=1000)
best = sampleset.first
print(best.sample, best.energy)
num_reads=1000 runs the annealing process 1,000 times independently and keeps every result, since simulated and quantum annealing alike are heuristic: no single run is guaranteed to land on the ground state, so a batch of reads and the lowest-energy result among them is the standard pattern. For this graph, expect best.energy to land at −4, with best.sample reading out one of the two equivalent bipartitions, {0, 2} on one side and {1, 3} on the other, or the reverse. Both are valid: Max-Cut has no notion of which side is "first," so this is a genuine symmetry in the problem, not a bug in the sampler.
The Mistake: Ignoring the Embedding
Everything above runs on a classical simulated annealer, which has no connectivity limits: any variable interacts freely with any other. Real D-Wave hardware works differently. Physical qubits sit on a fixed, sparse topology (Pegasus or Zephyr, depending on the generation), and most pairs of qubits simply aren't wired together directly.
To place a problem where variable i needs to interact with variable j but no physical qubit pair provides this connection, Ocean's minor-embedding step chains several physical qubits together to act as one logical variable. This is automatic, dwave-system's EmbeddingComposite handles the process, but the process isn't free: chains need extra qubits, and a chain sometimes "breaks", the physical qubits meant to agree end up disagreeing after annealing, silently corrupting this variable's readout. Larger or denser problems need longer chains, which break more often, and dense enough problems eventually stop embedding on a given chip at all. This is the single most common surprise for anyone moving a working simulated-annealing problem onto real hardware for the first time: the algorithm didn't get worse, the chip's physical connectivity became the bottleneck.
What Annealing Doesn't Do
An annealer does not run Grover's search, does not run Shor's factoring, and has no general notion of a circuit at all. Its qubits aren't directly comparable to gate-model qubits: D-Wave's systems exceed 5,000 qubits, far more than any gate-model QPU, but this figure describes optimization capacity on the QUBO/Ising problem class specifically, not general computational power. Whether annealing delivers a real speedup over the best classical optimization heuristics on useful problems remains genuinely contested in the literature and appears to depend heavily on the specific problem's structure, not something to assume by default.
Running on Real D-Wave Hardware
Swap the sampler and the rest of the code stays identical:
from dwave.system import DWaveSampler, EmbeddingComposite
sampler = EmbeddingComposite(DWaveSampler())
sampleset = sampler.sample(bqm, num_reads=1000)
D-Wave's Leap cloud service offers a free monthly allotment of QPU time for exactly this kind of experimentation, the annealing equivalent of IBM Quantum's free tier for gate-model hardware. EmbeddingComposite handles the minor-embedding step automatically, but check the returned sampleset.info for chain-break statistics before trusting a result on anything beyond a modest toy problem.
Next Steps
- QAOA tutorial: the gate-model approach to the same Max-Cut problem
- Quantum Annealing glossary entry: the concept in brief
- D-Wave's dual-rail erasure qubit gate: D-Wave's move toward gate-model hardware alongside its annealing line
- Glossary: QAOA, quantum advantage, and the rest of the vocabulary