Sampler replay improves reinforcement learning by training the sampler directly

Sampler Replay: Train The Sampler Not The Trainer in Reinforcement Learning with Verifiable Rewards

Machine LearningArtificial IntelligenceComputation and Language

Summary

Reinforcement learning sometimes struggles because the system that generates test decisions (the sampler) isn't trained as well as the model that learns from those decisions (the trainer). The authors propose focusing on training the sampler itself since it directly affects performance during testing. Their method, Sampler Replay, reuses earlier sampler decisions during training to better approximate how the sampler will behave in practice. This approach stabilizes training and improves results in several challenging scenarios.

What this means in practice

  • For reinforcement learning engineers: Enhance the stability and performance of reinforcement learning systems using verifiable rewards by implementing Sampler Replay to reduce train-inference mismatch.
  • For machine learning system developers: Improve training robustness of models deployed under hardware constraints like quantization by incorporating replay of sampler states during training.

Authors

Milad Aghajohari, Kamran Chitsaz, Sarath Chandar, Alessandro Sordoni, Michael Noukhovitch, Aaron Courville

Abstract

Train-inference mismatch is a well-known problem that degrades reinforcement learning with verifiable rewards (RLVR) performance. This problem is currently framed as training the trainer with samples coming from an imperfect version of itself: a sampler optimized to meet some efficiency criteria. Therefore, current RLVR algorithms are designed to account for the discrepancy in the trainer's gradient due to the sampler's off-policy rollouts. In this paper, we reframe the problem: we argue that RLVR should strive to \emph{train the sampler}, since it is the sampler's performance at test time that we ultimately care about. Therefore, we view the trainer merely as a mechanism to get an approximation of the sampler's true gradient. We propose \emph{Sampler Replay}, an algorithm that replays the sampler's hidden states, logits, and routing decisions in the trainer's forward pass to better approximate the sampler's gradient. Across tasks and model scales, we show that Sampler Replay stabilizes training under severe train-inference mismatch induced by quantization (weights, activations, KV cache), weight perturbation, and staleness, outperforming strong baselines. Furthermore, we show that Sampler Replay is a generalization of techniques that have been widely used in the literature to address TIM but that, so far, have been treated independently. Notably, we mathematically prove that Score Centering is a special case of Sampler Replay, where only the logits are replayed.