Skip to main content
QUICK REVIEW

[Paper Review] Reducing Activation Recomputation in Large Transformer Models

Vijay Anand Korthikanti, Jared Casper|arXiv (Cornell University)|May 10, 2022
Parallel Computing and Optimization TechniquesComputer Science52 citations
TL;DR

The paper introduces sequence parallelism and selective activation recomputation to dramatically reduce activation memory and recomputation overhead, enabling training of very large transformers with less memory and about 30% higher throughput.

ABSTRACT

Training large transformer models is one of the most important computational challenges of modern AI. In this paper, we show how to significantly accelerate training of large transformer models by reducing activation recomputation. Activation recomputation is commonly used to work around memory capacity constraints. Rather than storing activations for backpropagation, they are traditionally recomputed, which saves memory but adds redundant compute. In this work, we show most of this redundant compute is unnecessary because we can reduce memory consumption sufficiently without it. We present two novel yet very simple techniques: sequence parallelism and selective activation recomputation. In conjunction with tensor parallelism, these techniques almost eliminate the need to recompute activations. We evaluate our approach on language models up to one trillion parameters in scale and show that our method reduces activation memory by 5x, while reducing execution time overhead from activation recomputation by over 90%. For example, when training a 530B parameter GPT-3 style model on 2240 NVIDIA A100 GPUs, we achieve a Model Flops Utilization of 54.2%, which is 29% faster than the 42.1% we achieve using recomputation. Our implementation will be available in both Megatron-LM and NeMo-Megatron.

Motivation & Objective

  • Motivate the memory bottleneck of activation storage in large transformer training.
  • Develop methods to reduce activation memory without heavy compute overhead.
  • Combine tensor and sequence parallelism to minimize recomputation.
  • Introduce selective activation recomputation to further cut memory and overhead.
  • Provide empirical evaluation up to models near one trillion parameters.

Proposed method

  • Derive activation memory estimates for transformer layers to quantify memory needs (Equation 1).
  • Apply tensor parallelism to split activations inside attention and MLP blocks (Equation 2).
  • Introduce sequence parallelism to partition non-tensor-parallel regions along the sequence dimension (leading to Equation 4).
  • Combine tensor and sequence parallelism with pipeline parallelism and derive converters g and g to minimize extra communications (Figures 5 and 6).
  • Propose selective activation recomputation that targets high-activation regions (e.g., attention-related ops) to reduce memory with modest FLOP overhead (Equation 6).
  • Evaluate memory and runtime impacts on models up to 1T parameters using Megatron-LM and NeMo-Megatron implementations.

Experimental results

Research questions

  • RQ1How much activation memory is required for training large transformer models with standard memory layouts?
  • RQ2Can hybrid tensor/sequence/pipeline parallelism reduce activation memory without incurring large compute/communication penalties?
  • RQ3Does selective activation recomputation meaningfully cut memory while keeping FLOP overhead low?
  • RQ4What end-to-end throughput gains are achievable for trillion-parameter transformers when applying these techniques?

Key findings

  • Activation memory can be reduced by about 5x when applying sequence parallelism and selective activation recomputation together.
  • Selective activation recomputation lowers recomputation FLOPs overhead to under 3% for large models, versus 30-40% for full recomputation.
  • End-to-end iteration throughput improves by about 29-32% across tested configurations compared to full recomputation.
  • For GPT-3 530B and MT-NLG, the approach significantly reduces memory per transformer layer and enables training without heavy recomputation.
  • On a 2240-A100 setup for a 530B GPT-3 style model, Model FLOPs Utilization is 54.2%, 29% faster than the 42.1% baseline.
  • Memory savings scale with model size, achieving about 5x reduction overall and enabling training where baseline activations would exceed device memory.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.