Skip to content

fix(cuda_graph): preserve explicit empty cuda_graph_scope as [] when clearing modules#4738

Closed
ko3n1g wants to merge 1 commit into
NVIDIA-NeMo:yuya/mb4583-cuda-graph-local-scopefrom
svcnemo-autobot:heal/cuda-graph-scope-empty-list
Closed

fix(cuda_graph): preserve explicit empty cuda_graph_scope as [] when clearing modules#4738
ko3n1g wants to merge 1 commit into
NVIDIA-NeMo:yuya/mb4583-cuda-graph-local-scopefrom
svcnemo-autobot:heal/cuda-graph-scope-empty-list

Conversation

@ko3n1g

@ko3n1g ko3n1g commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Background

On this branch, the unit test
tests/unit_tests/recipes/test_override_precedence.py::TestFullChainSanity::test_I_combined_overrides_end_to_end
fails with AssertionError: assert None == [] — an explicit model.cuda_graph_scope=[] override does
not survive the perf-script override chain (it is dropped to None).

Root cause

set_cuda_graph_modules() in src/megatron/bridge/utils/cuda_graph.py, when clearing the per-layer
modules, set config.cuda_graph_scope = None. That destroys an explicit empty-list scope: a caller
passing cuda_graph_scope=[] (via a Hydra/CLI override) means "no per-layer scope", and that intent
must survive as [], not become None.

Fix

Preserve the empty-list convention — set config.cuda_graph_scope = [] instead of None when
clearing modules (1 file, +6/-1).

Tested

Reproduced and verified by running the exact test on the aws-h100 cluster via a Kubeflow TrainJob
(nvcr.io/nvidia/nemo:26.04, with the branch's megatron.core from the 3rdparty/Megatron-LM
submodule):

Stage Branch Result
Reproduce yuya/mb4583-cuda-graph-local-scope 1 failed (assert None == [])
Verify this fix 1 passed
$ pytest tests/unit_tests/recipes/test_override_precedence.py::TestFullChainSanity::test_I_combined_overrides_end_to_end
============================== 1 passed in 2.83s ===============================

Opened on behalf of an automated implement-and-heal agent that reproduced the failure, authored the
fix, and verified it green on a real GPU cluster before this PR was raised. Draft for the branch
owner's review.

…clearing modules

set_cuda_graph_modules() cleared the deprecated per-layer cuda_graph_scope
field to None on the current MCore API. This dropped an explicit
cuda_graph_scope=[] (e.g. a Hydra/CLI override meaning "no per-layer scope")
to None through the perf-script override chain (validate_cuda_graph_configuration
-> clear_cuda_graph_modules -> set_cuda_graph_modules). Set it to [] instead,
matching the legacy branch and the load_megatron_model expectation.
@copy-pr-bot

copy-pr-bot Bot commented Jul 8, 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.

@ko3n1g

ko3n1g commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Closing — re-running the heal loop from scratch with a matured agent (fast exec_in_env env-diagnosis, no pre-fed command).

@ko3n1g ko3n1g closed this Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant