Prioritized Experience Replay
Replay past transitions with large prediction errors more often, and down-weight their updates to remove the sampling bias.
Standard deep Q-learning samples past transitions uniformly at random from a million-step replay buffer, giving a rare game-winning move the same training budget as a million identical empty frames. Prioritized Experience Replay samples each transition in proportion to the size of its value-prediction error, scales down those updates with weights that tighten over training to cancel the sampling bias, and halves the training time on Atari.
Explaining the paperPrioritized Experience ReplayDecoupling replay frequency from experience frequency with one exponent for priority, one annealed exponent for importance weights, and a binary sum-tree that runs in 20 operations at a million transitions.
Experience replay and uniform waste
An online reinforcement learning (RL) agent interacts with an environment one step at a time, collecting transitions made of five pieces: the previous state , the action , the reward , the discount factor (0 if the episode ended, typically 0.99 otherwise), and the next state . Updating a neural network directly on that live stream fails for two reasons. Consecutive frames look almost identical, breaking the independent-samples assumption of stochastic gradient descent, and a rare transition is used for a single gradient step and discarded.
Experience replay (Lin, 1992) fixes both problems by keeping the last transitions in a circular buffer and sampling random minibatches from it. In DQN (Mnih et al., 2015) and Double DQN (van Hasselt et al., 2016), the buffer holds transitions, and the learner draws a uniform random minibatch of transitions once every agent steps. Because 32 transitions are sampled for every 4 that enter, each transition is replayed times on average before the circular buffer overwrites it.
Uniform sampling treats every slot in that buffer as equally valuable, which wastes most of the learner's gradient budget in two ways. First, in any game where rewards are sparse or critical decisions happen occasionally, almost all million slots hold routine transitions whose action values the network already predicts accurately; replaying them produces near-zero gradients. Second, uniform draws from a sliding window leave a long wait before fresh data is seen: the expected delay until a new transition is drawn once is agent steps (500,000 Atari frames), by which time the policy has undergone over 31,000 gradient updates. Raising to the 250,000 learner updates that occur while a transition sits in memory gives roughly , or 0.034% (about 335 transitions per million) overwritten without ever being replayed once.
Think of studying flashcards for an exam. Uniform replay shuffles all 1,000 cards back into one pile and draws at random, drilling facts you already got right ten times in a row just as often as the five cards you keep missing. Prioritized Experience Replay (PER), introduced by Tom Schaul, John Quan, Ioannis Antonoglou, and David Silver at DeepMind, keeps the same replay memory and the same neural network, and changes which cards get pulled from the deck.
The Blind Cliffwalk: why replay order matters
Before proposing a practical priority rule, the authors isolate how large the gap between uniform replay and an ideal replay order can be. They construct a synthetic task called the Blind Cliffwalk (Section 3.1 and Appendix B.1): a chain of states where every state has two actions, one right and one wrong. Taking the wrong action at any state terminates the episode immediately with reward 0. Taking the right action advances from state to , and taking the right action at the final state pays reward 1 and ends the episode. Which action index (0 or 1) is right alternates at every state so a function approximator cannot generalize across actions.
To populate the replay memory at the exact frequencies a random explorer would experience, the experiment executes all possible action sequences until termination. Only one sequence reaches the final reward of 1, a probability of . Counting every step across all episodes gives total transitions in the buffer, with state appearing times for each action. The discount factor is so the true start-state value stays near 0.368 () regardless of chain length, allowing a fixed step size .
For , the buffer holds transitions: 256 leave , 128 leave , and only a single transition in the entire buffer leaves with reward . Both agents run identical Q-learning updates on that same fixed buffer until the mean-squared error (MSE) across all state-action values drops below . Under uniform replay, the single rewarding transition is drawn only once every 510 updates on average, and moving the final state's right-action value from near 0 to within 0.03 of 1 at step size 0.25 takes about 13 updates on that transition alone, plus backward propagation through all seven earlier states: 6,453 updates in total. A hindsight oracle that tests every transition and picks whichever update cuts global MSE the most finishes in 319 updates.
Press Play or drag the step slider in Figure 1 to watch Q-values propagate backward from the goal along the chain under proportional PER (teal) versus uniform replay (amber), and drag the chain length up to 12 to inspect the log-log scaling curve.
At ( transitions, still only 1 rewarding), uniform replay needs 106,782 updates, proportional PER (stochastic sampling weighted by error magnitude, defined below) finishes in 11,943 (8.9 times fewer), greedy temporal-difference (TD) prioritization (always picking the single transition with the largest stored prediction error, covered in the next section) finishes in 8,721, and the hindsight oracle finishes in 671. Greedy TD still sits near because every unseen transition enters at maximal priority and gets checked once before the learner locks onto the rewarding chain; the oracle skips the duplicate failure transitions from the start.
Using TD error as the priority score
A hindsight oracle is unusable in practice because measuring the true global loss reduction of every candidate transition requires knowing the true value function and testing all updates. Instead, PER uses a quantity Q-learning already computes on every update: the magnitude of the temporal-difference (TD) error . In standard Q-learning (Watkins & Dayan, 1992), the TD error of transition compares the network's current prediction for the state and action taken against its one-step bootstrap target (the observed reward plus the network's own discounted estimate of the best future value from the next state):
In (1), is the immediate reward, is the discount factor (0 on terminal transitions), and is the highest estimated future return from the next state. In Double DQN, the target uses the online network to choose the next action and a lagging target network (a periodically frozen copy of the online weights) to score it, preventing the upward maximization bias covered in the Double DQN explainer:
Suppose the network predicts 0.20 for the action taken, the transition yields reward 1.0 with , and the target network scores the best next action at 0.50. The bootstrap target is 1.495 (1.0 plus 0.99 times 0.50), giving a TD error of (clipped to in Atari DQN). Because a Q-learning step updates the weights in proportion to , a large signals that replaying this transition will move the network's prediction substantially, whereas a near-zero means the prediction already matches its bootstrap target.
This criterion adapts prioritized sweeping (Moore & Atkeson, 1993) from model-based planning, which queues states by the size of their pending Bellman backup so value changes propagate backward along the transitions that feed into them. PER brings the same priority signal to model-free RL, where the agent has no transition model and learns only from stored samples. Because new transitions arrive before the learner has scored them, PER inserts every new transition at the current maximum priority in memory (starting from ), guaranteeing that every new experience is replayed at least once.
On the deterministic tabular Blind Cliffwalk of Figure 1, greedy TD prioritization (always replaying the single transition with the largest stored ) beat stochastic prioritization. Once you move to noisy environments or neural function approximation, pure greedy selection fails in three concrete ways:
- Stale priorities starve low-error transitions. Recomputing TD errors across all stored frames after each step is computationally prohibitive, so PER refreshes a transition's priority only when that transition is replayed. A transition whose initial happens to be near zero sinks to the bottom of the heap and is never revisited, even if later updates change the value of its next state and make its true TD error large. Even on Blind Cliffwalk, greedy prioritization stalls if Q-values are initialized to zero instead of small random noise (Footnote 2 of the paper), because every unrewarded transition produces on first visit.
- Noise spikes hijack the queue. When environment rewards or transitions are stochastic, a single noisy transition keeps producing large every time it is checked, trapping a greedy sampler on irreducible noise. Function-approximation errors in bootstrap targets create a similar noise floor.
- Loss of diversity causes overfitting. With a deep neural network, one gradient step shrinks a transition's TD error only slightly, so greedy replay draws the same tiny subset of high-error frames thousands of times in a row while the rest of the buffer goes stale.
How prioritized replay samples transitions
To keep high-error transitions near the front without starving low-error ones or locking onto noise, Schaul et al. replace greedy argmax selection with stochastic sampling. Every transition gets a positive priority and is sampled with probability:
The exponent controls how sharply sampling concentrates on high priorities. Setting reduces every numerator to , recovering uniform sampling . Increasing tilts the distribution toward higher priorities while guaranteeing for every transition in the buffer, and taking recovers greedy prioritization.
The paper defines two ways to turn into :
The left formula is proportional prioritization: priority equals the absolute TD error plus a small constant so transitions whose error lands at zero keep a non-zero chance of being revisited. The right formula is rank-based prioritization: transitions are ordered from largest to smallest , and priority is the reciprocal of the integer rank from 1 to . Plugging that reciprocal rank into (3) yields a Zipf-like power-law distribution proportional to , whose shape depends only on and and ignores raw error magnitudes.
Compare both formulas on a four-transition buffer with absolute TD errors 1.00, 0.20, 0.05, and 0.00, using and . Under proportional prioritization, raising each to the 0.6 power produces 1.006, 0.392, 0.185, and 0.063 (sum 1.646), giving sampling probabilities of 61.1%, 23.8%, 11.2%, and 3.8%. Under rank-based prioritization, raising ranks 1 through 4 to the power produces 1.000, 0.660, 0.517, and 0.435 (sum 2.612), giving probabilities of 38.3%, 25.3%, 19.8%, and 16.7%. Now multiply the first transition's error by 10 to simulate a noisy reward spike (): its proportional weight jumps to 3.983, pulling its share from 61.1% to 86.2% and squeezing the other three combined to 13.8%, while the rank-based probabilities remain unchanged at 38.3%, 25.3%, 19.8%, and 16.7%.
Test this directly in Figure 2: sweep from 0 (uniform) to 1.5, click any bar to compare the two variants, and flip the outlier-spike tab to watch proportional sampling collapse onto transition #1 while rank-based stays fixed.
Rank-based prioritization buys outlier immunity by throwing away error scale; proportional prioritization keeps error scale, which helps when a few transitions carry larger learning signal than the rest. On Atari, the two perform close to each other, with proportional pulling ahead on median human-normalized score (128% versus 113% of human level on Double DQN, where higher is better; defined in the Atari section below). The paper attributes that closeness to DQN's clipping of rewards and TD errors to , which removes extreme outliers before proportional prioritization computes their priorities.
Why importance-sampling weights are needed
Stochastic prioritization solves starvation and diversity, and introduces a statistical bias: it changes the distribution that the stochastic gradient estimates. Standard Q-learning on a replay buffer of size takes stochastic steps whose expected direction is the uniform average of (where are the Q-network weights and is its value prediction for transition ) across all transitions. Drawing from instead weights each transition's gradient by rather than . Even if the policy and buffer contents were frozen, those two expectations do not share the same fixed point whenever function approximation cannot fit every state-action value with zero error: the network spends its limited capacity fitting high-TD-error states at the expense of accurate predictions on low-error ones. Later work by Fujimoto, Meger, and Precup (2020) made that distortion exact: proportional sampling with no bias correction yields the same expected gradient as uniform sampling under a higher-power loss , which penalizes large errors far more heavily than squared error.
To restore the exact uniform expectation without giving up prioritized draws, PER multiplies each sampled transition's update by an importance-sampling (IS) weight:
Here controls how strongly the sampling bias is corrected ( applies no correction, giving ). At , every factor of in the sampling probability cancels the in the weight, recovering the uniform expected gradient exactly:
Because multiplies the entire TD error inside the gradient update (matching weighted least squares, Mahmood et al., 2014), the authors classify it as weighted IS rather than ordinary off-policy IS (which scales only the return target and leaves unweighted). For a rare low-priority transition with , however, the raw weight can be large and destabilize a gradient step. PER therefore divides every weight by the buffer's maximum weight so all normalized weights lie in and only scale updates downward. Because the maximum raw weight occurs at the smallest sampling probability , both and the normalizing sum in (3) cancel out:
Check (7) with real numbers. Suppose a buffer of transitions contains a high-error transition sampled at (10 times uniform) and a lowest-priority transition sampled at (one-tenth of uniform). At , the raw weights from (5) are 0.1 for the high-error transition and 10.0 for the low-priority one. Dividing both by yields normalized weights of 0.01 and 1.0. Multiplying sampling probability by normalized weight gives for the high-error transition and for the low-priority one: identical expected contribution, scaled down uniformly by the buffer-wide constant 0.1.
Rather than fixing from step 1, Schaul et al. linearly anneal from an initial value (0.4 for proportional, 0.5 for rank-based) up to 1.0 over the full training run (50 million agent steps on Atari). Early in deep RL, the policy, the replay buffer distribution, and the bootstrapped targets are all shifting rapidly, so a modest sampling bias is small compared to faster progress on high-error states; unbiased convergence matters near the end of training when the policy settles. Appendix Figure 12 of the paper confirms this trade-off: setting from the start slows early learning compared to , while avoiding occasional late-training collapse.
Sweep from 0 to 1 in Figure 3 (or click the schedule presets) and watch two effects happen together: the effective expected update share flattens onto the uniform dashed line at , while the average normalized weight drops sharply, acting as an automatic learning-rate decay late in training (Appendix B.2.1).
Importance sampling also provides a second optimization effect for nonlinear neural networks (Section 3.4). Without PER, a rare high-error transition gets one huge gradient step where the network's local linear approximation is unreliable. With PER and IS weights, that same transition is visited many times with smaller weights , letting gradient descent re-linearize the loss surface after each small step.
Sum-trees and binary heaps
Sampling from (3) naively takes work per draw: sum all priorities, walk the array accumulating a prefix sum until crossing a random threshold, and repeat 32 times per minibatch, costing 32 million array reads per learner step and making sampling slower than the GPU; scaling to a million transitions therefore requires sampling and priority updates.
Proportional PER uses a sum-tree. A sum-tree is a complete binary tree stored in a flat array of length (where is the smallest power of two at least ). The leaf nodes at indices through store directly, each parent stores the sum of its two children (tree[u] = tree[2*u] + tree[2*u+1]), and the root tree[1] holds the total priority mass . Updating one leaf after a minibatch step, or overwriting the oldest slot when the circular buffer wraps around after steps, modifies only its ancestors up to the root: 20 additions (). To sample a minibatch of transitions with lower variance, the interval from 0 to is split into equal segments of width , one uniform value is drawn inside each segment, and each descends the tree in 20 comparisons: if , go left; otherwise subtract from and go right. Drawing an entire 32-transition minibatch takes scalar comparisons instead of scanning a million entries.
In Figure 4, drag the query slider (or click anywhere along the cumulative strip) to trace the exact root-to-leaf descent, click any leaf node to change its priority and watch the three parent sums refresh upward in amber, or switch to the stratified batch tab to see four equal-width segments draw across the buffer at once.
Rank-based PER uses an approximate binary heap. Keeping a perfectly sorted tree of continuously changing TD errors dominated early Atari runs (Appendix B.2.1). The authors instead store transitions in an array-based binary max-heap and read the heap array itself as an approximate sorted list, running a full sort only once every steps so the array does not drift too far from sorted order. Because the power-law distribution depends only on and , the boundaries of equal-probability rank segments can be precomputed and reused across thousands of steps. Each minibatch draws one transition uniformly from each segment, guaranteeing one high-error transition, one medium-error transition, and so on down the tail. Both the sum-tree and heap implementations added only 2% to 4% wall-clock overhead and negligible memory next to storing a million Atari frames.
# sum_tree.py: complete binary tree of power-of-two capacity C in array [2*C].
# Leaves sit at indices C..2*C-1 holding p_i^alpha; node 1 holds p_total.
class SumTree:
def __init__(self, capacity):
self.cap = capacity
self.tree = [0.0] * (2 * capacity) # [2*C] float64 sums
def update(self, leaf_idx, priority_alpha):
pos = self.cap + leaf_idx # map 0..C-1 to leaf slot
diff = priority_alpha - self.tree[pos]
while pos >= 1: # O(log C): 20 steps at 1M
self.tree[pos] += diff
pos //= 2
def sample(self, s): # s in [0, p_total]
node = 1
while node < self.cap: # O(log C) root-to-leaf walk
left = 2 * node
if s <= self.tree[left]:
node = left
else:
s -= self.tree[left]
node = left + 1
return node - self.cap # leaf index in 0..C-1Double DQN with PER in code
Combining Equations (2), (3), (4), and (7) gives Algorithm 1 of the paper. Every environment step writes the new transition into the circular replay buffer at the current maximum priority (starting from ). Once every agent steps, the learner draws a stratified minibatch of transitions from the sum-tree, computes exact buffer-wide normalized IS weights using a companion min-tree (matching OpenAI Baselines's MinSegmentTree so stays ), evaluates the Double DQN TD errors, takes one step with RMSProp (DQN's adaptive gradient optimizer) weighted by , and writes the refreshed priorities back into both trees. The paper omits a numeric value for ; OpenAI Baselines defaults to 1e-6.
Only one existing Double DQN hyperparameter had to change. Because prioritized minibatches concentrate high-error transitions, their average gradient norm is larger than a uniform batch's, especially early in training while . Schaul et al. cut the RMSProp learning rate by a factor of 4, from 0.00025 to 0.0000625, and kept the network architecture, target copy period, buffer size, and reward and TD-error clipping untouched.
# per_step.py: one Double DQN + proportional PER step (B=32, every K=4 steps).
# Shapes: s, s_next [B, 4, 84, 84]; a, idx [B]; r, done, w [B].
p_total = sum_tree.tree[1]
seg = p_total / B # B=32 equal mass segments
idx = [sum_tree.sample((j + rand()) * seg) for j in range(B)]
probs = sum_tree.leaves(idx) / p_total # [B], Eq. (3) P(i)
p_min = min_tree.min_leaf() / p_total # scalar min_j P(j) over N
w = (p_min / probs) ** beta # [B], Eq. (7) normalized IS
s, a, r, done, s_next = buffer.get(idx) # s, s_next: [B, 4, 84, 84]
q_sa = online(s)[arange(B), a] # [B] current Q(S_{j-1}, A)
with no_grad():
a_star = online(s_next).argmax(dim=1) # [B] online selects action
q_next = target(s_next)[arange(B), a_star] # [B] target evaluates it
y = r + 0.99 * (1.0 - done) * q_next # [B] Double DQN target
delta = y - q_sa # [B], Eq. (2) TD error
loss = (w * clipped_sq_loss(delta)).mean() # weighted IS, Sec. 3.4
loss.backward() # updates online net only
optimizer.step() # RMSProp, eta = 0.00025 / 4
new_p = (delta.detach().abs() + eps) ** alpha # [B], Eq. (4) with +eps
for i, pa in zip(idx, new_p):
sum_tree.update(i, pa) # O(log N) priority refresh
min_tree.update(i, pa)Watch a subtle implementation difference in line 7 above: dividing by the buffer-wide (via min_tree.min_leaf()) versus dividing by the minibatch maximum over the 32 sampled transitions. Buffer-wide normalization is a deterministic scalar for the current buffer state, so it scales the entire expected gradient by a constant without changing its direction. Minibatch-only normalization avoids keeping a second tree, at the cost of a small random rescaling that varies from batch to batch whenever a low-priority transition lands in the draw.
# Atari settings (Schaul et al., Table 3 & Appendix B.2; base: tuned Double DQN)
replay capacity N 1,000,000 transitions # sliding circular window
minibatch k / period K 32 every 4 agent steps # 8 replays/transition avg
learning rate eta 0.0000625 # 0.00025 / 4 (RMSProp)
proportional PER alpha = 0.6, beta: 0.4 -> 1.0 over 50M agent steps
rank-based PER alpha = 0.7, beta: 0.5 -> 1.0 over 50M agent steps
DQN + rank-based (early) alpha: 0.5 -> 0.0, beta = 0 (no IS; anneals alpha)
priority offset eps omitted in paper # OpenAI Baselines uses 1e-6
reward & TD-error clip [-1, 1]
eval epsilon (human/test) 0.001 / 0.01 (Double DQN variants)Atari results on 57 games
The paper evaluates PER on the Arcade Learning Environment (Atari 2600) using the same human starts protocol as Double DQN: the best checkpoint found during 200 million frames (50 million agent steps) of training is evaluated for 100 episodes of up to 30 minutes each, starting from states sampled out of human gameplay traces so a memorized open-loop sequence cannot score well. Raw scores are normalized between a random agent (0%) and a human tester (100%):
The absolute value in the denominator exists for one game: Video Pinball, where random play scores 20,452.0 while the human reference scores 15,641.1. That small denominator turns Video Pinball into 7,367% under proportional Double DQN, which is why the paper emphasizes median normalized score over mean (without Video Pinball, the 56-game mean drops from 551% to 429% for proportional Double DQN, and from 418% to 297% for the uniform Double DQN baseline).
Two results anchor Table 1. First, adding rank-based PER to standard DQN across the original 49 Atari games more than doubles median human-normalized performance, from 48% to 106% (mean 122% to 355%), beating uniform DQN on 41 of 49 games (with 2 ties and 6 losses) and raising games above human level from 14 strictly (15 rounded in Table 1) to 25. That early DQN run did not use IS weights (); instead it annealed linearly from 0.5 down to 0 so sampling returned to uniform. Second, the gain stacks cleanly on top of Double DQN across all 57 games: proportional PER raises median normalized score from 111% to 128% (rank-based: 113%), mean from 418% to 551% (rank-based: 454%), outperforms uniform Double DQN on 42 of 57 games (rank-based: 38 of 57), and pushes 33 of 57 games past human level (up from 30).
Inspect every game in Figure 5: hover, tap, or press the left and right arrow keys to read exact Table 6 normalized scores and Table 7 raw scores, and switch tabs to compare the 57-game Double DQN suite against the 49-game DQN suite.
The learning-speed curves (Figure 4 of the paper) show the practical payoff in compute. Measuring the training step at which the median game reaches 100% of uniform Double DQN's final peak score, proportional PER arrives at 38% of total training time and rank-based PER at 47% (43% and 41% on cumulative mean score), roughly a 2x speedup across the suite. Individual jumps are largest on games with delayed or clustered rewards: Gopher rises from 728% to 2,792%, Space Invaders from 191% to 693%, James Bond 007 from 161% to 1,038% (1,172% rank-based), Atlantis from 2,335% to 4,425%, River Raid from 74% to 128%, and Seaquest from 36% to 97%. In games that otherwise sit flat for millions of frames before taking off (Battlezone, Zaxxon, Frostbite), prioritized replay shortens that delay substantially.
MNIST, off-policy links, and limits
Because Equation (3) needs only a scalar per-example error, Section 6 tests whether the same sampler helps ordinary supervised learning when classes are heavily skewed. The authors take MNIST handwritten digits, delete 99% of training examples for digits 0 through 4 (creating a 100:1 class imbalance), and leave the balanced test set untouched. A 4-layer convolutional network trained with uninformed proportional prioritization (, , given no hint that half the classes were thinned) trains faster and nearly matches the test error of an informed uniform baseline whose rare-class losses are explicitly multiplied by 100. Rare digits keep higher prediction errors longer, so prioritized sampling oversamples them automatically alongside hard decision-boundary examples from the common digits.
Section 6 also points out a direct link to off-policy RL with policy importance ratio (the probability of action under the target policy divided by its probability under the behavior policy that collected the transitions): setting with and recovers weighted importance sampling, setting with and recovers rejection sampling, and setting combines off-policy relevance with TD error in one priority score.
PER's empirical and structural limits appear directly in the Atari tables and Appendix A:
- Prioritization cannot fix exploration. On Montezuma's Revenge (0%), Gravitar (-1%), Private Eye (-1%), and Pitfall! (5%), PER produces no meaningful gain over uniform Double DQN. Replaying high-error transitions faster helps only after the agent actually stumbles onto informative experience and places it in the buffer.
- Stale TD errors and noisy rewards. Priorities refresh only when a transition is drawn, so a transition whose error changes because of updates elsewhere in the state space waits until stochastic sampling revisits it. When rewards are stochastic, conflates learnable error with irreducible noise. Appendix A tests using the change in since last replay and asymmetric positive/negative TD weighting, and finds neither beats plain on near-deterministic Atari.
- Memory and interaction with optimizers. In DQN, RAM is dominated by the million stored frames rather than the network weights; PER only decides what to replay, not what to keep or evict (Section 6 flags prioritized eviction as open work). Cutting the learning rate by 4x was also tuned for RMSProp; pairing PER with Adam or other adaptive optimizers changes how gradient scale interacts with and .
Two years later, proportional PER became one of the six building blocks of Rainbow DQN (Hessel et al., 2018), where the priority signal generalized from scalar TD error to the Kullback-Leibler (KL) divergence (a distance between two probability distributions, where lower is closer) of C51 distributional RL, with , annealed from 0.4 to 1.0, and the same 4x learning-rate reduction. In Rainbow's ablation study, removing prioritized replay caused one of the sharpest drops in Atari performance alongside removing multi-step returns or distributional value learning. Parallel on-policy agents such as A3C dropped replay buffers in favor of concurrent actors, while later off-policy codebases including Rainbow and Google Dopamine kept proportional sum-tree replay as their default buffer.
Questions you might still have
Why not just recompute every transition's TD error before each minibatch?
A DQN replay buffer holds 1,000,000 transitions of four 84 x 84 frames each. Scoring all million through the convolutional Q-network before a single 32-transition gradient step would cost 31,250 times more forward passes than training itself. Storing only the last-seen TD error makes priority refresh free, at the price of stale priorities for transitions not recently sampled.
Why do new transitions enter at the maximum priority instead of computing their TD error right away?
Computing the TD error on insertion would add an extra forward pass on every environment step, and starting at max_i p_i guarantees that every new transition is sampled at least once quickly even when its initial TD error would have been small. Once it is drawn in a minibatch, its stored priority updates to its actual |delta_i| + epsilon.
If importance sampling at beta = 1 cancels the sampling bias, why does PER still learn faster than uniform replay?
Unbiasedness only fixes the expected gradient, not its variance or the order of updates early in training. First, beta starts at 0.4 (proportional) or 0.5 (rank-based), so early training leans harder on high-error transitions while the policy is still moving. Second, even at beta = 1, replaying a high-error transition many times with smaller weights lets a nonlinear neural network follow curved loss surfaces in small local steps rather than taking one oversized jump.
Should I implement proportional PER or rank-based PER in practice?
Almost all modern libraries (OpenAI Baselines, Google Dopamine, Ray RLlib) use proportional PER with a sum-tree. On Atari, proportional Double DQN reached a higher median (128% vs 113%) and higher mean (551% vs 454%) than rank-based, and a sum-tree needs no periodic full-buffer re-sorting. Rank-based is worth considering if your rewards or TD errors are unclipped and prone to extreme outliers.
Why did the authors divide the learning rate by 4 when turning on PER?
Sampling high-TD-error transitions concentrates large gradients into every minibatch, especially while beta is below 1. Keeping Double DQN's learning rate of 0.00025 made updates too aggressive; cutting it to 0.0000625 stabilized all 57 Atari games with a single setting. Rainbow DQN kept that exact 4x learning-rate reduction.
Why does PER still fail on Montezuma's Revenge (0%) and Pitfall! (5%)?
Prioritized replay only changes the sampling probabilities of transitions already sitting in the buffer. On Montezuma's Revenge, an epsilon-greedy policy almost never reaches a key or door, so zero rewarding transitions enter the memory in the first place.
Footnotes & further reading
- The paper: Schaul, Quan, Antonoglou & Silver, Prioritized Experience Replay (ICLR 2016; arXiv:1511.05952v4, February 2016).
- Foundations of experience replay and planning priority: Lin (1992), Self-improving reactive agents based on reinforcement learning, planning and teaching (Machine Learning 8:293–321); Moore & Atkeson (1993), Prioritized sweeping: Reinforcement learning with less data and less time (Machine Learning 13:103–130); Watkins & Dayan (1992), Q-learning (Machine Learning 8:279–292).
- Baselines modified by PER: Mnih et al. (2015), Human-level control through deep reinforcement learning (Nature 518:529–533; see the DQN explainer); van Hasselt, Guez & Silver, Deep Reinforcement Learning with Double Q-learning (AAAI 2016; see the Double DQN explainer).
- Weighted importance sampling in linear function approximation: Mahmood, van Hasselt & Sutton, Weighted Importance Sampling for Off-policy Learning with Linear Function Approximation (NeurIPS 2014).
- Reference sum-tree implementations: OpenAI Baselines replay_buffer.py (SumSegmentTree + MinSegmentTree) and Google Dopamine sum_tree.py.
- Subsequent integration and theory: Hessel et al., Rainbow: Combining Improvements in Deep Reinforcement Learning (AAAI 2018; see the Rainbow explainer); Fujimoto, Meger & Precup, An Equivalence between Loss Functions and Non-Uniform Sampling in Experience Replay (NeurIPS 2020).
How could this explainer be improved? Found an error, or something unclear? I read every message.