fix(gptq): delegate native GPTQModel loads - #2469
Open
ZX-ModelCloud wants to merge 5 commits into
Open
Conversation
Qubitium
suggested changes
Jul 28, 2026
ZX-ModelCloud
marked this pull request as ready for review
July 29, 2026 02:18
Qubitium
suggested changes
Jul 30, 2026
Contributor
There was a problem hiding this comment.
@ZX-ModelCloud Unit test is testing pr change but actually not testing why we want this PR upstreamed to transformers. For example, you need write a specific test using hf/modelcloud hosted small quantied moe model with dynamic bit/groups gptq and test that it only loads correctly with our delegate.
This appears to be the last change I see before we can remove the wip tag.
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.
What does this PR do?
This PR allows Optimum to delegate native GPTQModel checkpoint preparation and post-initialization to GPTQModel when its optional loading bridge is available.
The existing GPTQ loading path discovers linear modules from the model structure and replaces them using a globally selected
QuantLinearimplementation. Native GPTQModel checkpoints may instead contain:Replacing modules outside that manifest can incorrectly convert an intentionally dense layer or select a kernel that does not support its shape.
This PR:
hf_gptqmodel_prepare_model_for_loadandhf_gptqmodel_post_init_for_load.There is no new hard dependency. GPTQModel versions that do not expose the bridge APIs continue using the existing Optimum behavior.
Testing
pytest -q tests/gptq/test_quantization.py -k "GPTQNativeLoadBridgeTest or GPTQPostInitTest"ruff check optimum/gptq/quantizer.py tests/gptq/test_quantization.pypython -m py_compile optimum/gptq/quantizer.py tests/gptq/test_quantization.pyBefore submitting
Who can review?
GPTQ and quantization: @SunMarc, @IlyasMoutawwakil