Home / Companies / Lightning AI / Blog / Post Details
Content Deep Dive

Faster PyTorch Training by Reducing Peak Memory (combining backward pass + optimizer step)

Blog post from Lightning AI

Post Details
Company
Date Published
Author
JP Hennessy
Word Count
2,082
Company Posts That Month
5
Language
English
Hacker News Points
-
Post removed?
No
Summary

Training large models often encounters GPU out-of-memory errors and performance degradation because parameters, optimizer states, activations, gradients, communication buffers, and allocator behavior can create damaging peak-memory spikes. The described Lightning Fabric feature, `fsdp_overlap_step_with_backward`, addresses this by applying optimizer updates during backpropagation as each parameter’s gradient becomes available, immediately releasing gradient memory instead of retaining all gradients until the backward pass ends; it requires one optimizer per parameter and can reduce peak memory by roughly 20–40% or more. In experiments with FSDP-trained Lit-LLaMA models, the approach also reduced allocator pressure and GPU stalls, delivering substantially faster and more consistent training, including a reported 7× throughput gain on 20% fewer GPUs for a 7B model and a 3.4× speed improvement for a 13B model. The discussion also identifies fused optimizer operations such as AdamW’s default `foreach=True`, excessive FSDP all-gathers, and PyTorch’s reserved-versus-allocated memory behavior as additional sources of memory pressure, with settings such as disabling `foreach` and enabling `limit_all_gathers=True` helping in the evaluated workload.

Trends Found in this Post
Trend Post Mentions Total Month Mentions Posts Companies MoM
LLM 2 1,992 221 98 +25%
Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.