~/satyajit

Token-level RL is a first-order approximation to the reward you actually want

mdjsonmcp

2026-07-24 · 11 min · reinforcement-learning · llm · mixture-of-experts · post-training · explainer

RL for reasoning models rests on a mismatch nobody had really justified. The reward is assigned to a whole response — you sample a full chain of thought, check the final answer, and hand back one scalar. But the optimizer — REINFORCE, GRPO, and the rest — works one token at a time. We reward the sequence and update the tokens, and we mostly just trust that closing the loop this way improves the thing we scored.

The Qwen team's Stabilizing Reinforcement Learning with LLMs (Zheng et al., arXiv:2512.01374) takes that trust and makes it a theorem with fine print. Their claim: the token-level objective is a first-order approximation to the true sequence-level reward — exact in the limit, and valid only when two specific gaps are small. The nice part is what falls out of it. Importance-sampling correction, clipping, and Routing Replay for Mixture-of-Experts models — a grab-bag of stabilization tricks that each arrived with its own justification — turn out to be the same move: keep the approximation valid. One lens, and the whole toolbox lines up behind it.

The objective you can't optimize

Write the thing we actually want to maximize — expected reward over responses the current policy would generate:

Jseq(θ)  =  ExD,  yπθ(x)[R(x,y)].J^{\text{seq}}(\theta) \;=\; \mathbb{E}_{x\sim\mathcal{D},\; y\sim\pi_\theta(\cdot|x)}\big[R(x,y)\big].

There's an immediate wrinkle: we don't sample yy from the policy we're training. Responses come out of a fast inference engine (vLLM, SGLang) running policy μθold\mu_{\theta_{\text{old}}}, while gradients are taken in a training engine (Megatron, FSDP) holding πθ\pi_\theta. The standard fix is an importance-sampling reweight onto the rollout policy μ\mu:

Jseq(θ)  =  ExD,  yμθold(x) ⁣[πθ(yx)μθold(yx)sequence-level IS weightR(x,y)].J^{\text{seq}}(\theta) \;=\; \mathbb{E}_{x\sim\mathcal{D},\; y\sim\mu_{\theta_{\text{old}}}(\cdot|x)}\!\left[\underbrace{\frac{\pi_\theta(y|x)}{\mu_{\theta_{\text{old}}}(y|x)}}_{\text{sequence-level IS weight}} R(x,y)\right].

This is correct and completely impractical. A sequence likelihood is a product of hundreds or thousands of per-token probabilities, so the ratio πθ(yx)/μθold(yx)\pi_\theta(y|x)/\mu_{\theta_{\text{old}}}(y|x) swings across an enormous dynamic range with brutal variance. Its gradient is technically right and numerically hopeless. Nobody trains on it directly.

The surrogate everyone actually uses

So instead we optimize the token-level objective — sum the per-token IS ratios instead of multiplying them:

Jtoken(θ)  =  ExD,  yμθold(x) ⁣[t=1yπθ(ytx,y<t)μθold(ytx,y<t)token-level IS weightR(x,y)].J^{\text{token}}(\theta) \;=\; \mathbb{E}_{x\sim\mathcal{D},\; y\sim\mu_{\theta_{\text{old}}}(\cdot|x)}\!\left[\sum_{t=1}^{|y|}\underbrace{\frac{\pi_\theta(y_t|x,y_{<t})}{\mu_{\theta_{\text{old}}}(y_t|x,y_{<t})}}_{\text{token-level IS weight}} R(x,y)\right].

Its gradient is just REINFORCE with a per-token IS weight — stable, cheap, the workhorse of every modern RL post-training run. The paper's key move is to show why it's allowed to stand in for the sequence objective. Write each token ratio as πθ(yt)μθold(yt)=1+δt\tfrac{\pi_\theta(y_t|\cdot)}{\mu_{\theta_{\text{old}}}(y_t|\cdot)} = 1+\delta_t with δt\delta_t small. Then the true sequence ratio is a product, and a product of near-ones is, to first order, one plus the sum:

πθ(yx)μθold(yx)  =  t=1y(1+δt)    1+t=1yδt  +  O(δ2).\frac{\pi_\theta(y|x)}{\mu_{\theta_{\text{old}}}(y|x)} \;=\; \prod_{t=1}^{|y|}(1+\delta_t) \;\approx\; 1 + \sum_{t=1}^{|y|}\delta_t \;+\; O(\delta^2).

Drop the O(δ2)O(\delta^2) terms and the gradient of the intractable sequence objective becomes exactly the gradient of the token surrogate. That's the whole theorem: the token-level objective is the linear part of the sequence objective. They agree when the per-token ratios hug 1, and they part ways as those ratios drift — because the neglected second-order cross terms i<jδiδj\sum_{i<j}\delta_i\delta_j are precisely what the linear surrogate throws away. Drive the two gap sources and watch the true product pull away from the surrogate:

