Repository navigation
Conversation
export(..., 'mlx') left the device implicit, so the loader picked the accelerator whenever one was visible. The MLX converter only reads packed tensors from the checkpoint and never runs a quantized forward, and the AWQ GEMV/GEMV_FAST Torch readers are CPU-only, so those two formats always failed with 'does not support device: cuda:0' on a GPU host before any conversion. Load with device='cpu' instead: the conversion is host-only and now works on any host.
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
GPTQModel.export(path, out, "mlx")always failed on a host with a visible accelerator for AWQFORMAT.GEMV/FORMAT.GEMV_FASTcheckpoints:The export picks a backend per method (
models/auto.py) and passed nodevice, so the loader took the default device — the accelerator whenever one is visible. For AWQ it picksBACKEND.AWQ_TORCH, whose GEMV/GEMV_FAST readers are CPU-only (SUPPORTS_DEVICES = [DEVICE.CPU], added for #4554/#4736). The failure happens before any conversion, andCUDA_VISIBLE_DEVICES=""was the only workaround.The MLX converter only reads the packed tensors from the checkpoint; it never runs a quantized forward. The accelerator is not needed at all.
Fixes #4809.
What Changed
gptqmodel/models/auto.py— the MLX export path now loads the checkpoint withdevice="cpu". That is the only load on this branch: thehfpath returns earlier, so no other export is affected.tests/test_export_contract_4386.py—test_export_mlx_loads_the_checkpoint_on_cpu, 4 nodes (GPTQ, AWQ, Paro, GGUF), extending the existing mocked-load contract tests in that file.Behaviour change:
export(..., "mlx")is now host-only and works identically with or without a GPU visible. No API change.Tests
ruff check gptqmodel docs/eora tests setup.py: All checks passed.Red / green evidence
Reverting only the
auto.pyhunk, keeping the new test:test_export_mlx_loads_the_checkpoint_on_cpu[gptq-...]assert None == 'cpu'— kwargs{'backend': GPTQ_TORCH, 'trust_remote_code': False}...[awq-...]{'backend': AWQ_TORCH, ...}...[paro-...]{'backend': PARO_CUDA, ...}...[gguf-...]{'backend': GGUF_TORCH, ...}Red run:
4 failed. Green run:16 passed. The assertion shows the load receiving nodeviceat all, which is exactly the reported defect.Real-device evidence (not the mock)
I quantized a real AWQ
format="gemv"checkpoint (Qwen2.5-0.5B-Instruct, 32 calibration rows,CUDA_VISIBLE_DEVICES=0so the accelerator is visible) and drove the load the export path performs:Before the fix,
export(..., "mlx")of that checkpoint on this GPU host failed with the reportedValueError. After the fix the same call gets past the load and stops at the MLX import, which is this host's limitation (below), not the device.Limit: the full conversion could not be exercised here.
mlx==0.32.4installs on this platform butimport mlx.corefails withlibmlx.so: cannot open shared object file, andmlx-corehas no wheel for this Python. Both packages were uninstalled afterwards, so the environment is back to its original state. The load is the half that failed, and that half is verified on a real checkpoint above.Kernel Accuracy Requirements
Not applicable — no kernel or numerics change. The export path does not run a quantized forward.
Logic Flow Documentation
Not applicable: this pins one argument on one existing load call. No stage is added or reordered, no dispatch table changes, and no fallback is introduced — the MLX branch already existed and already only reads host tensors.
Model Support / Module Plan
Not applicable — no
MODEL_MAPentry, definition or fusion config is touched.Review Requirements
test_export_mlx_forwards_trust_remote_code, same mocked-load style).GPTQModel.loadthe way the file already does.paro,gguf,gptq,awqGEMM and GEMV,nf12,macaqandfp8all resolve to a CPU-capable kernel fordevice=cpu(checked withselect_quant_linear).exl3usesBACKEND.EXL3_TORCH, the documented CPU/ROCm portable kernel, andbitsandbyteshas noselect_quant_linearentry to check here (the package is not installed on this host); both are unaffected by thehfpath.Notes
FORMAT.GEMV_FASTcould not be selected in isolation in aselect_quant_linearprobe because the checkpoint's ownpack_dtypeis required; the real end-to-end repro above usedFORMAT.GEMV. The two readers share the CPU-only declaration (gemv_awq.py:510,gemv_fast_awq.py:397/469) and the same export branch.