Back to articles

Sampler Replay: Aligning RLVR Training with the Inference Sampler

3 min read

Introduction

In reinforcement learning with verifiable rewards (RLVR), a model generates answers that can be checked by a rule or verifier, and the result guides policy updates. Yet the system that generates training rollouts may not behave exactly like the system used to compute gradients—or like the sampler used at inference. Quantization, changing weights, and stale inference states can create train-inference mismatch (TIM), so updates may point away from the behavior that matters at deployment.

The paper Sampler Replay proposes a change in perspective. Rather than treating the sampler as an imperfect version of the policy being trained, it argues that the sampler is the real object of interest: it is the sampler’s test-time performance that ultimately matters. The trainer, in this framing, is a mechanism for approximating the sampler’s gradient.

How the method works

Sampler Replay aims to make the trainer’s forward pass reproduce key parts of the sampler’s computation. The trainer can then perform the backward pass while using a forward computation closer to the one that produced the sampled outputs. The method replays three kinds of information:

  • Hidden states, representing intermediate computations inside the sampler.
  • Logits, the sampler’s scores for possible next tokens.
  • Routing decisions, which capture choices about which internal components or experts are used.

The trainer remains the gradient engine; replay changes the information available during its forward pass so that its update better approximates the sampler’s own gradient. According to the paper summary, experiments across tasks and model scales find that the method stabilizes training under severe mismatch caused by weight, activation, or KV-cache quantization, as well as weight perturbations and staleness. The authors also report that it outperforms strong baselines. The supplied material does not include numerical results, so it does not establish the size of those gains or how they vary by setting.

A unifying view of prior techniques

The authors connect Sampler Replay to methods previously considered separately. In particular, they mathematically prove that Score Centering is a special case of Sampler Replay in which only logits are replayed. This places a familiar technique inside a broader framework: different approaches to TIM can be understood in terms of which parts of the sampler’s computation are reproduced during training.

Why it matters—and what remains open

The central contribution is a shift in what training should approximate. If a particular sampler produces the answers users see, then optimizing a gradient closer to that sampler’s gradient may be more relevant than correcting the trainer in isolation. The framework could help organize existing alignment techniques and guide choices about what to replay in a given inference stack.

There are practical questions the supplied material does not answer, including the runtime and memory costs of replay, the contribution of each replayed component, and the conditions under which the method is most useful. Those details matter when deciding whether the approach is worthwhile in a real training pipeline.

Source: Hugging Face Daily Papers

Comments

Checking sign-in status...

Loading comments...

Related articles