Repository navigation
fix(looper): stage serial forward on the surviving filtered device - #3842
Merged
Merged
Conversation
ForwardExecutor.run applies compute_device_filter after select_forward_devices has expanded the base device to its family. When the filter leaves exactly one device, the serial fallback still received the pre-filter cur_layer_device, so inputs were staged and the module was rehomed on an excluded device. Pass the sole surviving filtered device to run_single. Keep cur_layer_device when the filtered list is empty, matching _filter_forward_devices' existing fallback. Fixes #3826.
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.
TL;DR
ForwardExecutor.run()filtered the forward device pool but still handed the pre-filtercur_layer_deviceto the serial fallback. One-line behavior fix plus a regression test; 3 files, +95/-1.1. The problem
select_forward_devices()expands a concrete device to its whole family.run()then appliescompute_device_filter, and when exactly one device survives it dispatches torun_single(). The old code passed the originalcur_layer_device, so a filter that excluded the base device had no effect on input staging, module rehome, or output placement.flowchart TD A["ForwardExecutor.run"] --> B["select_forward_devices cur_layer_device"] B --> C["_filter_forward_devices"] C --> D{"Filtered device count"} D -- "1" --> E["run_single cur_layer_device"] E --> F["Stage inputs and rehome module on pre-filter cur_layer_device"] classDef failure fill:#ffe8e8,stroke:#b30000,color:#111; class F failure;5853af0cf)gptqmodel/looper/forward_executor.py:232-248)run_single, butcur_layer_devicewas forwarded unchangedrun_singlereceivesdevices[0]from the filtered listForwardExecutor.run_single)ForwardExecutor.run_single)ForwardExecutor._filter_forward_devices)2. The new flow
flowchart TD A["ForwardExecutor.run"] --> B["select_forward_devices cur_layer_device"] B --> C["_filter_forward_devices"] C --> D{"Filtered device count"} D -- "0" --> E["Keep cur_layer_device"] D -- "1" --> F["single_device = devices[0]"] D -- "2+" --> G["run_parallel devices"] E --> H["run_single cur_layer_device"] F --> H H --> I["Stage inputs and rehome module on cur_layer_device"] classDef failure fill:#ffe8e8,stroke:#b30000,color:#111; class E failure;3. Failure and ambiguity contract
_filter_forward_deviceskeeps the unfiltered poolrun_parallelreceives the filtered list4. Change inventory
gptqmodel/looper/forward_executor.pyrun_singletests/test_compute_device_filter.pydocs/multi_gpu_quantization.md5. Tests
tests/test_compute_device_filter.py::test_serial_fallback_stages_on_sole_surviving_filtered_devicerun_singletests/test_compute_device_filter.pycasestests/module_tree/test_forward_executor_parallel.pycases6. Validation
observed=[('single', 'cuda:0')]; afterobserved=[('single', 'cuda:1')].pytest tests/test_compute_device_filter.py tests/module_tree/test_forward_executor_parallel.py— 6 passed.pytest tests/test_stage_modules.py— 49 passed.pytest tests/test_calibration_data_device.py— 22 passed.ruff check gptqmodel/looper/forward_executor.py tests/test_compute_device_filter.py— passed.tests/test_weight_only_looper.py::test_weight_only_looper_respects_dense_and_moe_vram_strategy_devicesfails on the unmodified base commit as well; unrelated to this change.Fixes #3826.