OpenFlowLM-Next icon indicating copy to clipboard operation
OpenFlowLM-Next copied to clipboard

Gemma 3 loaded straight from a GGUF uses two norms in the wrong places

Open Cyronius opened this issue 1 month ago • 0 comments

When a Gemma 3 model is loaded directly from a .gguf file (not a converted model.q4nx), the engine swaps two of each layer's norm weights: the one after attention and the one before the feed-forward block.

Why. The engine asks for weights by their Hugging Face names and translates them to llama.cpp's GGUF names in GgufFile::gguf_name (src/open_qwen36/gguf_file.cpp:266-270). The name post_attention_layernorm means different things in the two model families:

  • In Llama, Qwen and most others it is the norm before the feed-forward block. GGUF calls that ffn_norm.
  • In Gemma it really is the norm after attention. GGUF calls that post_attention_norm, and Gemma's pre-feed-forward norm is pre_feedforward_layernorm, which GGUF calls ffn_norm.

The map always used the Llama meaning, and it also sent pre_feedforward_layernorm to post_attention_norm. So a Gemma 3 GGUF got each of the two vectors in the other's place. The converted-container route (configs/gemma3.json) maps them correctly, and that is the route with hardware results, so no shipped result is affected. gguf_pack_test.cpp:285 asserted the wrong mapping.

Not yet seen on hardware. Found by reading the code while tracing the Gemma name maps for Gemma 4. No Gemma 3 GGUF-direct run is recorded in the spec.

Cyronius avatar Oct 21 '26 11:10 Cyronius