You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] rotation is accepted on Gemma2/Gemma3 (and other LlamaQModel subclasses) and silently breaks the model #4169
Severity: high — silent corruption Version: 7.11.0 @ 6c3421c
Summary
models/base.py:2124-2128 guards rotation with isinstance(self, (LlamaQModel, Qwen2QModel)). The error message says "llama/qwen2 only", but Gemma2QModel, Gemma3QModel and about 17 other definitions subclass LlamaQModel, so they pass the check.
On Gemma, each of the following is wrong:
The tree tags input_layernorm and post_attention_layernorm with :norm, so the "two declared norms" check passes. post_attention_layernorm is then fused into gate/up, but in Gemma that norm sits on the attention output. The real MLP input norm is pre_feedforward_layernorm.
reset_ln sets the norm gain to 1, but Gemma's RMSNorm computes x * (1 + w), so the effective gain becomes 2.
The post-norms are not rotation-invariant.
Reproduce (tiny random models, CPU)
Fuse norms, rotate (hadamard), and add the online Hadamard on down_proj.
Check the exact model type rather than isinstance, or add an explicit supports_rotation = True opt-in on qualified definitions.
Add a neutral-rotation test, rotated logits ≈ original logits, for every definition that opts in.
Found during an AI-assisted review (Claude Code) of 6c3421c; repros were run on RTX 4090/5090 (CUDA 13) and Radeon AI PRO R9700 (ROCm) unless marked static/suspected.
Activity
fix(models): gate model rotation on explicit per-model-type opt-in (#…