Skip to content

Port Multi-Latent Attention to HybridModel - #4452

Merged
Phlip79 merged 39 commits into
NVIDIA:mainfrom
janEbert:hybrid-mla-port
Jul 23, 2026
Merged

Port Multi-Latent Attention to HybridModel#4452
Phlip79 merged 39 commits into
NVIDIA:mainfrom
janEbert:hybrid-mla-port

Conversation

@janEbert

@janEbert janEbert commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Add Multi-Latent Attention (MLA) support to HybridModel (similar to DSA support in #3553).

Also includes a minor rename for Mamba→Hybrid that wasn't caught in the earlier large PRs.

Note that the QK norm spec resolution functionality also catches errors that the existing implementation doesn't catch when the spec is misconfigured, therefore we need to make some additional changes.

@janEbert
janEbert requested review from a team as code owners April 23, 2026 18:53
@svcnvidia-nemo-ci
svcnvidia-nemo-ci marked this pull request as draft April 23, 2026 18:53
@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.

@copy-pr-bot

copy-pr-bot Bot commented Apr 23, 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.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added this to the Core 0.16 milestone Apr 23, 2026
@janEbert
janEbert marked this pull request as ready for review April 23, 2026 18:54
@svcnvidia-nemo-ci
svcnvidia-nemo-ci requested a review from a team April 23, 2026 18:54
@janEbert

Copy link
Copy Markdown
Contributor Author

/ok to test bded2ae

@janEbert

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

@janEbert

Copy link
Copy Markdown
Contributor Author

/ok to test a46c197

@janEbert

Copy link
Copy Markdown
Contributor Author

/ok to test 6ae9873

@Phlip79 Phlip79 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This MLA spec ignores --qk-layernorm and --qk-l2-norm and doesn't expose --mla-down-proj-fusion like GPTModel does.

@janEbert
janEbert requested a review from a team as a code owner April 24, 2026 20:42
@janEbert

Copy link
Copy Markdown
Contributor Author

This MLA spec ignores --qk-layernorm and --qk-l2-norm and doesn't expose --mla-down-proj-fusion like GPTModel does.

Addressed; the logic for QK layernorm is quite complex, so this blew the PR up. I could put this into another PR to make this one easier to review.

@janEbert

Copy link
Copy Markdown
Contributor Author

/ok to test 5336c52

janEbert added 21 commits July 20, 2026 18:53
We obviously want to return an instance here, not a type.

Signed-off-by: janEbert <janpabloe@nvidia.com>
Signed-off-by: janEbert <janpabloe@nvidia.com>
It's more likely that we encounter non-fused custom layers, so check in
this direction instead.

Signed-off-by: janEbert <janpabloe@nvidia.com>
Signed-off-by: janEbert <janpabloe@nvidia.com>
Previously, we rejected anything unusual. Not, we allow for unconsidered
specs to be used, granting more flexibility in exchange for less
certainty that the implementation isn't broken.

Signed-off-by: janEbert <janpabloe@nvidia.com>
Signed-off-by: janEbert <janpabloe@nvidia.com>
Signed-off-by: janEbert <janpabloe@nvidia.com>
Signed-off-by: janEbert <janpabloe@nvidia.com>
Signed-off-by: janEbert <janpabloe@nvidia.com>
Signed-off-by: janEbert <janpabloe@nvidia.com>
Signed-off-by: janEbert <janpabloe@nvidia.com>
Signed-off-by: janEbert <janpabloe@nvidia.com>
This reverts commit 7697f16.

Signed-off-by: janEbert <janpabloe@nvidia.com>
Also clean up tests a bit. (Especially redundant imports.)

Signed-off-by: janEbert <janpabloe@nvidia.com>
Signed-off-by: janEbert <janpabloe@nvidia.com>
Signed-off-by: janEbert <janpabloe@nvidia.com>
It's a lot of boilerplate code, so we try to keep
`multi_latent_attention.py` clean by having the resolver functionality
in the new module.

We try to mark it "private" by not explicitly exporting anything from
it.

Signed-off-by: janEbert <janpabloe@nvidia.com>
Signed-off-by: janEbert <janpabloe@nvidia.com>
Signed-off-by: janEbert <janpabloe@nvidia.com>
Signed-off-by: janEbert <janpabloe@nvidia.com>
Signed-off-by: janEbert <janpabloe@nvidia.com>
@janEbert

Copy link
Copy Markdown
Contributor Author

/ok to test 19af620

@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/30034259054

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: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants