Repository navigation
fix(exl3): give routed-expert Hessians a concrete owner device (#5093) - #5144
Merged
Merged
Conversation
EXL3 pins each routed expert's shared Hessian accumulator to an "owner" device. With the default config the owner list came from the bare `qcfg.device` family, and `as_torch_device` keeps families index-less on purpose. `GPTQ.process_batch` then moved every partial to `"cuda"` -- the calling worker's current GPU -- while keying it under `"cuda"`, so with `auto_forward_data_parallel=True` the cuda:1 worker added its partial to the cuda:0 tensor and layer 0 failed with "Expected all tensors to be on the same device". Resolve ownership to concrete ordinals: - `routed_expert_owner_devices` prefers the configured `moe_vram_strategy_devices`, then the looper's resolved MoE pool (`_moe_quant_devices`, after `compute_device_filter`), then expands a bare `qcfg.device` family to the runtime's visible ordinals. - `ModuleLooper` binds that pool to processors that own per-device capture state, so capture stays on the devices the run may use. - `GPTQ.set_hessian_accumulator_device` rejects an index-less accelerator device, since it can never name a shared accumulator key. The serial forward now also spreads experts round-robin instead of accumulating everything on the forward thread's current device.
ZX-ModelCloud
force-pushed
the
fix/exl3-moe-dp-hessian-owner-5093
branch
from
November 18, 2026 06:03
75445dd to
8fb800e
Compare
Qubitium
marked this pull request as ready for review
November 18, 2026 06:04
This was referenced Nov 18, 2026
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
Fixes #5093.
EXL3 pinned each routed expert's shared Hessian accumulator to an "owner"
device, but with the default config the owner list came from the bare
qcfg.devicefamily (exllamav3_processor.py:147-162), whichas_torch_devicekeeps index-less on purpose.GPTQ.process_batch(
gptq.py:1356-1361) then moved every partial totorch.device("cuda")--the calling worker's current GPU -- while keying it under
"cuda". Withauto_forward_data_parallel=Truethe cuda:1 worker added its partial to thecuda:0 tensor and layer 0 failed with
Expected all tensors to be on the same device. Dense models never reach this path, which is why they were fine.The owner list now resolves to concrete ordinals, so every worker accumulates
into the same device-keyed entry.
What Changed
routed_expert_owner_devicesnow prefers the configuredmoe_vram_strategy_devices, then the looper's resolved MoE pool(
ModuleLooper._moe_quant_devices, aftercompute_device_filter), andfinally expands a bare
qcfg.devicefamily to the runtime's visibleordinals. Indexed and CPU entries are preserved.
ModuleLooperbinds that pool to processors that own per-device capturestate via
EXL3Processor.bind_moe_quant_devices, so capture stays on thedevices the run is allowed to use.
GPTQ.set_hessian_accumulator_devicerejects an index-less acceleratordevice. A thread-relative device can never name a shared accumulator key;
failing at preprocess names the module instead of crashing in layer 0.
auto_forward_data_parallel=False) now also spreadsexperts round-robin instead of accumulating everything on the forward
thread's current device. The reduced sum is unchanged.
docs/multi_gpu_quantization.mddocuments the ownership flow.No API change: the public config surface is unchanged.
Tests
The two-device tests skip when fewer than two CUDA devices are visible; the
runs above had two and skipped nothing.
Red evidence, same test file on a worktree at the pre-fix revision:
Green behavior on two CUDA devices with the default
auto_forward_data_parallel=True: quantization completes, owners arecuda:0andcuda:1, all 24 routed projections captured 128 tokens, and thelayer-0 Hessian (whose inputs come from the dense embeddings) matches the
serial capture with a normalized error <= 4.3e-8. Single-device and serial
controls also complete.
Model Support / Module Plan
Not applicable: no new model, alias, definition or module-plan change.
AWQ onboarding safety
Not applicable: no AWQ grouping, search, replay or fold change.
Logic Flow Documentation
This change alters owner resolution, a device boundary, and tensor lifecycle,
so the diagrams and the mechanism page are included.
flowchart TD A["EXL3Processor.preprocess<br/>routed expert identity"] --> B{"moe_vram_strategy_devices configured"} B -- "yes" --> C["as_torch_device per entry"] B -- "no" --> D{"looper MoE pool bound"} D -- "yes" --> E["ModuleLooper._moe_quant_devices<br/>after compute_device_filter"] D -- "no" --> F["qcfg.device through as_torch_device"] C --> G["_expand_family_owner_devices<br/>cuda becomes cuda:0 .. cuda:N-1"] E --> G F --> G G --> H["resolve_hessian_owner_device<br/>expert_index modulo len devices"] H --> I["GPTQ.set_hessian_accumulator_device"] I --> J["process_batch moves the batch to the owner<br/>and keys the partial under that device"] I -. "index-less accelerator" .-> X["ValueError: concrete ordinal required"] style X fill:#f8d7da,stroke:#c82333[as_torch_device(qcfg.device)], index-less (exllamav3_processor.py:147-162)"cuda"(its GPU) but keys it under"cuda"(gptq.py:1356-1361)existing.add_(xtx)mixescuda:0withcuda:1(gptq.py:889)add_runs on one deviceValueErrorat preprocess naming the moduleThe same diagram and the before/after table are in
docs/multi_gpu_quantization.md#routed-expert-hessian-ownership-exl3, which islinked from the README's multi-GPU entry.
Review Requirements
Kernel Accuracy Requirements
Not a kernel change. The capture split is validated against the serial
capture: the layer-0 Hessian (inputs from the dense embeddings, so independent
of quantization) has a normalized error <= 4.3e-8, and every routed projection
records the same per-module sample count.
Notes
the already-quantized layer 0, and data-parallel quantization is not
bit-identical to the serial path (documented in
docs/multi_gpu_quantization.md), so their inputs legitimately differ.ValueErrorguard is defense in depth: the resolver no longer producesan index-less accelerator owner, but a future caller that bypasses it fails
early with the module name.