Detect MTP routed-expert layout separately (dense NVFP4 vs MTP MXFP4)#1
Conversation
|
Reviewed against main: _get_safetensors_header_for_tensor and the surrounding function are identical there, the mtp_layout==layout and missing-tensor fallbacks look right, and group_size 32 for MXFP4 matches get_mxfp4_quant_algo's expectations -- happy to take this as-is into the branch, and the upstream PR is already open (NVIDIA#16276, currently scoped to the two validated halves; I'll fold this in and bring MTP into scope once merged here). Two mechanical things the upstream repo enforces before I can merge it: each commit needs your DCO Signed-off-by (git commit --amend -s), and their contribution guidelines disallow AI co-author trailers in commit messages, so the Co-Authored-By line needs to go. If you push the amended commit I'll merge and update NVIDIA#16276 the same hour. |
…MXFP4) The ModelOpt experts-only NVFP4 repacks (e.g. nvidia/DeepSeek-V4-Pro-NVFP4) re-quantize only the dense routed experts to NVFP4 (U8) and leave the MTP routed experts at the base model's MXFP4 (I8). _set_deepseek_v4_routed_moe_ quant_config detected a single layout from layers.0 and applied it to every MoE layer including the MTP layer, so the MTP experts got NVFP4 and crashed in fused_moe load_quant_scales. Detect the MTP expert dtype separately and assign the MTP layer indices the correct (MXFP4) config. Validated end-to-end on real weights: nvidia/DeepSeek-V4-Pro-NVFP4 on 4x B300, TP4, moe_backend=TRTLLM, rc15.post1 (equivalent change), with the construction fix from 3972f5e: loads 100% + serves + generates, MTP=1 and MTP=3 (mtp_eagle_one_model builds one shared MTP layer). MTP accept_len ~2.86. Signed-off-by: d3nb <wanxiren@gmail.com>
2c578af to
5442601
Compare
|
Amended: dropped the AI co-author trailer and added my DCO |
|
Merged and pushed — NVIDIA#16276 now carries your commit with authorship intact, and I've updated its body to bring MTP into scope. Thanks for the quick amend and the B300 validation. |
Builds on your construction-time resolution (3972f5e) to close the MTP half of NVIDIA#16196.
What this adds
_set_deepseek_v4_routed_moe_quant_configdetects a single routed-expert layout fromlayers.0.ffn.experts.0.w1.weightand applies it to every MoE layer, including the MTP layer. But in the ModelOpt experts-only NVFP4 repacks the two regions differ:layers.0..N.ffn.experts→ dtypeU8= NVFP4 (re-quantized);mtp.0.ffn.experts→ dtypeI8= MXFP4 (left at the base model precision).So the MTP experts were getting the dense NVFP4 config and dying in
fused_moe/quantization.pyload_quant_scales. This change detects the MTP expert dtype separately (mtp.0.ffn.experts.0.w1.weight) and assigns the MTP layer indices the correctW4A8_MXFP4_*config; dense layers are unchanged.Validation (real weights + B300)
Ran on the real
nvidia/DeepSeek-V4-Pro-NVFP4(851 GB, 64 shards), 4× B300, TP4,moe_backend=TRTLLM, with your construction fix applied (I validated the equivalent construction change on the1.3.0rc15.post1wheel, since that's what loadsdeepseek_v4configs for us;_set_deepseek_v4_routed_moe_quant_configis essentially identical onmain):Application startup complete→ generates correctly;num_nextn_predict_layers):MTP routed experts layout=mxfp4/dense NVFP4, serves + generates;mtp_eagle_one_modelbuilds a single shared MTP layer regardless ofnum_nextn_predict_layers, so covering the checkpoint's MTP layer count is sufficient — no per-duplicated-layer handling needed.Happy to adjust naming/placement to your taste, and to re-run any revision against the real weights + B300. Ref NVIDIA#16196.