Repository navigation
fix(writer): apply after_make_quant in the export shell (#5716) - #5745
Merged
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.
Summary
ModelWriter's export shell (get_model_with_quantize) rebuilds the quantized model withmake_quant()and then fills it from the checkpoint under the same unmaterialized-parameterguard the loader uses (
load_checkpoint_in_model_then_tie_weights). The loader applies adefinition's
after_make_quanthook to reattach runtime modules thatmake_quant()does notreplace; the export shell did not. Re-saving a loaded DiffusionGemma checkpoint therefore
raised before writing anything:
Fixes #5716
What Changed
gptqmodel/models/writer.py: call the model definition'safter_make_quanthook (whencallable) immediately after
make_quant()in the export shell, before the checkpoint fill.This mirrors the load path and lets tied/shared modules be reattached first.
tests/models/test_diffusion_gemma.py: extended the existing tied-decoder test to coverload → re-save → reload → forward. Extracted
_assert_tied_decoder_is_quantizedso both thefirst load and the reload assert the decoder shares the encoder's quantized leaves.
Tests
The new assertions fail on
origin/mainat the re-save:and pass with the fix:
Notes on the test environment: this run is on an Apple/MPS host, so the quantize load pins
device="cpu"inGPTQConfig; that pin only keeps the CPU test deterministic and is not partof the fix. CUDA-only suites were not run because no CUDA device is available.
Model Support / Module Plan
Not applicable: no new model, alias, or definition change; this is a localized writer hook call.
Model test node IDs and results (or "not applicable"): not applicable.