INT-FlashAttention: Enabling Flash Attention for INT8 Quantization

Shimao Chen, Zirui Liu, Zhiying Wu, Ce Zheng, Peizhuang Cong +4 more
9/25/2024
cs.LGcs.AI

No official code found. Best implementation: INT-FlashAttention2024/INT-FlashAttention (91 stars, last commit 2025-01-23).

Abstract

As the foundation of large language models (LLMs), self-attention module faces the challenge of quadratic time and memory complexity with respect to sequence length. FlashAttention accelerates attention computation and reduces its memory usage by leveraging the GPU memory hierarchy. A promising research direction is to integrate FlashAttention with quantization methods. This paper introduces INT-FlashAttention, the first INT8 quantization architecture compatible with the forward workflow of FlashAttention, which significantly improves the inference speed of FlashAttention on Ampere GPUs. We implement our INT-FlashAttention prototype with fully INT8 activations and general matrix-multiplication (GEMM) kernels, making it the first attention operator with fully INT8 input. As a general token-level post-training quantization framework, INT-FlashAttention is also compatible with other data formats like INT4, etc. Experimental results show INT-FlashAttention achieves 72% faster inference speed and 82% smaller quantization error compared to standard FlashAttention with FP16 and FP8 data format.

View on arXivView PDF

Code Implementations(1)

915C++, CudaSep 21, 20241 years ago

Similar Papers

Cite this paper

@article{chen2024intflashattention,
  title  = {INT-FlashAttention: Enabling Flash Attention for INT8 Quantization},
  author = {Shimao Chen and Zirui Liu and Zhiying Wu and Ce Zheng and Peizhuang Cong and Zihan Jiang and Yuhan Wu and Lei Su and Tong Yang},
  year   = {2024},
  eprint = {2409.16997},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2409.16997v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2409.16997.svg)](https://codeofpaper.com/paper/2409.16997)

Discussion