[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

Aperta
#41 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python, pytorch

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

[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.

Lingua principale
Nessun dato sulla lingua
Stelle
588
Fork
83
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MiniMax-AI/MiniMax-M2.5

Tutte le issue di MiniMax-AI/MiniMax-M2.5

Issue simili

Altre issue su AI Infra & Agents

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.