Skip to content

[BUG] AWQ + moe_vram_strategy=BALANCED (the documented multi-GPU MoE config) crashes in layer 0 on every MoE model: the norm-anchored scale group spans experts on both GPUs and _accumulate_awq_weight_mean adds across devices #5104

Closed

Description

@Qubitium

Found on main @ e75181d, RTX 4090 + RTX 5090 (2 GPUs), torch 2.15 + CUDA 13.2. Same result on Python 3.14 with the GIL on and on free-threaded 3.14t with PYTHON_GIL=0.

What is wrong

AWQ crashes in layer 0 on every MoE model when the balanced MoE device pool from docs/multi_gpu_quantization.md is configured (moe_vram_strategy=VramStrategy.BALANCED, with or without moe_vram_strategy_devices=["cuda:0", "cuda:1"]):

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:1!
  awq_processor.py:3420 _search_best_scale -> w_mean = _compute_awq_weight_mean(layers, group_sizes)
  awq_processor.py:164  _accumulate_awq_weight_mean -> w_sum += weight_abs.sum(dim=0, dtype=torch.float32)

Cause:

  • stage_subset.py:~548-562 places MoE work round-robin per expert (moe_groups keyed by expert) across the MoE pool.
  • AWQ's scale-search group for a MoE block is anchored on the shared post_attention_layernorm. It contains the gate/up projections of all experts: 128 linears for OLMoE (64 experts), 122 for Qwen1.5-MoE. Those now sit on both GPUs.
  • _accumulate_awq_weight_mean (awq_processor.py:124-165) allocates w_sum on layers[0]'s device and adds every other layer's weight sum into it without moving it. The later per-group steps (activation mean, scale search over the group) make the same single-device assumption.

GPTQ, QQQ and EXL3 with the same balanced config quantize the same 2-layer models on these two GPUs and keep every routed token. AWQ with the default (exclusive) strategy on 2 GPUs also works. Only AWQ + balanced fails.

Repro

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 AWQConfig, VramStrategy
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]
qc = AWQConfig(bits=4, group_size=128, device="cuda:0",
               moe_vram_strategy=VramStrategy.BALANCED, moe_vram_strategy_devices=["cuda:0", "cuda:1"])
m = GPTQModel.load("olmoe2", qc, dtype=torch.bfloat16)
m.quantize(CalibrationConfig(dataset=calib))

Output (spy on _accumulate_awq_weight_mean):

SPAN 128 layers on ['cuda:0', 'cuda:1']   (olmoe2: experts.*.gate_proj + experts.*.up_proj, norm-anchored group)
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:1!
qmoe2: SPAN 122 layers on ['cuda:0', 'cuda:1'] -> same RuntimeError
config (2 GPUs, olmoe2) result
GPTQ / QQQ / EXL3 + moe_vram_strategy="balanced" OK
AWQ default (exclusive) OK
AWQ + moe_vram_strategy="balanced" (GIL on, and 3.14t PYTHON_GIL=0) crash in layer 0

Suggested fix

For AWQ, either keep every member of a scale-search group on one device (for a norm-anchored MoE group, the reductions can gather onto the group's input device), or make the group reductions device-aware. For example, accumulate w_sum on the activation's device with weight_abs.sum(0).to(w_sum.device), and apply/evaluate scales per member on that member's device. At minimum, refuse moe_vram_strategy=BALANCED for AWQ with a clear message instead of crashing after calibration capture.

Test that should have caught it

No test combines AWQ with moe_vram_strategy. Add a 2-GPU node (tiny Qwen3-MoE fixture from tests/test_dp_subset_early_stop_4904.py) that runs AWQConfig(moe_vram_strategy="balanced"), and a CPU unit test that feeds _compute_awq_weight_mean layers on two devices.

Severity

Medium-high: the multi-GPU MoE configuration the docs recommend cannot be used with AWQ (hard crash in layer 0, after input capture).

🤖 Generated with Claude Code

Activity

  1. ZX-ModelCloud commented on Nov 18, 2026

    @ZX-ModelCloud
    Collaborator

    Agent claim released: agent-c8b91a8dccb6 finished this issue.

    Pull request: #5177

    Reproducing AWQ + balanced MoE device pool crash on the norm-anchored per-expert scale group

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions