Skip to content

fix(load): let a quantize device sequence span GPU compute capabilities (#4875) - #4920

Merged
Qubitium merged 1 commit into
ModelCloud:mainfrom
Qubitium:fix/4875-quantize-device-seq
Nov 17, 2026
Merged

Qubitium merged 1 commit into
ModelCloud:mainfrom
Qubitium:fix/4875-quantize-device-seq

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

GPTQModel.load(model, GPTQConfig(...), device=(0, 1)) on a 5090 + 4090 host raised before the model was loaded:

ValueError: Quantized kernel selection does not support a device map spanning different GPU compute capabilities: cuda:0=12.0, cuda:1=8.9

…although the default pool and a compute_device_filter that keeps both GPUs quantize on exactly that pair, and docs/multi_gpu_quantization.md documents the tuple as the way to constrain the quantization pool. Closes #4875.

The single-capability rule exists because one inference kernel is selected for a whole placement map (#4632/#4705/#4734). A quantization load runs the dense model on CPU and selects no inference kernel for its pool, so the quantization entry points must not apply it.

Fix

site change
importer.normalize_device_device_map new validate_families keyword, default True
loader._explicit_requested_devices same keyword, default True
ModelLoader.from_pretrained (quantize) passes False
auto._quantize_warmup_devices passes False, and builds its candidates from the explicit sequence instead of select_forward_devices (which keeps only the first capability group)

Every inference caller keeps the rule unchanged — from_quantized, the layer-wise map resolvers and hf_load all still raise for a mixed map.

Measurements

5090 (cuda:0, sm_120) + 4090 (cuda:1, sm_89):

call before after
device=(0, 1) ValueError loads; compute_device_filter covers both
device=("cuda:1", "cuda:0") ValueError loads; filter covers both
quantize() on device=(0, 1) n/a completes, peak MiB [406, 386] (matches the default/filter runs in the issue)
inference map spanning both capabilities ValueError ValueError (unchanged)

Tests

New tests/test_quantize_device_sequence_4875.py, three of four red on the parent commit:

python -m pytest tests/test_quantize_device_sequence_4875.py -q
# 4 passed on the mixed 5090+4090 host; 3 passed + 1 skipped on a CPU-only host
# parent commit: test_quantize_sequence_may_span_capabilities,
#                test_quantize_warmup_accepts_a_mixed_sequence and
#                test_mixed_generation_sequence_loads_for_quantization fail

test_inference_sequence_still_requires_one_capability passes on both — it is the guard that the rule is still enforced where it belongs.

Related suites (CPU, this host):

python -m pytest tests/test_layerwise_device_placement.py tests/test_excluded_device_warmup.py \
    tests/kernels/test_selection.py tests/test_default_device_capability_group_map_4734.py -q
# 178 passed, 4 failed -- the same 4 in test_default_device_capability_group_map_4734.py
# fail on the unmodified parent commit here (they need real GPUs)

tests/test_excluded_device_warmup.py stubs _explicit_requested_devices with a one-argument lambda; it now accepts the new keyword.

ruff check on the touched files: All checks passed.

Logic Flow Documentation

docs/multi_gpu_quantization.md gains a paragraph: a quantization pool may span GPU generations; the single-capability rule is for inference kernel selection.

Model Support / Module Plan

Not applicable: no definition or plan change.

…es (ModelCloud#4875)

`GPTQModel.load(model, GPTQConfig(...), device=(0, 1))` on a 5090 + 4090 host
raised

    ValueError: Quantized kernel selection does not support a device map
    spanning different GPU compute capabilities: cuda:0=12.0, cuda:1=8.9

before the model was loaded, although the default pool and a
`compute_device_filter` keeping both GPUs quantize on exactly that pair.

The single-capability rule exists because one *inference* kernel is selected for
a whole placement map (ModelCloud#4632/ModelCloud#4705/ModelCloud#4734). A quantization load runs the dense
model on CPU and selects no inference kernel for its pool, so the quantization
entry points now skip that validation:

* `normalize_device_device_map` and `_explicit_requested_devices` take
  `validate_families`, defaulting to `True` so every inference caller keeps the
  rule.
* `ModelLoader.from_pretrained` (quantize) passes `False`, as does the prewarm
  resolver `_quantize_warmup_devices`.
* `_quantize_warmup_devices` now builds its candidates from the explicit
  sequence instead of `select_forward_devices`, which keeps only the first
  capability group and would have warmed one of the two GPUs.

Measured on 5090 (cuda:0, sm_120) + 4090 (cuda:1, sm_89):

| call | before | after |
| --- | --- | --- |
| `device=(0, 1)` | ValueError | loads, filter covers both |
| `device=("cuda:1", "cuda:0")` | ValueError | loads, filter covers both |
| quantize on `device=(0, 1)` | n/a | completes, peak MiB [406, 386] |
| inference map spanning both | ValueError | ValueError (unchanged) |

Regression tests: `tests/test_quantize_device_sequence_4875.py` pins the
inference guard, the quantize allowance, the prewarm pool and an end-to-end load
on a mixed host. Three of the four fail on the parent commit.

`tests/test_excluded_device_warmup.py` stubs `_explicit_requested_devices` with a
one-argument lambda; it now accepts the new keyword.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant