Skip to content

[BUG] load(max_memory=...) validates kernels against every visible GPU instead of the budget's devices: mixed-arch hosts (4090+5090) refuse even single-GPU or GPU+CPU budgets #4632

Closed

Description

@Qubitium

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:

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

  1. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Taking this. max_memory is 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions