Skip to main content
QUICK REVIEW

[Paper Review] TransNormerLLM: A Faster and Better Large Language Model with Improved TransNormer

Zhen Qin, Li Dong|arXiv (Cornell University)|Jul 27, 2023
Topic ModelingComputer Science5 citations
TL;DR

TransNormerLLM is a linear attention-based large language model that outperforms conventional Transformer models in both accuracy and efficiency by integrating advanced techniques such as LRPE with exponential decay, Lightning Attention for accelerated training, a gating mechanism, tensor normalization, and a robust inference algorithm. It achieves over 2× speedup in training and 4× memory reduction, while maintaining high performance across 385M to 175B parameter scales.

ABSTRACT

We present TransNormerLLM, the first linear attention-based Large Language Model (LLM) that outperforms conventional softmax attention-based models in terms of both accuracy and efficiency. TransNormerLLM evolves from the previous linear attention architecture TransNormer by making advanced modifications that include positional embedding, linear attention acceleration, gating mechanisms, tensor normalization, and inference acceleration and stabilization. Specifically, we use LRPE together with an exponential decay to avoid attention dilution issues while allowing the model to retain global interactions between tokens. Additionally, we propose Lightning Attention, a cutting-edge technique that accelerates linear attention by more than twice in runtime and reduces memory usage by a remarkable four times. To further enhance the performance of TransNormer, we leverage a gating mechanism for smooth training and a new tensor normalization scheme to accelerate the model, resulting in an impressive acceleration of over $20\%$. Furthermore, we develop a robust inference algorithm that ensures numerical stability and consistent inference speed, regardless of the sequence length, showcasing superior efficiency during both training and inference stages. We also implement an efficient model parallel schema for TransNormerLLM, enabling seamless deployment on large-scale clusters and facilitating expansion to even more extensive models, i.e., LLMs with 175B parameters. We validate our model design through a series of ablations and train models with sizes of 385M, 1B, and 7B on our self-collected corpus. Benchmark results demonstrate that our models not only match the performance of state-of-the-art LLMs with Transformer but are also significantly faster. Code is released at: https://github.com/OpenNLPLab/TransnormerLLM.

Motivation & Objective

  • To develop a large language model that surpasses conventional softmax attention-based Transformers in both accuracy and inference efficiency.
  • To address the limitations of existing linear attention mechanisms, including attention dilution and poor real-world performance, through architectural and optimization innovations.
  • To enable scalable training and deployment of ultra-large models (up to 175B parameters) using efficient model parallelism and memory optimization.
  • To ensure numerical stability and consistent inference speed across varying sequence lengths, enhancing practical deployment viability.
  • To validate the model on a large-scale, self-collected corpus of over 2 trillion tokens, demonstrating strong generalization and scalability.

Proposed method

  • Replaced DiagAttention in TransNormer with linear attention to achieve linear complexity and improve global token interactions.
  • Introduced LRPE (Learned Relative Positional Encoding) with exponential decay to mitigate attention dilution while preserving long-range dependencies.
  • Developed Lightning Attention, a novel IO-aware technique that accelerates linear attention by >2× and reduces memory usage by 4× during training.
  • Applied a gating mechanism to stabilize training and a new tensor normalization scheme to accelerate inference, achieving >20% speedup.
  • Designed a robust inference algorithm ensuring numerical stability and constant inference speed regardless of sequence length.
  • Implemented an efficient model parallel schema with support for up to 8-way parallelism, enabling deployment on large-scale clusters and scaling to 175B-parameter models.

Experimental results

Research questions

  • RQ1Can a linear attention-based LLM achieve both higher accuracy and better efficiency than standard Transformer models?
  • RQ2How can attention dilution in linear attention mechanisms be mitigated while preserving long-range sequence modeling capabilities?
  • RQ3To what extent can novel acceleration techniques like Lightning Attention reduce training time and memory consumption in large-scale LLMs?
  • RQ4Can a unified inference algorithm maintain consistent speed and numerical stability across diverse sequence lengths?
  • RQ5What is the scalability ceiling of a linear attention-based LLM when trained on massive datasets and distributed across large-scale GPU clusters?

Key findings

  • TransNormerLLM-7B achieves 4081.0 tokens/sec/GPU, outperforming the Transformer-7B's 3362.7 tokens/sec/GPU under identical conditions.
  • With model parallelism of size 8, TransNormerLLM-7B reduces GPU memory usage to 24.1GB, a 62.3% reduction compared to the 1× configuration.
  • On a 175B-parameter model, TransNormerLLM achieves a relative training speed of 1.35× compared to the Transformer baseline at the same context length.
  • The model maintains a consistent inference speed across sequence lengths due to its robust inference algorithm, ensuring predictable performance.
  • Lightning Attention reduces memory usage by 4× and accelerates training by over 2×, demonstrating significant efficiency gains in real-world training scenarios.
  • The model achieves competitive performance on a 6TB, 2-trillion-token self-collected corpus, matching or exceeding state-of-the-art results for similar-sized models.

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.