fix: reject train-sampling temperature=0 (produces NaN logprobs)#3090
Closed
dumko2001 wants to merge 1 commit into
Closed
fix: reject train-sampling temperature=0 (produces NaN logprobs)#3090dumko2001 wants to merge 1 commit into
dumko2001 wants to merge 1 commit into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
dumko2001
marked this pull request as ready for review
July 20, 2026 11:41
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
TrainSamplingConfig.temperatureisField(1.0, ge=0, le=2.0), so 0 is accepted. To a sampler 0 means greedy decoding, so it looks like a valid request, yet it silently corrupts training.orchestrator/train_sink.py) and reused by the trainer to rescale logits:scaled_logits = logits / temperatures(trainer/rl/train.py). At 0 that divide isx / 0→ inf →selective_log_softmax→ NaN loss. Nothing raises; the run just stops learning.temperature: float = Field(1.0, gt=0, le=2.0), matching the guards already on neighbouring fields (e.g.dp: int = Field(1, ge=1)).Verification
With the new bound, a config with
temperature=0fails Pydantic validation before the run starts. Reproducing the trainer's divide gives all-NaN logprobs at 0 and finite values at any positive temperature.Note
Low Risk
Single Pydantic bound and docstring on training config; prevents a silent training failure mode with no runtime behavior change for valid configs.
Overview
TrainSamplingConfig.temperaturevalidation changes fromge=0togt=0, sotemperature=0is rejected at config load time instead of being accepted.That value is not only a rollout sampling knob: it is stored per token and reused in the trainer as
logits / temperature. Zero temperature caused division by zero and non-finite log-probs/loss with no clear error. The field docstring now documents that constraint.EvalSamplingConfigis unchanged and may still allow 0 for inference-only eval.Reviewed by Cursor Bugbot for commit ecc4d8a. Bugbot is set up for automated code reviews on this repo. Configure here.