Skip to content

Add megatron/core/ops with its contributor guide and shared helpers (1/4) - #7380

Merged
guihong-nv merged 5 commits into
NVIDIA:mainfrom
guihong-nv:pr1/move-into-ops
Oct 12, 2026
Merged

guihong-nv merged 5 commits into
NVIDIA:mainfrom
guihong-nv:pr1/move-into-ops

Conversation

@guihong-nv

@guihong-nv guihong-nv commented Sep 16, 2026 •

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

What does this PR do?

Adds megatron/core/ops, the implementation home for SSM, sparse-attention and future fused operations, together with its contributor guide and the two shared helpers every later move uses. No existing code changes.

  • megatron/core/ops/README.md: layout and file roles; how to add a new operation; how to add a new backend kernel to an existing operation; dependency checks; kernel selection; deprecated import paths. Pointers added to megatron/core/README.md and docs/developer/contribute.md.
  • ops/_compat.deprecated_module: PEP 562 forwarders for moved import paths (one DeprecationWarning, lazy attribute resolution, from old import * and legacy pickles keep working).
  • ops/_backends.require: construction-time optional-dependency checks with one exception type and the cause chained.
  • tests/unit_tests/ops/test_deprecated_imports.py and a CI bucket: the regression suite for deprecated paths. Its table (deprecated_paths.py) is empty here and filled by each move PR, so family-specific tests skip until their move lands.

This is PR 1 of 4 re-slicing #7239 (which the stack supersedes), per the "Unified Kernel Backend Management" design doc. The moves themselves follow, each a pure move leaving deprecated aliases at the old paths:
2. ops-move/2-ssm — SSM helpers, Mamba2, GDN/GDN2, GDP, chunkwise CP → megatron/core/ops/ssm (149 files, 39 renames)
3. ops-move/3-attention — DSA, CSA, absorbed MLA, DeepSeek-v4 → megatron/core/ops/attention (78 files, 24 renames)
4. ops-move/4-layers-configs — MambaLayer, MLPLayer and the per-layer configs → megatron/core/transformer (63 files)

The previous single-PR head is kept at guihong-nv:pr1/move-into-ops-full for reference; the stack's end state is identical to it apart from dropping an unused test helper.

⚠️ For major changes (either in lines of code or in its impact), please make sure to first share a design doc with the team. If you're unsure what's the best way to do so, contact @NVIDIA/mcore-oncall.

Issue tracking

For PRs from open-source community contributors:

  • New features: a linked issue is required. Please open a feature request and reference it here before submitting the PR.
  • Small updates (bug fixes, minor improvements): a linked issue is recommended and will accelerate the PR review process.

Linked issue:

Contribution process

Pre-checks

  • I have added relevant unit tests
  • I have added relevant functional tests
  • If this PR adds or changes a GPU kernel (Triton, jit_fuser/torch.compile, CUDA extension, TE or external-library dispatch, or a scatter/index accumulation), I have added or updated its bit-exact determinism test and registered it in tests/unit_tests/determinism/kernels/manifest.py (guide)
  • I have added proper typing to my code Typing guidelines
  • I have added relevant documentation
  • I have run the autoformatter.sh on my PR

Code review

Feel free to message or comment @NVIDIA/mcore-oncall to help accelerate your merge into main. The less complex your PR is, the faster it will be approved and merged!

All PRs start as draft. If you open a non-draft PR, it will be automatically converted to draft.

Step 1: Mark PR as "Ready for Review"

  1. When your PR is ready, click Ready for Review.
  2. An oncall reviewer is auto-assigned and expert reviewers are notified based on your changes.
    • Some PRs may jump straight to step 2. This is determined by .github/CODEOWNERS.

⚠️ Only mark as ready once merge-conflicts are resolved and the CI is passing.
Final Review might get declined if these requirements are not fulfilled.

Step 2: Final Review

For PRs that change megatron/core, once all expert reviewers have approved, the Final Review label is applied automatically and final reviewers are assigned.

For PRs outside megatron/core, this step is skipped.

Step 3: Approved

Once all required reviewers have approved, the Approved label is applied automatically.

Merge

Any member of mcore-engineers will be able to merge your PR.

@copy-pr-bot

copy-pr-bot Bot commented Sep 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.

@guihong-nv

Copy link
Copy Markdown
Contributor Author

/claude fix

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

❌ Claude fix stopped because a workflow step failed. Inspect the run.

@guihong-nv

Copy link
Copy Markdown
Contributor Author

/ok to test 6a4ec5f

@guihong-nv guihong-nv changed the title Move SSM and experimental-attention implementations into megatron/core/ops with deprecated aliases (1/4) Add megatron/core/ops with its contributor guide and shared helpers (1/4) Sep 17, 2026
…helpers

megatron/core/ops is the implementation home for SSM, sparse-attention and future
fused operations. This adds the package README (layout and file roles, how to add a
new operation, how to add a new backend kernel to an existing operation, dependency
checks, selection, deprecated import paths), pointers from megatron/core/README.md and
the contribution guide, the two shared helpers every move uses -- _compat.deprecated_module
(PEP 562 forwarders for moved paths) and _backends.require (construction-time optional
dependency checks) -- and the regression suite for deprecated paths, whose table is filled
in by each move. No existing code changes.

Signed-off-by: Guihong Li <guihongl@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Sep 17, 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.

Comment thread megatron/core/ops/README.md Resolved
Comment thread megatron/core/ops/_backends.py Resolved
Comment thread megatron/core/ops/_backends.py Resolved
@guihong-nv
guihong-nv requested a review from Phlip79 September 18, 2026 17:18
…warn when a version cannot be determined, document require()'s variadic symbols

- README: drop the 'Status (PR 1 of 4)' callout and the other PR-numbered asides; the
  guide now describes the package conventions without referring to the PR sequence.
- _backends.installed_version: every None is logged with its reason (import failure,
  no __version__ and no distribution metadata, non-PEP-440 string).
- _backends.require: explain why symbols is variadic and the remaining options are
  keyword-only.

Signed-off-by: Guihong Li <guihongl@nvidia.com>
Only reject paths present in the forwarding table so the foundation PR permits modules that have not moved yet. Resolve relative imports and cover partial migrations with regression cases. Apply the pinned formatting to the test suite.

Signed-off-by: Guihong Li <guihongl@nvidia.com>
Document construction using current selectors and ModuleSpec APIs, and distinguish intended family layouts from registered migrations. Exercise deprecated_module with synthetic importable modules independently of the migration table. Schedule the ops bucket for both dev and LTS on the latest checkout.

Signed-off-by: Guihong Li <guihongl@nvidia.com>
@guihong-nv

Copy link
Copy Markdown
Contributor Author

/ok to test 7661b40

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the Final Review PR is in the "final review" stage label Sep 20, 2026
Cover availability probes, package and distribution versions, required exports, and chained import and lazy-load errors without external kernel dependencies.

Signed-off-by: Guihong Li <guihongl@nvidia.com>
@guihong-nv

Copy link
Copy Markdown
Contributor Author

/ok to test ed6a75e

@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 9, 2026
@guihong-nv
guihong-nv enabled auto-merge October 12, 2026 16:36
@guihong-nv
guihong-nv added this pull request to the merge queue Oct 12, 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/38279933104

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

Merged via the queue into NVIDIA:main with commit ee8b998 Oct 12, 2026
109 of 111 checks passed
@guihong-nv
guihong-nv deleted the pr1/move-into-ops branch October 12, 2026 19:23

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants