Repository navigation
fix: gate MTP layers from the nccl-reshard bulk refit path - #3619
Conversation
Co-trained MTP drafter weights must not take the bulk xferdtensor path: vLLM keeps the drafter separate from the main model and updates it through load_weights, and bulk-resharding MTP layers either trips the layer_prefix assert / per-stage KeyError on the train side or targets main-model params vLLM does not have. MTP weights are recognized two ways: - bare mtp.-prefix HF names (NemotronH, Qwen3.5) in is_nccl_reshard_param - DeepSeek-style MTP exported as trailing model.layers.N indices via provenance: the Megatron-side name on the Bridge conversion tasks is uniformly mtp.*, so the worker collects those HF layers (_collect_mtp_hf_layer_names) and routes them to the misc path Run nccl_reshard_refit finalization through _weight_update_lifecycle so the drafter gets _maybe_process_mtp_drafter_after_loading() like the ipc/collective transports — freshly refit MTP MoE weights need their runtime (grouped-GEMM/quant) layout conversion. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Youngeun Kwon <[email protected]>
|
/ok to test 31ff9af |
youngeunkwon0405
left a comment
There was a problem hiding this comment.
Team review: 4 agents (RL expert, test reviewer, bug finder, devil's advocate) + lead; every finding independently re-verified against the pinned Megatron-Bridge SHA (0c565c9a) before posting.
The fix is correct and necessary. All three pre-PR failure modes were verified real: the layer_prefix assert fires for bare-mtp. families (NemotronH/Qwen3.5), DeepSeek's trailing-index MTP hits the per-stage KeyError, and the lifecycle switch newly runs the MTP drafter post-load processing that the old inline finalization never did. Verified clean: finalization ordering is exactly preserved vs main (independently diffed by two agents); the provenance gate operates on wildcard-resolved mappings with literal MTP layer indices, so no false or missed keys are possible for the pinned bridges; GLM-4.5's grouped MTP experts are correctly excluded by the layer-key design (a per-param gate would have missed them); and the two added tests use exact bridge-exported names.
3 inline comments, none blocking: a free CPU test-coverage gap for the new prefix gate (verified rows provided), a docstring/design-doc accuracy fix for the "uniformly mtp.*" claim (two counterexample families at the pin), and an optional setup-time guard for the real-quant combination the lifecycle change newly touches. Linter (ruff check + format): clean.
Generated by Claude Code
Signed-off-by: Youngeun Kwon <[email protected]>
Signed-off-by: Youngeun Kwon <[email protected]>
|
/ok to test 1127c81 |
Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Youngeun Kwon <[email protected]>
|
/ok to test 926e5a5 |
terrykong
left a comment
There was a problem hiding this comment.
Re-review at 926e5a5. The fix is correct and needed — I could not construct a case where it breaks, and both pre-PR failure modes are real, not hypothetical:
- Bare-
mtp.families (NemotronH/Qwen3.5):mtp.layers.0.mixer.up_proj.weightends inup_proj.weight, so it took the bulk path, and_extract_layer_prefixthen returnedmtpagainst abackboneincumbent → thelayer_prefix mismatchassert. - DeepSeek-style: MTP exports at
model.layers.61, so the assert passes but_build_layer_to_pp_stagenever emits that index → theKeyErrorwhose message already names MTP as the expected cause.
Verified clean, for the record:
- Nothing is dropped. The gate sits on the
ifof anif/else; theelsewritesmisc_meta, and because_task_is_miscfilters againstset(misc_meta.keys()), the MTP conversion tasks land in_misc_conversion_taskstoo. Both halves of the misc path carry MTP, so there's no silent stale-drafter case. - Keying the exclusion by HF layer rather than by param was the right call. It keeps
_task_is_misc's "first HF name is representative" assumption valid for compound mappings — a whole MTP layer moves to misc together, so aGatedMLPMappingcan never end up half-bulk/half-misc and desync the packed-broadcast order. - The provenance gate can't go stale per-family. The key is derived with
_extract_layer_namefrom the same task'shf_paramthat produces the name being tested, so it matches by construction. Checked at the pinned Bridge: 17 families define MTP mappings, all name the Megatron modulemtp.layers.N, and a grep fornextn|eagle|draft|speculatin anymegatron_param=returns nothing. - GLM-4.5's grouped-MoE MTP is handled — its HF name ends in
experts.gate_up_proj, sois_nccl_reshard_paramreturns True and only the provenance set excludes it. A per-param gate would have missed this. - No over-broad exclusion is possible. MTP names without a
layers.Nproduce coarse keys (mtp,model.embed_tokens). Those can never collide with an FFN param: every FFN name sits underlayers.Nand keys as<prefix>.layers.N, while the fallback branches structurally cannot emit that shape. - The lifecycle refactor preserves ordering exactly and adds the one thing that was missing — the deleted inline block was a hand-rolled copy of the base
finalize()that omitted_maybe_process_mtp_drafter_after_loading(). Adopting the shared hook matches howipcandcollectivealready call it. - The
real_quantguard closes the loop. The bulk xferdtensor phase sits outside thewith, while ModelOpt's override runsinitialize_layerwise_reloadon entry — the new violation forbids exactly that pairing. Guard and narrowwithare a matched pair.
Reviewed by a 7-agent team; every finding was re-verified against the pinned Megatron-Bridge SHA 0c565c9a before posting. Two candidate findings were dropped under challenge: a missing real_quant row in the config-validation test table (that table spot-checks 2 of 17 violations, so there's no convention being broken), and a GLM-4.5 test fixture (the existing DeepSeek fixture already exercises the provenance-only path). Linters pass; pyrefly couldn't run in my environment, so it's unchecked rather than failing.
Three comments below, all low severity, none blocking — and all the same shape: the routing rule changed, and one of the four places describing it got updated. No code changes requested.
Generated by Claude Code
Co-authored-by: Terry Kong <[email protected]> Signed-off-by: Youngeun Kwon <[email protected]>
b28b4a4 to
c0589ee
Compare
|
/ok to test c0589ee |
I am separating PR #3532 into two. Wire-safe part and the MTP gating part.
What does this PR do ?
Gate the MTP layers from the nccl-reshard path. It will force the use of the conventional refit path for the MTP layer.
The PR also contains the correct MTP gating for the DeepSeek MTP and the refactor in the misc path call to correctly update the MTP drafter in the vLLM engine.
Issues
List issues that this PR closes (syntax):
Usage
# Add a code snippet demonstrating how to use thisBefore your PR is "Ready for review"
Pre checks:
Additional Information