#10273·ms-swift

[RFC] Support Score Centering for GRPO training-inference mismatch correction

Author: hkxxxxxCreated Sep 30, 2026Updated Sep 30, 2026

Motivation

I would like to propose adding Score Centering support to GRPO training in ms-swift.

Paper: Score Centering Stabilizes Off-policy Reinforcement Learning

Official implementation: martin-marek/score-centering

Score Centering removes the drift term caused by training-inference mismatch by subtracting the expected policy score under the rollout distribution. This is different from reward/advantage normalization (scale_rewards), TIS/MIS importance sampling, and Off-Policy Sequence Masking.

ms-swift already supports TIS/MIS (#6678) and Off-Policy Sequence Masking (#6978), but it does not currently implement Score Centering.

Related implementations

The following implementations provide useful references:

These implementations consistently treat Score Centering as an additive policy-gradient correction term rather than as reward normalization or a standalone loss family.

Proposed MVP

To keep the first contribution focused, I propose an opt-in initial implementation with:

  • vLLM rollout support first;
  • single-turn GRPO support;
  • top_p=1 and top_k=-1 initially;
  • configurable sampler top-k log probabilities;
  • a REINFORCE-compatible policy-gradient path;
  • Score Centering disabled by default;
  • strict failure when sampler top-k data is missing or misaligned;
  • no TIS/MIS composition in the first PR unless maintainers prefer it.

The paper's top-k approximation requires the rollout to preserve, for every response token:

  • the sampled-token log probability;
  • sampler top-k token IDs;
  • sampler top-k log probabilities.

The trainer then evaluates its own log probabilities at those sampler top-k IDs and applies the tail-mass correction. The implementation should use a chunked, memory-conscious computation rather than materializing the full [batch, sequence, vocabulary] log-probability tensor.

Proposed controls

For example:

--score_centering true
--score_centering_top_k 32

The default top-k and the interaction with vLLM's max_logprobs limit need to be decided. The paper uses 128, while smaller values such as 32 also performed well in the paper.

Design questions

  1. Should the first implementation introduce an explicit loss_type=reinforce, or should Score Centering be attached to an existing ms-swift policy-gradient path?
  2. Should Score Centering be modeled as a correction term or as a new loss type in ms-swift?
  3. Which rollout backends should be supported initially?
  4. Should TIS/MIS composition be included in the first PR or follow in a separate PR?
  5. What top-k value and vLLM configuration are practical for ms-swift's rollout modes?

Validation plan

  • Compare the PyTorch implementation against the official implementation.
  • Test matched distributions, where the correction should be zero.
  • Test sampled tokens both inside and outside the retained top-k head.
  • Test tail-mass clipping and malformed or missing rollout metadata.
  • Test padding and multi-turn alignment if supported.
  • Add a small GRPO smoke test and report memory and throughput overhead.

I would be happy to prepare an implementation PR after the supported objective, rollout backend, and top-k data contract are confirmed.