Quantum Circuits for Machine Learning
Variational quantum circuits are the building blocks of quantum ML. They use parameterized gates as trainable weights, optimized by classical computers in a hybrid loop.
Variational Quantum Circuits (VQCs)
A variational quantum circuit (also called a parameterized quantum circuit) is the quantum equivalent of a neural network. It consists of:
Data Encoding
Encode classical data into quantum states using rotation gates. Each feature maps to a qubit rotation angle.
Parameterized Layers
Apply layers of rotation gates with trainable parameters (θ) and entangling gates (CNOT) between qubits.
Measurement
Measure qubits to get classical output. The expectation values serve as model predictions.
Classical Optimization
A classical optimizer (Adam, COBYLA) updates the parameters to minimize a loss function.
Data Encoding Strategies
| Encoding | Method | Qubits Needed | Best For |
|---|---|---|---|
| Angle Encoding | Each feature → rotation angle on one qubit | n (one per feature) | Small feature sets |
| Amplitude Encoding | Features encoded as amplitudes of quantum state | log(n) | Large feature sets |
| Basis Encoding | Binary features mapped to computational basis | n (one per bit) | Binary data |
| IQP Encoding | Features encoded with entangling interactions | n | Capturing feature correlations |
Ansatz Design
The ansatz is the structure of the parameterized circuit. Common designs include:
- Hardware-efficient ansatz: Uses gates native to the quantum hardware. Minimizes circuit depth but may be hard to train (barren plateaus).
- Strongly entangling layers: Alternating rotation and CNOT layers with full qubit connectivity. Good expressibility.
- Problem-inspired ansatz: Circuit structure tailored to the specific problem (e.g., UCCSD for chemistry).
- Tensor network ansatz: Mimics tensor network structures like MPS or MERA. Good for structured data.
Quantum Kernels
An alternative to VQCs is using quantum computers to compute kernel functions. The idea: map data into quantum Hilbert space and compute inner products (overlaps) between quantum states. This can create feature spaces that are exponentially hard to compute classically.
- Encode data point x into quantum state |φ(x)〉
- Compute kernel: K(x, x') = |〈φ(x)|φ(x')〉|²
- Use the kernel matrix with classical SVM or other kernel methods
The Barren Plateau Problem
A major challenge in training VQCs is the barren plateau phenomenon: as the number of qubits grows, gradients of the cost function vanish exponentially, making optimization impossible. Mitigation strategies include:
- Using shallow circuits with local cost functions
- Problem-inspired ansatz designs
- Layer-wise training (train one layer at a time)
- Parameter initialization strategies
Lilly Tech Systems