Skip to content

Fix import error by DSA spec - #8414

Merged
xuantengh merged 2 commits into
NVIDIA:mainfrom
xuantengh:xuantengh/fix-dsa-spec-import
Oct 22, 2026
Merged

xuantengh merged 2 commits into
NVIDIA:mainfrom
xuantengh:xuantengh/fix-dsa-spec-import

Conversation

@xuantengh

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

What does this PR do?

This PR fixes the CI import checking error caused by the DSA spec introduced in #7156.

Signed-off-by: Xuanteng Huang <xuantengh@nvidia.com>
@xuantengh
xuantengh requested review from a team as code owners October 21, 2026 15:16
@svcnvidia-nemo-ci
svcnvidia-nemo-ci marked this pull request as draft October 21, 2026 15:16
@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 Final Review PR is in the "final review" stage label Oct 21, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 21, 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 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.

The path-copying change looks sound in this light static review. One non-blocking coverage suggestion:

Add a regression test for non-deepcopyable builders

The new derivation logic deliberately avoids copying optional-dependency builders. The existing DSA spec tests check module selection, upstream nonmutation, and mixer differences, but do not exercise a builder that rejects deepcopy. With dependencies installed, those assertions also pass under the old implementation, leaving the import-failure mechanism unpinned by a unit test.

Suggested addition to that test file, using its existing imports:

from dataclasses import replace

from megatron.core.transformer.experimental_attention_variant.dsa_layer_specs import (
    _with_dsa_gqa_attention,
)


class _UncopyableBuilder:
    def __call__(self, *args, **kwargs):
        raise AssertionError("Spec derivation must not instantiate builders")

    def __deepcopy__(self, memo):
        raise TypeError("cannot pickle 'cell' object")


@pytest.mark.parametrize("upstream", [hybrid_stack_spec, gated_delta_product_stack_spec])
def test_dsa_derivation_does_not_copy_optional_builders(upstream):
    mixer = replace(upstream.submodules.mamba_layer, module=_UncopyableBuilder())
    source = replace(upstream, submodules=replace(upstream.submodules, mamba_layer=mixer))
    derived = _with_dsa_gqa_attention(source)

    assert derived.submodules.mamba_layer is mixer
    assert derived.submodules.attention_layer is not source.submodules.attention_layer

Preservation and acceptance: This proposed test should return normally for both upstream stacks; reverting to whole-stack deepcopy should raise the synthetic TypeError. Retain the existing assertions that both derived stacks use DSGroupedSelfAttention, neither upstream attention module changes, and the two mixers remain different. Also check that separate derivations receive distinct indexer specs and retain the upstream dense-attention builder for warmup. The invariant is selective copying without instantiating builders or mutating upstream specs—not restoring whole-stack deepcopy.

Suggested code requires author verification. Tests were not executed.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@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 Oct 21, 2026
@xuantengh

Copy link
Copy Markdown
Contributor Author

/ok to test 41855ab

@xuantengh

Copy link
Copy Markdown
Contributor Author

/ok to test 57f1ed7

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

Merged via the queue into NVIDIA:main with commit a747bac Oct 22, 2026
154 checks passed
@xuantengh
xuantengh deleted the xuantengh/fix-dsa-spec-import branch October 22, 2026 18:03
asolergi-nv added a commit to asolergi-nv/Megatron-LM that referenced this pull request Oct 23, 2026
Seventeen upstream commits since 9e5aad0, none touching a file this branch
changes; no conflicts. The merge brings in NVIDIA#8414 ("Fix import error by DSA
spec"), which repairs the import of
megatron.core.transformer.experimental_attention_variant.dsa_layer_specs that
made the Installation Test fail on main from 2026-10-21 up to and including
9e5aad0, and therefore on this branch's head 09cced3.

Also in: NVIDIA#8404 removed eight gpt functional-test cases (the corpus-parity
gate now covers 297 configs), NVIDIA#7394 added two MoE router flags (outside the
data group; the data-arguments snapshot is unchanged), NVIDIA#7926 removed an
inference flag.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: asolergi-nv <asolergibert@nvidia.com>
lmcafee-nvidia added a commit to lmcafee-nvidia/Megatron-LM that referenced this pull request Oct 26, 2026
…tegration-20261021

Picks up NVIDIA#8414, which fixes the DSA layer-spec import failure inherited from main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lawrence McAfee <lmcafee@nvidia.com>

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants