Score centering optimizes the sampler's policy
In RL post-training of language models, one engine samples and another one trains. The sampler is an inference engine, often quantized, sometimes a few steps stale. The trainer is the model you backpropagate through. They hold the same weights and still assign slightly different probabilities to the same token. Call the sampler’s distribution \(q\) and the trainer’s \(p\).
Score centering (Marek and Ryabinin, 2026) is a recent fix for the instability this causes: subtract from every token’s score its expectation under the sampler. The paper presents it as a bias correction. It removes a term, called drift, from the expected update.
This post looks at it from the logits. Differentiate the score-centered loss with respect to the logits, and the trainer’s probabilities cancel. What is left is \(e_y - q\), one-hot minus the sampler’s probabilities, which is the score function of the sampler’s policy. Seen this way, score centering is not a correction to the trainer’s policy gradient. It is the sampler’s policy gradient, backpropagated through the trainer.
The derivation takes three steps.
Setup
Fix one position in one response. The prefix up to this position was generated by the sampler.
- \(z \in \mathbb{R}^V\) are the trainer’s logits at this position, and \(p = \operatorname{softmax}(z)\) its probabilities.
- \(q\) are the sampler’s probabilities at the same position. They were recorded during the rollout, so for the gradient they are constants.
- \(y\) is the token that was sampled, \(y \sim q\), and \(e_y\) is its one-hot vector.
- \(R\) is the scalar that weights this token in the loss: a return or an advantage.
Vanilla REINFORCE on these samples uses the loss \(-R \log p_y\). Score centering adds one term:
\[L = -R \left( \log p_y - \sum_{v} \operatorname{sg}[q_v] \, \log p_v \right)\]where \(\operatorname{sg}\) is stop-gradient. The three steps below compute the gradient of the bracket with respect to \(z\).
Step 1: the score of one token
Write the log-probability out from the softmax:
\[\log p_y = z_y - \log \sum_{u} \exp z_u\]Differentiate with respect to one logit \(z_j\). The first term gives 1 if \(j = y\) and 0 otherwise. The second gives \(\exp z_j / \sum_u \exp z_u\), which is \(p_j\):
\[\frac{\partial \log p_y}{\partial z_j} = \mathbf{1}[j = y] - p_j\]Stack the \(V\) entries into a vector:
\[\nabla_z \log p_y = e_y - p\]This is the familiar picture: push the sampled token’s logit up by one, push every logit down by its own probability.
Step 2: the centering term
The centering term is \(c(z) = \sum_v q_v \log p_v\), with \(q\) held constant. Apply step 1 to each \(\log p_v\):
\[\nabla_z c = \sum_v q_v \, (e_v - p) = \sum_v q_v \, e_v - \Big( \sum_v q_v \Big) \, p\]The first sum puts \(q_v\) at position \(v\), so it is the vector \(q\). In the second, the probabilities sum to one. So:
\[\nabla_z c = q - p\]This vector has a meaning of its own. It is \(\mathbb{E}_{y \sim q}[e_y - p]\), the average score when tokens are drawn from the sampler. When the two engines agree it is zero, the standard fact that the expected score vanishes on-policy. When they disagree it is not, and vanilla REINFORCE picks up \(\mathbb{E}_q[R] \, (q - p)\) at every position: a pull of the trainer toward the sampler, scaled by the average reward. That is the paper’s drift.
Step 3: subtract
\[\nabla_z \Big( \log p_y - c \Big) = (e_y - p) - (q - p) = e_y - q\]The trainer’s probabilities are gone. The gradient that arrives at the trainer’s logits is fixed by two things: which token the sampler drew, and the probabilities the sampler assigned. Nothing in it comes out of the trainer’s forward pass.
The sampler’s policy gradient
Whose score is \(e_y - q\)? Run step 1 again, this time for the sampler. If its logits are \(z^{s}\) and \(q = \operatorname{softmax}(z^{s})\), then
\[\nabla_{z^{s}} \log q_y = e_y - q\]So the vector that score centering puts on the trainer’s logits is the score of the sampler’s policy with respect to the sampler’s own logits.
The expectation says the same thing. Let \(R_v\) be the expected reward when token \(v\) is chosen at this position and the sampler generates the rest. Then
\[\mathbb{E}_{y \sim q}\big[ R \, (e_y - q) \big] = \sum_v q_v R_v \, (e_v - q) = \nabla_{z^{s}} \sum_v q_v R_v\]The right-hand side is the gradient of the sampler’s expected reward with respect to its logits. Tokens drawn from \(q\), scored with the score of \(q\): at the logits this is plain on-policy REINFORCE, for the sampler. And since the sampler’s log-probability of a response is the sum over its tokens, with every prefix generated by the sampler, summing \(R \, (e_{y_t} - q_t)\) over positions gives the sampler’s REINFORCE gradient for the whole trajectory.
One consequence is that the baseline is free again. \(\mathbb{E}_q[e_y - q] = 0\), so a constant added to \(R\) does not change the expected update. The uncentered score does not have this property under mismatch: \(\mathbb{E}_q[e_y - p] = q - p\), so a baseline \(b\) moves the update by \(b \, (q - p)\).
Forward from the sampler, backward through the trainer
Logits are not what the optimizer updates. The chain rule multiplies by the Jacobian of the logits with respect to the parameters \(\theta\), and backpropagation runs through the trainer, so that Jacobian is the trainer’s, \(J_p = \partial z / \partial \theta\). The sampler’s own would be \(J_q = \partial z^{s} / \partial \theta\). Putting the pieces side by side:
| Estimator | Tokens drawn from | Signal at the logits | Jacobian |
|---|---|---|---|
| REINFORCE with no mismatch | \(p\) | \(e_y - p\) | \(J_p\) |
| vanilla REINFORCE under mismatch | \(q\) | \(e_y - p\) | \(J_p\) |
| score centering | \(q\) | \(e_y - q\) | \(J_p\) |
| the sampler’s own policy gradient | \(q\) | \(e_y - q\) | \(J_q\) |
Row two mixes two policies: samples from one, score from the other. Score centering makes the score match the samples. It differs from the last row in one place only, the Jacobian.
That is a straight-through estimator. Define
\[\tilde{z} = z + \operatorname{sg}[z^{s} - z]\]In the forward direction \(\tilde{z}\) equals the sampler’s logits. In the backward direction the gradient flows into \(z\), and from there through the trainer. The policy \(\operatorname{softmax}(\tilde{z})\) has the sampler’s probabilities, and \(\nabla_z \log \operatorname{softmax}(\tilde{z})_y = e_y - q\). Score-centered REINFORCE is REINFORCE on that policy. It does not even need the sampler’s logits: the softmax ignores a constant shift, so the recorded log-probabilities are enough.
The substitution of \(J_p\) for \(J_q\) is a natural one. An inference engine has no backward pass. If the sampler is quantized, its own Jacobian is useless anyway, because rounding has zero derivative almost everywhere. Running a full-precision backward under a quantized forward is what quantization-aware training does. Score centering arrives at the same construction for RL, from a different starting point.
Importance sampling goes the other way
A policy gradient needs the samples and the score to come from the same policy. Under mismatch they do not: the samples come from \(q\) and the score from \(p\). There are two ways to make them agree.
Importance sampling fixes the samples. Weight each token by \(p_y / q_y\) and the expectation under \(q\) becomes an expectation under \(p\):
\[\mathbb{E}_{y \sim q}\Big[ \frac{p_y}{q_y} \, R \, (e_y - p) \Big] = \mathbb{E}_{y \sim p}\big[ R \, (e_y - p) \big]\]Samples and score now both belong to the trainer. The policy being optimized is \(p\).
Score centering fixes the score. It leaves the samples where they are and moves the score from \(e_y - p\) to \(e_y - q\). Samples and score now both belong to the sampler. The policy being optimized is \(q\).
The two can be combined, by centering the weighted score, and the combination shows the same split. With exact weights \(w_v = p_v / q_v\) the centering term is \(\sum_v q_v w_v \, (e_v - p) = \sum_v p_v \, (e_v - p) = 0\): once the samples have been moved all the way to \(p\), there is nothing left to center. With truncated weights, as in TIS, the samples are moved part of the way and centering covers the rest.
The top-k head
Logging the sampler’s whole distribution for every token is expensive, so in practice only the top \(k\) tokens \(H\) are recorded, and the tail is modeled by the trainer’s tail, rescaled to the sampler’s tail mass:
\[\hat{q}_v = \begin{cases} q_v & v \in H \\ \rho \, p_v & v \notin H \end{cases} \qquad \rho = \frac{1 - q(H)}{1 - p(H)}\]The centering term for \(\hat{q}\) only needs the head. The expected score under the trainer itself is zero, \(\sum_v p_v \, (e_v - p) = 0\), so the tail sum can be traded for a head sum:
\[\sum_v \hat{q}_v \, (e_v - p) = \sum_{v \in H} (q_v - \rho \, p_v)(e_v - p)\]The three steps then go through with \(\hat{q}\) in place of \(q\), and the gradient at the logits is \(e_y - \hat{q}\): the sampler’s policy on the head, the trainer’s own shape on the tail.
Closing
When \(p = q\), the centering term is zero and score centering does nothing. That puts it next to the approach of my previous post, which makes the two engines agree bit for bit. Both restore an on-policy update. One does it by removing the difference between the engines. The other does it by choosing the sampler as the policy to optimize, and using the trainer for what only it can provide: a backward pass.
References
- Martin Marek and Max Ryabinin, Score Centering Stabilizes Off-policy Reinforcement Learning, 2026.
- Score centering in verl: rollout correction docs.
Enjoy Reading This Article?
Here are some more articles you might like to read next: