You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Regression from #6274+#6253: published pre-7.3.4 GPTQ checkpoints fail with device_map="auto" + max_memory offload (ValueError: GPTQ Marlin requires CUDA tensors, got cpu) #6383
A published GPTQ v1 checkpoint (ModelCloud/DeepSeek-R1-Distill-Qwen-7B-gptqmodel-4bit-vortex-v1, meta.quantizer: ["gptqmodel:1.7.4"], checkpoint_format: "gptq", bits=4, group_size=32, desc_act=true, sym=true) loads fine with device_map="cpu" but fails with device_map="auto" + max_memory offload on main (3082b02d0):
The same checkpoint on 0dd8e8ab (before today's 12-PR merge wave) loads and runs: offload OK {'TorchLinear': 196}.
Mechanism
#6274's per-layer dispatcher now keeps the AUTO kernel for group-aligned layers, so an offloaded layer is a real MarlinLinear instead of the shape-blind TorchLinear fallback. #6253's _reselect_offloaded_marlin_kernels is supposed to swap such a layer for an offload-safe kernel, but at reselect time the layer is still a meta placeholder, hf_device_map is not attached yet, and there is no _h_f_hook, so:
_marlin_needs_offload_kernel(meta=True)
-> _marlin_offload_needs_reselection()
-> _layer_offload_hook() raises RuntimeError # no hook yet
-> except RuntimeError: return False # "bridge does not own the map"
it declines to reselect. _post_init_cpu_offloaded_marlin then sees a payload that is no longer meta (materialized onto the CPU device), finds no hook, and takes its resident path -> module.post_init() on CPU tensors -> Marlin rejects.
Reproduction (no download needed if the checkpoint is cached)
A 1-layer synthetic equivalent also reproduces (quantize a tiny Llama with QuantizeConfig(bits=4, group_size=32, sym=True, desc_act=False), BACKEND.GPTQ_TORCH, save, then set checkpoint_format: "gptq" and meta.quantizer: ["gptqmodel:1.7.4"] in both quantize_config.json and config.json).
Scope
Any pre-7.3.4 GPT-QModel GPTQ checkpoint (a large share of the Hub) whose layer widths are group-aligned, loaded with device_map="auto" + max_memory. Third-party (AutoGPTQ) v1 checkpoints are affected the same way, because they have no meta.quantizer and take the same "cannot prove it is current" branch.
Suggested direction
_marlin_needs_offload_kernel must not conclude "the bridge does not own the map" from a missing hook when the payload is still meta and no device map is attached — that state is transient (Accelerate resolves max_memory after the kernel is selected). Either reselect when the resolved execution device is CPU even for a meta payload, or make _post_init_cpu_offloaded_marlin refuse to run post_init() on a CPU-resident Marlin layer and reselect there.
Fixed by #6391 (merged as c32f2b346). Re-measured on that commit with the published checkpoint: both the disk-offload (350MiB) and mixed (1GiB) max_memory maps now load with TorchLinear x196, matching 0dd8e8ab. A separate case (max_memory={0: "3GiB"}) still fails with ValueError: qzeros is on the meta device — that is #6274's deferred-qzeros-at-dispatch-time issue, tracked separately.
The report conflated three independent defects that only appear together on a published pre-7.3.4 GPTQ checkpoint + device_map="auto" + max_memory:
#
defect
fix
1
a resident-CPU layer kept MarlinLinear because the offload test looked at checkpoint_payload_is_meta() (True only because the deferredqzeros is meta) → ValueError: GPTQ Marlin requires CUDA tensors, got 'cpu'
after reselect, the portable kernel inherited Marlin's tile-layoutqzerosParameter, and _materialize_hf_sym_qzeros emptied it → IndexError on the first forward
a matching-width qzeros was still deferred to meta and never loaded, so accelerate.dispatch_model's init_hook raised qzeros is on the meta device, we need a 'value' to put in on 0 on any GPU/disk placement
loads, 196× MarlinLinear, no metaqzeros, finite forward
same
{0:"1GiB"}
loads, 196× TorchLinear, no metaqzeros
Llama-3.2-1B-…-vortex-v1 (gptqmodel:1.1.0)
{0:"1GiB"}
loads, 112× MarlinLinear, finite forward
same
{0:"350MiB"} + offload_folder
loads, 112× TorchLinear, finite forward
same
device_map="cpu"
loads, 112× TorchCpuAvx512Linear, finite forward
Floor-width control (out_features % 32 != 0) still defers and still rebuilds correctly; current >=7.3.4 checkpoints never take the legacy path.
One caveat worth recording: for a floor-width legacy checkpoint on a CPU/disk-offloaded layer, the documented refusal still fires:
RuntimeError: a legacy floor-width symmetric GPTQ checkpoint cannot be materialized on a
CPU/disk-offloaded layer. Load it with offload_state_dict=False and a resident device map.
Note that offload_state_dict=False is not actionable on transformers 5.23 (it pops and ignores that kwarg in modeling_utils.py), so only the "resident device map" half of that advice works. That is unchanged by these fixes and is the intended fail-closed behaviour rather than a silent wrong result.
Activity
Qubitium commentedon Nov 29, 2026
Fixed by #6391 (merged as
c32f2b346). Re-measured on that commit with the published checkpoint: both the disk-offload (350MiB) and mixed (1GiB)max_memorymaps now load withTorchLinearx196, matching0dd8e8ab. A separate case (max_memory={0: "3GiB"}) still fails withValueError: qzeros is on the meta device— that is #6274's deferred-qzeros-at-dispatch-time issue, tracked separately.Merge origin/main into fix/6383-reselected-qzeros
Qubitium commentedon Nov 29, 2026
Fixed by three merged PRs. Closing.
What was actually broken
The report conflated three independent defects that only appear together on a published pre-7.3.4 GPTQ checkpoint +
device_map="auto"+max_memory:MarlinLinearbecause the offload test looked atcheckpoint_payload_is_meta()(True only because the deferredqzerosis meta) →ValueError: GPTQ Marlin requires CUDA tensors, got 'cpu'c32f2b346)qzerosParameter, and_materialize_hf_sym_qzerosemptied it →IndexErroron the first forward407298ad2)qzeroswas still deferred tometaand never loaded, soaccelerate.dispatch_model'sinit_hookraisedqzeros is on the meta device, we need a 'value' to put in on 0on any GPU/disk placement203031939)Defect 3 was filed separately as #6396 and is fixed there; defects 1 and 2 are the two halves of this report.
Verification on
main=407298ad2GPU (RTX 4090,
CUDA_VISIBLE_DEVICES=1):Real published checkpoints, via
transformers.AutoModelForCausalLM.from_pretrained:DeepSeek-R1-Distill-Qwen-7B-gptqmodel-4bit-vortex-v1(gptqmodel:1.7.4){0:"3GiB","cpu":"14GiB"}MarlinLinear, nometaqzeros, finite forward{0:"1GiB"}TorchLinear, nometaqzerosLlama-3.2-1B-…-vortex-v1(gptqmodel:1.1.0){0:"1GiB"}MarlinLinear, finite forward{0:"350MiB"}+offload_folderTorchLinear, finite forwarddevice_map="cpu"TorchCpuAvx512Linear, finite forwardFloor-width control (
out_features % 32 != 0) still defers and still rebuilds correctly; current >=7.3.4 checkpoints never take the legacy path.One caveat worth recording: for a floor-width legacy checkpoint on a CPU/disk-offloaded layer, the documented refusal still fires:
Note that
offload_state_dict=Falseis not actionable on transformers 5.23 (it pops and ignores that kwarg inmodeling_utils.py), so only the "resident device map" half of that advice works. That is unchanged by these fixes and is the intended fail-closed behaviour rather than a silent wrong result.