Skip to content

fix(loader): keep the default layer-wise map inside one capability group (#4734) - #4744

Merged
Qubitium merged 1 commit into
mainfrom
fix/issue-4734
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/issue-4734

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #4734 (completes #4714).

Problem

#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 finds no explicit list and 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: the load succeeded because placement escaped the group, not because it stayed in it.

Fix

_resolve_default_layerwise_device now returns the resolved group as an explicit sequence even when it holds one card (the multi-device case already returned a tuple). The map builder then sees one explicit target and places every layer on cuda:0. Explicit device=/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 that #4714 left calling expand_selector_device_family() without single_capability_group, which failed on main with TypeError. The stub now records the keyword, pinning that the default placement asks for one capability group.

Tests

tests/test_default_device_capability_group_map_4734.py (6 CPU-mocked):

  • [(8,9),(12,0)] → 1 target, ["cuda:0"]; fails on the parent commit (assert 2 == 1: map used cuda:0 and cuda:1)
  • [(8,9),(12,0),(8,9)] → ["cuda:0","cuda:2"]
  • homogeneous 2-GPU → both; single device → one; explicit homogeneous sequence keeps its span; explicit mixed span still raises.

Verified: new file + test_default_device_mixed_capability_4705, test_layerwise_device_placement, test_compute_device_filter, test_max_memory_kernel_devices_4632, test_tenstorrent_support → 190 passed, 15 skipped, 1 failed. The failure (test_calibration_hessian_strides_through_the_text) reproduces identically on pristine origin/main (verified in a clean worktree). ruff check gptqmodel tests clean.

Residual

  • CPU-mocked topology; not run on real 4090+5090 hardware.
  • In the default single-GPU case the resolved device is now a 1-tuple rather than a scalar when it reaches select_quant_linear/make_quant; the homogeneous multi-GPU path already passes N-tuples and the loader suites pass, but it is a shape change worth a reviewer's eye.

…oup (#4734)

#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.
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