Skip to content

Conversation

@winnie0617
Copy link

What does this PR do?

This PR fixes a bug that for generating with cache using T5Gemma. Due to the nested structure of its config class, the field num_hidden_layers, which is used to initialize a dynamic cache, only exists under config.decoder.

This PR added a one line change to initialize config.num_hidden_layers using config.decoder.num_hidden_layers.

Fixes #41073

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

@gante @Rocketknight1

Following up on this issue since I encountered the same error. Happy to provide more information or discuss alternative solutions to help get this merged :)

@github-actions
Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: t5gemma

@ydshieh
Copy link
Collaborator

ydshieh commented Oct 1, 2025

cc @gante ?

(but maybe we should handle this in the cache class instead of adding a new attribute only for this purpose ?)

@gante
Copy link
Contributor

gante commented Oct 1, 2025

This PR is the actual fix 🤗

(this has been in review for a while, I'll ping a reviewer)

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.

use_cache=True does not work with T5GemmaForConditionalGeneration.generate()

3 participants