Curriculum / Quantum Hardware & NISQ / VQE Under Hardware Constraints
VQE Under Hardware Constraints
Implement a simple VQE-style parameterized ansatz and optimization loop.
VQE Under Hardware Constraints
The Variational Quantum Eigensolver (VQE) finds the minimum energy state of a Hamiltonian using a parameterized quantum circuit (ansatz) and classical optimization. You met the variational idea at the end of the Quantum Algorithms track; this lesson is about making it work on a real device, where circuit depth is precious and every expectation value is noisy.
The Variational Principle
For any quantum state , the expectation value of a Hamiltonian H satisfies:
where is the true ground state energy. By minimizing the expectation value over all , VQE approximates the ground state.
Single-Qubit Example
For the simplest Hamiltonian (the Pauli Z operator, whose ground state is ):
Using the ansatz :
The energy is minimized when , i.e., . This corresponds to the state , which is indeed the ground state of .
The Ry Ansatz
The Ry gate rotates around the Y axis:
Measuring the expectation value:
- •
- •
- •
To minimize , find where is most negative: .
The Grid Search Approach
For a single parameter, grid search is the simplest optimizer:
- 1.Evaluate at many values of
- 2.Find the that gives the lowest energy
- 3.Report the optimal and minimum energy
For multi-parameter circuits, gradient-based methods (gradient descent, BFGS, COBYLA) are needed. But for VQE with one parameter, grid search is exact.
VQE does not run the quantum circuit just once. It runs it thousands of times: once for each evaluation in the optimization landscape. Each evaluation measures the energy at a specific parameter value. The classical optimizer uses these measurements to navigate toward the minimum. This iterative loop is the defining feature of variational quantum algorithms, the quantum computer is a function evaluator, and the classical computer is the optimizer.
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 hands-on coding challenge. You write Qiskit-compatible Python in the browser editor, run it instantly via WebAssembly, watch the circuit and Bloch sphere react, and pass automatic output checks. The AI tutor Qubitus gives Socratic hints if you get stuck.
Part of: Quantum Hardware & NISQ
Explore the physics of real quantum computers, understand noise, and learn near-term algorithms designed for today's noisy hardware.
This lesson is part of Pro
Unlock Quantum Hardware & NISQ and all 10 tracks with Pro: $12.99/month, $79/year, or $97 lifetime. Start with the free track first if you are new.