Repository navigation
[Bugfix][Model] Fix MiMo-V2.5 fused fp8 qkv_proj sharding (pre-shard count is num_key_value_heads; MTP path too) - #57508
Merged
vllm-bot merged 8 commits intoSep 19, 2026
Conversation
… pre-shard count is num_key_value_heads Signed-off-by: vllmellm <vllm.ellm@embeddedllm.com>
…qkv_proj Signed-off-by: vllmellm <vllm.ellm@embeddedllm.com>
…c decode Signed-off-by: vllmellm <vllm.ellm@embeddedllm.com>
…ometry checks Signed-off-by: vllmellm <vllm.ellm@embeddedllm.com>
Signed-off-by: vllmellm <vllm.ellm@embeddedllm.com>
vllmellm
requested review from
AndreasKaratzas,
DarkLight1337 and
ywang96
as code owners
September 18, 2026 05:56
Member
|
/ci run |
|
✅ @vllmellm, CI is now available for this PR.
|
tjtanaa
enabled auto-merge (squash)
September 18, 2026 08:07
|
❌ This PR is 6 commits behind upstream |
Contributor
Author
|
/ci run |
|
✅ Triggered Buildkite CI #89804 for commit |
Contributor
Author
|
/ci run |
|
✅ Triggered Buildkite CI #89847 for commit |
Contributor
Author
|
/ci retry |
|
✅ Queued 6 failed job(s) for retry in Buildkite CI #89847. |
Contributor
Author
|
/ci retry |
|
✅ Queued 1 failed job(s) for retry in Buildkite CI #89847. |
4 tasks done
Malav-P
pushed a commit
to Malav-P/vllm
that referenced
this pull request
Oct 1, 2026
…count is num_key_value_heads; MTP path too) (vllm-project#57508) Signed-off-by: vllmellm <vllm.ellm@embeddedllm.com>
michael-gpu
pushed a commit
to practical-inference/vllm-ampere-extended
that referenced
this pull request
Oct 20, 2026
…count is num_key_value_heads; MTP path too) (vllm-project#57508) Signed-off-by: vllmellm <vllm.ellm@embeddedllm.com>
5 of 6 tasks
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.
Purpose
XiaomiMiMo/MiMo-V2.5cannot load on current main at any TP size.Currently with TP4, on mi355x/mi300x we will hit this error.
This is not platform specific, so every platform that runs this checkpoint is affected.
The root cause is, the checkpoint's fused
qkv_projis pre-sharded atckpt_tp = config.num_key_value_heads(4 here), each chunk holding[Q_c | K_c | V_c]with its own fp8 block scales, while_shard_fp8_qkv_proj(#45200) assumes one chunk per KV head. The assumption holds for Pro (8 KV heads / 8 chunks) and for V2.5's GA layers (4/4) — those load fine today — but not for the SWA layers: 8 KV heads over 4 chunks, so each chunk carries two KV heads.Concretely, for
model.layers.1.self_attn.qkv_proj:(14848, 4096)= 4 chunks of 3072 Q + 384 K + 256 V = 3712 rows = 29 blocks exactlyweight_scale_inv(116, 32)= 4 × 29; the one-per-KV-head reading expects 8 × 15 = 120 and per-group-floor 112, so the loader's116 // 8 = 14expands to 1792 rows vs the 1856-row sliceFor GA layers (
(13568, 108), chunks of 3392 = 3072+192+128) and Pro ((27136, 216), 8 chunks of 3392) the pre-shard count happens to equal the KV-head count, which is why SWA breaks.Change
_shard_fp8_qkv_projtakesckpt_tp(=config.num_key_value_heads, i.e. the number of ranks the checkpoint was pre-sharded into — 4 for MiMo-V2.5, 8 for Pro) and derives the chunk geometry from the layer's own heads/dims.tp_size == ckpt_tp→ plain chunk of weight and scales (the chunk already is[Q_r|K_r|V_r]; scale rows line up withceil(rows/128));(row // rows_per_chunk) * ceil(rows_per_chunk/128) + (row % rows_per_chunk) // 128, reorder and requantize (zero-padding the 26.5-block tail, sincescaled_quantizeneeds full blocks);num_kv_heads(GA layers at TP=8) via KV replication, the same conventionQKVParallelLinearuses for split checkpoints: rank r owns KV headr // (tp_size // num_kv_heads), so each Q head stays with the KV head it attends to.mimo_v2_mtp.py: the MTP draft loader sharded the fused qkv with a plainchunk(tp_size)for weight and scales. At TP=4 that is correct by coincidence, at TP=8 the scale chunks come out[15]*7 + [11]against a 15-row parameter (rank 7 asserts indefault_weight_loader) and mid-block ranks take a neighbouring block's scale. It now buffers weight +weight_scale_invper layer and shards them through_shard_fp8_qkv_projwithckpt_tp = config.num_key_value_heads; non-fp8 fused checkpoints keep the old path.tests/models/quantization/test_mimo_v2_qkv_shard.py: new CPU-only unit test. It builds GA, SWA and Pro checkpoints in the export's chunk layout with known fp32 weights and asserts, for TP = 1, 2, 4, 8, that every rank's dequantized rows match an independent reference; that tp_size == ckpt_tp returns the checkpoint chunk unchanged; and that reading the SWA scales as one slice per KV head is detectably wrong (relL2 > 5x tolerance).For reference, #53242 fixes only the SWA symptom (global row map — exact for SWA, but it mis-scales 62.7% of GA rows and would mis-scale 81.4% of Pro's), and #46755 adds the TP >
num_kv_headscase with per-KV-head scale arithmetic, which for V2.5's MTP tensors would compute116 // 8 = 14and break TP=4 spec decode that works today.Test Plan
Non-spec, the reported configuration (TP=4) and TP=8 + EP:
Spec decode (MTP), both TP sizes:
vllm serve XiaomiMiMo/MiMo-V2.5 --trust-remote-code --generation-config vllm \ --gpu-memory-utilization 0.9 --max-model-len auto --tensor-parallel-size 4 \ --speculative-config '{"method":"mimo_v2_mtp","num_speculative_tokens":1}' \ --tool-call-parser mimo --enable-auto-tool-choice --reasoning-parser mimolm_eval --model local-chat-completions \ --model_args model=XiaomiMiMo/MiMo-V2.5,base_url=http://127.0.0.1:8000/v1/chat/completions,num_concurrent=32,max_retries=10,max_length=32000,timeout=60000 \ --gen_kwargs '{"max_tokens":16000,"until":[]}' --batch_size auto \ --tasks gsm8k --num_fewshot 25 --apply_chat_templateTest Result
vllm serve ... --tensor-parallel-size 4AssertionError: TP size must evenly split the number of KV headsnum_speculative_tokens=1)ckpt_tp = num_kv_heads) on SWAEssential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.