Skip to content

feat(megatron): expose training CUDA Graph config - #3483

Merged
terrykong merged 6 commits into
NVIDIA-NeMo:mainfrom
seonjinn:sj/nemorl-megatron-cuda-graph-config
Aug 15, 2026
Merged

terrykong merged 6 commits into
NVIDIA-NeMo:mainfrom
seonjinn:sj/nemorl-megatron-cuda-graph-config

Conversation

@seonjinn

@seonjinn seonjinn commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

What

  • Expose cuda_graph_modules and cuda_graph_warmup_steps in the NeMo-RL Megatron config.
  • Normalize module names with Megatron-Bridge before model construction.
  • Forward the warmup setting and add disabled-by-default examples and focused tests.

Why

NeMo-RL already forwarded cuda_graph_impl, but ignored these two existing Megatron-Core options when configured in YAML.

Configuration

policy:
  megatron_cfg:
    cuda_graph_impl: transformer_engine
    cuda_graph_modules: [attn, mlp]
    cuda_graph_warmup_steps: 3

This is configuration plumbing only. Defaults remain disabled with cuda_graph_impl: "none"; 3 matches the Megatron-Core default.

@copy-pr-bot

copy-pr-bot Bot commented Aug 4, 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.

@seonjinn seonjinn added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Aug 4, 2026
@seonjinn

seonjinn commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

/claude review

@seonjinn
seonjinn marked this pull request as ready for review August 4, 2026 02:25
@seonjinn
seonjinn requested review from a team as code owners August 4, 2026 02:25
@seonjinn
seonjinn requested a review from terrykong August 4, 2026 02:35
Signed-off-by: seonjinn <[email protected]>

# Conflicts:
#	tests/unit/models/megatron/test_megatron_setup.py
@seonjinn

seonjinn commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 16fb7fd

@seonjinn

Copy link
Copy Markdown
Contributor Author

/ok to test af13d90

@seonjinn

Copy link
Copy Markdown
Contributor Author

/ok to test af13d90

@seonjinn

Copy link
Copy Markdown
Contributor Author

/ok to test d66e7bf

@seonjinn

seonjinn commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Self-review (/review-pr-team)

Reviewed the PR with independent RL/config, Megatron-Bridge/Megatron-Core API, test/bug, and design/process passes, followed by adversarial reconciliation.

Resolved findings

  • Correctness: raw cuda_graph_modules strings could remain unnormalized when NeMo-RL uses the low-level Bridge get_model() path without re-finalizing the provider. Commit af13d9076 now uses set_cuda_graph_modules() before model construction, and the unit test asserts the resulting CudaGraphModule enum values.
  • Documentation: clarified that scoped training capture requires cuda_graph_impl: transformer_engine; Bridge rejects scoped module capture with local.

No other actionable correctness, API, or maintainability issues remained after reconciliation. This PR is disabled-by-default configuration plumbing, so it does not change training performance unless users explicitly enable CUDA Graphs.

Verification

  • Merged latest origin/main and initialized recursive submodules.
  • git diff --check: passed.
  • GitHub lint, docs, submodule, DCO, copyright, and branch-up-to-date checks: passed.
  • Full GitHub CI completed on commit d66e7bf54: 71 checks passed, including all L0 MCore unit-test shards and Lfast Megatron/SFT functional tests; 0 failed and 0 pending.

@seonjinn
seonjinn requested a review from yuki-97 August 14, 2026 23:23
@terrykong
terrykong merged commit c138570 into NVIDIA-NeMo:main Aug 15, 2026
81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants