[Bug] MiniMax-M2.5 W8A8: `weight_scale` contains NaN/inf and many exact zeros (dead expert channels?), which collapses logits to token 0 on some backends

未关闭
#41 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python, pytorch

调研方向

Start from the report's own repro: open model-00001-of-00047.safetensors with safetensors.safe_open and re-run the scan over every weight_scale key to confirm the NaN/inf/exact-zero counts. Then compare the checkpoint names (model.layers.N.block_sparse_moe.experts.<i>.w1|w2|w3) with the runtime model.layers.N.mlp.experts path and the compressed-tensors quant config. Done means a maintainer decision on re-exporting the W8A8 checkpoint with clamped scales, plus a model-card note on expert naming; the backend NaN in section 3 is separate work.

由索引模型根据 Issue 内容生成。

描述

[Bug] MiniMax-M2.5 W8A8: weight_scale contains NaN/inf and many exact zeros (dead expert channels?), which collapses logits to token 0 on some backends

TL;DR

While bringing up MiniMax-M2.5 (W8A8, RedHat/Neural-Magic quantized) on a non-NVIDIA backend, the model produced only token id 0 (\u0000). The immediate cause was that 1 / weight_scale produced inf/NaN for a subset of expert channels. Scanning the checkpoint shows those scales really do contain NaN, inf and a lot of exact zeros — so the issue is in the checkpoint (and possibly in the base model's dead channels), not only in the loader.

Environment

Item Value
Model MiniMax-M2.5 (MiniMaxM2ForCausalLM), 62 layers, hidden 3072, 256 experts, top-k 8, moe_intermediate 1536, sigmoid routing, 192K ctx
Checkpoint MiniMax-M2.5-quantized.w8a8 (RedHat / Neural Magic), compressed-tensors INT8, 47 shards / 217 GB
Runtime vLLM 0.25.1 + Kunlun P800 (XPU) plugin, torch 2.9.0, driver 5.0.21.47
Also tested bf16 checkpoint (125 shards / 426 GB)

Findings 1 and 2 below are checkpoint-level and backend-independent (I verified them by reading the safetensors directly, no inference involved). Finding 3 is backend-specific and included only as context.

1. weight_scale tensors contain NaN, inf and a large number of exact zeros

Full scan of all 47 shards (47,616 scale tensors, 97,517,568 elements):

tensors: 47,616
elements: 97,517,568
exact zeros: 193,518   (0.20 %)
inf:              4
NaN:            400     across 12 tensors
tensors with >50 % zeros: 100

Examples (layer 0):

model.layers.0.block_sparse_moe.experts.16.w1.weight_scale    -> 97 NaN
model.layers.0.block_sparse_moe.experts.198.w1.weight_scale   -> 2 NaN
model.layers.0.block_sparse_moe.experts.198.w2.weight_scale   -> 2 NaN
model.layers.0.block_sparse_moe.experts.110.w1.weight_scale   -> 846 / 1536 zeros
model.layers.0.block_sparse_moe.experts.110.w2.weight_scale   -> 1705 / 3072 zeros
model.layers.0.block_sparse_moe.experts.110.w3.weight_scale   -> 879 / 1536 zeros

Repro (no GPU needed):

from safetensors import safe_open
import torch
f = "model-00001-of-00047.safetensors"
with safe_open(f, framework="pt", device="cpu") as sf:
    for k in sf.keys():
        if "weight_scale" in k:
            t = sf.get_tensor(k).float()
            print(k, int((t == 0).sum()), int(torch.isnan(t).sum()), int(torch.isinf(t).sum()))

2. Effect on inference

Any loader that computes dequant = int8_weight * (1 / weight_scale) turns those channels into inf, then a matmul turns them into NaN, and greedy decoding collapses to token 0 for every position (with logprobs contains 'Out of range float values'). Sanitizing the scales fixes it:

torch.nan_to_num_(scale, nan=0.0, posinf=0.0, neginf=0.0)
scale.clamp_(min=1e-6)

After that the model answers normally (13/19 on our fixed math/reasoning probe).

Question: are the NaN/inf entries and the 60 %-zero experts expected? If they come from dead channels in the base model, would you consider re-exporting the W8A8 checkpoint with weight_scale clamped to a safe minimum? A checkpoint-level fix would help every backend (vLLM, SGLang, llama.cpp-style loaders) rather than each of them patching the dequant path.

3. Backend note (not the main ask)

On the same backend the unquantized bf16 checkpoint emits token 0 everywhere. A probe inside the MoE op shows the hidden states are already NaN when entering the MoE (bf16: 48 × 3072 = 147,456 / 147,456 entries NaN; fp16: 6,144 NaN + -inf), i.e. the corruption happens upstream of the experts (attention / norm / RoPE path of this backend). Weights were verified clean (781 tensors sampled, no inf/NaN). This part looks backend-specific; I mention it only in case the base model has activation-spike characteristics that are known to overflow fp16.

4. Minor: expert naming

Expert modules are exported as model.layers.N.block_sparse_moe.experts.<i>.w1|w2|w3, while the runtime module path is model.layers.N.mlp.experts. Generic compressed-tensors loaders that match quant configs by module name silently fall back to "unquantized" (our backend did), which also results in token 0. Not a bug per se, but documenting the naming in the model card (or aliasing it) would save other backends a day of debugging.

主要语言
没有语言数据
星标
588
派生
83
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

MiniMax-AI/MiniMax-M2.5 的其他 Issue

查看 MiniMax-AI/MiniMax-M2.5 的全部 Issue

相似的 Issue

更多 AI Infra & Agents Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。