Repository navigation
Description
Found on main @ e75181d, RTX 4090 + RTX 5090 (2 GPUs), torch 2.15 + CUDA 13.2, Python 3.14 (GIL on).
What is wrong
EXL3 quantization of any MoE model crashes in layer 0 on 2+ GPUs with the default auto_forward_data_parallel=True:
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:1!
gptqmodel/quantization/gptq.py:889 existing.add_(xtx) (GPTQ.add_batch)
gptqmodel/looper/exllamav3_processor.py:2419 capture.add_batch(...)
One GPU works, and so does auto_forward_data_parallel=False on the same two GPUs. Dense models are not affected.
Cause:
- For each routed expert, EXL3 pins the Hessian capture to an "owner" device:
exllamav3_processor.py:2306-2319→routed_expert_owner_devices(self.qcfg)→resolve_hessian_owner_device(...)→task.set_hessian_accumulator_device(owner_device). - Without
moe_vram_strategy_devices,routed_expert_owner_devices(exllamav3_processor.py:147-162) returns[as_torch_device(qcfg.device)]. For a quantize load,qcfg.deviceis the bare family (ModelLoader.from_pretrainedstrips ordinals,loader.py:~2310-2325).as_torch_devicekeeps it index-less on purpose ("honoring the caller's current CUDA device"), so every expert's owner istorch.device("cuda"). GPTQ.process_batch(gptq.py:1354-1361) then seescuda:1 != cuda, so it callsreshaped_inp.to("cuda")and keys the partial undertorch.device("cuda"). With data parallel, each replica forwards on its own worker thread with its own current device. The cuda:0 thread stores the"cuda"partial on cuda:0, and the cuda:1 thread's"cuda"xtx lands on cuda:1. They share the dict key, andexisting.add_(xtx)mixes devices.
So the routed-expert owner policy never assigns a concrete GPU, and the device the Hessian lands on depends on which thread ran. Even with auto_forward_data_parallel=False, all experts accumulate on the forward thread's current device instead of being spread round-robin.
Repro (public API)
olmoe2 / qmoe2 = OLMoE-1B-7B-0924 / Qwen1.5-MoE-A2.7B with num_hidden_layers=2 (config copy, same weights).
import json, gzip, torch
from gptqmodel import GPTQModel, CalibrationConfig
from gptqmodel.quantization.config import EXL3Config
calib = [t for t in (json.loads(l)["text"][:1500] for l in gzip.open("c4-train.00000-of-01024.json.gz", "rt")) if len(t) >= 1000][:16]
for dp in (True, False):
m = GPTQModel.load("olmoe2", quantize_config=EXL3Config(bits=4, auto_forward_data_parallel=dp), dtype=torch.bfloat16)
try:
m.quantize(CalibrationConfig(dataset=calib)); print(dp, "OK")
except Exception as e:
print(dp, "FAIL", type(e).__name__, e)Output:
CUDA_VISIBLE_DEVICES=<4090>,<5090> dp=True FAIL RuntimeError Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:1!
CUDA_VISIBLE_DEVICES=<4090>,<5090> dp=False OK
CUDA_VISIBLE_DEVICES=<4090> dp=True OK
qmoe2 (Qwen1.5-MoE, 2 GPUs, dp=True) FAIL RuntimeError (same)
A spy on GPTQ.process_batch shows the mixed key:
mlp.experts.0.gate_proj inp cuda:0 acc cuda key cuda xtx cuda:0
mlp.experts.0.gate_proj inp cuda:1 acc cuda key cuda xtx cuda:1 existing cuda:0 <- crash
For comparison, GPTQ, AWQ, QQQ, GPTAQ, FOEM and Paro quantize the same 2-layer OLMoE on the same two GPUs with data parallel, and they keep every routed token (single-GPU == 2-GPU counts).
Suggested fix
Resolve the owner list to concrete ordinals before choosing an owner. When qcfg.device is a bare family, use the quantize pool the looper already computed (ModuleLooper._moe_quant_devices, after compute_device_filter), or else the visible devices of that family. set_hessian_accumulator_device / process_batch should also refuse an index-less accelerator device, because a thread-relative device can never be a shared accumulator key.
Test that should have caught it
tests/test_exl3_rocm_moe_devices_4667.py checks only that the owner resolves to a torch.device. Add a node asserting that routed_expert_owner_devices returns indexed devices for the default config. Also add a 2-GPU smoke test (as in tests/test_dp_subset_early_stop_4904.py) that runs EXL3 on the tiny Qwen3-MoE fixture with auto_forward_data_parallel=True.
Severity
High for multi-GPU users: EXL3 cannot quantize any MoE model on 2+ GPUs with the default config (hard crash in layer 0). The workarounds are one GPU or auto_forward_data_parallel=False.
🤖 Generated with Claude Code
Activity
ZX-ModelCloud commentedon Nov 18, 2026
Agent claim released:
agent-65e889e3257afinished this issue.Pull request: #5144
Reproducing EXL3 MoE data-parallel Hessian owner device crash and checking whether main already fixed it
docs(multi-gpu): cite the EXL3 owner-device PR (#5093)
fix(exl3): give routed-expert Hessians a concrete owner device (#5093)
docs(multi-gpu): cite the EXL3 owner-device PR (#5093)
fix(exl3): give routed-expert Hessians a concrete owner device (#5093) (
test(exl3): inherit device visibility in the routed-owner regression (#…
refactor(moe): one Hessian-sharing path; DS4/GLM experts declare :in=x
refactor(moe): one Hessian-sharing path; DS4/GLM experts declare :in=x (