nemo-mbridge-perf-activation-recompute
Validate and use selective and full activation recompute in Megatron Bridge to reduce GPU memory usage at the cost of extra compute.
Skill by sayalinvidia
Chalk Labs
Need help deploying nemo-mbridge-perf-activation-recompute?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/sayalinvidia-nemo-mbridge-perf-activation-recompute
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/nemo-mbridge-perf-activation-recompute
What's inside
- Skill name
nemo-mbridge-perf-activation-recompute- Description
- Validate and use selective and full activation recompute in Megatron Bridge to reduce GPU memory usage at the cost of extra compute.
- License
- Apache-2.0
- Instructions
- 212 lines in SKILL.md · view on GitHub
Files (6)
- BENCHMARK.md
- SKILL.md
- card.yaml
- evals.json · evals/
- skill-card.md
- skill.oms.sig
SKILL.md (first lines)
# Activation Recompute
Stable docs: @docs/training/activation-recomputation.md
Card: @skills/nemo-mbridge-perf-activation-recompute/card.yaml
## Answer Checklist
For OOM or CUDA graph questions, lead with this exact sequence:
1. First try `PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True`; many
borderline failures are allocator fragmentation, not activation capacity.
2. Prefer selective recompute before full-layer recompute:
`recompute_granularity="selective"` with `recompute_modules=["core_attn"]`.
3. If still borderline, optionally add `"layernorm"`; use `"mlp"` only as a
last resort because it has a large compute cost on wide dense FFNs.
4. Use full-layer recompute only after selective recompute fails to fit, and
always name the required fields: `recompute_granularity="full"`,
`recompute_method`, and `recompute_num_layers`.
5. If FP8 or TE-scoped CUDA graphs are enabled, call out the assertion risk:
full-layer recompute is incompatible with TE scopes such as `attn`, `mlp`,
and `moe_router`. Valid fixes are selective recompute, `cuda_graph_impl="none"`,
or `cuda_graph_impl="local"` with `cuda_graph_scope="full_iteration"`.
## What It Is
Activation recompute trades GPU compute for memory by discarding intermediate
activations during the forward pass and recomputing them during backward.
Megatron Bridge supports two granularities:
| Granularity | What you specify | What gets recomputed | Memory savings | Compute cost |
|---|---|---|---|---|
| `selective` | `recompute_modules` list (e.g. `core_attn`, `mlp`) | specific submodules within each layer | moderate (module-dependent) | low to high |
| `full` | `recompute_num_layers` + `recompute_method` | entire transformer layers (N layers) | strongest | highest |
Note: MCore names these "selective" (submodule-level) vs "full" (layer-level).
"Full" means recomputing full layers, not the full model — you still choose
how many layers via `recompute_num_layers`.
## Quick Decision
1. **Set `PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True` first** — most
borderline OOMs are caused by memory fragmentation, not capacity. This
fixes it at zero cost. See @skills/nemo-mbridge-perf-memory-tuning/SKILL.md.
2. Start with `recompute_granularity=selective`, `recompute_modules=[core_attn]`
(often already the default in recipes).
3. Add `layernorm` to recompute modules — nearly free compute-wise but saves
negligible memory. Only helps in extremely borderline cases.
4. Add `mlp` as a last resort — saves ~3 GB but costs ~16% GPU utilization on
large dense models (Llama3 70B).
5. Use `recompute_granularity=full` only when selective recompute still does
not fit.
CPU offloading (`cpu_offloading=True`) is an alternative that avoids recompute
cost entirely, but it is **incompatible with PP > 1**.
## Enablement
### Selective recompute
```python
cfg.model.recompute_granularity = "selective"
cfg.model.recompute_modules = ["core_attn"] # add "layernorm", "mlp", or other valid modules as needed
```
### Full-layer recompute
```python
cfg.model.recompute_granularity = "full"
cfg.model.recompute_method = "uniform"
cfg.model.recompute_num_layers = 4
```
### Available recompute_modules
| Module | What it recomputes | Compute cost | Memory savings |
|---|---|---|---|
| `core_attn` | attention softmax/dropout/QKV dot product | low (Flash Attention already recomputes internally) | moderate |
| `layernorm` | layer normalization | negligible (~0%) | negligible |
| `mlp` | full FFN block | high (~16% on Llama3 70B, hidden=28672) | ~3 GB |
| `moe` | MoE expert dispatch | varies | varies |
| `moe_act` | MoE activation functions | low | small |
| `shared_experts` | shared expert layers | moderate | moderate |
| `mla_up_proj` | Multi-Latent Attention up projection | moderate | moderate |
### Performance harness CLI
```bash
python scripts/performance/run_performance_workload.py \
--recompute_granularity selective \
--recompute_modules core_attn layernorm \
...
```
## Compatibility and Constraints
- `recompute_granularity=selective` requires a non-empty `recompute_modules` list
- `recompute_granularity=full` requires `recompute_method` and `recompute_num_layers`
- **Layer-level recompute (`recompute_granularity="full"` +
`recompute_num_layers`) is incompatible with TE-scoped CUDA graphs.**
MCore calls this "full" granularity — the name refers to recomputing
full transformer layers, not the full model. Even though you're selecting
how many layers to recompute, MCore treats it differently from submodule
recompute. Any TE-scoped scope (`attn`, `mlp`, `moe_router`, etc.) will
assert. This commonly hits FP8 configs that enable TE-scoped graphs by
default (e.g. `LLAMA3_70B_SFT_CONFIG_H100_FP8_CS_V1` sets
`cuda_graph_impl="transformer_engine"`, `cuda_graph_scope="mlp"`). Options:
- use submodule recompute (`recompute_granularity="selective"` +
`recompute_modules`) — compatible with TE-scoped graphs
- disable CUDA graphs (`cuda_graph_impl="none"`) and use layer-level recompute
- switch to `cuda_graph_impl="local"`, `cuda_graph_scope="full_iteration"`
- `distribute_saved_activations=True` cannot be combined with `sequence_parallel=True`
- Combining `mlp` + `core_attn` recompute is slightly worse than `mlp` alone
due to double recompute overhead
## Measured Results
Llama3 70B SFT on 32x H100 80GB, FP8 (Current Scaling):
- Baseline: TP=4, PP=4, VPP=5, DP=2, MBS=1, GBS=32, seq_len=4096
- Golden GPU utilization: 709.93 TFLOP/s/GPUFrom sayalinvidia/sayali-skills-test, Apache-2.0.
More from sayalinvidia/sayali-skills-test
- 0.476score
physical-ai-neural-reconstruction
NVIDIA Physical AI
Router for NVIDIA NuRec/NRE: USDZ rendering, NCore conversion, 3DGS, gRPC sensor sim, PhysicalAI HF datasets.
SkillCFreshness: CClaude Code +9 - 0.475score
omniverse-cad-to-simready
Omniverse
Coordinate the end-to-end CAD/source-asset to SimReady workflow.
SkillCFreshness: CClaude Code +9 - 0.473score
omniverse-realtime-viewer
NVIDIA Omniverse
Use as the top-level router for Omniverse Realtime Viewer USD app requests and focused viewer reference documents.
SkillCFreshness: CClaude Code +9 - 0.472score
omniverse-usd-performance-tuning
NVIDIA Omniverse
Top-level workflow skill for USD performance diagnosis and optimization.
SkillCFreshness: CClaude Code +9 - 0.471score
cuopt-user-rules
NVIDIA cuOpt Team
Base rules for end users calling NVIDIA cuOpt (routing/LP/MILP/QP/install/server).
SkillCFreshness: CClaude Code +9 - 0.471score
nemo-mbridge-perf-memory-tuning
sayalinvidia
Techniques for reducing peak GPU memory in Megatron Bridge — expandable segments, parallelism resizing, activation recompute, CPU offloading constraints, and…
SkillCFreshness: CClaude Code +9 - 0.446score
physical-ai-infrastructure-setup-and-resilient-scaling
NVIDIA Physical AI
Use when the user wants to set up, scale, validate, or harden NVIDIA physical AI infrastructure for synthetic data generation workflows across local MicroK8s…
SkillCFreshness: CClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 43
- Last commit (this folder)
- Jun 5, 2026 (4 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- Apache-2.0
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from sayalinvidia
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get nemo-mbridge-perf-activation-recompute running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
nemo-mbridge-perf-activation-recompute skill. Agent Mart. https://agentmart.dev/skills/sayalinvidia-nemo-mbridge-perf-activation-recompute (last updated 2026-10-24)