Refactoring training inference importance sampling with seqeunce/geometry level#429
Merged
zhuzilin merged 70 commits intoTHUDM:mainfrom Oct 20, 2025
Merged
Conversation
Collaborator
Author
|
/gemini review |
5459cfc to
0695c73
Compare
yitianlian
reviewed
Oct 8, 2025
slime/utils/tis.py
Outdated
Comment on lines
+225
to
+229
| seq_mean = masked_mean(tis_weights, eos_mask, dim=-1) | ||
| metrics["tis_seq_mean"] = seq_mean.mean() | ||
| metrics["tis_seq_std"] = seq_mean.std() | ||
| metrics["tis_seq_max"] = seq_mean.max() | ||
| metrics["tis_seq_min"] = seq_mean.min() |
Collaborator
There was a problem hiding this comment.
I think it might have a problem when cp>1.
yitianlian
reviewed
Oct 8, 2025
slime/backends/fsdp_utils/actor.py
Outdated
| tis_clip = torch.clamp( | ||
| tis, min=getattr(self.args, "tis_clip_low", 0.1), max=getattr(self.args, "tis_clip", 2.0) | ||
| # Build eos mask from loss masks | ||
| eos_mask = torch.cat(loss_masks, dim=0).to(device=log_probs.device) |
Collaborator
There was a problem hiding this comment.
I think it might have a problem when cp>1. Because the loss mask is not split by cp_size, while logp is split by cp_size. You can reuse the implementation of sum_of_sample_mean in cp_utils.
Further modify tis
zhuzilin
reviewed
Oct 16, 2025
yitianlian
reviewed
Oct 17, 2025
fzyzcjy
reviewed
Oct 18, 2025
zhuzilin
approved these changes
Oct 20, 2025
nanjiangwill
pushed a commit
to nanjiangwill/slime
that referenced
this pull request
Oct 22, 2025
…etry level (THUDM#429) Co-authored-by: Jiajun Li <guapisolo@gmail.com>
llltttwww
pushed a commit
to llltttwww/slime
that referenced
this pull request
Nov 30, 2025
…etry level (THUDM#429) Co-authored-by: Jiajun Li <guapisolo@gmail.com>
Yangruipis
pushed a commit
to rednote-ai/slime
that referenced
this pull request
Feb 28, 2026
…etry level (THUDM#429) Co-authored-by: Jiajun Li <guapisolo@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks so much to the contribution of this paper When Speed Kills Stability: Demystifying RL Collapse from the Training-Inference Mismatch
This PR refactors the Importance Sampling (IS) functionality, replacing the legacy
--use-tisparameter with a more flexible--use-train-infer-isparameter system. We introduce multiple aggregation levels and processing modes to handle training-inference mismatch problems better.--use-tis,--tis-clip,--tis-clip-lowparameters--use-train-infer-is: Enable training-inference importance sampling--train-infer-is-level: Aggregation level (token/sequence/geometric)--train-infer-is-mode: Processing mode (truncate/mask/clip)--train-infer-is-lower-bound/--train-infer-is-upper-bound: Weight bounds--train-infer-is-veto-threshold: Catastrophic token thresholdToken Level (default):
w_i = exp(log π_train(x_i) - log π_rollout(x_i))Sequence Level:
w_seq = exp(Σ(log π_train(x_i) - log π_rollout(x_i)))Geometric Level:
w_seq = exp(mean(log π_train(x_i) - log π_rollout(x_i)))Truncate Mode (TIS):
Mask Mode (MIS):
Clip Mode (CIS):
--train-infer-is-veto-threshold# Using geometric mean + mask mode --use-train-infer-is \ --train-infer-is-level geometric \ --train-infer-is-mode mask \ --train-infer-is-lower-bound 0.5 \ --train-infer-is-upper-bound 2.0 \ --train-infer-is-veto-threshold 1e-3