◆ Module 9 · Intermediate

Variational Quantum Circuits & Core QML Algorithms

Maya's data can finally get into a circuit. Now: what makes that circuit actually learn something? This module is the payoff of everything so far — seven real algorithms built from one shared trainable idea.

8 Chapters 7 Core Algorithms 24 Quick-Check Questions 1 Adaptive Assessment ~55 min
M
Maya & Dr. Okafor, continued
Same lab, the actual learning part

Module 8 ended with Maya's molecule data properly loaded into a quantum state. Today she asks the question that's been sitting under everything: encoding gets the data in — what makes the circuit smart?

CHAPTER 01

The Variational Idea

"Encoding gets your data into the circuit," Dr. Okafor says. "It doesn't make the circuit smart." Maya frowns — so what does? He draws the same loop she saw all the way back in Module 6, but this time he fills in the blanks with real, nameable algorithms. "Every single one of these seven ideas," he says, circling the diagram, "is this exact loop, wearing a different costume."

Every algorithm in this module shares one skeleton: encode data → apply a trainable parameterized circuit → measure → let a classical optimizer update the parameters → repeat. What changes between VQC, QSVM, QNN, and the rest is which part of that loop does the heavy lifting, and what you do with the result.

The Shared Loop, Once More
Encode Data Trainable Circuit Measure classical optimizer updates parameters

Tap each card below for a one-line preview of where this module is headed.

Algorithm Menu — Tap Each Card
Takeaway: You already know this loop from Module 6. This module just spends eight chapters showing you exactly how many different, genuinely useful things you can build out of it.
◈ Quick Check
0 / 3
CHAPTER 02

Parameterized Quantum Circuits

Dr. Okafor sketches a repeating block: a row of rotation gates, then a row of entangling gates, then the same thing again. "This," he says, "is the one shape almost everything in this module is built from. We call it an ansatz — a template with blanks left for the optimizer to fill in."

A Parameterized Quantum Circuit (PQC) is a fixed circuit structure with free parameters θ — usually rotation angles — that get tuned by training, exactly like weights in a classical network. Drag the slider to add more layers and watch the ansatz grow.

Platform Feature Spotlight — Quantum Circuit SimulatorThis is a simplified preview of building an ansatz layer-by-layer in the full drag-and-drop Circuit Simulator on the live platform.
Ansatz Layers
1
  • Two gate types alternate: single-qubit rotations (Rx, Ry, Rz) hold the trainable parameters; entangling gates (usually CNOT) let qubits influence each other.
  • Parameter count scales with layers and qubits — more layers means more expressive power, but also more parameters to train.
  • The familiar tension returns: deeper ansätze are more expressive, but also more prone to the barren plateaus you met in Module 7.
Takeaway: Every algorithm in this module starts by choosing an ansatz shape. Get comfortable with this diagram — you'll see it, in disguise, in every chapter that follows.
◈ Quick Check
0 / 3
CHAPTER 03

Variational Quantum Classifiers (VQC)

"Let's make this concrete," Dr. Okafor says. "Your actual job: does this molecule bind, yes or no." He walks Maya through her first real algorithm — encode the molecule, run it through the ansatz, measure one qubit, and read the result as a class score.

A Variational Quantum Classifier is the loop from Chapter 1, made literal: encode → ansatz → measure an observable (commonly ⟨Z⟩ on one qubit) → compare against the true label → compute a loss → let a classical optimizer adjust the ansatz's parameters. Click through the pipeline, then hit train.

Platform Feature Spotlight — Hands-on Coding LabsHere's roughly what a VQC training step looks like as real PennyLane code on the live platform.
VQC Pipeline
Step 1
Encode Molecule
Step 2
Ansatz
Step 3
Measure ⟨Z⟩
Step 4
Compare to Label
loss
# one VQC training step in PennyLane
def cost(params, x, y):
  pred = circuit(params, x) # encode + ansatz + measure
  return (pred - y) ** 2
params = optimizer.step(cost, params)
Takeaway: A VQC isn't a new kind of physics — it's a classifier that happens to compute its predictions on a quantum circuit instead of a classical one.
◈ Quick Check
0 / 3
CHAPTER 04

Quantum Support Vector Machines (QSVM)

"Not every quantum model needs full end-to-end training on a quantum computer," Dr. Okafor says. "Some just use the quantum circuit to answer one question: how similar are these two data points? Then they hand that answer to an ordinary classical SVM."

This is the kernel trick from Module 7, wearing a quantum costume. A quantum kernel measures the overlap between two quantum-encoded data points: K(xᵢ,xⱼ) = |⟨φ(xᵢ)|φ(xⱼ)⟩|². Feed a whole matrix of these values into a classical SVM, and the quantum computer's job is already done.

Platform Feature Spotlight — QML PlaygroundThe QML Playground lets you compute both kernel matrices below on real data and benchmark which one classifies your dataset better.
Classical vs Quantum Kernel Matrix
Classical (RBF) Kernel
  • Two-step split: quantum computer → kernel matrix; classical computer → the actual SVM optimization.
  • Often easier to get running on today's hardware than a fully-trained VQC, since the quantum circuit is only called once per pair of points, not once per training iteration.
  • Directly reuses IQP encoding from Module 8 as one popular choice of quantum feature map.
