Conversation
Signed-off-by: taking-lying-flat <1615405@qq.com>
Signed-off-by: taking-lying-flat <1615405@qq.com>
taking-lying-flat
force-pushed
the
fix/grpo-response-prefix-from-rollout
branch
from
September 16, 2026 14:16
21d897d to
6ba1186
Compare
hjh0119
approved these changes
Sep 17, 2026
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.
PR type
PR information
GRPO/GKD can reconstruct a sampled response with a different response prefix from generation. Training previously selected thinking/non-thinking prefixes directly from template metadata, bypassing the template's actual prefix resolver.
response_prefixchat_template_kwargs.response_prefixresponse_prefix=""Resolve the training prefix through
Template._get_response_prefixwith the sample's chat-template settings, including teacher views and requests. This also respects model-specific resolver overrides. Default thinking/non-thinking configurations continue to use the template's existing rules.For example, tokens sampled after
prompt + CUSTOM:must be trained with that same context. The prefix belongs to the prompt and is excluded from completion loss. The original sampled response IDs are reused directly; only the prompt prefix is tokenized.When reinserting the prefix, recognize an already inserted prefix by both its IDs and zero loss mask, so an actual sampled repetition is preserved. Copy the outer token/mask lists to avoid modifying stored rollout IDs during repeated encoding.
Text, image, and video samples share this response encoding path. Visual preprocessing and teacher image selection retain their existing behavior. The diff is limited to
swift/rlhf_trainers/utils.pyandswift/rlhf_trainers/gkd_helpers.py(25 additions, 27 deletions). No test code is committed.Fixes #10106.
Experiment results
Validation on the final diff:
git diff --checkpassed.Validation scripts and tests were run locally and are not included in this PR. These checks do not constitute an end-to-end vLLM or Megatron training run.