Repository navigation
Description
Summary
The fix for #5514 added the after_make_quant hook so the loader can reattach the tied DiffusionGemma decoder leaves before the unmaterialized-parameter guard runs (gptqmodel/models/loader.py:3496-3498). The writer's export shell, get_model_with_quantize, rebuilds the same quantized model from config and fills it through the same load_checkpoint_in_model_then_tie_weights guard, but it never calls after_make_quant. Re-saving a loaded quantized model of a definition that relies on the hook (currently DiffusionGemmaQModel) therefore hits the #5514 failure again on the save side. This covers a plain GPTQModel.load(q).save(out) and also re-saving with a format change.
Impact
- Saving (correctness / availability): medium, for affected definitions. The save raises
RuntimeError: Loader: the checkpoint ... does not provide tensors for N non-quantized parameter(s)for every tied decoder parameter. No checkpoint is written, so a v1<->v2 format conversion or a re-shard of a loaded DiffusionGemma checkpoint is impossible. - No silent accuracy loss: the guard fails closed.
Location (85caf6c)
- Loader calls the hook:
gptqmodel/models/loader.py:3496-3498after_make_quant = getattr(cls, "after_make_quant", None) if callable(after_make_quant): model = after_make_quant(model)
- Writer shell does not call it:
gptqmodel/models/writer.py:2871-2952(make_quant(...)is followed directly byload_checkpoint_in_model_then_tie_weights(model, ..., checkpoint=self.checkpoint_file_name, ...)). - The guard:
gptqmodel/utils/model.py:4529-4533->_raise_on_unmaterialized_checkpoint_parameters(model.py:3442). - The hook implementation:
gptqmodel/models/definitions/diffusion_gemma.py:274-284.
Mechanism
- A quantized DiffusionGemma checkpoint stores only the encoder owner. The decoder leaves are the same
QuantLinearobjects at save time, soget_state_dict_for_savededups them. get_model_with_quantizebuildsfrom_config.make_quantreplaces only the encoder leaves named bymodule_tree. The decoderq_proj/k_proj/... stay densenn.Linearwithtorch.emptystorage, because init is suspended.load_checkpoint_in_model_then_tie_weightsfinds no checkpoint tensors for those decoder weights.tie_weightscannot alias them either, because the tie source is now aQuantLinearwith noweight. The guard therefore raises, exactly as described in [BUG] Quantized DiffusionGemma checkpoints cannot be reloaded: GPTQModel.load raises 'does not provide tensors' for every tied decoder parameter (after_model_load decoder sync runs after the loader guard) #5514 for the loader.
Reproduction / Validation
Not executed: on the audit host import gptqmodel is blocked by the torch dev-build version gate. The script is CPU-only and extends the existing tests/models/test_diffusion_gemma.py::test_quantized_checkpoint_reloads_with_tied_decoder with the load -> save round trip:
import sys, tempfile, pathlib, torch
sys.path.insert(0, "tests/models")
from transformers import AutoModelForMultimodalLM
from gptqmodel import GPTQModel, GPTQConfig, CalibrationConfig
from gptqmodel.models.definitions.diffusion_gemma import DiffusionGemmaQModel
from test_diffusion_gemma import _tiny_diffusion_gemma_config
DiffusionGemmaQModel.require_load_processor = False
tmp = pathlib.Path(tempfile.mkdtemp()); src, q1, q2 = tmp/"src", tmp/"q1", tmp/"q2"
AutoModelForMultimodalLM.from_config(_tiny_diffusion_gemma_config(), dtype=torch.bfloat16).save_pretrained(src)
rows = [{"input_ids": list(range(1+i, 49+i)), "attention_mask": [1]*48} for i in range(8)]
m = GPTQModel.load(str(src), GPTQConfig(bits=4, group_size=32), dtype=torch.bfloat16)
m.quantize(CalibrationConfig(dataset=rows, batch_size=1)); m.save(str(q1))
loaded = GPTQModel.load(str(q1), device="cpu") # passes since #5514
loaded.save(str(q2)) # expected: RuntimeError from the guardSuggested fix
Apply the same hook in the export shell, right after make_quant and before the checkpoint fill:
make_quant(
model,
...
bias_dtype=model_dtype,
)
+
+ after_make_quant = getattr(type(self), "after_make_quant", None)
+ if callable(after_make_quant):
+ model = after_make_quant(model)Add the load -> save -> load round trip above to tests/models/test_diffusion_gemma.py.
Notes
- The analysis comes from code reading at HEAD and the mechanism documented in [BUG] Quantized DiffusionGemma checkpoints cannot be reloaded: GPTQModel.load raises 'does not provide tensors' for every tied decoder parameter (after_model_load decoder sync runs after the loader guard) #5514 / fix(diffusion_gemma): reload quantized checkpoints with tied decoder #5554. It has not been run.
- Any future definition that overrides
after_make_quantinherits the same gap. Factoring the shell build (from_config-> defuse -> module filter ->make_quant->after_make_quant) into one helper shared by loader and writer would stop the two paths drifting.
Found by automated code audit (Claude Code).
Activity
Qubitium commentedon Nov 20, 2026
Agent claim released:
agent-24e6fcac08d0finished this issue.Pull request: #5745
Applying after_make_quant in the writer export shell and extending the DiffusionGemma load-save-load round trip
fix(writer): apply after_make_quant in the export shell (#5716) (#5745)
test(fixtures): ship a usable tokenizer in the DiffusionGemma tied-de…