Quantum Reinforcement Learning
Quantum reinforcement learning (QRL) uses quantum circuits to represent policies or value functions:
- Quantum policy: parameterized quantum circuit maps states to actions
- Quantum value function: quantum circuit estimates state values
- Quantum exploration: superposition enables simultaneous exploration of actions
QRL can potentially achieve quadratic speedups in exploration and representational capacity.
Three layouts appear in the literature, and they differ in how much of the agent stays classical. The policy-encoded circuit loads the state into an amplitude-encoded register, treats its rotation angles as the policy parameters, and samples the action by measuring the output register directly. The value-encoded circuit only estimates the state value while a classical argmax picks the action, so the circuit is a subroutine inside an otherwise conventional agent. The hybrid layout keeps the replay buffer, target network and optimizer classical and uses the circuit purely as a feature map. That last one is what most NISQ experiments actually report, because a two-layer, four-qubit ansatz holds 32 real parameters and trains comfortably on a laptop simulator.
Quantum Bandits
Quantum bandits use quantum superposition to explore arms simultaneously:
Classical bandit: try one arm at a time, regret Quantum bandit: try all arms in superposition, regret
The quantum advantage comes from the ability to evaluate multiple actions in superposition and use interference to amplify good actions.
The size of that claim deserves numbers. Classical minimax regret over rounds with arms scales as , so a four-arm instance pulled for rounds leaves roughly 2000 reward units unclaimed; a logarithmic bound would leave about 14. The catch sits in the model: logarithmic regret is proved for an agent holding a coherent sample oracle — a block-encoded draw from the reward distribution that the agent can uncompute — and a vending machine, a robot arm or a trading desk does not ship that interface. Read log regret as a statement about oracle complexity, and ask which oracle a paper assumes before quoting its bound.
Quantum Policy Gradient
Quantum policy gradient extends the REINFORCE algorithm:
where is the quantum policy.
The gradient is estimated using the parameter-shift rule:
Worked once: with rad, evaluate the identical circuit at and at . If the measured costs are 0.61 and 0.44, the estimate is . That is two circuit evaluations per parameter, so a 32-parameter policy costs 64 circuit runs per gradient step before shot repetition; at 512 shots each, one update is 32,768 circuit executions. The rule is exact for generators with two eigenvalues — every Pauli rotation qualifies — and silently wrong for other generators, which is the standard source of broken reparameterization code.
Quantum Exploration
Quantum superposition enables efficient exploration:
- Superposition of actions: evaluate multiple actions simultaneously
- Interference: amplify rewards for good actions
- Entanglement: correlate actions across time steps
The quantum exploration bonus:
where is the number of visits to state . Quantum exploration can achieve this bound with fewer samples.
The mechanism behind that claim is amplitude estimation rather than repeated sampling. Estimating a mean to additive error costs coherent queries instead of the shots classical Monte Carlo needs, so the visit-count term improves quadratically. The price is depth: amplitude estimation runs controlled iterations of a Grover iterate, so a device that can execute 200 gates reliably cannot finish the routine at useful precision. On hardware today the workable choice is an ordinary count-based bonus on top of a small quantum feature map, with the quadratic result recorded as an asymptotic one.
Variational Quantum RL
Variational quantum RL uses parameterized quantum circuits as function approximators:
- State encoding: encode environment state into quantum state
- Policy network: quantum circuit with trainable parameters
- Action selection: measure to get action
- Reward signal: classical reward updates parameters
The quantum circuit can represent complex policies with fewer parameters than classical networks.
Parameter counts are the honest measure of that sentence. A four-qubit ansatz with two rotation layers carries 32 real angles — the same budget as a 32-unit classical layer — so the saving comes from the exponentially large state space, not from a smaller optimizer. The risk points the other way: gradients of hardware-efficient random circuits concentrate exponentially, with variance falling as , so passing 20 qubits without cost structure or a problem-informed ansatz buries the signal under shot noise. Depth stays shallow for the same reason. Two or three layers of RY–RZ rotations with a light entangling ring is the working size in published experiments.
When Quantum RL Stops Paying
A decision rule that keeps experiments honest:
| Situation | Recommended choice | Why |
|---|---|---|
| Simulator, 10 qubits or fewer, shots are free | Variational QRL baseline | Parameter-shift gradients are cheap once sampling noise disappears |
| Real device, more than 32 parameters | Classical gradient plus quantum kernel features | Coherent depth and shot budget bite before expressivity does |
| Small discrete action space | Treat quantum bandits as a research branch | UCB1 and Thompson sampling already reach the practical regret floor |
| Deterministic reward per state | Drop the exploration bonus | The bonus exists for stochastic rewards, so it only injects variance |
| Claimed speedup with no oracle model stated | Record it as unquantified | Logarithmic-regret proofs assume coherent access no environment provides |
| Continuous control with smooth dynamics | Classical actor-critic first | Encoding an angle space into amplitudes costs more gates than the policy needs |
The table reflects deployment reality: quantum advantage in reinforcement learning has been shown for oracle models and small simulators, not for industrial control loops. A fair experiment reports qubit count, circuit depth, shots per gradient, and the classical baseline it beat. If any of those four numbers is missing, the comparison is not yet a result.
Python: Quantum Bandit
import numpy as np
def quantum_bandit_step(params, n_arms=3):
# One step of quantum bandit algorithm.
# Quantum circuit with rotation angles
thetas = params[:n_arms]
# Compute arm probabilities
probs = np.abs(np.sin(thetas))**2
probs = probs / np.sum(probs)
# Sample arm
arm = np.random.choice(n_arms, p=probs)
return arm, probs
def quantum_bandit_episode(rewards, n_steps=100):
# Run quantum bandit for one episode.
n_arms = len(rewards)
params = np.random.uniform(0, np.pi, n_arms)
total_reward = 0
for _ in range(n_steps):
arm, probs = quantum_bandit_step(params)
reward = rewards[arm] + np.random.randn() * 0.1
total_reward += reward
# Update params
params[arm] += 0.1 * reward
return total_reward
rewards = [1.0, 0.5, 0.8] # True rewards
episode_rewards = [quantum_bandit_episode(rewards) for _ in range(10)]
print(f"Average reward: {np.mean(episode_rewards):.2f}")
The episode return settles near the mean of the best arm minus the noise floor, and the interesting quantity is the gap to the greedy policy: with arms at 1.0, 0.5 and 0.8 and a 0.1 noise scale, an agent that never explores the first arm loses about 0.2 reward per pull. Ten episodes is far too few to separate that from variance, which is exactly why bandit papers quote regret curves over rounds rather than average returns over ten runs.
Python: Parameter-Shift Policy Gradient
The script above learns one scalar per arm; this one differentiates a circuit policy with the parameter-shift rule, so the same loop scales to any ansatz:
import numpy as np
def ry_layer(params, state):
# Ry(theta) = exp(-i theta Y / 2) on each qubit of a real state vector.
out = state.astype(complex).copy()
n = len(state)
for q in range(int(np.log2(n))):
step = 2 ** (q + 1)
for i in range(0, n, step):
for k in range(i, i + step // 2):
a, b = out[k], out[k + step // 2]
c, s = np.cos(params[q] / 2), np.sin(params[q] / 2)
out[k] = c * a - s * b
out[k + step // 2] = s * a + c * b
return out
def value(params, state, observable):
psi = ry_layer(params, state)
return float(np.sum(observable * np.abs(psi) ** 2))
def shift_gradient(params, state, observable, shift=np.pi / 2):
grad = np.zeros_like(params)
for i in range(len(params)):
up, down = params.copy(), params.copy()
up[i] += shift
down[i] -= shift
grad[i] = (value(up, state, observable) - value(down, state, observable)) / 2
return grad
state = np.array([1, 0, 0, 0])
observable = np.array([1.0, -1.0, 0.5, -0.5])
rng = np.random.default_rng(7)
params = rng.uniform(0, np.pi, 2)
for step in range(300):
params -= 0.3 * shift_gradient(params, state, observable)
if step % 100 == 99:
print(f"step {step + 1:3d} value={value(params, state, observable):+.4f}")
print(f"trained angles: {np.round(params, 3)}")
Two evaluations per parameter show up directly as two calls to value, so the 32-parameter policy from the discussion above is 64 evaluations per step here, and every shot-based run repeats that 64-wide sweep. The value column improves quickly and then flattens: once the per-step gain falls below the shot noise a real device would add, extra epochs buy nothing and the ansatz has become the limit rather than the optimizer.
Quantum RL Algorithms
| Algorithm | Type | Quantum Speedup | Practical status |
|---|---|---|---|
| Quantum bandits | Exploration | Logarithmic regret under coherent oracle | Simulator only |
| Quantum policy gradient | Policy optimization | Quadratic shot reduction with amplitude estimation | Needs deep coherent circuits |
| Quantum DQN | Value-based | Better exploration on small state spaces | Benchmarked on grid worlds |
| Quantum PPO | Policy optimization | Stable training with fewer parameters | Hybrid classical loop |
| Quantum natural gradient | Second-order | Fisher matrix from quantum Fisher information | Parameter counts below 40 |
Quantum Exploration Advantage
Classical exploration: regret for bandits Quantum exploration: regret for bandits
Those two lines are the abstract's claim; reproducing it requires four checks that separate a result from a demo. Baseline parity: the classical agent gets the same features, the same sample count and the same hyperparameter budget. Oracle accounting: every coherent query is priced in circuit depth instead of treated as free. Shot budget: shots per gradient component are stated — 32 parameters at 512 shots is 32,768 circuit executions per update, and wall-clock time must include it. Seed spread: median and interquartile range over at least 20 seeds, because return curves on small QRL benchmarks routinely overlap inside one standard deviation.
A claim that survives all four is usually narrower than its abstract — a quadratic improvement in oracle calls on a simulated 12-qubit bandit, not a faster agent on a control task. That narrower claim is still worth publishing. The failure mode to avoid is presenting it as a drop-in replacement for a tuned classical learner, where the baseline's search budget rather than the optimizer family decides the outcome.
Common Mistakes
Quoting logarithmic bandit regret as a deployable speedup
Fix: State the oracle model first — every log-T proof assumes coherent, uncomputable access to the reward distribution that a real environment does not expose
Scaling the ansatz until gradients vanish
Fix: Keep the circuit at two or three layers and under 32 parameters, then verify that the gradient norm stays above shot noise before adding width
Comparing QRL against an untuned classical baseline
Fix: Give the classical agent the identical feature map, sample count and hyperparameter search, then compare medians over 20 or more seeds
Treating parameter-shift gradients as free
Fix: Budget two circuit evaluations per parameter per step: 32 parameters at 512 shots is 32,768 circuit executions for a single update
Key Takeaways
- QRL comes in three layouts — policy-encoded, value-encoded and hybrid — and published NISQ results almost always use the hybrid one, where the circuit is a feature map inside a classical agent
- Logarithmic bandit regret assumes a coherent sample oracle; classical minimax regret is the square root of K times T, so the honest comparison is oracle complexity rather than deployment speed
- The parameter-shift rule costs exactly two circuit evaluations per parameter per step, which turns a 32-parameter policy at 512 shots into 32,768 circuit executions per update
- Gradient variance of hardware-efficient random circuits falls as one over two to the n, so usefulness on hardware ends near a few dozen parameters unless the ansatz encodes problem structure