Skip to content

fix(gptqmodel engine): stop passing device_map= to GPTQModel.load; use placement= - #154

Merged
Qubitium merged 1 commit into
mainfrom
fix/gptqmodel-placement-kwarg
Dec 2, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/gptqmodel-placement-kwarg

Conversation

@Qubitium

@Qubitium Qubitium commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #153
Related: ModelCloud/GPTQModel#6511

Root cause

load_gptqmodel_runtime always passed device_map=config.device_map to GPTQModel.load. GPT-QModel's weight_loader migration (ModelCloud/GPTQModel#6473) rejects every Accelerate placement keyword, including device_map=None, so every GPTQModel engine build raised TypeError before loading.

Change

New _gptqmodel_placement_kwargs builds the placement keywords:

flowchart TD
    A["load_gptqmodel_runtime"] --> B{"config.device_map is None?"}
    B -- yes --> C["device=resolved device (no device_map key)"]
    B -- no --> D{"GPTQModel.load signature has placement?"}
    D -- yes --> E["placement=device_map ('auto' -> 'accel:auto')"]
    D -- no --> F["device_map=device_map (older GPT-QModel)"]
    E --> G["device=config.device only if set"]
    F --> G
Loading

Old flow: always device_map=config.device_map plus device= when device_map was None or device was set. The device= rule is unchanged.

Tests

  • test_load_gptqmodel_runtime_uses_quantized_loader: no longer expects a device_map=None key.
  • New test_load_gptqmodel_runtime_uses_placement_with_weight_loader_gptqmodel (4 cases: default, "auto", device string + device, mapping) against a load stand-in with the current GPT-QModel signature that rejects device_map.
  • New test_load_gptqmodel_runtime_keeps_device_map_for_legacy_gptqmodel: older signature still receives device_map.
Check Before fix After fix
pytest --noconftest tests/test_gptqmodel_engine.py -k "not can_generate" 5 failed (TypeError: GPTQModel.load() does not accept device_map), 9 passed 14 passed
Real GPT-QModel main (c649fcb5f) + ModelCloud/Llama-3.2-1B-gptqmodel-ci-4bit on an RTX 4090, evalution.GPTQModel(device="cuda:0").build(...) then generate TypeError 'Paris, 1.5', input device cuda:0
Same with device_map="auto" TypeError 'Paris, 1.5' (placement accel:auto)
GPT-QModel tests/test_requant_embed_lm_head_e2e.py (Evalution-backed ARC eval) 1 failed (TypeError) 1 passed (490 s)

Skips / not verified:

  • The suite's conftest requires a free-threaded Python with PYTHON_GIL=0; the test host env is a GIL build, so the unit file ran with --noconftest.
  • test_gptqmodel_engine_can_generate_and_score_on_cuda requests flash_attention_2, which is not installed here; after the fix it gets past GPTQModel.load and stops at the FlashAttention import (before the fix it failed at the TypeError).
  • Legacy GPT-QModel (with device_map) checked only with the signature stand-in, not a real older release.

🤖 Generated with Claude Code

…e placement= (#153)

GPT-QModel's weight_loader migration (ModelCloud/GPTQModel#6473) makes
GPTQModel.load reject Accelerate placement keywords, including
device_map=None, so every GPTQModel engine build raised TypeError.

Default loads now pass only device=. An explicit device_map becomes
placement= when GPTQModel.load accepts it ('auto' -> 'accel:auto');
older GPT-QModel releases without placement= still get device_map.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Qubitium
Qubitium marked this pull request as ready for review December 2, 2026 03:51
@Qubitium
Qubitium merged commit 45f3485 into main Dec 2, 2026
2 checks passed
@Qubitium
Qubitium deleted the fix/gptqmodel-placement-kwarg branch December 2, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GPTQModel engine passes device_map= to GPTQModel.load, which GPT-QModel main now rejects (TypeError)

1 participant