Repository navigation
Description
Found on main @ 597b39b, RTX 5090 (sm_120) + RTX 4090 (sm_89) visible as cuda:0 / cuda:1, CUDA 13.2, torch 2.15.
What is wrong
GPTQModel.load(quantized_ckpt, max_memory=...) ignores which devices the budget names when it picks the kernel-selection device set. Any max_memory that contains an accelerator entry falls through to the "all visible GPUs" path:
gptqmodel/models/loader.py:2343_resolve_max_memory_device()returnsNoneas soon as one non-CPU entry exists (it only special-cases CPU-only budgets, [BUG] Follow-up on #4071/#4082/#4083/#4085: AWQ batch_size>1 crash (regression), CPU AUTO kernels corrupt state_dict (inf/NaN), v1<->v2 state_dict copy, PEFT on Marlin, HF random weights for exl3/gguf, MLX batched generate #4091 item 7).requested_device_mapisNonefor amax_memoryload, soloader.py:2361calls_resolve_default_layerwise_device(device=None, ...). That expands the CUDA family to every visible GPU (loader.py:689,expand_selector_device_family).importer.py:1008-1030_validate_selector_device_familiesthen sees cuda:0=12.0 and cuda:1=8.9 and raises.
So on a host with two different GPU generations (a common 4090 + 5090 workstation), every max_memory load fails, including:
- a budget that names one GPU only (
{1: "20GiB"},{0: "20GiB"}); - a GPU + CPU offload budget, even with the portable
BACKEND.TORCH.
The equivalent placement through device="cuda:1" or an explicit device_map dict works, because those paths use the devices that were actually named. On a uniform-arch host the same code still validates kernels against GPUs that the budget excludes, but the refusal does not show there.
Repro
import torch
from gptqmodel import GPTQModel, BACKEND
P = "Llama-3.2-1B-Instruct-GPTQ-4bits-gp128" # any GPTQ checkpoint
print([torch.cuda.get_device_capability(i) for i in range(torch.cuda.device_count())])
for kw in (dict(device="cuda:1"), dict(max_memory={1: "20GiB"}), dict(max_memory={0: "20GiB"}),
dict(max_memory={0: "600MiB", "cpu": "20GiB"}, backend=BACKEND.TORCH)):
try:
m = GPTQModel.load(P, **kw)
print("OK ", kw, sorted({str(p.device) for p in m.model.parameters()}))
except Exception as e:
print("FAIL", kw, type(e).__name__, str(e)[:160])Output:
[(12, 0), (8, 9)]
OK {'device': 'cuda:1'} ['cuda:1']
FAIL {'max_memory': {1: '20GiB'}} ValueError Quantized kernel selection does not support a device map spanning different GPU compute capabilities: cuda:0=12.0, cuda:1=8.9.
FAIL {'max_memory': {0: '20GiB'}} ValueError Quantized kernel selection does not support a device map spanning different GPU compute capabilities: cuda:0=12.0, cuda:1=8.9.
FAIL {'max_memory': {0: '600MiB', 'cpu': '20GiB'}, 'backend': <BACKEND.TORCH: 'torch'>} ValueError Quantized kernel selection does not support a device map spanning different GPU compute capabilities: cuda:0=12.0, cuda:1=8.9.
Suggested fix
max_memory is already treated as the authoritative device list for placement (#4082). Use the same list for kernel selection. When the budget has accelerator entries, resolve device to the tuple of those concrete devices, e.g. tuple(torch.device(f"cuda:{i}") for i in budget accelerator keys), instead of expanding the family. CPU entries only set cpu_offload, as they do today. The mixed-capability check then runs on the GPUs that will actually hold weights, so a single-GPU budget never sees the other card.
Test that should have caught it
tests/kernels/test_selection.py already monkeypatches mixed capabilities for device_map. Add a case for ModelLoader.from_quantized(max_memory={1: ...}) with fake capabilities (8,0)/(9,0). It should resolve to (cuda:1,) and not raise. A {0: ..., "cpu": ...} variant should select a CPU-offload-capable kernel for cuda:0 only.
Severity
Medium. It is a hard failure of a documented placement API on mixed-generation multi-GPU hosts, and the only workaround is to drop max_memory (which loses CPU offload budgeting) or to mask GPUs with CUDA_VISIBLE_DEVICES.
🤖 Generated with Claude Code
Activity
Qubitium commentedon Nov 17, 2026
Taking this.
max_memoryis already the authoritative placement list (#4082), so kernel selection will use exactly the accelerator devices the budget names instead of expanding the CUDA family, with a regression test for mixed-capability hosts.fix(loader): validate kernels against the max_memory devices, not eve…
fix(loader): keep the default placement inside one compute-capability…
fix(load): let a quantize device sequence span GPU compute capabiliti…
fix(hf): resolve an accelerate keyword map before validating capabili…