[논문 리뷰] SLAB: Efficient Transformers with Simplified Linear Attention and Progressive Re-parameterized Batch Normalization
이 논문은 SLAB를 도입합니다. 이는 재매개변수화된 BatchNorm(RepBN)으로 LayerNorm의 점진적 교체와 간소화된 선형 주의(SLA)를 결합해 비전 및 언어 태스크에서 정확도를 유지하면서 대기 지연(latency)이 낮은 더 효율적인 트랜스포머를 구축합니다.
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.
연구 동기 및 목표
- 트랜스포머 정규화 및 어텐션 모듈의 계산 병목 현상을 식별한다.
- 평가 중 BN의 안정성을 유지하기 위해 LayerNorm을 대체하는 Progressive Re-parameterized BatchNorm(PRepBN)을 도입한다.
- 성능을 유지하면서 계산 비용을 줄이는 Simplified Linear Attention(SLA)을 개발한다.
- 이미지 분류, 객체 탐지 및 언어 모델링 태스크에서 SLAB의 효율성을 시연한다.
- PRepBN과 SLA가 LN 기반 또는 기존 선형 어텐션 트랜스포머에 비해 더 낮은 대기 지연과 비교 가능하거나 더 나은 정확도를 보임을 보인다.
제안 방법
- 훈련 중 LN에서 BN 기반 트랜스포머로의 전환을 점진적으로 수행하기 위해 감소 제어 감마를 사용해 LN 지배에서 BN 기반으로의 전이를 진행한다.
- RepBN(X) = BN(X) + eta X로 eta를 학습 가능한 매개변수로 두어 사후 학습 재매개변화를 통해 표준 BN으로 변환할 수 있게 한다.
- 재매개변수화 보조정리를 제공하여 RepBN을 추론 시 표준 BN 형태로 변환한다.
- Progressive LN -> RepBN 정의: PRepBN(X) = gamma*LN(X) + (1-gamma)*RepBN(X)로, gamma가 학습 단계에 따라 감소한다.
- SLA를 제안하여 Sim_SLA(Qi, Kj) = ReLU(Qi) ReLU(Kj)^T로 정의하고, 그 뒤에 정규화된 집계와 로컬 향상을 위한 깊이 방향 컨볼루션을 적용한다.
- SLA의 선형 시간 복잡도와 하드웨어 친화적 연산을 시연하고 주의 다양성을 주의 맵에서 시각화대로 보존한다.
실험 결과
연구 질문
- RQ1 LN을 점진적으로 학습되는 RepBN으로 대체해 추론 지연 시간을 줄이고 정확도 손실 없이 달성할 수 있는가?
- RQ2제안된 SLA가 기존의 선형 주의 방법의 성능에 도달하거나 이를 능가하면서 계산 비용은 더 낮아지는가?
- RQ3비전 태스크에서 DeiT, PVT, Swin 등의 서로 다른 트랜스포머 백본에서 PRepBN과 SLA가 어떻게 상호작용하는가?
- RQ4표준 벤치마크에서 PRepBN과 SLA를 결합했을 때의 구체적인 정확도-지연 무역Assess는 무엇인가?
주요 결과
- Progressive LN 전이와 함께하는 PRepBN은 정확도를 더 높이고 BN 기반 트랜스포머에서 추론 지연을 더 낮춘다.
- SLAB-Swin-T는 ImageNet-1K에서 83.6%의 top-1 정확도와 16.2 ms의 지연으로, Flatten-Swin에 비해 지연을 2.4 ms 줄이고 약간 더 높은 정확도를 달성한다.
- SLA는 백본 전반에서 지연을 크게 줄이면서 Flatten 트랜스포머에 비해 경쟁력 있는 정확도를 유지한다.
- 다양한 백본에서 SLAB 변형은 처리량이 개선되거나 정확도가 비슷하고 지연이 더 낮다(예: SLAB-DeiT-T 9.6 ms에서 74.3% top-1, Flatten-DeiT-T의 15.2 ms에서 74.1%).
- 언어 모델링 및 LLaMA-350M 실험에서, PRepBN은 추론 지연을 줄이고 처리량을 높이면서 유사한 perplexity를 보인다.
이 논문 읽기
누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.
누빈트에서 이 논문 읽기이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.