-
Notifications
You must be signed in to change notification settings - Fork 402
Refactor loss ctx #1442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jayhenry
wants to merge
21
commits into
InternLM:main
Choose a base branch
from
jayhenry:refactor_loss_ctx
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Refactor loss ctx #1442
Conversation
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
HIT-cwh
reviewed
Jan 26, 2026
HIT-cwh
reviewed
Jan 26, 2026
Collaborator
|
xtuner/xtuner/v1/rl/base/worker.py Line 770 in 8f8bf16
_train_one_step_sft 这里也需要对应修改 |
Collaborator
|
是不是类似 CELossContextInputItem 这样的 class 都不需要了 |
HIT-cwh
reviewed
Jan 26, 2026
0fcd257 to
3f97f80
Compare
Collaborator
Author
Yes |
50ca706 to
b30755b
Compare
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.
Summary
This PR refactors the loss subsystem to standardize how loss contexts are constructed, sequence-parallelism (SP) is handled, and batches are built.
Now Trainer/Worker only interact with LossConfig and LossContext objects.
It introduces unified builders across losses, removes legacy input-item types.
Highlights
BaseLossConfig.build, andBaseLossContext.build_batches. Removes*ContextInputItem, andBaseLossKwargsnow include built-into,sp_splitinstead.CELossConfig.buildandCELossContext.build_batches.BaseRLLossConfig,BaseRLLossKwargs,BaseRLLossContext.BaseRLLossContextinternalizes rollout importance-sampling handling.LossContext.build_batches.compute_actor_logprobsandcompute_ref_logprobsreturnList[torch.Tensor]for clearer data flow.Compatibility
Testing