Repository navigation
Conversation
This was referenced Sep 30, 2026
This branch has not been deployed
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.
Motivation
#40826 added temperature-scaled scoring, and #38965 added setwise scoring (
score_extraction_token_id) forSequenceClassificationmodels. The setwise paths bypass the temperature handling. A request withapply_softmax=Trueandtemperature != 1passes validation, but every setwise row is still normalized at temperature 1, so the value is silently ignored.Example: pooled logits [1.0, 3.0] with temperature=2.0 should score softmax([0.5, 1.5]) = [0.269, 0.731]. Both setwise paths return [0.119, 0.881]. This affects:
--enable-misoff):_process_single_item_scoring_results(per_item_matrix=True)hadtemperaturein scope but did not pass it to_multi_position_score_rows;--enable-mison):_process_multi_item_extraction_resultsnever receivedtemperaturefromscore_request.Pointwise classification and CausalLM scoring already honor temperature and are unchanged.
Modifications
_multi_position_score_rowstakes a keyword-onlytemperatureand applies the same numerically stable softmax as the pointwise branch: float64, subtract each row's max, then divide by temperature. The argument is required so a new call site cannot silently drop it. Withapply_softmax=False, raw logits are returned unchanged, as before._process_multi_item_extraction_resultsacceptstemperature(default 1.0), andscore_requestpasses it on the--enable-missetwise path.temperaturethrough.test_setwise_classification_temperatureintest/registered/unit/test_token_scoring.py. It drivesscore_request end to end through the existingScoringManagerfake (only model execution is faked), for bothenable_mis=Falseandenable_mis=True, with two items that have different anchor counts (1 and 2). It checks every row attemperature=2.0and attemperature=1e-300. The latter guards the max-subtraction: an uncenteredsoftmax(x / T)returns NaN there. The fake now returns one row per pooled position whentoken_indices_to_poolis set.test_setwise_score_mixin.py: the three direct calls to_multi_position_score_rowspasstemperature=1.0.Overlap with #41188 (CausalLM setwise): it calls
_multi_position_score_rowsfor the classification branches. Whichever PR lands second needs to addtemperature=temperatureat those calls; the required keyword turns a missed call into a TypeError rather than silently wrong scores. @sundar24295s, happy to rebase onto yours, or to adjust if you'd prefer to fold this in there.Accuracy Tests
No model forward, kernel, or pooling code changed; only post-processing of the pooled logits. Temperature-1 results are unchanged up to float precision: the softmax now runs in float64, matching the pointwise branch.
Unit tests (CPU, Python 3.11, torch 2.13.0+cpu, WSL2):
Not run: an end-to-end
/v1/scoresmoke test against a real SequenceClassification model.Speed Tests and Profiling
N/A. There is no performance claim: this changes a small softmax on the already-pooled
[num_positions, num_labels]result.Checklist
.pre-commit-config.yaml; the full pre-commit suite was not run.)docs/yet.)CI States
Latest PR Test (Base): ❌ Run #36176566684
Latest PR Test (Extra): ❌ Run #36176566343
Latest PR Test (AMD ROCm 10): ❌ Run #36176566873