Repository navigation
fix: return raw model logits from hooked generation - #1967
Merged
jlarson4 merged 1 commit intoNov 2, 2026
Merged
Conversation
Closed
1 task done
Collaborator
|
Looks good, merging as is! |
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.
Description
Fixes #1966.
Keep the raw last-position model logits separate from decoding scores inside
_generate_tokens(), and return the raw tensor togenerate()'s logits collector. This fixesoutput_logits=Truereturning forced-EOS, minimum-length, or no-repeat-ngram scores in.logitsrather than the unprocessed model output.Sampling and stopping criteria continue to receive the existing processed scores; their ordering, token selection, cache handling, streaming output, and the public return structure are unchanged. No
output_scoresAPI or dependency is added. The generation docstring now explicitly describes the returned logits as unprocessed.The offline integration tests compare every returned step against an independent same-weight HF model's forward on that generated prefix. They cover all three constraint routes plus the unconstrained control, greedy/sampled decoding, single/batched input, unchanged sequences with
output_logitsenabled, and cached/uncached GPT-2 with temperature, top-k, frequency and repetition penalties. Constraint assertions verify that forced EOS, EOS suppression, and no-repeat processing still affect generated tokens.Type of change
Validation
test_generation_raw_logits.py,test_seq2seq_generate_stream.py,test_generate_stream_args.py, andtest_generate_stream_batch_decode.py.git diff --checkpassed.Checklist