#10273·ms-swift

[RFC] 支持 GRPO 训练-推理不匹配的中心化校正

作者: hkxxxxx创建于 2026年9月30日更新于 2026年9月30日

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: - slime #2405 and #2406 - verl RFC #8009 and PR #8010 - reef RFC #672 and PR #673 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: ```text --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

内容来源: modelscope/ms-swift