Skip to content

Reject non-finite Softmax temperature - #1044

Open
alaabenfatma wants to merge 1 commit into
NVIDIA:mainfrom
alaabenfatma:fix/softmax-finite-temperature
Open

alaabenfatma wants to merge 1 commit into
NVIDIA:mainfrom
alaabenfatma:fix/softmax-finite-temperature

Conversation

@alaabenfatma

Copy link
Copy Markdown
Contributor

Fixes the SoftmaxTemperature item in #105.

Softmax only rejected temperature <= 0, so nan and inf were accepted: nan turned every probability into NaN and inf quietly returned a uniform distribution. It now raises unless the temperature is finite and positive, matching ClipSoft's max_absolute_value check.

@copy-pr-bot

copy-pr-bot Bot commented Oct 5, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Oct 5, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/structured-data-models/.coderabbit.yaml
  • Review profile: QUIET
  • Plan: Enterprise
  • Run ID: 923e3ff4-51f1-4e6d-a8b9-eca0eb654288
📥 Commits

Reviewing files that changed from the base of the PR and between 999212f and 58a5719.

📒 Files selected for processing (2)
  • sdm/processing/output/softmax.py
  • test/processing/output/test_softmax.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Softmax now rejects non-finite temperatures, including NaN and infinity, as well as zero and negative values.

Walkthrough

Softmax now requires temperature to be finite and positive. The invalid-temperature test covers zero, a negative value, NaN, and positive and negative infinity.

Changes

Softmax temperature validation

Layer / File(s) Summary
Temperature contract and validation
sdm/processing/output/softmax.py, test/processing/output/test_softmax.py
The documentation and constructor require finite, positive temperatures. The test covers zero, a negative value, NaN, and positive and negative infinity.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Merge Risk: ⚪ Minimal · up to 58a57

Softmax now rejects invalid temperatures while accepting valid positive values; no actionable merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: Softmax rejects non-finite temperatures.
Description check ✅ Passed The description explains the invalid-temperature behavior and the change that addresses it.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@RBendias

RBendias commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Hi - thanks for the PR. We try to keep the checks as minimal as possible see: https://github.com/NVIDIA/structured-data-models/blob/e22aecb0d902c380f758de2771e3a66d41cd5022/AGENTS.md#pythonpytorch-coding-style

Add an explicit runtime check only when a bad value could otherwise be silently accepted with wrong semantics (e.g. a count mismatch that remaps members incorrectly). Do not add positivity, finiteness, range, or shape checks that fail on first use anyway.

I'll update the issue accordingly. We rather need to update ClipSoft then.

This branch has not been deployed

No deployments
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