Curriculum / Quantum Machine Learning / QML Capstone
QML Capstone
Solve a real optimization problem with variational quantum methods.
QML Capstone: Variational Quantum Optimizer
Every variational quantum algorithm, VQE for chemistry, QAOA for optimization, quantum classifiers for machine learning, is the same engine under the hood: a parameterized circuit, a cost measured from its output, gradients of that cost, and a classical loop that walks downhill. In this capstone you build that engine in miniature and verify every moving part: the cost function from real circuit counts, exact gradients via the parameter shift rule, gradient descent to the minimum, and a final check that you actually arrived.
The Ansatz and the Objective
The circuit is two parameterized rotations and one entangler: on qubit 0, on qubit 1, then CNOT(0, 1). The objective is to maximize the probability of measuring , written as a cost to minimize:
Work out the landscape by hand. The outcome 11 requires qubit 0 to read 1, which happens with probability . And because the CNOT flips qubit 1 exactly when qubit 0 is 1, reading 11 requires qubit 1 to have been 0 before the CNOT, with probability . So
with minimum at , . Your optimizer should find that point without being told.
The Parameter Shift Rule
For gates of the form , the gradient of any measured expectation is given exactly by two extra circuit evaluations per parameter:
Unlike finite differences, which approximate the slope with a small step and suffer from noise amplification, the parameter shift rule is an exact identity: the cost of a rotation gate is a sinusoid in , and sampling it a quarter-period left and right recovers the true derivative. The shift comes from the Pauli eigenvalues and . This is how gradients are computed on real quantum hardware, where backpropagation through the quantum state is impossible.
This is the opening of the lesson. The full walkthrough, the interactive circuit, and the graded challenge continue inside myqubit.
How this lesson works
A multi-step project that combines several concepts into one larger build, checked checkpoint by checkpoint as you go.
Part of: Quantum Machine Learning
Apply quantum computing to machine learning with variational circuits and optimization.
This lesson is part of Pro
Unlock Quantum Machine Learning and all 10 tracks with Pro: $12.99/month, $79/year, or $97 lifetime. Start with the free track first if you are new.