first-order approximation · one sequenceillustrative
per-token ratio · rₜ = πθ(yₜ)/µθ(yₜ) = 1 + δₜrₜ = 112345678910aggregate ↓true sequence ratio · what RL wants∏ₜ (1 + δₜ)1.39×token surrogate · what REINFORCE optimizes1 + ∑ₜ δₜ1.33×
train–inference gap3
policy staleness3
first-order approximation: holdsdropped O(δ²) mass · gap = 0.05 (3.9%)

The surrogate keeps only the linear term of the product. When every ratio hugs 1, the two agree ( ) and improving the cheap token objective improves the true reward. Widen either gap and the neglected second-order terms pile up — the surrogate stops tracking the objective (), which is what training instability looks like.

The intuition to keep: the surrogate isn't wrong, it's truncated. As long as the policy you're optimizing stays close to the policy that generated the data, the truncation is negligible and improving the cheap objective improves the real reward. Let them separate and the surrogate starts optimizing something that isn't the reward anymore — which, in practice, is exactly what a training collapse looks like.

Two gaps, and the tricks that close them

"Keep πθ\pi_\theta close to μθold\mu_{\theta_{\text{old}}}" sounds abstract until you factor the token ratio into its two honest sources:

πθ(yt)μθold(yt)  =  πθold(yt)μθold(yt)training–inference discrepancy  ×  πθ(yt)πθold(yt)policy staleness.\frac{\pi_\theta(y_t|\cdot)}{\mu_{\theta_{\text{old}}}(y_t|\cdot)} \;=\; \underbrace{\frac{\pi_{\theta_{\text{old}}}(y_t|\cdot)}{\mu_{\theta_{\text{old}}}(y_t|\cdot)}}_{\text{training–inference discrepancy}} \;\times\; \underbrace{\frac{\pi_\theta(y_t|\cdot)}{\pi_{\theta_{\text{old}}}(y_t|\cdot)}}_{\text{policy staleness}}.

Now the stabilization toolbox reads as one idea — shrink these two gaps so the first-order approximation holds:

Why MoE breaks it, and how Routing Replay repairs it

In a Mixture-of-Experts model, the probability of a token depends on which experts the router activated for it. That turns the token ratio into a comparison over possibly different active parameters: the inference engine routes the token to expert set eμe^\mu, the training engine to eπe^\pi, and when those sets disagree the ratio πθ(yt)/μθold(yt)\pi_\theta(y_t|\cdot)/\mu_{\theta_{\text{old}}}(y_t|\cdot) stops measuring "a small change in the policy" and starts measuring "two different subnetworks." The δt\delta_t are no longer small, and the first-order approximation collapses. Routing is entangled with both gaps — the engines can route differently (discrepancy) and the router's choice can shift as weights update (staleness). Toggle the fix:

MoE routing · one token, two enginesillustrative
expert bank · router activates top-k per tokenE1E2E3E4E5E6E7E8inference enginerollout µθ · FP8 · picks eµtraining enginetarget πθ · BF16 · picks eπ
Routing Replay
expert overlap 1/3 · IS ratio invalid — routing entangled

Off, the two engines route the same token to different experts— the per-token ratio compares different active parameters and stops meaning “a small policy change,” so the first-order approximation collapses. On, replay pins the training engine to the rollout’s experts, and the token is optimized like a dense one. The trade: pinning the experts subtly biases the target policy away from its own natural routing.

Routing Replay (Zheng et al., 2025; Ma et al., 2025) pins the routed experts during optimization so the token is scored over one fixed subnetwork — the model is optimized like a dense one, and the ratio means what it should again. The paper formalizes two flavors, differing only in whose routing you replay:

replaysclosesfirst mini-batch
R2 — Vanilla Routing Replaythe training engine's rollout experts eoldπe^\pi_{\text{old}}policy stalenesstarget policy unaltered
R3 — Rollout Routing Replaythe inference engine's experts eoldμe^\mu_{\text{old}}discrepancy and stalenesstarget policy altered

There's no free lunch here, and the paper is careful to say so. Fixing the experts restores the approximation but biases the target policy — you're now optimizing a model whose routing is frozen to a past choice, not the routing it would pick itself. R2 leaves the first mini-batch's target policy untouched; R3 alters it from step one but kills more of the discrepancy. Which bias is worth paying turns out to depend on how off-policy you run — a question only experiments can settle.

MiniRL: the smallest honest baseline

To test the formulation instead of a pile of confounded tricks, the authors strip RL down to MiniRL — REINFORCE with the token-level IS weight, group-normalized advantages (subtract the per-prompt mean reward), and PPO-style clipping. That's it. It's deliberately the minimal algorithm whose gradient stays faithful to the surrogate the theory justifies, which makes it the right probe: if the formulation is real, the things that preserve the approximation should be the things that stabilize MiniRL.

