Repository navigation
fix(sampling): use neutral temperature and accept top_k=-1 - #5081
Merged
silencelamb merged 1 commit intoNov 2, 2026
Merged
Conversation
silencelamb
requested review from
RunningLeon,
caikun-pjlab and
yidingcheng0206
November 1, 2026 02:58
caikun-pjlab
approved these changes
Nov 2, 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.
Motivation
Requests that omit temperature currently fall back to
0.8, which sharpens the model distribution, and clients usingtop_k=-1to disable top-k filtering are rejected. Use a neutral temperature fallback and accept the disabling convention used by vLLM and SGLang.This complements #5079 and can be reviewed and merged independently.
Modification
1.0inGenerationConfig, the PyTorch sampling parameters, and the CLI argument helper.top_k=-1alongside0in Chat Completions, Completions, Responses, Anthropic Messages, and/generate. Normalize-1to0in the sharedGenerationConfigbefore either inference backend receives it; continue rejecting values below-1.BC-breaking
Sampled outputs may change when neither the request nor the effective model/server defaults supplies a temperature. Set
temperature=0.8explicitly to retain the previous fallback behavior. Explicit request/model temperatures retain their precedence; greedy decoding is unaffected. Acceptingtop_k=-1is an additive compatibility change.Validation
/generatetests: 211 passed, 4 deselected with Transformers 5.16.0.git diff --checkpassed.