Skip to content

feat(optimizer): AUT-2316 reapply DeepSeek-V3 NVFP4 training support - #7328

Merged
balasaajay merged 6 commits into
NVIDIA:mainfrom
svcnemo-autobot:revert/deepseek-nvfp4-6841
Sep 24, 2026
Merged

balasaajay merged 6 commits into
NVIDIA:mainfrom
svcnemo-autobot:revert/deepseek-nvfp4-6841

Conversation

@svcnemo-autobot

@svcnemo-autobot svcnemo-autobot commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Background

PR #7326 ("ci: Revert recently merged changes as they cause CI unit test failures") reverted three recently-merged changes. This PR re-applies one of them: "Add DeepSeek-V3 NVFP4 training support (#6841)", reverted by commit 014508b.

What changed

Reverts the revert commit 014508ba8d2158d33b39a9462b630efc60e25cfd, restoring DeepSeek-V3 NVFP4 training support across the distributed optimizer, GPT model, multi-token prediction, and transformer block/layer, plus the related unit tests. Rebased onto current main.

Details

Rebased onto main @ 18a991265. One conflict resolved at the root: main added hash_moe_layer_threshold to MultiTokenPredictionBlock's pattern-build path where this change renames MTP layers to layers.{layer_number - 1} (NVFP4 checkpoint-key namespacing). The resolution keeps main's new kwarg and this change's layer naming. gpt_model.py is restored identical to current main so the re-apply no longer regresses main's MTP input validation. The fused-MLA reload test asserts the canonical fused key (...self_attention.linear_qkv_down_proj.layer_norm_weight).

Tested

Rebase conflict resolution verified: post-rebase tree-vs-main diff is identical to the pre-rebase change for all touched files (same 6 files, 167 insertions / 26 deletions) modulo the intended hash_moe_layer_threshold context line and line-number drift. Local lint/test toolchain unavailable in the rootless authoring workstation; GitHub CI on the pushed head is the authoritative gate.

@copy-pr-bot

copy-pr-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci
svcnvidia-nemo-ci marked this pull request as draft September 15, 2026 00:20
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically converted to draft because all PRs must start as drafts.

When you are ready for review, click Ready for Review to begin the review process. This will:

  1. Add the oncall reviewer (optional reviewer)
  2. Add required review teams based on your changes

See the contribution guide for more details.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the Run full unit tests Run the full H100 unit-test suite instead of PR impact selection label Sep 15, 2026
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

/ok to test e5c89ba

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

/ok to test 7b9ac78

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

/ok to test 2fc3a99

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

/ok to test ac2564e

@balasaajay
balasaajay marked this pull request as ready for review September 15, 2026 19:32
@Phlip79
Phlip79 removed the request for review from a team September 21, 2026 23:52
@balasaajay balasaajay removed the Run full unit tests Run the full H100 unit-test suite instead of PR impact selection label Sep 21, 2026
Reapply "Add DeepSeek-V3 NVFP4 training support (NVIDIA#6841)".

This reverts the revert commit 014508b
("Revert 'Add DeepSeek-V3 NVFP4 training support (NVIDIA#6841)'") from PR NVIDIA#7326,
restoring the original change.

Signed-off-by: svcnemo-autobot <svcnemo-autobot@nvidia.com>
…load test

The re-applied DeepSeek-V3 NVFP4 change (NVIDIA#6841) adds
test_distributed_optimizer_reload_main_params_from_fused_mla_canonical_state_dict,
whose precondition asserted the checkpoint canonicalizes the fused input
LayerNorm to 'decoder.layers.0.input_layernorm.'. The layer's
sharded_state_dict_keys_map rewrites 'self_attention.linear_qkv_down_proj.layer_norm_'
to 'input_layernorm.' *within* the layer, so the canonical checkpoint key is
'decoder.layers.0.self_attention.input_layernorm.' (the layer's input_layernorm is a
sublayer of the transformer layer). Correct the asserted prefix so the test
exercises the reload path instead of failing its own precondition.

Signed-off-by: svcnemo-autobot <svcnemo-autobot@nvidia.com>
Signed-off-by: svcnemo-autobot <svcnemo-autobot@nvidia.com>
Signed-off-by: svcnemo-autobot <svcnemo-autobot@nvidia.com>
…eload test

The captured canonical sharded_state_dict for the fused-MLA layer keeps the
input LayerNorm fused on linear_qkv_down_proj.layer_norm_weight rather than
remapping it to a separate self_attention.input_layernorm.* key. Fix the
over-strict assertion (and stale docstring) to match the real canonical keys,
and drop the temporary diagnostic prints.

Signed-off-by: svcnemo-autobot <svcnemo-autobot@nvidia.com>
…re-apply

The revert-of-revert of NVIDIA#6841 predates and stripped several additions main made
to gpt_model.py after NVIDIA#6841 merged: the freeze_base_model_for_mtp / mtp_hsm /
mtp_hybrid_override_pattern input validation, the output-logits observe_tensor
call, and the conditional decoder name. Their removal broke main's GPTModel
tests (test_hsm_requires_two_mtp_layers, test_rejects_hybrid_mtp_override).
Restore main's content for gpt_model.py so the NVFP4 re-apply no longer
regresses those validations; gpt_model.py is now unchanged from main.

Signed-off-by: svcnemo-autobot <svcnemo-autobot@nvidia.com>
@nemo-autobot-origin
nemo-autobot-origin Bot force-pushed the revert/deepseek-nvfp4-6841 branch from 899707a to efb182d Compare September 22, 2026 15:57
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the Run full unit tests Run the full H100 unit-test suite instead of PR impact selection label Sep 22, 2026
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

/ok to test efb182d

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the Final Review PR is in the "final review" stage label Sep 23, 2026
@balasaajay
balasaajay added this pull request to the merge queue Sep 23, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added Approved All necessary approvals have been made and removed Final Review PR is in the "final review" stage labels Sep 23, 2026
@nemo-automation-bot

Copy link
Copy Markdown

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/35937923675

Merged via the queue into NVIDIA:main with commit fb60136 Sep 24, 2026
106 of 108 checks passed

This branch was previously deployed

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

Labels

Approved All necessary approvals have been made Run full unit tests Run the full H100 unit-test suite instead of PR impact selection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants