Repository navigation
fix(load): let a quantize device sequence span GPU compute capabilities (#4875) - #4920
Merged
Merged
Conversation
…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.
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.
Summary
GPTQModel.load(model, GPTQConfig(...), device=(0, 1))on a 5090 + 4090 host raised before the model was loaded:…although the default pool and a
compute_device_filterthat keeps both GPUs quantize on exactly that pair, anddocs/multi_gpu_quantization.mddocuments 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
importer.normalize_device_device_mapvalidate_familieskeyword, defaultTrueloader._explicit_requested_devicesTrueModelLoader.from_pretrained(quantize)Falseauto._quantize_warmup_devicesFalse, and builds its candidates from the explicit sequence instead ofselect_forward_devices(which keeps only the first capability group)Every inference caller keeps the rule unchanged —
from_quantized, the layer-wise map resolvers andhf_loadall still raise for a mixed map.Measurements
5090 (cuda:0, sm_120) + 4090 (cuda:1, sm_89):
device=(0, 1)ValueErrorcompute_device_filtercovers bothdevice=("cuda:1", "cuda:0")ValueErrorquantize()ondevice=(0, 1)[406, 386](matches the default/filter runs in the issue)ValueErrorValueError(unchanged)Tests
New
tests/test_quantize_device_sequence_4875.py, three of four red on the parent commit:test_inference_sequence_still_requires_one_capabilitypasses 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.pystubs_explicit_requested_deviceswith a one-argument lambda; it now accepts the new keyword.ruff checkon the touched files: All checks passed.Logic Flow Documentation
docs/multi_gpu_quantization.mdgains 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.