SinoTechIntel Academic Portal
Open AccessDOI: 10.1631/FITEE_2400602Original Research

Memory-efficient tensor parallelism for long-sequence Transformer training

Peng LIANG¹,Linbo QIAO¹,Yanqi SHI¹,Hao ZHENG¹,Yu TANG¹,Dongsheng LI¹

National Key Laboratory of Parallel and Distributed Computing, College of Computer Science and Technology, National University of Defense Technology, Changsha 410073, China

Read Executive PreviewQuick FAQ
Memory-efficient tensor parallelism for long-sequence Transformer training
Graphical Abstract / Figure
Published In
Frontiers of Information Technology & Electronic Engineering
Published:May 4, 2025Edition:Vol. 32, Issue 5 • pp. 592-604Citation:Peng LIANG et al. (2025), Frontiers of Information Technology & Electronic Engineering
Impact Factor2.7 (Q2 - Springer)
Sponsored Research Partner
Keywords & Index Terms:distributed learninglarge language modellong sequencemachine learning systemmemory efficiencytensor parallelismFlashAttention

Key Takeaways & Executive Findings

  • • METP avoids duplicated tensors and uses send/recv communication instead of collective communication, improving memory efficiency. • With double buffering, METP achieves effective overlap between computation and communication, with a theoretical condition for full overlap. • METP provides O(1/p^3) memory overhead without FlashAttention and saves at least 41.7% memory compared to TP when using FlashAttention. • On eight A100 GPUs, METP increases the maximum sequence length by 2.38–2.99 times versus other parallelism methods.
Sponsored Research Highlight

Abstract

Transformer-based models like large language models (LLMs) have attracted significant attention in recent years due to their superior performance. A long sequence of input tokens is essential for industrial LLMs to provide better user services. However, memory consumption increases quadratically with the increase of sequence length, posing challenges for scaling up long-sequence training. Current parallelism methods produce duplicated tensors during execution, leaving space for improving memory efficiency. Additionally, tensor parallelism (TP) cannot achieve effective overlap between computation and communication. To solve these weaknesses, we propose a general parallelism method called memory-efficient tensor parallelism (METP), designed for the computation of two consecutive matrix multiplications and a possible function between them (O = f(AB)C), which is the kernel computation component in Transformer training. METP distributes subtasks of computing O to multiple devices and uses send/recv instead of collective communication to exchange submatrices for finishing the computation, avoiding producing duplicated tensors. We also apply the double buffering technique to achieve better overlap between computation and communication. We present the theoretical condition of full overlap to help instruct the long-sequence training of Transformers. Suppose the parallel degree is p; through theoretical analysis, we prove that METP provides O(1/p^3) memory overhead when not using FlashAttention to compute attention and could save at least 41.7% memory compared to TP when using FlashAttention to compute multi-head self-attention. Our experimental results demonstrate that METP can increase the sequence length by 2.38–2.99 times compared to other methods when using eight A100 graphics processing units (GPUs).

1. Introduction

Training language models with long sequences is crucial for handling long-context tasks such as document summarization, dialogue systems, and technical writing (Beltagy et al., 2020; Kaddour et al., 2023; Tarassow, 2023). This is because the context length determines the maximum word count a language model can handle, and longer sequences improve contextual understanding and semantic coherence, allowing models to generate more coherent and contextually appropriate text (Achiam et al., 2023; Huang et al., 2023). However, it requires O(s^2) memory for a sequence with s tokens to complete the attention computation in Transformer models. This memory limitation makes it challenging for language models to calculate extremely long sequences during training. Additionally, training with long sequences costs O(s^2) time for attention computation, bringing computation challenges to a single device.

