Repository navigation
fix(loader): validate kernels against the max_memory devices, not every GPU (#4632) - #4637
Merged
Merged
Conversation
…ry GPU max_memory is the authoritative placement list (#4082), but kernel selection expanded the CUDA family to every visible GPU. On a mixed-generation host (RTX 5090 sm_120 + RTX 4090 sm_89) the capability check then rejected budgets that never touched the other card: max_memory={1: '20GiB'} and even a GPU+CPU offload budget with BACKEND.TORCH failed with cuda:0=12.0, cuda:1=8.9. Resolve max_memory to the concrete accelerator devices it names and hand that tuple to the layer-wise/kernel path, so the capability check only sees GPUs that will hold weights. Integer ordinals now resolve against the active accelerator instead of CPU when no device was passed, and a device that contradicts the budget is rejected with an actionable message. Issue #4632.
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.
Root cause
max_memoryis the authoritative placement list (#4082), but kernel selection ignored which devices it named:_resolve_max_memory_device()returnedNoneas soon as one non-CPU entry existed, so the loader fell through to_resolve_default_layerwise_device(device=None), which expands the CUDA family to every visible GPU;_validate_selector_device_familiesthen sawcuda:0=12.0, cuda:1=8.9on a 5090 + 4090 host and refused the load — including budgets that only ever touch one card ({1: "20GiB"},{0: "20GiB"}) and GPU+CPU offload budgets withBACKEND.TORCH.Integer
max_memoryordinals were also resolved against CPU when nodevice=was passed, so{1: "20GiB"}normalized tocpu:1and looked accelerator-free.Change (
gptqmodel/models/loader.py)_resolve_max_memory_device()now returns the tuple of concrete accelerator devices the budget names (deduplicated, in budget order) instead ofNone; CPU-only budgets still returnDEVICE.CPU._default_accelerator_family()) when nodevice=was given, and a clear error is raised if an ordinal is used on a host with no accelerator.device=that contradicts the budget is rejected: different family, or a concrete ordinal the budget does not fund. Matching requests are accepted._layerwise_device_count,_layerwise_device_stringsand the placement builder use exactly those devices.Tests
New
tests/test_max_memory_kernel_devices_4632.py(8 tests) fakes a 2-GPU host with capabilities(12,0)/(8,9)and runs the realfrom_quantizedchain (_resolve_max_memory_device→_resolve_default_layerwise_device→_validate_selector_device_families) for:{1: ...},{0: ...},{"cuda:1": ...},{0: ..., "cpu": ...}→ resolve to exactly(cuda:N,)and no longer raise;DEVICE.CPU; contradiction cases raise actionable errors.On unmodified
main6 of the 8 fail with the reportedcuda:0=12.0, cuda:1=8.9error; with the fix all 8 pass.tests/test_layerwise_device_placement.py::test_max_memory_with_an_accelerator_keeps_device_resolutionasserted the oldis Nonecontract; it is updated to the new resolved-tuple contract (same intent: an accelerator budget keeps going down the device path).Closes #4632.