The setup is a genuine stress test. A 30B MoE (cold-started from Qwen3-30B-A3B-Base), FP8 inference against BF16 training — deliberately mismatched precisions to inflate the training–inference discrepancy — on 4,096 verifiable math problems, scored as average accuracy over 32 samples on HMMT25, AIME25, and AIME24. Hundreds of thousands of GPU hours, roughly 5–6 GPU-hours per gradient step. They track not just reward but two diagnostics: policy entropy and the training–inference KL divergence, since a collapse announces itself as a KL spike before the score falls.

What the experiments say

On-policy (one gradient update per batch), the ablation lands exactly where the theory predicts:

Four-panel on-policy training curves over 1,200 gradient steps: benchmark score, training-inference KL divergence, training reward, and entropy. MiniRL climbs highest and steadiest; adding length normalization is slightly worse; removing the training-inference IS correction collapses within ~150 steps with a KL spike and an entropy crash.
On-policy training (gbs = mbs = 1,024). MiniRL (blue) is the most stable; dropping the training–inference IS correction (green) collapses within ~150 steps as KL spikes and entropy craters; length normalization is stable but suboptimal (arXiv:2512.01374, Figure 1).

Three reads, each a prediction of the formulation:

on-policy final benchmark score, avg of HMMT25/AIME25/AIME24 (read from Fig. 1, approximate)
MiniRL
0.77
MiniRL + R3
0.76
+ length-norm
0.75
− train-infer IS (collapsed)
0.6
00.20.40.60.8

Off-policy (split the batch into NN mini-batches for NN updates), staleness enters and the picture changes. Now clipping and Routing Replay both become necessary — drop either and training collapses early:

Four-panel off-policy training curves (global batch = 4x mini-batch) over 4,000 gradient steps. MiniRL without clipping and R2 without clipping both collapse early; MiniRL+R2 collapses around 2,500 steps with an entropy blow-up; MiniRL+R3 stays stable to 4,000 steps with a slowly rising KL.
Off-policy training (gbs = 4 × mbs). Without clipping, runs collapse fast; even MiniRL+R2 destabilizes near ~2,500 steps (entropy blow-up, KL spike), while MiniRL+R3 (red) sustains stable training the longest (arXiv:2512.01374, Figure 3).

The nuance the paper draws out: at small off-policiness (gbs=2×mbs\text{gbs}=2\times\text{mbs}), R2 beats R3 — R2's lighter bias wins when the approximation is only mildly stressed. At larger off-policiness (4×4\times, 8×8\times), R3 wins — R2 can't hold training together and R3's stronger discrepancy-killing earns its bias back. The recipe isn't "always use X"; it's "match the replay to how off-policy you're willing to run."

The result that reframes the field

The finding I keep coming back to isn't a trick — it's about what matters. Take one base model, cold-start it three different ways (distilling from Qwen3-Max-Thinking-Preview, DeepSeek-R1-0528, and gpt-oss-120b), then run the same stable recipe. They converge to the same place:

Two panels over ~600 gradient steps. Left: benchmark score (AIME25 and AIME24) for three cold-start initializations rising and converging to roughly 0.86. Right: response length for the three, drifting apart but with all improving.
Three different cold-start initializations, one stable RL recipe (MiniRL+R2), converging to comparable final accuracy on AIME25 & AIME24 (arXiv:2512.01374, Figure 5).
final AIME25 & AIME24 accuracy by cold-start init — same recipe (read from Fig. 5, approximate)
Qwen3-Max-Thinking
0.86
DeepSeek-R1-0528
0.86
gpt-oss-120b (high)
0.85
00.51

Once training is stable, how you started barely matters — prolonged RL washes out the cold-start differences and even on-policy and off-policy runs reach comparable peaks. The implication is pointed: the field spends enormous effort curating cold-start data, and this says that effort is mostly erased by enough stable RL. The lever that actually moves the ceiling is stability, not initialization.

The take


Built on Stabilizing Reinforcement Learning with LLMs: Formulation and Practices (Zheng et al., Qwen Team, Alibaba). Routing Replay's two flavors trace to GSPO (R2) and Ma et al., 2025 (R3, arXiv:2510.11370). Figures are the paper's; the interactive diagrams are mine.

Cite this article

For attribution, please use the following reference or BibTeX:

Satyajit Ghana, "Token-level RL is a first-order approximation to the reward you actually want", ai.thesatyajit.com, July 2026.

bibtex
@misc{ghana2026firstorderrl,
  author = {Satyajit Ghana},
  title  = {Token-level RL is a first-order approximation to the reward you actually want},
  url    = {https://ai.thesatyajit.com/articles/first-order-rl},
  year   = {2026}
}
share