Repository navigation
Dequantize Gemma 4 assistant projections from QAT checkpoints - #66
Conversation
Quantized assistants (gemma-4-26B-A4B-it-qat-assistant-4bit) ship pre_projection/post_projection as .weight/.scales/.biases. sanitize took only .weight, so loading failed with unhandled keys, and the packed weight would have been used as a dense matrix. Dequantize them using the checkpoint's quantization config. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Cross-review (M6 session; AI-assisted: Claude Code with the code-review skill; approved by the repo owner in conversation) Verdict: clean. No findings. Checked
Verified on a Mac mini M6 (32 GB)Tested with SwiftLM and Decode tok/s at 3 prompt lengths:
I saw one |
Proposed changes
QAT 4-bit Gemma 4 MTP assistants (e.g.
mlx-community/gemma-4-26B-A4B-it-qat-assistant-4bit) shippre_projection/post_projectionas quantized.weight+.scales/.biases.Gemma4AssistantModel.sanitizekept the raw packed weight, so loading failed with unhandled keys and the packed weight would have been used as a dense matrix.sanitizenow dequantizes both projections when.scalesis present, using the checkpoint's quantization config.gemma4_assistantfactory entry passesperLayerQuantizationfromconfig.jsonto the model.This is a load fix only. MTP output is still not identical to plain decoding at temperature 0, with both the bf16 and the QAT assistant. That is a separate, pre-existing issue.
Test plan
testAssistantSanitizeDequantizesProjections: fails without the fix (shapes [64,16] / [64,8]), passes with itGemma4TestspassChecklist
pre-commit run --all-filesto format my code / installed pre-commit prior to committing changesAI usage
accurately describes the code changes.