Skip to content

[BUG] Quantize with an explicit device sequence spanning two GPU generations (device=(0, 1) on 5090+4090) is refused by the inference-kernel capability check, although the default pool and compute_device_filter quantize on the same two GPUs fine #4875

Closed

Description

@Qubitium

Found on main @ 4f287eb, 2 GPUs visible: cuda:0 = RTX 5090 (sm_120), cuda:1 = RTX 4090 (sm_89).

What is wrong

Quantizing on a mixed-generation pool works. The default GPTQModel.load(model_id, QuantizeConfig(...)) quantizes on both the 5090 and the 4090, and so does a compute_device_filter that keeps both. But naming those same GPUs through the documented explicit-sequence route raises before the model is loaded:

GPTQModel.load(model_id, GPTQConfig(bits=4, group_size=128), device=("cuda:1", "cuda:0"))   # or device=(0, 1)
ValueError: Quantized kernel selection does not support a device map spanning different GPU compute capabilities: cuda:1=8.9, cuda:0=12.0. Place the model on one capability group with `device="cuda:N"`, a `max_memory` budget that names one card, or a `CUDA_VISIBLE_DEVICES` list.

docs/multi_gpu_quantization.md ("Explicit device sequences") says a tuple of ordinals constrains quantization to those devices, and that from_pretrained needs a sequence for this (device="cuda:N" does not constrain the quantization pool). The quantize path still applies the inference-only check to that sequence:

So on a mixed host, the only way to quantize on a chosen subset that spans two generations is compute_device_filter. For example, use the 5090 plus one of two 4090s, or leave a busy card out. The documented tuple route fails, and its error suggests device="cuda:N", which for from_pretrained does not restrict the pool at all.

Repro

import gzip, json, torch
from gptqmodel import GPTQModel, CalibrationConfig
from gptqmodel.quantization import GPTQConfig
calib = [...]  # 16 C4 texts
for name, lkw, ckw in [
    ("default", {}, {}),
    ("filter_both", {}, dict(compute_device_filter=lambda ds: [d for d in ds if d.index in (0, 1)])),
    ("tuple10", dict(device=("cuda:1", "cuda:0")), {}),
]:
    m = GPTQModel.load("Qwen2.5-0.5B-Instruct", GPTQConfig(bits=4, group_size=128, **ckw), dtype=torch.float16, **lkw)
    m.quantize(CalibrationConfig(dataset=calib))
    print(name, [torch.cuda.max_memory_allocated(i) >> 20 for i in range(2)],
          m.tokenizer.decode(m.generate(**m.tokenizer(["The capital of France is"], return_tensors="pt"), max_new_tokens=8, do_sample=False)[0][-8:]))

Output:

default      peak MiB [418, 386]  ' Paris. The capital of the United States'
filter_both  peak MiB [418, 386]  ' Paris. The capital of the United States'
tuple10      ValueError: Quantized kernel selection does not support a device map spanning different GPU compute capabilities: cuda:1=8.9, cuda:0=12.0 ...

device=("cuda:1",) and device=("cuda:0",) work. Their checkpoints are bitwise identical to CUDA_VISIBLE_DEVICES=<that GPU> runs, and the other GPU gets no context or allocations. Only multi-entry sequences that span capabilities are refused.

Suggested fix

Do not apply the capability check when the sequence describes a quantization pool. For example, give _explicit_requested_devices a validate_capability flag (family-only for from_pretrained and _quantize_warmup_devices), or validate only the family there. The kernel-selection check stays on the from_quantized / inference-map path, where it belongs.

Test that should have caught it

tests/test_default_device_mixed_capability_4705.py covers only the inference loader. Add a case with fake capabilities where from_pretrained(device=(0, 1)) builds the 2-device compute_device_filter without raising.

Severity

Low-medium: a documented placement API fails on mixed-generation hosts while the equivalent filter works.

🤖 Generated with Claude Code

Activity

  1. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Agent claim: agent-root-4875-device-seq is working on this issue now.

    Started 2026-11-17T18:28:50Z. The claim expires 4.0h after this comment was last edited (heartbeat). Other agents: do not start this issue while the claim is live.

    claiming: let an explicit quantize device sequence span compute capabilities; keep the single-capability check for the inference kernel selection

  2. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Agent claim released — fixed and merged.

    #4920 landed as 436053174 on main; the issue is closed.

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