Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix: add num_hidden_layers property to T5GemmaConfig and add test for use_cache#41077

Open
priyankabolem wants to merge 1 commit into
huggingface:mainfrom
priyankabolem:fix/t5gemma-use-cache
Open

Fix: add num_hidden_layers property to T5GemmaConfig and add test for use_cache#41077
priyankabolem wants to merge 1 commit into
huggingface:mainfrom
priyankabolem:fix/t5gemma-use-cache

Conversation

@priyankabolem

Copy link
Copy Markdown

This PR fixes a bug in T5GemmaConfig where the configuration did not expose num_hidden_layers, which is required by generation/cache utilities (use_cache=True).
• Added num_hidden_layers property to T5GemmaConfig.
• Ensured fallback to decoder’s layer count if not set explicitly.
• Added a unit test (test_generation_t5gemma.py) to verify generation runs successfully with cache enabled.

Testing
• Added test_generate_use_cache_works_for_t5gemma.
• Verified test passes locally with pytest.

@github-actions

Copy link
Copy Markdown
Contributor

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

run-slow: t5gemma

@priyankabolem

Copy link
Copy Markdown
Author

Local pytest for t5gemma passes. The failing CI jobs seem unrelated. Please advise if changes are needed.

@ydshieh

ydshieh commented Sep 23, 2025

Copy link
Copy Markdown
Collaborator

Hi @priyankabolem Could you share an example (or a test in the library) that is failing prior to this PR?

@priyankabolem

Copy link
Copy Markdown
Author

Hi @ydshieh, thanks for the feedback!

I ran the test locally before and after the fix to confirm the issue:

  • On main (before fix): test_generate_use_cache_works_for_t5gemma fails with
    AttributeError: 'T5GemmaConfig' object has no attribute 'num_hidden_layers'.
Fail
  • On my branch (after fix): the same test passes successfully.
Pass

This shows that the fix (adding num_hidden_layers to T5GemmaConfig) resolves the issue.

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.

2 participants