Repository navigation
Fix quantized Gemma 3 MLP activation (gelu_pytorch_tanh, not SiLU) - #3747
Open
Sammy-Dabbas wants to merge 1 commit into
Open
Sammy-Dabbas wants to merge 1 commit into
Sammy-Dabbas wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fixes #3745
The quantized Gemma 3 MLP hardcoded SiLU, but Gemma 3 gates its feed-forward network with gelu_pytorch_tanh. The non-quantized gemma3.rs applies cfg.hidden_activation (gelu_pytorch_tanh for Gemma 3 checkpoints). The quantized model loads from GGUF metadata and has no config field, so it applies the activation directly, the same way quantized_glm4.rs hardcodes its Activation. This routes through the same code path as the non-quantized model (Activation::GeluPytorchTanh, the gelu tanh approximation).
SiLU and gelu_pytorch_tanh behave similarly, so the wrong one does not crash or produce obvious garbage; it just makes the output worse, which is why it went unnoticed. #3326 attempted a sliding-window plus GELU rework but was self-closed by its author, so this is the focused activation-only fix.