Check for output_extra.weight when loading Gemma4 assistant models#1817
Merged
Conversation
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.
PR #1810 added the ability to add an extra output tensor quantized with fewer bits per weight by adding
--extra-output-tensorto thellama-quantizecommand.This creates the opportunity for some clever user to do so for the Gemma4 assistant models. But then loading this model will fail because no attempt is made to load this additional tensor.
This PR fixes the loading failure of such a hypothetical model.
How do I know that this issue might occur? Well, after observing performance improvement when using MTP with the Qwen3.6 models by creating such an additional output tensor (see #1809, #1810), I went ahead to see if this will do something for Gemma4 MTP. With Gemma4 the MTP part is a separate "assistant model". This model does not have an
output.weighttensor (as usual for Gemma models the token embedding tensor is uses also as output tensor), so quantizing a Gemma4 assistant model with--extra-output-tensordoes createoutput_extra.weight, but the resulting model fails to load. So, to try, I had to fix it.The bad news is that this does not improve Gemma4 MTP performance. But at least we avoid having an issue filed.