Loki: Low-rank Keys for Efficient Sparse Attention

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Singhania, Prajwal, Singh, Siddharth, He, Shwai, Feizi, Soheil, Bhatele, Abhinav
Formato: Preprint
Publicado: 2024
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866929582826848256
author Singhania, Prajwal
Singh, Siddharth
He, Shwai
Feizi, Soheil
Bhatele, Abhinav
author_facet Singhania, Prajwal
Singh, Siddharth
He, Shwai
Feizi, Soheil
Bhatele, Abhinav
contents Inference on large language models (LLMs) can be expensive in terms of the compute and memory costs involved, especially when long sequence lengths are used. In particular, the self-attention mechanism used in LLM inference contributes significantly to these costs, which has sparked an interest in approximating the self-attention computation to reduce such costs. In this work, we propose to approximate self-attention by focusing on the dimensionality of key vectors computed in the attention block. Our analysis reveals that key vectors lie in a significantly lower-dimensional space, consistently across several datasets and models. Exploiting this observation, we propose Loki, a novel sparse attention method that ranks and selects tokens in the KV-cache based on attention scores computed in low-dimensional space. Our evaluations show that Loki is able to speed up the attention computation due to reduced data movement (load/store) and compute costs while maintaining the efficacy of the models better than other popular approximation methods.
format Preprint
id arxiv_https___arxiv_org_abs_2406_02542
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Loki: Low-rank Keys for Efficient Sparse Attention
Singhania, Prajwal
Singh, Siddharth
He, Shwai
Feizi, Soheil
Bhatele, Abhinav
Machine Learning
Inference on large language models (LLMs) can be expensive in terms of the compute and memory costs involved, especially when long sequence lengths are used. In particular, the self-attention mechanism used in LLM inference contributes significantly to these costs, which has sparked an interest in approximating the self-attention computation to reduce such costs. In this work, we propose to approximate self-attention by focusing on the dimensionality of key vectors computed in the attention block. Our analysis reveals that key vectors lie in a significantly lower-dimensional space, consistently across several datasets and models. Exploiting this observation, we propose Loki, a novel sparse attention method that ranks and selects tokens in the KV-cache based on attention scores computed in low-dimensional space. Our evaluations show that Loki is able to speed up the attention computation due to reduced data movement (load/store) and compute costs while maintaining the efficacy of the models better than other popular approximation methods.
title Loki: Low-rank Keys for Efficient Sparse Attention
topic Machine Learning
url https://arxiv.org/abs/2406.02542