Skip to content

Comments

fix(gguf): Ensure Gemma2 configs have hidden_act for backward compatibility#30411

Open
kitaekatt wants to merge 1 commit intovllm-project:mainfrom
kitaekatt:fix/30404-gemma2-hidden-act
Open

fix(gguf): Ensure Gemma2 configs have hidden_act for backward compatibility#30411
kitaekatt wants to merge 1 commit intovllm-project:mainfrom
kitaekatt:fix/30404-gemma2-hidden-act

Conversation

@kitaekatt
Copy link
Contributor

Summary

Fixes AttributeError: 'Gemma2Config' object has no attribute 'hidden_act' when loading Gemma2 GGUF models.

Changes

  • In ModelConfig.__init__, if model_type is "gemma2" and config has hidden_activation but not hidden_act, copy the value

Root Cause

  • Transformers' Gemma2Config only defines hidden_activation, not hidden_act
  • vLLM's gemma2.py directly accesses config.hidden_act without fallback

Testing

Tested with bartowski/gemma-2-2b-it-GGUF - model resolves architecture correctly.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several fixes and improvements related to GGUF model loading. The primary fix ensures backward compatibility for Gemma2 models by setting the hidden_act attribute in the configuration, resolving a potential AttributeError. Additionally, the PR enhances dtype handling for quantized models by automatically selecting a compatible dtype when a conflict arises, which improves user experience by avoiding crashes. It also addresses hardware-specific precision issues on Blackwell GPUs for GGUF models by disabling bfloat16. Finally, it correctly handles tied word embeddings in GGUF models. The changes are well-implemented and improve the robustness of GGUF model support in vLLM.

@mergify
Copy link

mergify bot commented Dec 15, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @kitaekatt.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Dec 15, 2025
@kitaekatt kitaekatt force-pushed the fix/30404-gemma2-hidden-act branch from 126db87 to 8108f82 Compare December 29, 2025 20:42
@mergify mergify bot removed the needs-rebase label Dec 29, 2025
@kitaekatt kitaekatt force-pushed the fix/30404-gemma2-hidden-act branch from 8108f82 to a9fb4d7 Compare January 19, 2026 17:27
…bility

GGUF-loaded configs may only have hidden_activation from config.json,
but Gemma2MLP model code expects hidden_act attribute. This adds a
post-processing step to copy hidden_activation to hidden_act when needed.

Fixes AttributeError: 'Gemma2Config' object has no attribute 'hidden_act'
when loading Gemma2 GGUF models.

Signed-off-by: Christina <truffle@gmail.com>
Copy link
Member

@yewentao256 yewentao256 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the work!

@yewentao256 yewentao256 added the ready ONLY add when PR is ready to merge/full CI is needed label Feb 5, 2026
Copy link
Member

@hmellor hmellor left a comment

Choose a reason for hiding this comment

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

  • Model specific edge cases in config classes should be avoided if possible
  • Why can't we just update gemma2.py to access hidden_activation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants