Repository navigation
fix(loader): keep the default layer-wise map inside one capability group (#4734) - #4744
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.devicewhen it held one card. A scalar reads as an abstract family downstream:_layerwise_device_countfinds no explicit list and falls back totorch.cuda.device_count(), sobuild_layerwise_device_mapspread 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 sawcuda:0and passed: the load succeeded because placement escaped the group, not because it stayed in it.Fix
_resolve_default_layerwise_devicenow 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 oncuda:0. Explicitdevice=/device_map/max_memoryand 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()withoutsingle_capability_group, which failed on main withTypeError. 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 usedcuda:0andcuda:1)[(8,9),(12,0),(8,9)]→["cuda:0","cuda:2"]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 pristineorigin/main(verified in a clean worktree).ruff check gptqmodel testsclean.Residual
deviceis now a 1-tuple rather than a scalar when it reachesselect_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.