Megatron: Nemotron RL support - #51
Merged
Merged
Conversation
added 3 commits
June 10, 2026 06:52
Squashed transplant of mtp-hybrid + cleanup pass: - Design mirrors nvidia/main (parse_hybrid_pattern, mtp_model_layer rename, is_mtp_layer plumbing, standalone process_mtp_loss, MTP FLOPs accounting). - Fixes the routing-replay MTP bypass regression (is_mtp_layer into the R3 gate; the old Router.is_mtp flag had lost its only writer); removes dead set_is_mtp; upstream-form isinstance attn-mask validation; deduped arguments asserts; zero reformat-only churn. - Carries the make_viewless_tensor dead-store fix and the vocab_size test typo fix. - Rebased onto current miles-main (router layer_number / tid2eid / R3 input_ids co-exist with is_mtp_layer).
The bridge/mamba path lacks the GPT provider's enable/disable dance around MTP block construction, so MTP MoE routers registered replay slots that the trainer-side fill (which only records main-decoder MoE layers) never populates -- a main layer then pops an empty slot (IndexError: len(top_indices_list)=0). Gate registration on is_mtp_layer, mirroring the existing is_mtp bypass in topk routing.
The MambaStack layer builder passed is_mtp_layer to attention layers but not to MoE layers, so MTP-block MoE routers saw is_mtp_layer=False -- defeating both the rollout-replay slot-registration skip and the is_mtp topk bypass (the slot/fill desync then popped an empty replay: IndexError len(top_indices_list)=0).
The mtp_model_layer rename changed every MTP parameter name (mtp.layers.N.transformer_layer.* -> mtp.layers.N.mtp_model_layer.*), which breaks miles' megatron-to-hf converters for existing MTP models (qwen3.5/3.6, qwen3-next, glm4.7-flash, mimo, deepseek nextn) and makes previously saved torch_dist checkpoints unloadable. Keep the original name for both the GPT path and the new MambaStack path; nothing outside this repo referenced the new name.
fzyzcjy
added a commit
that referenced
this pull request
Aug 5, 2026
Nemotron RL support (#51) swapped this import block to the newer multi_token_prediction API but left the legacy MTP loss body in place, so roll_tensor, MTPLossAutoScaler and MTPLossLoggingHelper lost their imports while keeping seven call sites. Any run that reaches the MTP branch dies with NameError: name 'roll_tensor' is not defined; process_mtp_loss is imported but never called, which is what gives the mismerge away.
Zhichenzzz
added a commit
that referenced
this pull request
Aug 5, 2026
MTP inner layers now number from 1, which puts them inside layer_number <= dsv4_n_hash_layers on dsv4 models; before #51 they numbered past the decoder and always used learned routing. Guard on is_mtp_layer to preserve that.
Zhichenzzz
added a commit
that referenced
this pull request
Aug 5, 2026
fzyzcjy
added a commit
that referenced
this pull request
Aug 9, 2026
Nemotron RL support (#51) swapped this import block to the newer multi_token_prediction API but left the legacy MTP loss body in place, so roll_tensor, MTPLossAutoScaler and MTPLossLoggingHelper lost their imports while keeping seven call sites. Any run that reaches the MTP branch dies with NameError: name 'roll_tensor' is not defined; process_mtp_loss is imported but never called, which is what gives the mismerge away.
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.
radixark/miles#1284