Skip to main content
QUICK REVIEW

[Paper Review] SLAB: Efficient Transformers with Simplified Linear Attention and Progressive Re-parameterized Batch Normalization

Jialong Guo, Xinghao Chen|arXiv (Cornell University)|May 19, 2024
Advanced Memory and Neural ComputingEngineering7 citations
TL;DR

This paper introduces SLAB, which combines a progressive replacement of LayerNorm with re-parameterized BatchNorm (RepBN) and a simplified linear attention (SLA) to build more efficient transformers with lower latency while maintaining accuracy across vision and language tasks.

ABSTRACT

Transformers have become foundational architectures for both natural language and computer vision tasks. However, the high computational cost makes it quite challenging to deploy on resource-constraint devices. This paper investigates the computational bottleneck modules of efficient transformer, i.e., normalization layers and attention modules. LayerNorm is commonly used in transformer architectures but is not computational friendly due to statistic calculation during inference. However, replacing LayerNorm with more efficient BatchNorm in transformer often leads to inferior performance and collapse in training. To address this problem, we propose a novel method named PRepBN to progressively replace LayerNorm with re-parameterized BatchNorm in training. Moreover, we propose a simplified linear attention (SLA) module that is simple yet effective to achieve strong performance. Extensive experiments on image classification as well as object detection demonstrate the effectiveness of our proposed method. For example, our SLAB-Swin obtains $83.6\%$ top-1 accuracy on ImageNet-1K with $16.2$ms latency, which is $2.4$ms less than that of Flatten-Swin with $0.1\%$ higher accuracy. We also evaluated our method for language modeling task and obtain comparable performance and lower latency.Codes are publicly available at https://github.com/xinghaochen/SLAB and https://github.com/mindspore-lab/models/tree/master/research/huawei-noah/SLAB.

Motivation & Objective

  • Identify computational bottlenecks in transformer normalization and attention modules.
  • Propose Progressive Re-parameterized BatchNorm (PRepBN) to replace LayerNorm with stable BN during inference.
  • Develop Simplified Linear Attention (SLA) that reduces computational cost while maintaining performance.
  • Demonstrate SLAB's efficiency on image classification, object detection, and language modeling tasks.
  • Show that PRepBN and SLA yield lower latency with comparable or better accuracy than LN-based or prior linear-attention transformers.

Proposed method

  • Progressively replace LayerNorm with Re-parameterized BatchNorm (RepBN) during training using a decay-controlled gamma to transition from LN-dominated to BN-based transformers.
  • Introduce RepBN(X) = BN(X) + eta X, with eta as a learnable parameter, enabling a post-training re-parameterization to standard BN.
  • Provide a re-parameterization lemma to convert RepBN into a standard BN form for inference.
  • Define Progressive LN -> RepBN: PRepBN(X) = gamma*LN(X) + (1-gamma)*RepBN(X) with gamma decaying over training steps.
  • Propose Simplified Linear Attention (SLA) where Sim_SLA(Qi, Kj) = ReLU(Qi) ReLU(Kj)^T, followed by a normalized aggregation and a depth-wise convolution for local enhancement.
  • Demonstrate SLA’s linear-time complexity and hardware-friendly operations, preserving attention diversity as visualized in attention maps.

Experimental results

Research questions

  • RQ1Can replacing LayerNorm with progressively trained RepBN reduce inference latency without sacrificing accuracy?
  • RQ2Does the proposed SLA match or surpass the performance of existing linear attention methods while offering lower computational cost?
  • RQ3How do PRepBN and SLA interact across different transformer backbones (DeiT, PVT, Swin) in vision tasks and in language modeling?
  • RQ4What are the concrete accuracy-latency trade-offs when combining PRepBN with SLA on standard benchmarks?

Key findings

  • PRepBN with progressive LN transition yields higher accuracy and enables BN-based transformers with lower inference latency.
  • SLAB-Swin-T achieves 83.6% top-1 accuracy on ImageNet-1K with 16.2 ms latency, improving latency by 2.4 ms over Flatten-Swin with slightly higher accuracy.
  • SLA reduces latency significantly across backbones while maintaining competitive accuracy compared to Flatten transformers.
  • Across multiple backbones, SLAB variants show improved throughput or comparable accuracy with lower latency (example: SLAB-DeiT-T 74.3% top-1 at 9.6 ms vs Flatten-DeiT-T 74.1% at 15.2 ms).
  • In language modeling and LLaMA-350M experiments, PRepBN yields similar perplexity with lower inference latency and higher throughput.

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.