Skip to content

Fix GPT2 DynamicCache handling for Transformers 4.55 compatibility#2342

Merged
regisss merged 2 commits intohuggingface:mainfrom
HabanaAI:main-GPT2LMHeadModel_forward_fix
Dec 2, 2025
Merged

Fix GPT2 DynamicCache handling for Transformers 4.55 compatibility#2342
regisss merged 2 commits intohuggingface:mainfrom
HabanaAI:main-GPT2LMHeadModel_forward_fix

Conversation

@gplutop7
Copy link
Collaborator

@gplutop7 gplutop7 commented Nov 7, 2025

This PR updates GaudiGPT2LMHeadModel to ensure full compatibility with Transformers v4.55 cache behavior.

In Transformers 4.55, the past_key_values object may still be returned as a legacy tuple when use_cache=True, even though the internal implementation now relies on DynamicCache.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@gplutop7 gplutop7 changed the title Fix GPT2 DynamicCache handling for Transformers 4.55 compatibilit Fix GPT2 DynamicCache handling for Transformers 4.55 compatibility Nov 7, 2025
Copy link
Collaborator

@regisss regisss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@regisss regisss merged commit f87daf5 into huggingface:main Dec 2, 2025
3 of 5 checks passed
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.

3 participants