Skip to main content
QUICK REVIEW

[Paper Review] Sequence Parallelism: Making 4D Parallelism Possible

Shenggui Li, Fuzhao Xue|arXiv (Cornell University)|May 26, 2021
Advanced Neural Network ApplicationsComputer Science23 references12 citations
TL;DR

This paper introduces sequence parallelism, a memory-efficient training method that splits long sequences across multiple GPUs, enabling longer sequence modeling by communicating attention embeddings via ring-style all-reduce. It achieves 13.7× larger batch size and 3.0× longer sequence length than tensor parallelism on 64 P100 GPUs, with full compatibility to data and pipeline parallelism in PyTorch.

ABSTRACT

Within Transformer, self-attention is the key module to learn powerful context-aware representations. However, self-attention suffers from quadratic memory requirements with respect to the sequence length, which limits us to process longer sequence on GPU. In this work, we propose sequence parallelism, a memory efficient parallelism method to help us break input sequence length limitation and train with longer sequence on GPUs. Compared with existing parallelism, our approach no longer requires a single device to hold the whole sequence. Specifically, we split the input sequence into multiple chunks and feed each chunk into its corresponding device (i.e. GPU). To compute the attention output, we communicate attention embeddings among GPUs. Inspired by ring all-reduce, we integrated ring-style communication with self-attention calculation and proposed Ring Self-Attention (RSA). Our implementation is fully based on PyTorch. Without extra compiler or library changes, our approach is compatible with data parallelism and pipeline parallelism. Experiments show that sequence parallelism performs well when scaling with batch size and sequence length. Compared with tensor parallelism, our approach achieved $13.7 imes$ and $3.0 imes$ maximum batch size and sequence length respectively when scaling up to 64 NVIDIA P100 GPUs. We plan to integrate our sequence parallelism with data, pipeline and tensor parallelism to further train large-scale models with 4D parallelism in our future work.

Motivation & Objective

  • Address the quadratic memory growth of self-attention in Transformers, which limits sequence length on GPUs.
  • Overcome the bottleneck of requiring a single device to hold the entire input sequence during attention computation.
  • Enable efficient training of long sequences by distributing sequence chunks across multiple GPUs without requiring model or hardware modifications.
  • Design a communication-efficient attention mechanism compatible with existing parallelism strategies like data and pipeline parallelism.
  • Achieve scalable training with both batch size and sequence length by integrating sequence parallelism into a 4D parallelism framework.

Proposed method

  • Split the input sequence into multiple chunks and assign each chunk to a separate GPU, eliminating the need for any single device to store the full sequence.
  • Use ring-style all-reduce communication to exchange attention embeddings across GPUs during self-attention computation, enabling distributed attention calculation.
  • Introduce Ring Self-Attention (RSA), a novel attention mechanism that integrates ring communication directly into the attention computation pipeline.
  • Implement the method natively in PyTorch without requiring compiler or library changes, ensuring broad compatibility with existing training frameworks.
  • Combine sequence parallelism with data parallelism and pipeline parallelism to enable 4D parallelism for large-scale model training.
  • Maintain gradient consistency and model accuracy by synchronizing attention outputs across devices using ring all-reduce during backward passes.

Experimental results

Research questions

  • RQ1Can sequence parallelism break the sequence length limitation in Transformers by distributing sequence chunks across multiple GPUs?
  • RQ2How does sequence parallelism compare to tensor parallelism in terms of maximum batch size and sequence length scaling?
  • RQ3To what extent can sequence parallelism scale with both batch size and sequence length when combined with data and pipeline parallelism?
  • RQ4Is it possible to integrate sequence parallelism with existing parallelism strategies like data and pipeline parallelism without architectural or compiler-level changes?
  • RQ5How efficient is the ring-style communication in sequence parallelism for attention computation compared to standard all-reduce or parameter sharing?

Key findings

  • Sequence parallelism enables training with 13.7× larger batch size compared to tensor parallelism when scaling to 64 NVIDIA P100 GPUs.
  • The method supports 3.0× longer input sequences than tensor parallelism under the same hardware setup.
  • The approach achieves high scalability with both increasing batch size and sequence length, demonstrating strong linear scaling efficiency.
  • The implementation is fully compatible with data parallelism and pipeline parallelism, enabling seamless integration into existing training pipelines.
  • Ring Self-Attention (RSA) effectively reduces communication overhead by leveraging ring all-reduce, maintaining high throughput during training.
  • The method requires no changes to PyTorch or external libraries, making it easily deployable in existing deep learning workflows.

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.