Takeaway: QSVM is a reminder that "quantum machine learning" doesn't always mean training on a quantum computer — sometimes it just means computing one clever number there.
◈ Quick Check
0 / 3
CHAPTER 05

Quantum Neural Networks (QNN)

Maya has seen the term "QNN" everywhere and assumed it meant something different from VQC. "Honestly?" Dr. Okafor shrugs. "Most people use them interchangeably. QNN is really just the umbrella term — any layered, trainable quantum circuit built to echo the structure of a classical neural network."

The analogy is genuinely useful, with one honest wrinkle: quantum evolution is linear (unitary), so the nonlinearity that gives classical networks their power has to sneak in some other way — usually through measurement, or a small classical layer stitched on afterward.

The Analogy, Side by Side
Classical Neural Network
Neuron
Weight
Weighted sum
Activation function
Quantum Neural Network
← Qubit
← Gate parameter (θ)
← Entangling gate layer
← Measurement + classical nonlinearity
  • Same skeleton as Chapter 2's PQC — QNN is a framing, not a different circuit structure.
  • Nonlinearity is the honest sticking point: unitary operations alone can't produce it, so QNNs borrow it from measurement statistics or a small classical post-processing step.
  • Layered QNN variants with local, weight-shared structure lead directly to QCNNs, which you'll meet properly in Module 11.
Takeaway: If a paper's "QNN" and another paper's "VQC" look identical, that's not a mistake — the terms really do overlap that much in practice.
◈ Quick Check
0 / 3
CHAPTER 06

Quantum Kernel Methods

"QSVM was one example," Dr. Okafor says. "But quantum kernels aren't married to SVMs. Ridge regression, Gaussian processes, anything that classically takes a kernel — you can hand it a quantum-computed one instead." Then his tone shifts, the way it did for QRAM. "Just know this trick has a real failure mode."

As a quantum feature map (like IQP from Module 8) gets more expressive, the kernel values it produces can start to concentrate — collapsing toward a near-constant value almost everywhere. When that happens, the kernel can no longer tell data points apart, and both trainability and generalization suffer.

Platform Feature Spotlight — Research HubKernel concentration is an active research topic — the Research Hub tracks the current best mitigations, including bandwidth tuning and shallower feature maps.
Expressivity vs. Generalization
3
  • The general idea: any kernel method can plug in a quantum kernel instead of a classical one.
  • The real risk: kernel concentration — deep, highly expressive feature maps can wash out the very differences a kernel is supposed to detect.
  • The sweet spot is often a shallower, carefully-designed feature map — not the deepest one available.
Careful: More expressive is not automatically better. This is the kernel-method version of the barren plateau problem from Module 7.
◈ Quick Check
0 / 3
CHAPTER 07

Quantum PCA

Maya's molecule descriptors number in the hundreds — she'd normally run PCA to compress them before anything else. "There's a quantum version of that too," Dr. Okafor says, "and it comes with the same asterisk you saw with QRAM."

Classical PCA finds directions of maximum variance via eigen-decomposition of a covariance matrix. Quantum PCA (qPCA) uses phase estimation and density matrix exponentiation to extract dominant eigenvalues/eigenvectors — claimed to scale exponentially better in the number of features, under specific assumptions.

Classical PCA vs Quantum PCA — Scaling Claim
  • Classical PCA: cost grows polynomially with the number of features (roughly cubic for a direct eigen-decomposition).
  • Quantum PCA: claimed logarithmic scaling in feature count — a dramatic theoretical improvement.
  • The asterisk: that speedup typically assumes the data is already available as an efficiently-preparable quantum state — the same efficient-state-preparation assumption that made QRAM (Module 8) an open problem, not a solved one.
Careful: A speedup that "assumes efficient state preparation" is a conditional result, not an unconditional one — the same pattern you learned to watch for with QRAM.
◈ Quick Check
0 / 3
CHAPTER 08

Quantum Autoencoders

Dr. Okafor saves a fun one for last. "What if you trained a circuit to compress quantum data itself — and just threw away the qubits that didn't matter?" Maya's molecule outliers, he points out, might reveal themselves exactly this way: data that refuses to compress cleanly is often the data worth a second look.

A quantum autoencoder is a PQC trained to squeeze an n-qubit state into fewer "latent" qubits, while the discarded "trash" qubits are pushed toward a fixed reference state — typically |0⟩. Drag the slider to change how many qubits get kept versus discarded.

Platform Feature Spotlight — Hands-on Coding LabsTraining a quantum autoencoder end-to-end is a full walkthrough available in the Coding Labs, including the fidelity-based loss function used to judge the trash qubits.
Latent vs. Trash Qubits
3
  • Training goal: minimize how far the trash qubits drift from |0⟩ — usually measured via a SWAP test or direct fidelity.
  • Applications: compressing quantum simulation data, denoising, and anomaly detection — data that compresses poorly may be genuinely unusual.
  • Closes the loop on this module: like every other algorithm here, it's the same encode → ansatz → measure → optimize pattern from Chapter 1, aimed at a new goal.
Takeaway: Compression and classification turn out to be the same trick wearing different clothes — which is exactly the point of learning the shared loop first.
◈ Quick Check
0 / 3
◆ Adaptive Assessment

Module 9 Assessment

Eight synthesis questions, one per chapter. Your result adapts to your whole session — chapters where you struggled above get flagged for review here, regardless of how this final round goes.