Repository navigation
Set explicit neutral top_p in GKD on-policy generation - #6337
Merged
Merged
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
albertvillanova
approved these changes
Jul 10, 2026
albertvillanova
left a comment
Member
There was a problem hiding this comment.
Thanks for for the detailed report and the fix!
The fix is minimal, the reasoning is sound, and it closes a real silent-truncation bug for models that ship sampling defaults (Qwen3, Gemma, etc.).
Closed
5 tasks done
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.
What does this PR do?
Since transformers v5, unset
GenerationConfigfields default toNone, which means "inherit the value from the model'sgeneration_config" (huggingface/transformers#42702).GKDTrainerbuilds its on-policy generation config with an explicittop_k=0but notop_p, so models that ship sampling defaults (e.g. Qwen3 or Gemma withtop_p=0.95) silently truncate the on-policy sampling distribution during training.Repro (CPU):
This sets an explicit neutral
top_p=1.0, completing the intent of the explicittop_k=0and matching the sibling trainers (PPO hardcodestop_p: 1.0; GOLD, Distillation, SDFT, SSD and SDPO settop_pexplicitly from their configs).Before submitting
AI writing disclosure
Who can review?
@kashif
Note
Low Risk
Small, targeted change to GKD training-time generation kwargs; improves consistency with intended temperature-only sampling and aligns with other TRL trainers, with no auth or data-path impact.
Overview
GKD on-policy sampling no longer inherits the student model’s default
top_p(e.g. 0.95 on Qwen/Gemma).GKDTrainernow setstop_p=1.0alongside the existingtop_k=0, so transformers v5’s “unset field inherits frommodel.generation_config” behavior cannot narrow the training-time sampling distribution.test_generation_config_initassertstrainer.generation_config.top_p == 1.0.Reviewed by Cursor Bugbot for commit ddf75ee. Bugbot is set up for automated code reviews on this repo. Configure here.