Skip to content

fix: reject train-sampling temperature=0 (produces NaN logprobs)#3090

Closed
dumko2001 wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
dumko2001:fix/train-sampling-temperature-nonzero
Closed

fix: reject train-sampling temperature=0 (produces NaN logprobs)#3090
dumko2001 wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
dumko2001:fix/train-sampling-temperature-nonzero

Conversation

@dumko2001

@dumko2001 dumko2001 commented Jul 20, 2026

Copy link
Copy Markdown

Summary

  • TrainSamplingConfig.temperature is Field(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.
  • The rollout temperature is recorded per token (orchestrator/train_sink.py) and reused by the trainer to rescale logits: scaled_logits = logits / temperatures (trainer/rl/train.py). At 0 that divide is x / 0 → inf → selective_log_softmax → NaN loss. Nothing raises; the run just stops learning.
  • Fix: 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=0 fails 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.temperature validation changes from ge=0 to gt=0, so temperature=0 is 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.

EvalSamplingConfig is 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.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@dumko2001
dumko2001 marked this pull request as ready for review July 20, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants