Fix _maybe_unbatch return annotation (Float -> Array) in t5gemma - #762
Open
PratikDhanave wants to merge 1 commit into
Open
Conversation
_maybe_unbatch is a dtype-preserving passthrough (unbatch) over an Array['B *d'] input, and its only caller (the `tokens` property) declares Int and passes the integer predicted_tokens buffer. Annotating the return as Float['*d'] is a copy-paste error; mirror the generic input as Array['*d'].
PratikDhanave
force-pushed
the
fix/t5gemma-maybe-unbatch-return-annotation
branch
from
July 25, 2026 06:12
97694e0 to
22afad1
Compare
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.
In
gemma/research/t5gemma/sampling.py,_maybe_unbatchis annotated:The body just unbatches and returns
xunchanged (dtype-preserving), and its only caller is thetokensproperty, declaredInt['B L'] | Int['L']and passing the integerpredicted_tokensbuffer. So the return is neverFloat— it's whatever integer array is passed in. Change the return annotation to mirror the generic input typeArray['*d'], which is correct for a dtype-preserving passthrough. Annotation only; no behavior change.