Skip to content

fix(loader): keep the default placement inside one compute-capability group (#4705) - #4714

Merged
Qubitium merged 1 commit into
mainfrom
fix/default-device-mixed-capability-4705
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/default-device-mixed-capability-4705

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #4705.

Problem

With no device, device_map or max_memory, _resolve_default_layerwise_device() expanded the CUDA family to every visible GPU, and _validate_selector_device_families() then refused a map spanning different compute capabilities. On a host with an RTX 4090 next to an RTX 5090, the plainest call — GPTQModel.load(path) — always raised, even for a model that fits on one card. #4632 fixed only the max_memory path.

Fix

  • expand_selector_device_family(..., single_capability_group=False): when set, the expansion is filtered to the first device's compute-capability group before validation. Devices whose capability cannot be queried are kept; the function falls back to the unfiltered list rather than returning empty.
  • _resolve_default_layerwise_device() uses single_capability_group=True.
  • Explicit placement arguments (device=("cuda:0","cuda:1"), device_map, max_memory) are unchanged: they still span every GPU and still fail closed on a mixed map.
  • The refusal message now names remedies (device="cuda:N", max_memory, CUDA_VISIBLE_DEVICES).

Tests

tests/test_default_device_mixed_capability_4705.py (CPU, 6 tests):

  • mixed 12.0/8.9 default → (cuda:0,); fails on main with the capability error
  • homogeneous default → both GPUs
  • single visible GPU unchanged
  • explicit mixed placement still refused, message names the remedy
  • explicit single device unchanged
  • refusal message carries capabilities + remedies

Verified: PYTHONPATH=/root/work-4705 python -m pytest tests/test_default_device_mixed_capability_4705.py tests/test_layerwise_device_placement.py tests/test_compute_device_filter.py tests/test_kernel_device_error_reason.py -q -p no:randomly → 55 passed, 1 skipped. ruff check gptqmodel tests clean.

… group (#4705)

Without device/device_map/max_memory the loader expanded the CUDA family to
every visible GPU, and kernel selection refused any map spanning different
compute capabilities. On a 4090+5090 host GPTQModel.load(path) therefore
always raised, even for a model that fits on one card (#4632 only fixed the
max_memory path).

expand_selector_device_family() gains single_capability_group; the default
placement keeps the first device's capability group. Explicit placement
arguments still span every GPU and fail closed, now with actionable remedies.

Tests: tests/test_default_device_mixed_capability_4705.py (6 passed; 3 fail
on main for the intended reason), plus 49 existing placement/filter tests.
@Qubitium
Qubitium merged commit 60376e9 into main Nov 17, 2026
9 checks passed
@Qubitium
Qubitium deleted the fix/default-device-mixed-capability-4705 branch November 17, 2026 10:42
Qubitium added a commit that referenced this pull request Nov 17, 2026
…oup (#4734) (#4744)

#4714 kept kernel selection inside the first device's compute-capability group
but returned that group as a scalar torch.device when it held one card. A
scalar reads as an abstract family downstream: _layerwise_device_count falls
back to torch.cuda.device_count(), so build_layerwise_device_map spread decoder
layers over every visible GPU - including the generation the group excluded. On
a 4090 + 5090 host with one card per capability the mixed-capability guard only
saw cuda:0 and passed, so the load succeeded because placement escaped the
group, not because it stayed in it.

_resolve_default_layerwise_device now returns the resolved group as an explicit
sequence even when it holds one card, which is what the multi-device case
already did. The map builder then sees one explicit target and places every
layer on cuda:0. Explicit device sequences, device_map, max_memory and the
homogeneous multi-GPU case are unchanged; an explicit mixed span is still
refused.

Also fixes the Tenstorrent device-resolution test stub, which #4714 left
calling expand_selector_device_family() without its single_capability_group
keyword and so failed on main with TypeError. The stub now records the keyword,
which pins that the default placement asks for one capability group.

Tests: tests/test_default_device_capability_group_map_4734.py (6 CPU-mocked
tests). The one-GPU-per-capability case fails on the parent commit
(assert 2 == 1: the map would use cuda:0 and cuda:1) and passes with the fix;
the [8.9, 12.0, 8.9] host still maps to cuda:0 + cuda:2 and a homogeneous
2-GPU host still uses both.
Qubitium added a commit that referenced this pull request Nov 17, 2026
Fix the test-side fallout of #4716, #4657, #4627 and #4508. Only entries
that fail on this sm_80 host (PG506) and whose stated reasoning reproduces
were changed; the rest are recorded with their outcome.

1. 8587f0b (#4716, native FP8 GEMM for a wide bias)
   - tests/kernels/test_fp8_kernel.py::test_fp8_default_forward_is_w8a16
     REPRODUCED on sm_80: 6 bf16 cases failed with 1-ulp (0.0078125) diffs
     against rtol/atol 2e-3. The oracle now narrows the decoded weight to
     the activation dtype, matching the native path; the bound is the
     half-ulp at unity (2^-9 ~= 2e-3). FIXED.
   - tests/test_fp8_bias_range.py::test_fp8_gpu_dequant_fallback_keeps_bias_wide
     REPRODUCED on sm_80 (fp16: actual 0.0 vs oracle 0.0078125). Renamed to
     test_fp8_gpu_native_gemm_keeps_bias_wide and rewritten for the #3737
     intent: finite output, FP32 bias, residual bounded by one activation-
     dtype ulp of |x.w|. FIXED.

2. bf5adeb (#4657, Marlin bias kept in checkpoint order)
   - tests/test_marlin_scratch_cuda.py 288/200 cases REPRODUCED on sm_80:
     8 failed with "b_bias.size(0) != size_n". scripts/marlin_scratch_fixture.py
     now passes layer._kernel_bias(a) (padded, tile-ordered FP32) instead of
     the checkpoint-order layer.bias. FIXED (8 failed -> 68 passed, 2 skipped).

3. 60376e9 (#4714, default placement in one capability group)
   - tests/test_tenstorrent_support.py already passes on current main: the
     monkeypatched _record accepts **kwargs (fixed upstream by 50f1752).
     ALREADY PASSES on sm_80.

4. 34672a7 (#4585, modules snapshot the kernel policy)
   - tests/kernels/test_bitsandbytes_rocm_triton.py triton cases SKIP on
     sm_80 (no tuned bitsandbytes tile for this family). DEFERRED: the
     stated failure cannot be reproduced here.

5. dfa180d (#4627, GGUF path chosen from static gates)
   - both tests REPRODUCED on sm_80 with AttributeError
     _benchmark_forward_runner. The removed timing hook is no longer patched;
     each test asserts the hook stays absent. FIXED.

6. fd8d524 (#4599, AwqGEMVTorchLinear CPU reader)
   - both kernel-registry contract tests already pass on current main
     (AwqGEMVTorchLinear is in EXCLUDED and the ROCm audit table; fixed
     upstream by ab151fe). ALREADY PASSES on sm_80.

7. d2a0508 (#4283, dense-module adapters)
   - tests/kernels/test_gptq.py::TestKernelOutput errors on sm_80 before the
     adapter path: this host's flash_attn_2_cuda has an undefined symbol, so
     the stated Lora assertion is never reached. DEFERRED: blocked by the
     pre-existing host flash_attn failure; the fix cannot be verified here.

8. f201837 (#4508, activation-quantization wording)
   - both tests REPRODUCED on sm_80. The refusal still fires; the regex now
     matches "activation quantized|activation scales". FIXED.

9. b225a43 (#4727, static-cache compile test)
   - ROCm-only failure. On sm_80 the CUDA leg runs and fails earlier on the
     host flash_attn symbol, so the ROCm gate cannot be reproduced.
     DEFERRED.

Test run (GPU 4):
  tests/kernels/test_fp8_kernel.py tests/test_fp8_bias_range.py
  tests/test_marlin_scratch_cuda.py tests/test_marlin_scratch_benchmark.py
  tests/kernels/test_gguf_cpp_activation_quantization.py
  tests/kernels/test_gguf_cpp_path_selection.py tests/test_auto_module_decoder.py
  => 254 passed, 35 skipped, 1 failed.
The single failure is the pre-existing sm_80
test_fp8_w8a8_forward_is_batch_invariant (native torch._scaled_mm needs
sm_89+); it fails identically on origin/main.
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