Repository navigation
Fix RecurrentGemma padded generation by declaring its layer_types
#50577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+30
−13
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c9db053
Fix RecurrentGemma padded generation by declaring its `layer_types`
ydshieh 6820072
Use `layers_block_type` (aliased as `layer_types`) instead of a secon…
ydshieh c655463
Update RecurrentGemma integration test expected values
ydshieh ba5a0d9
Update RecurrentGemma left-padding expected values
ydshieh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,6 +181,13 @@ def test_assisted_decoding_matches_greedy_search(self): | |
| def test_left_padding_compatibility(self): | ||
| pass | ||
|
|
||
| @unittest.skip( | ||
| "RecurrentGemma's recurrent block has no chunked-continuation support: a cached multi-token forward is " | ||
| "treated as a new prefill, so the split-vs-single comparison cannot match regardless of padding masking." | ||
| ) | ||
| def test_recurrent_layers_mask_padding_on_continued_forward(self): | ||
| pass | ||
|
|
||
|
Comment on lines
+184
to
+190
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it was skipped before. I don't want to handle this in the current PR.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea its expected tbh |
||
| @pytest.mark.generate | ||
| @unittest.skip(reason="Relies on `past_key_values` returned by the model. Not supported with recurrent gemma") | ||
| def test_assisted_decoding_sample(self): | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
layer_typesmaps recurrent blocks to"linear_attention"and attention blocks to"sliding_attention". Whengeneratehas already preparedattention_maskas a dict, this line always takesattention_mask["sliding_attention"]and uses that one tensor for every layer. A RecurrentGemma whoseblock_typesare all"recurrent"(or a generate path that only filledlinear_attention) will KeyError here. Even on the usual mixed stack, the linear/recurrent layers are then masked with the sliding-window tensor rather than thelinear_attentionmask that was prepared for them.If recurrent blocks ignore the mask and only the attention blocks need the sliding window, please say so in the comment — but I'd still use
.get("sliding_attention")and fall back tocreate_sliding_window_causal_mask(...)when that key is missing. If they do consume the mask, the dict should be passed through (or indexed perlayer_types[i]) so the linear-attention entry is not dropped. The new skip ontest_recurrent_layers_mask_padding_on_continued_forwardis fair given the missing chunked-continuation support, but it means padded continued generation stays untested after this fix.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the model is so old, that it would require too much effort to fix it up properly imo
some of your initial points are more theoretical issues which are not really important