To address these challenges, researchers proposed various techniques such as tensor parallelism (TP) (Narayanan et al., 2021a), fully sharded data parallelism (FSDP) (Zhao et al., 2023), sequence parallelism (SP) (Li SG et al., 2023; Jacobs et al., 2024), and pipeline parallelism (PP) (Huang et al., 2019; Narayanan et al., 2021b; Liu ZM et al., 2023) to distribute computation and memory costs across multiple devices. These techniques can reduce the memory cost of training large language models (LLMs) to O(1/p), where p denotes the parallel degree. Since these methods are orthogonal to each other, using multiple parallelism methods simultaneously, such as 3D parallelism (Narayanan et al., 2021a; Lai et al., 2023), can reduce the memory footprint to O(1/(pt pd pp)), where pt, pd, and pp represent the parallel degrees of TP, data parallelism (DP), and PP, respectively. However, 3D parallelism could only reduce memory footprint to Ω(1/#device). This work aims to find a 1D parallelism method that can achieve memory usage lower than Ω(1/#device).

FlashAttention (Dao et al., 2022) achieves high memory efficiency by employing tiling techniques to optimize the attention computation process, which comprises two matrix multiplications interleaved with a Softmax operation. This method divides the query, key, and value matrices into submatrices and calculates attention scores for each query submatrix by iterating over all the key and value submatrices, avoiding the significant memory overhead of storing the query@key. As a result, it reduces the memory footprint of computing attention from O(s^2) to O(s), where s represents the sequence length.

SinoTechIntel Interactive Document Reader
Page 1–5 of Preview
100%
Download Full PDF

Loading authentic research manuscript (Pages 1–5)...

Sponsored Research Partner
Cite This Research Paper
Peng LIANG, Linbo QIAO, Yanqi SHI, Hao ZHENG, Yu TANG, Dongsheng LI (2025). Memory-efficient tensor parallelism for long-sequence Transformer training. Frontiers of Information Technology & Electronic Engineering. https://doi.org/10.1631/FITEE_2400602
SinoTechIntel Academic & Legal Disclaimer

Research & Educational Purpose Only:The translations, structured abstracts, analytical annotations, and data reports provided by SinoTechIntel are intended exclusively for academic research, internal corporate R&D, and educational benchmarking. They do not constitute formal engineering, chemical safety, legal, or professional advice.

Copyright & Intellectual Property Notice: Original copyright of the underlying source articles and experimental data remains with the respective authors, institutions, and original publishing journals. SinoTechIntel claims intellectual property only over its proprietary translations, analytical syntheses, and AEO structured enhancements in accordance with international fair use and academic citation principles.

Frequently Asked Questions

What is memory-efficient tensor parallelism (METP)?

METP is a general parallelism method for Transformer training that distributes subtasks of computing two consecutive matrix multiplications across multiple devices, using send/recv communication instead of collective communication to avoid duplicated tensors and improve memory efficiency.

How does METP reduce memory consumption compared to traditional tensor parallelism?

METP avoids producing duplicated tensors during execution and uses double buffering to overlap computation and communication. Theoretical analysis shows it provides O(1/p^3) memory overhead without FlashAttention and saves at least 41.7% memory compared to TP when using FlashAttention.

What are the experimental results of METP on A100 GPUs?

In experiments with eight A100 GPUs, METP increased the sequence length by 2.38–2.99 times compared to other parallelism methods.

Does METP require specific hardware or software?

METP is a general parallelization strategy applicable to Transformer-based models and can be implemented on distributed systems with multiple GPUs, such as eight A100 GPUs used in the experiments.

What is the significance of METP for large language model training?

By reducing memory overhead and enabling longer sequence training, METP helps scale up LLMs for long-context tasks, improving contextual understanding and semantic coherence while using fewer resources.

Recommended Scientific Literature & Research Partners

Related Technical Papers & Translations

Research Paper
Design and optimization of a high-efficiency distillation process for cellulosic fuel ethanol integrated with thermal coupling and molecular sieve adsorption

Design and optimization of a high-efficiency distillation process for cellulosic fuel ethanol integrated with thermal coupling and molecular sieve adsorption

To address the challenges of high energy consumption and prominent costs in the traditional three-columns distillation process for cellulosic fuel ethanol, a distillation—molecular sieve coupling separation process is proposed. This process integrates a three-column (crude distillation column, first distillation column, second distillation column) system with a 3A molecular sieve adsorption deep dehydration unit. A thermal coupling network is constructed via differential pressure design (steam from medium/high-pressure columns as mutual heat sources, reboiler liquid waste heat for feed preheating), and molecular sieve adsorption conditions are optimized. The study first performs a thermodynamic consistency test on the ethanol—water system, determines optimal non-random two-liquid (NRTL) model binary interaction parameters via experimental data regression for Aspen Plus simulation. Aiming at minimum total annual cost (TAC), Aspen Plus is used to optimize process parameters (theoretical tray number, feed location, reflux ratio, side-draw position, etc.). Economic analysis shows this process reduces CO2 emission costs by 27.56%, TAC by 15.58% (to 5.123 × 106 USD·a-1), and increases ethanol purity to >99.6%, providing an effective solution for green, efficient separation.

Read Abstract & PDF
Research Paper
A cohesion loss model for determining residual strength of deep bedded sandstone

A cohesion loss model for determining residual strength of deep bedded sandstone

Rock residual strength, as an important input parameter, plays an indispensable role in proposing the reasonable and scientific scheme about stope design, underground tunnel excavation and stability evaluation of deep chambers. Therefore, previous residual strength models of rocks established were reviewed. And corresponding related problems were stated. Subsequently, starting from the effects of bedding and whole life-cycle evolution process, series of triaxial mechanical tests of deep bedded s

Read Abstract & PDF
Research Paper
Federated model with contrastive learning and adaptive control variates for human activity recognition

Federated model with contrastive learning and adaptive control variates for human activity recognition

Recent attention to privacy issues demands a communication-safe method for training human activity recognition (HAR) models on client activity data. Federated learning (FL) has become a compelling technique to facilitate model training between the server and clients while preserving data privacy. However, classical FL methods often assume independent and identically distributed (IID) data among clients. This assumption does not hold true in practical scenarios. Human activity in real-world scena

Read Abstract & PDF