perf-cpu-offloading

Offloads Megatron Bridge activations or optimizer states to CPU to reduce GPU memory usage during training.

Updated May 23, 2026
One-click install
npx skills add https://github.com/yo-steven/skills-exploration-20260522 --skill perf-cpu-offloading-yo-steven
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: perf-cpu-offloading
Source: https://github.com/yo-steven/skills-exploration-20260522/tree/main/skills/Megatron-Bridge/perf-cpu-offloading
Command: npx skills add https://github.com/yo-steven/skills-exploration-20260522 --skill perf-cpu-offloading-yo-steven

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It reduces GPU memory pressure in Megatron Bridge training by offloading either layer activations or optimizer states to CPU, helping prevent OOMs and enable larger models or batch sizes.

Core Features & Use Cases

  • Activation offloading (layer-level): Offloads transformer layer activations (optionally weights) to CPU with strict constraints like pipeline_model_parallel_size = 1 and no recompute or CUDA graphs, which is mainly useful for small/medium models.
  • Optimizer offloading (fractional): Offloads Adam optimizer state to CPU via HybridDeviceOptimizer using optimizer_cpu_offload and optimizer_offload_fraction, supporting PP>1 and offering a controllable memory-speed tradeoff.
  • Practical performance guidance: Provides recommended fractions and overlap settings to balance memory savings against throughput, validated on large MoE experiments.

Quick Start

Enable optimizer CPU offloading by setting optimizer.optimizer_cpu_offload=True and optimizer.optimizer_offload_fraction=0.5 (optionally also setting optimizer.overlap_cpu_optimizer_d2h_h2d=True for higher fractions) to reduce GPU memory while keeping training numerically stable.

Frequently Asked Questions about perf-cpu-offloading

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

FAQPage Schema
How do I reduce GPU memory usage during Megatron Bridge training without causing OOMs?

You can reduce GPU memory usage by offloading either layer activations or Adam optimizer states to CPU, which relieves memory pressure and helps prevent out-of-memory errors during training.

How do I configure optimizer CPU offloading for large MoE models?

Enable optimizer CPU offloading by setting optimizer.optimizer_cpu_offload=True and optimizer.optimizer_offload_fraction to a value like 0.5, optionally enabling overlap_cpu_optimizer_d2h_h2d for higher fractions to maintain throughput.

Can I offload activations to CPU when using pipeline parallelism?

No, activation offloading requires pipeline_model_parallel_size = 1 and cannot be used with recompute or CUDA graphs, making it suitable only for small to medium models without pipeline parallelism.

Does optimizer offloading support pipeline parallelism for large models?

Yes, optimizer offloading via HybridDeviceOptimizer supports pipeline parallelism with PP>1 and is validated for large MoE runs, offering a controllable memory-speed tradeoff for large-scale training.

What are the limitations of using CUDA graphs with CPU offloading?

CUDA graphs cannot be used with activation offloading, which also requires no recompute and pipeline_model_parallel_size = 1, restricting this specific offloading technique to small or medium model configurations.

When should I enable overlap settings for CPU optimizer offloading?

Enable optimizer.overlap_cpu_optimizer_d2h_h2d=True when using higher optimizer offload fractions to balance memory savings against throughput and keep training numerically stable.