Skip to content

refactor: extract and split common logic between GDN & GDN2 - #5843

Merged
xuantengh merged 10 commits into
NVIDIA:mainfrom
xuantengh:xuantengh/gdn-refactor
Jul 28, 2026
Merged

refactor: extract and split common logic between GDN & GDN2#5843
xuantengh merged 10 commits into
NVIDIA:mainfrom
xuantengh:xuantengh/gdn-refactor

Conversation

@xuantengh

@xuantengh xuantengh commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
  • I, the PR author, have personally reviewed every line of this PR.

What does this PR do?

This is the first of several PRs to refactor the GDN module in order to support different variants of gated delta networks (GDN / GDN2) and different backend implementations (FLA, FlashInfer, FlashQLA, etc.). This PR extracts the parameter initialization logic into _GDNBase in common.py so that any GDN variant can inherit this base class to avoid code duplication. Also, it also keeps the original gated_delta_net.py file to hold back compatibility.

This wandb link shows the refactor produces exactly the same output (lm loss).

#5392 will be the next step to abstract away the CP communication logic.

@xuantengh
xuantengh requested review from a team as code owners July 16, 2026 09:56
@copy-pr-bot

copy-pr-bot Bot commented Jul 16, 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 July 16, 2026 09:56
@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.

@xuantengh

Copy link
Copy Markdown
Contributor Author

/ok to test c2cbf04

@xuantengh xuantengh changed the title [DON't MERGE] refactor: extract and split common logic between GDN & GDN2 refactor: extract and split common logic between GDN & GDN2 Jul 19, 2026
@xuantengh
xuantengh marked this pull request as ready for review July 19, 2026 16:17
@xuantengh

Copy link
Copy Markdown
Contributor Author

/claude review

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — clean refactor extracting shared GDN logic into gdn/common.py (_GDNBase) with a back-compat shim. Parameter registration order, split tables, CP all-to-all plumbing, and sharded checkpointing are preserved, and new tests (test_module_construction, test_gpu_forward_backward) plus the updated test_jit_compiled_helpers cover the new API. One trivial docstring typo noted inline.

Comment thread megatron/core/ssm/gdn/common.py Outdated
@xuantengh

Copy link
Copy Markdown
Contributor Author

/ok to test ba7e925

Comment thread megatron/core/ssm/gated_delta_net/common.py
Comment thread megatron/core/ssm/gated_delta_net/common.py
Comment thread megatron/core/ssm/gated_delta_net/common.py
Signed-off-by: Xuanteng Huang <xuantengh@nvidia.com>
@xuantengh

Copy link
Copy Markdown
Contributor Author

/ok to test 44bc4d3

@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 Jul 27, 2026
@xuantengh

Copy link
Copy Markdown
Contributor Author

/ok to test 112fc4a

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

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

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

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

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

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

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

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

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 complexity: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants