Repository navigation
refactor(api): remove the deprecated GPTQModel.export() API - #4831
Merged
Merged
Conversation
GPTQModel.export() was a static convenience wrapper that guessed a runtime backend from quantization_config and then routed to one of two checkpoint-level operations. Both destinations have their own explicit entry points, so the wrapper only duplicated dispatch. Hard remove it: no deprecation warning, shim, or alias. - Dense Transformers checkpoints: call gptqmodel.utils.model_dequant.dequantize_model() directly. - MLX-LM checkpoints: call GPTQModel.load() and gptqmodel.utils.mlx.convert_gptq_to_mlx_weights(..., stock_compatible=True). Tests: - test_export_api_removed.py pins the absence of the attribute and call. - Move the surviving dequantization coverage to test_model_dequant_dense.py and test_dequantize_model_dtype_4455.py, calling dequantize_model() directly. - Drop the export-contract tests; keep the copy_aux_files and BaseQModel.to regressions in dedicated tests. Docs: - Remove GPTQModel.export references from checkpoint interop, MLX, and MACaQ pages. - Document the removal, before/after flow, and replacements in docs/checkpoint-interop.md; link the page from README.md.
Rebase follow-up for the removal of GPTQModel.export(): - docs/export-hf-format-detection.md now documents dequantize_model() directly instead of the removed wrapper. - Delete tests/test_mlx_export_device_4809.py: it exercised the CPU-load behaviour of the removed wrapper through a mocked export() call, so there is no surviving API for it to test.
Qubitium
force-pushed
the
remove-export-api
branch
from
November 17, 2026 16:29
33ebdae to
c66bbe1
Compare
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
Hard-removes the deprecated
GPTQModel.export()API. The static wrapper only guessed a backend fromquantization_configand forwarded to one of two checkpoint-level operations, so it duplicated dispatch and could hand a checkpoint to a decoder that does not understand its layout. Net diff: +210 / -315 across 12 files. No deprecation warning, shim, or alias remains.What Changed
GPTQModel.export()fromgptqmodel/models/auto.py(95 lines).gptqmodel.utils.model_dequant.dequantize_model()directly (usegptqmodel.utils.hub.snapshot_download()first for repo ids).GPTQModel.load()+gptqmodel.utils.mlx.convert_gptq_to_mlx_weights(..., stock_compatible=True), thenmlx_lm.utils.save_model/save_config.tests/test_export_api_removed.py; moved surviving dequantization coverage totests/test_model_dequant_dense.pyandtests/test_dequantize_model_dtype_4455.py; dropped export-contract tests; preservedcopy_aux_filesandBaseQModel.toregressions in dedicated tests.docs/checkpoint-interop.md,docs/mlx-runtime.md,docs/macaq.md,docs/README.md; documented the removal and replacements; linked fromREADME.md.Tests
tests/test_export_api_removed.py).python -m pytest \ tests/test_model_dequant_dense.py \ tests/test_dequantize_model_dtype_4455.py \ tests/test_base_qmodel_to.py \ tests/test_export_api_removed.py \ tests/test_model_dequant_dynamic_bits.py -q -p no:randomly # 21 passed, 1 skipped in 1.35sSkips: local
/monster/data/model/AWQ-Llama-3.2-1B-g128-gemmcheckpoint is absent on this host.Red evidence on the parent commit (
origin/main@ 22f124d) with the new test file copied in:Static checks:
ruff check gptqmodel/models/auto.py tests/test_model_dequant_dense.py \ tests/test_dequantize_model_dtype_4455.py tests/test_base_qmodel_to.py \ tests/test_export_api_removed.py tests/test_mlx_packing.py # All checks passed!Collection baseline:
pytest tests -k "export or dequant" --collect-onlyreports the same 35 environment-only errors on bothorigin/mainand this branch (missingtriton,peft); no new collection failures.Model Support / Module Plan
Not applicable: no
MODEL_MAP, definition, module-plan, or fusion change.Model test node IDs and results: not applicable.
AWQ onboarding safety
Not applicable: no model onboarding, AWQ grouping, search, replay, or fold change.
AWQ evidence and per-variant policy: not applicable.
Logic Flow Documentation
file:lineevidence.docs/checkpoint-interop.mdrepeats the diagrams, is titled for the mechanism, and is linked fromREADME.md.Diagram summary: the removed wrapper guessed a backend and forwarded to
dequantize_model()orconvert_gptq_to_mlx_weights(). The replacement flow has the caller choose the destination and call that API directly.Review Requirements
Kernel Accuracy Requirements
Notes
DeprecationWarningwas added because the API is removed in the same release.hfwrote garbage for Paro/MACaQ) is moot and will be commented. Closed reports [BUG]GPTQModel.export(): unknown formats silently "succeed",trust_remote_codeis dropped on the non-hf path, andhfexports keepquantize_config.json, so the dense output can't be reloaded #4386, [BUG] Low-severity dequant/export/VLM-calib issues: VLM calibration rejects harmless metadata columns (regression from df6c9e6),export(..., "hf")always writes bf16,torch.dequantize_modelbuilds dense Linear on CPU #4455 (item 2), [BUG] Checkpoint interop: AutoAWQ modules_to_not_convert loads as NaN, format-change re-save writes stale qzeros, HF save_pretrained writes kernel runtime layout, Marlin ignores g_idx, is_marlin_format:false rejected, export broken #4053 (item 7), [BUG] MLX: runtime rejects standard generate() inputs (prompts/input_ids) and ignores max_new_tokens; export requant ignores dynamic (excluded modules quantized, 8-bit overrides -> 4-bit); KeyError on dynamic without bits #4076 (item 2), [BUG] MLX export/runtime pass transformers-5 rope_parameters to mlx-lm, which ignores it: exported Llama/Qwen2/Gemma run with rope_theta=10000 and no rope scaling #4607 and [BUG] Regression from #4617: MLX export/load of every Gemma 3 model now raises (per-layer rope_parameters rejected), although mlx-lm gemma3_text reads rope_theta + rope_local_base_freq #4678 concern the dequantizer/MLX conversion utilities, which remain.1. The problem
GPTQModel.export(model, target, format)was a static wrapper that validatedformat, guessed a runtime backend fromquantization_config, then routed to one of two checkpoint-level operations. It owned no checkpoint logic; it only duplicated dispatch.Old flow (removed)
flowchart TD A["GPTQModel.export(model, target, format)"] --> B{"format"} B -- hf --> C["snapshot_download when not local"] C --> D["dequantize_model()"] B -- mlx --> E["guess backend from quant_method"] E --> F["GPTQModel.load()"] F --> G["convert_gptq_to_mlx_weights<br/>stock_compatible=True"] B -- other --> X["ValueError"] style X fill:#f8d7da,stroke:#b02a37Mechanisms removed
origin/main@ 22f124d)export()entry point + format validationgptqmodel/models/auto.py:1247-1253format="hf"snapshot resolve + dequantizegptqmodel/models/auto.py:1257-1277dequantize_model()(callsnapshot_download()first for repo ids)quant_methodgptqmodel/models/auto.py:1279-1306GPTQModel.load(..., backend=...)chosen by the callerformat="mlx"load + convert + savegptqmodel/models/auto.py:1315-1340convert_gptq_to_mlx_weights(..., stock_compatible=True)+mlx_lm.utils.save_model/save_config2. The new flow
flowchart TD S["caller"] --> Q{"destination"} Q -- "dense Transformers" --> R["snapshot_download for repo ids"] R --> T["dequantize_model(source, target)"] T --> U["dense safetensors + config<br/>without quantization_config"] Q -- "MLX-LM" --> V["GPTQModel.load(source, backend=...)"] V --> W["convert_gptq_to_mlx_weights<br/>stock_compatible=True"] W --> Y["mlx_lm.utils.save_model / save_config"] style U fill:#d9f2d9,stroke:#2e7d32 style Y fill:#d9f2d9,stroke:#2e7d323. Failure and ambiguity contract
GPTQModel.export(...)AttributeErrorformatValueErrorafter argument parsingAttributeError; no format argument existsdequantize_model()raises fromdetect_format()4. Change inventory
gptqmodel/models/auto.pyGPTQModel.exporttests/test_export_api_removed.pytests/test_model_dequant_dense.py(renamed fromtest_export.py)dequantize_model(); keep metadata-drop andcopy_aux_filescoveragetests/test_dequantize_model_dtype_4455.py(renamed fromtest_export_dtype_4455.py)dequantize_model()tests/test_base_qmodel_to.pyBaseQModel.toregression from the deleted contract filetests/test_export_contract_4386.pytests/test_mlx_packing.pydocs/checkpoint-interop.mddocs/mlx-runtime.md,docs/macaq.md,docs/README.md,README.mdRebase note (merge-conflict resolution)
Rebased onto
main@ 5b58307 after #4824/#4828/#4809 landed, which touched the wrapper being removed:gptqmodel/models/auto.py: kept the removal; upstream's in-wrapper changes (fix(export): refuse an hf export whose method has no dense decoder (#4786) #4824 method refusal, [BUG] export(..., "mlx") of AWQ GEMV / GEMV_FAST checkpoints always fails on a GPU host: export forces BACKEND.AWQ_TORCH whose GEMV readers are CPU-only, but loads on the default accelerator ('does not support device: cuda:0') #4809 CPU load) went away with the wrapper.tests/test_model_dequant_dense.py: kept upstream'stest_export_hf_refuses_a_method_without_a_dense_decoder([BUG] export(..., "hf") silently writes garbage dense weights for Paro and MACaQ checkpoints: detect_format() sniffs Paro as AWQ and MACaQ ('mxfp4_macaq') as MXFP4, dropping rotations/Hadamard (nll 1.49 -> 13.28) #4786) astest_dequantize_model_refuses_a_method_without_a_dense_decoder; it callsdequantize_model()directly, so it still pins the refusal contract.docs/export-hf-format-detection.md: documentsdequantize_model()instead of the removed wrapper.tests/test_mlx_export_device_4809.py: it only exercised the removed wrapper's CPU-load behaviour through a mockedexport()call.Post-rebase validation:
python -m pytest tests/test_model_dequant_dense.py tests/test_dequantize_model_dtype_4455.py tests/test_base_qmodel_to.py tests/test_export_api_removed.py tests/test_model_dequant_dynamic_bits.py -q -p no:randomly-> 29 passed, 1 skipped;ruff checkclean.