Skip to content

Megatron: Nemotron RL support - #51

Merged
Zhichenzzz merged 5 commits into
miles-mainfrom
mtp-hybrid
Aug 5, 2026
Merged

Megatron: Nemotron RL support#51
Zhichenzzz merged 5 commits into
miles-mainfrom
mtp-hybrid

Conversation

@Zhichenzzz

@Zhichenzzz Zhichenzzz commented Jun 3, 2026

Copy link
Copy Markdown

@Zhichenzzz Zhichenzzz changed the title nemotron_h: MTP support for hybrid (Mamba) models + RL training fixes Megatron: Nemotron RL support Jun 3, 2026
Zhichenzzz 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).
yueming-yuan and others added 2 commits August 3, 2026 21:46
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.
@Zhichenzzz
Zhichenzzz merged commit 8f83233 into miles-main Aug 5, 2026
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.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants