perf-activation-recompute

Recompute transformer activations to reduce GPU memory usage during training.

852|445|Updated May 21, 2025
One-click install
npx skills add https://github.com/NVIDIA-NeMo/Megatron-Bridge --skill perf-activation-recompute
Or copy as Structured Prompt for Agentâ–¼
Please help me install this Agent Skill.
Skill: perf-activation-recompute
Source: https://github.com/NVIDIA-NeMo/Megatron-Bridge/tree/main/skills/perf-activation-recompute
Command: npx skills add https://github.com/NVIDIA-NeMo/Megatron-Bridge --skill perf-activation-recompute

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It reduces GPU memory usage during training by selectively recomputing activations, allowing larger models or batch sizes without crashing.

Core Features & Use Cases

  • Memory Optimization: Recomputes specific modules like attention and layernorm to save memory.
  • Training Efficiency: Helps investigate and fix out-of-memory issues caused by memory fragmentation or large model sizes.
  • Use Case: When training a large transformer model that exceeds available GPU memory, apply recompute strategies to fit the model into hardware constraints.

Quick Start

Configure your training setup to enable selective recompute on the attention modules and run your training script to reduce peak memory usage.

Frequently Asked Questions about perf-activation-recompute

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix out-of-memory errors when training a large transformer model on GPU?â–¼

To fix out-of-memory (OOM) errors during transformer training, apply selective activation recompute to reduce GPU memory usage. This technique recalculates specific module activations on the fly, freeing up memory to fit larger models or batch sizes without crashing.

What is selective activation recompute and how does it save GPU memory?â–¼

Selective activation recompute saves GPU memory by discarding intermediate activations during the forward pass and recomputing them during the backward pass. By targeting specific modules like attention and layernorm, it lowers memory requirements for large-scale training.

Does activation recompute slow down transformer training efficiency?â–¼

Activation recompute optimizes memory efficiency with minimal performance impact. While recomputing activations introduces a slight overhead, it enables successful training of large transformer models that would otherwise fail due to GPU memory constraints.

How do I configure selective recompute for attention modules in my training script?â–¼

To configure selective recompute, update your training setup to enable the feature on attention modules. Running your training script with this configuration will selectively recompute those activations, directly reducing peak memory usage.

Can I use activation recompute to fix GPU memory fragmentation issues during training?â–¼

Yes, activation recompute helps investigate and fix out-of-memory issues caused by memory fragmentation or large model sizes. By lowering the memory footprint of activations, it mitigates fragmentation and allows training to proceed.

When should I use selective recompute instead of reducing batch size for large transformer training?â–¼

Use selective recompute when reducing batch size is not viable or degrades training quality. It allows you to maintain larger batch sizes and fit large transformer models into hardware constraints by strategically managing memory for modules like attention.