Skip to content

Add HybridModel hash MoE routing - #6403

Draft
FDecaYed wants to merge 4 commits into
NVIDIA:mainfrom
FDecaYed:codex/dsv4-v2-p4-20260810
Draft

Add HybridModel hash MoE routing#6403
FDecaYed wants to merge 4 commits into
NVIDIA:mainfrom
FDecaYed:codex/dsv4-v2-p4-20260810

Conversation

@FDecaYed

Copy link
Copy Markdown
Contributor

Add HybridModel hash MoE routing

Summary

Add complete Hash MoE behavior for HybridModel, from token-ID transport through router selection, MoE execution, metrics, recompute, and gradient finalization.

Scope

  • Add persistent token-to-expert mappings and the supported hash combination-score modes.
  • Carry token IDs through HybridModel, Hybrid layers, MTP, recompute, and partial CUDA-graph paths.
  • Route only the intended leading MoE layers and preserve normal routing elsewhere.
  • Keep router/MoE metric slots and final gradient handling consistent with the Hybrid execution path.
  • Add focused router, HybridModel, recompute, and gradient-finalization tests.

Non-goals

  • mHC implementation; P2 owns that prerequisite.
  • Variable-token HybridEP correctness, packed-data scheduling, or static THD CUDA graphs.
  • GPTModel integration, DSv4 attention, or recipes.

Review boundary and dependencies

Requires #6401 (P2). The local branch temporarily carries P2 and its #5929/#4531 prerequisites, but this PR’s own review commit is:

c9657bcd64c91a375e242a013aab3cc3a6731c71

Its exact own diff is 16 files, +946/-45. Please review that commit only. This will target main, not a pull-request/<P2> base; after P2 merges, the own commit will be rebased onto current main.

Provenance

Reconstructed from the Hash MoE behavior tracked by #5795, including the focused recuts #5938 and #5945. The original feature and forced-routing correction came from #4481 and #5130.

Validation

Completed locally:

  • clean worktree;
  • signed-commit verification and required Signed-off-by trailer;
  • git diff --check;
  • Python bytecode compilation;
  • Ruff on all 16 files;
  • AST behavior comparison.

Black 26.3.1 passes 14 of 16 files. The two whole-file failures in megatron/training/argument_utils.py and megatron/training/arguments.py are identical on the P2 parent; P4 adds only one non-formatting line to each. Isort passes 15 of 16 files; the arguments.py failure is also present on the P2 parent, and P4 changes no imports there.

Runtime pytest is unavailable in the bare macOS environment because PyTorch/CUDA is not installed. Focused CUDA tests and full functional CI remain required after publication. No dependency or lock-file change is part of this commit.

Local artifact

P4-hybrid-hash-moe-routing.patch, generated from the own commit only. Verify it against SHA256SUMS.

Before publication

After P2 merges, replay this own commit onto then-current main; recheck current router, partial CUDA-graph, MTP, and gradient-finalization contracts; rerun focused/static validation; then verify signing/trailers and launch full functional CI.

FDecaYed and others added 4 commits August 10, 2026 19:40
Rematerialize the full current diff of NVIDIA#5929 at 1b35b41 onto the pinned main base.

Co-authored-by: Hongxiao Bai <hongxiaob@nvidia.com>
Signed-off-by: Deyu Fu <deyuf@nvidia.com>
Rematerialize the full current diff of NVIDIA#4531 at f1df30c onto the pinned main base, retaining the current-main partial CUDA graph cleanup.

Co-authored-by: Yan Xu <yxu1@nvidia.com>

Co-authored-by: jingqiny-99 <jingqiny@nvidia.com>

Co-authored-by: Dennis Liu <denliu@nvidia.com>
Signed-off-by: Deyu Fu <deyuf@nvidia.com>
Rematerialize frozen P2 9f86bee988afdab12ca34906f3ac16fafb872691 on current main plus the current NVIDIA#5929 and NVIDIA#4531 prerequisites, preserving current-main fused MLA construction.

Include the post-frozen FP32 mapping correctness fix from dev d8b7108.

Co-authored-by: jingqiny-99 <jingqiny@nvidia.com>
Signed-off-by: Deyu Fu <deyuf@nvidia.com>
Rematerialize frozen P4 eeac0315e9058f8b9eb71898b9bde1879873ab15 on the P2 candidate. Preserve current-main partial CUDA graph dispatcher outputs while forwarding token IDs required by hash routing.

Signed-off-by: Deyu Fu <deyuf@nvidia.com>
@FDecaYed FDecaYed added the deepseekv4 DeepSeek V4 PRs label Aug 10, 2026
@copy-pr-bot

copy-pr-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseekv4 DeepSeek V4 PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant