·
Last changedVersion:
This version passed the hardening gate. Hardening updated the skill content and independently checked the resulting changes. Classified findings before hardening: 4. Classified findings closed: 2. Classified findings remaining: 2. Unclassified scanner findings remaining: 0. Review findings closed: 3. Review findings remaining: 10.
1
3
2
Expand | File | Group | Subtype | Severity | Status |
|---|---|---|---|---|---|
SKILL.md | Prompt Injection | Direct prompt injection | High | Closed | |
card.yaml | Sensitive Data & Secret Exposure | Agent snooping | Medium | Open | |
SKILL.md | Sensitive Data & Secret Exposure | Agent snooping | Medium | Closed | |
BENCHMARK.md | Sensitive Data & Secret Exposure | Agent snooping | Medium | Open |
4 findings
CUDA graphs capture GPU operations once and replay them with minimal host-driver overhead. Bridge supports two implementations:
cuda_graph_impl | Mechanism | Scope support |
|---|---|---|
| MCore |
|
| TE |
|
Start with TE-scoped graphs for most training workloads, then verify replay timing against eager on the same dispatcher, layout, and container:
attn, then optionally mlpattn moe_router moe_preprocessUse local + full_iteration only when you specifically want full-iteration
capture and can satisfy the tighter constraints.
For recompute-heavy workloads:
local full-iteration graphs or away
from graphs entirelyValid CLI values live in scripts/performance/argument_parser.py:
VALID_CUDA_GRAPH_IMPLS: ["none", "local", "transformer_engine"]VALID_CUDA_GRAPH_SCOPES: ["full_iteration", "attn", "mlp", "moe", "moe_router", "moe_preprocess", "mamba"]The performance harness uses a comma-separated --cuda_graph_scope value and
auto-enables model.use_te_rng_tracker plus rng.te_rng_tracker when
--cuda_graph_impl is not none.
use_te_rng_tracker = True (enforced in gpt_provider.py)
full_iteration scope only with cuda_graph_impl = "local"
full_iteration scope requires check_for_nan_in_loss = False
Do not combine moe scope and moe_router scope
Tensor shapes must be static (fixed seq_length, fixed micro_batch_size)
With PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True, set
NCCL_GRAPH_REGISTER=0 (MCore enforces for local impl on arch < sm_100;
TE impl asserts unconditionally)
CPU offloading is incompatible with CUDA graphs
moe_preprocess scope requires moe_router scope to also be set
CudaGraphManager: megatron/core/transformer/cuda_graphs.pyTECudaGraphHelper: megatron/core/transformer/cuda_graphs.pyFullCudaGraphWrapper: megatron/core/full_cuda_graph.pyCudaGraphScope enum: megatron/core/transformer/enums.pysrc/megatron/bridge/perf_recipes/deepseek/gb300/deepseek_v3.pysrc/megatron/bridge/perf_recipes/qwen/gb300/qwen3_moe.pysrc/megatron/bridge/perf_recipes/gpt_oss/gb300/gpt_oss.py| File | Coverage |
|---|---|
|
|
|
|
| TE autocast with CUDA graphs |
| End-to-end local and TE graph smoke tests |
| TE + CUDA graph recipe config |
| TE + CUDA graph recipe config |
| VLM CUDA graph settings |
TE RNG tracker is mandatory: Setting cuda_graph_impl without
use_te_rng_tracker=True and rng.te_rng_tracker=True will assert
in the provider.
full_iteration requires NaN checks disabled: The entire fwd+bwd is
captured, so loss-NaN checking cannot inspect intermediate values.
MoE scope restrictions: moe scope and moe_router scope are
mutually exclusive. Token-dropless MoE can only graph moe_router and
moe_preprocess, not the full expert dispatch.
Memory overhead: CUDA graphs pin all intermediate buffers for the
graph's lifetime (no memory reuse). TE scoped graphs add a few GB;
full-iteration graphs can increase peak memory by 1.5–2×. PP > 1
compounds overhead since each stage holds its own graph.
Delayed wgrad interaction: When delay_wgrad_compute=True and
attention or MoE router is in cuda_graph_scope, additional constraints
apply: TE >= 2.12.0, gradient_accumulation_fusion=True, and no
attention bias.
Variable-length sequences break graphs: Sequence lengths must be constant across steps. Use padded packed sequences if packing is needed.
Graph cleanup is required: CUDA graph objects hold NCCL buffer
references. Bridge handles this in _delete_cuda_graphs() at the end
of training, but early exits must call it explicitly.
Older GPU architectures: On GPUs with compute capability < 10.0
(pre-Blackwell), set NCCL_GRAPH_REGISTER=0 when using
PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True. Enforced in MCore
CudaGraphManager (cuda_graphs.py:1428) and TECudaGraphHelper
(cuda_graphs.py:1697). The TE impl asserts unconditionally regardless
of arch.
CPU offloading incompatible: CUDA graphs cannot be used with CPU
offloading. Enforced in MCore transformer_config.py:1907.
MoE recompute + moe_router scope: MoE recompute is not supported
with moe_router CUDA graph scope when using cuda_graph_impl = "transformer_engine". Enforced in MCore transformer_config.py:1977.
Layer-level recompute requires full_iteration scope: Using
recompute_granularity="full" with recompute_num_layers (recompute N
whole transformer layers) is incompatible with TE-scoped graphs. MCore
calls this "full" granularity even though you're selecting how many
layers — the name refers to recomputing the full layer, not full model.
Any TE-scoped scope (attn, mlp, moe_router, etc.) will assert:
AssertionError: full recompute is only supported with full iteration CUDA graph.
This commonly hits FP8 configs that default to TE-scoped graphs (e.g.
LLAMA3_70B_SFT_CONFIG_H100_FP8_CS_V1 uses cuda_graph_impl= "transformer_engine", cuda_graph_scope="mlp"). Fix: use submodule
recompute (recompute_granularity="selective" + recompute_modules),
disable CUDA graphs, or switch to local + full_iteration. Enforced
in MCore transformer_config.py:2001-2005.
Benchmark numbers are workload-specific: graph wins are usually real when host overhead is visible, but the exact gain depends on batch shape, PP depth, recompute, dispatcher backend, and whether the eager baseline was already optimized.
A successful capture is not a speedup guarantee: On 2026-05-18,
Qwen3 30B A3B H100 BF16 pretrain with the all-to-all dispatcher captured
TE-scoped attn,moe_router,moe_preprocess graphs successfully (48
graphable layers, about 6.9 s capture time on rank 0), but replay
iterations 5-8 averaged 42.00 s versus 41.36 s for eager. Treat
scoped graphs as a bring-up candidate and validate on the target stack.
local and
transformer_engine implementations.Get started with chainctlchainctl skill install public/nvidia/nemo-mbridge-perf-cuda-graphs:latest
Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.
skills.chainreg.biz/public/github.com/nvidia/skills/nemo-mbridge-perf-cuda-graphs:latest
Apache-2.0
BENCHMARK.md
HARDENING.md
LICENSE
SKILL.md
card.yaml
evals/evals.json
skill-card.md
skill.oms.sig