[None][fix] Clamp small non-zero sampling temperature#15716
Open
chfeng-cs wants to merge 1 commit into
Open
Conversation
Contributor
📝 WalkthroughWalkthroughAdds a Temperature Clamping
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tensorrt_llm/sampling_params.py`:
- Around line 376-381: Update the public documentation for SamplingParams to
reflect the new temperature normalization behavior. In the SamplingParams class
docstring (and any temperature field description used by the user-facing API),
add that values greater than 0 but below MIN_SAMPLING_TEMPERATURE are clamped to
MIN_SAMPLING_TEMPERATURE, while 0 still means greedy decoding. Keep the wording
aligned with the existing temperature description in sampling_params.py so the
contract matches the behavior in the temperature handling logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 68c9e8a0-1271-425b-884b-35a8a0e8f402
📒 Files selected for processing (2)
tensorrt_llm/sampling_params.pytests/unittest/llmapi/test_sampling_params.py
770deb1 to
7f35e15
Compare
Signed-off-by: Ethan Feng <ethan.fengch@gmail.com>
7f35e15 to
cac012d
Compare
3 tasks
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 by CodeRabbit
Description
Fix #15715 .This PR clamps very small non-zero
SamplingParams.temperaturevalues to1e-2before they are passed to the sampling backend.temperature=0continues to represent greedy decoding, while positive values below the stability threshold are normalized to avoid excessive logit scaling fromlogits / temperature.TensorRT-LLM currently validates that
temperature >= 0, but values such as1e-12can still enter the sampling path and may lead toinf,nan, or unstable sampling behavior in edge cases.This mirrors the numerical stability guard used by vLLM while preserving the existing greedy decoding semantics for
temperature=0.Changes
Added
MIN_SAMPLING_TEMPERATURE = 1e-2.Clamped
0 < temperature < MIN_SAMPLING_TEMPERATUREtoMIN_SAMPLING_TEMPERATUREinSamplingParams._validate().Added debug logging when a small non-zero temperature is clamped.
Added a unit test covering
temperature=0, very small positive temperatures, the threshold value, and normal temperatures.Test Coverage
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.