fix(misc): normalize zero-temperature sampling - #5759
Open
yaoyu-33 wants to merge 1 commit into
Open
Conversation
Signed-off-by: Yu Yao <yaoyu.094@gmail.com>
Contributor
Author
|
/ok to test 34dc1cd |
Contributor
|
Light review — LGTM The change correctly fixes the Minor observations (non-blocking):
Suggested test cases
|
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.
Summary
The maintained standalone sync and async text-generation CLIs accept
--temperature 0 --top_p 0.9. Their shared sampling builder previously resolved that to active nucleus sampling with a zero temperature. The pinned MCore torch sampler then divided finite logits by zero and aborted generation with a non-finite probability error after model and distributed initialization.Normalize exact zero-temperature requests to greedy decoding (
top_k=1,top_p=0). This matches the pinned MCore OpenAI completion frontends and preserves every nonzero-temperature path.Root cause and fix
add_sampling_argsaccepts zero temperature, andbuild_sampling_paramsselectedtop_k=0whenever positive top-p was supplied. Both offline entrypoints forwarded that tuple unchanged to MCore. The minimal fix handles exact temperature zero at the shared Bridge ownership boundary before the existing omitted-top-k and incompatibility logic.The regression parses the supported Bridge CLI, exercises the production builder, and calls the exact pinned CPU-pure
torch_sampling.pyimplementation. Only the sampler's abstract base import is stubbed so this focused unit test does not initialize unrelated CUDA/MCore package dependencies.Regression evidence
Before the production fix, the new test failed with:
After the unchanged production fix:
Validation
Scope
No dependencies, lockfiles, workflows, public signatures, MCore source, server request handling, model code, or nonzero-temperature sampling behavior changed. No GPU, distributed, convergence, performance, or full-suite validation is claimed.