You are reading without signing in. Sign in or continue as guest to take quizzes and climb the ranks.
Variational circuits
Parameterised gates, a cost function and a classical optimiser: the loop behind VQE and QAOA.
- 01Draw the hybrid loop.
- 02Explain the parameter-shift rule.
- 03Recognise an ansatz and name its two knobs: depth and entangling pattern.
A variational algorithm keeps the quantum circuit short and lets a classical optimiser do the thinking. The circuit has rotation angles θ; running it and measuring gives a cost C(θ), such as the energy of a molecule or the number of satisfied constraints. The optimiser proposes new angles, and the loop repeats. The circuit is called an ansatz: layers of single-qubit rotations and an entangling pattern, repeated a few times.
A two-qubit ansatz
Select an RY gate and drag its slider: the probabilities in the State tab move smoothly with the angle. That smooth dependence is what the optimiser climbs. Try to find angles that put all the weight on |11⟩.
OPENQASM 3.0;
include "stdgates.inc";
qubit[2] q;
ry(pi/3) q[0];
ry(pi/5) q[1];
cx q[0], q[1];
ry(pi/4) q[0];
ry(pi/6) q[1];
2 questions · one try each counts
In a variational algorithm, what does the quantum computer compute?
Sign in to answer and climb the ranks; you will come back to this lesson.
Why is the parameter-shift rule preferred over finite differences on hardware?
Sign in to answer and climb the ranks; you will come back to this lesson.