Skip to main content
QUICK REVIEW

[논문 리뷰] Quantizable Transformers: Removing Outliers by Helping Attention Heads Do Nothing

Yelysei Bondarenko, Markus Nagel|arXiv (Cornell University)|2023. 06. 22.
Domain Adaptation and Few-Shot LearningComputer Science인용 수 10
한 줄 요약

요약: 이 논문은 두 가지 아키텍처 수정—클리핑된 소프트맥스와 게이트드 어텐션—을 도입하여 트랜스포머의 활성화 이상치를 줄이고, 추가 재학습 없이도 간단한 INT8 PTQ를 가능하게 한다. BERT, OPT, ViT 전반에 걸친 양자화 친화적 성능 향상을 입증한다.

ABSTRACT

Transformer models have been widely adopted in various domains over the last years, and especially large language models have advanced the field of AI significantly. Due to their size, the capability of these networks has increased tremendously, but this has come at the cost of a significant increase in necessary compute. Quantization is one of the most effective ways to reduce the computational time and memory consumption of neural networks. Many studies have shown, however, that modern transformer models tend to learn strong outliers in their activations, making them difficult to quantize. To retain acceptable performance, the existence of these outliers requires activations to be in higher bitwidth or the use of different numeric formats, extra fine-tuning, or other workarounds. We show that strong outliers are related to very specific behavior of attention heads that try to learn a "no-op" or just a partial update of the residual. To achieve the exact zeros needed in the attention matrix for a no-update, the input to the softmax is pushed to be larger and larger during training, causing outliers in other parts of the network. Based on these observations, we propose two simple (independent) modifications to the attention mechanism - clipped softmax and gated attention. We empirically show that models pre-trained using our methods learn significantly smaller outliers while maintaining and sometimes even improving the floating-point task performance. This enables us to quantize transformers to full INT8 quantization of the activations without any additional effort. We demonstrate the effectiveness of our methods on both language models (BERT, OPT) and vision transformers.

연구 동기 및 목표

  • 비전과 언어 모델 전반에서 활성화 이상치가 트랜스포머의 양자화를 방해하는 원인 식별.
  • FP 성능을 해치지 않으면서 이상치를 억제하는 어텐션의 아키텍처 수정 제안.
  • 다양한 모델 계열에서 PTQ 성능에 대한 이러한 수정의 영향을 평가.

제안 방법

  • 트랜스포머 어텐션 헤드에서의 이상치 현상과 소프트맥스 및 잔차 연결과의 상호작용 분석.
  • 드롭인 대체로서 정확한 제로를 생성하고 이상치를 감소시키는 클리핑된 소프트맥스 제안.
  • 가벼운 헤드별 게이팅 네트워크로 어텐션 출력을 조절하는 게이트드 어텐션 제안.
  • INT8로의 포스트 트레이닝 양자화 후 양자화된 성능과 FP 성능 및 이상치 지표 비교.
  • 표준 벤치마크에서 BERT-base, OPT-125M, ViT-S/16에 대해 평가.

실험 결과

연구 질문

  • RQ1NLP 및 CV 아키텍처 전반에서 트랜스포머 어텐션의 강한 활성화 이상치를 야기하는 원인은 무엇인가?
  • RQ2재학습 없이도 이상치를 억제하고 양자화를 개선할 수 있는 어텐션 메커니즘의 구조적 변화가 가능한가?
  • RQ3클리핑된 소프트맥스와 게이트드 어텐션이 FP 성능을 보존하거나 향상시키면서 PTQ 결과를 더 좋게 할 수 있는가?

주요 결과

  • 클리핑된 소프트맥스와 게이트드 어텐션은 어텐션 계층의 출력 이상치와 커토시스를 크게 감소시킨다.
  • 두 방법 모두 다양한 모델에서 FP 성능을 유지하거나 때때로 향상시키면서 W8A8 양자화 성능을 개선한다.
  • 게이트드 어텐션은 보고된 실험에서 OPT 및 ViT에 대해 가장 강한 PTQ 향상을 보인다.
  • 게이트드 어텐션이 max infinity norm 및 커토시스를 눈에 띄게 낮춰 양자화된 언어 모델의 perplexity를 개선한다.
  • BERT와 ViT는 두 방법 모두에서 우호적인 양자화 지표를 보여주며, OPT의 클리핑된 소프트맥스는 본 연구의 일부 구성에서 다소 미흡했다.

이 논문 읽기

누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.

누빈트에서 이 논문 읽기

이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.