Skip to content

Mask replay for GRPO - #254

Open
vx120 wants to merge 6 commits into
modelscope:mainfrom
vx120:mask_replay
Open

Mask replay for GRPO#254
vx120 wants to merge 6 commits into
modelscope:mainfrom
vx120:mask_replay

Conversation

@vx120

@vx120 vx120 commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

This PR adds sampling replay for selective log-probability computation.

During rollout, the sampler records the token support used at each generation step. During training, sampling replay reconstructs log-probabilities over the same support instead of recomputing them over a potentially different distribution. This better aligns the rollout and training policies.

Results

Reward is comparable with and without replay, with a small improvement when replay is enabled:

Setting mean train/total_reward
replay off 1.4297
replay on 1.4547

Reward comparison

The reward curves show similar total_reward, accuracy_reward, and format_reward trajectories in both settings. Replay preserves reward quality and is slightly better at the final rollout.

Setting mean importance_ratio_mean mean logp_diff_mean
replay off 0.99752 -0.00279
replay on 1.00000 -0.00031

Policy-alignment comparison

importance_ratio_mean measures the average ratio between the training-time and rollout-time probabilities of sampled tokens. The ideal value is 1.0.

logp_diff_mean measures the average difference between training-time and rollout-time token log-probabilities. The ideal value is 0.0.

With replay enabled, the importance ratio stays tightly centered around 1.0, while the log-probability difference remains much closer to 0.0. This reduces rollout/training mismatch and provides a more stable optimization signal, which should be beneficial for longer training runs.

vx120 and others added 5 commits July 28, 2026 20:10
Signed-off-by: vx120 <893600387@qq.com>
Signed-off-by: vx120 <893600387@qq.com>
Signed-off-by: vx120 <893600387@qq.com>
Signed-off-by: vx120 <893600387@qq.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Signed-off-by: vx120 <893600387@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant