Salvato in:
Dettagli Bibliografici
Autori principali: Joshi, Thomas, Saini, Herman, Dhillon, Neil, Martin, Antoni Viros i, Maghraoui, Kaoutar El
Natura: Preprint
Pubblicazione: 2025
Soggetti:
Accesso online:https://arxiv.org/abs/2506.07311
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866912419056451584
author Joshi, Thomas
Saini, Herman
Dhillon, Neil
Martin, Antoni Viros i
Maghraoui, Kaoutar El
author_facet Joshi, Thomas
Saini, Herman
Dhillon, Neil
Martin, Antoni Viros i
Maghraoui, Kaoutar El
contents Large Language Models (LLMs) encounter severe memory inefficiencies during long-context inference due to conventional handling of key-value (KV) caches. In this work, we introduce a novel integration of PagedAttention with PyTorch's FlexAttention, addressing internal fragmentation and inefficiencies associated with monolithic KV cache allocations. Implemented within IBM's Foundation Model Stack (FMS), our fused attention kernel efficiently gathers scattered KV data. Our benchmarks on an NVIDIA L4 GPU (24GB) demonstrate significantly reduced inference latency, growing only linearly (~2x) with sequence length from 128 to 2048 tokens when utilizing a global KV cache, compared to exponential latency increases without caching. While peak memory usage remains largely unchanged for single-step evaluations (dominated by model weights and activations), paged attention causes minimal incremental memory usage, observable only at sequence lengths exceeding 2048 tokens due to its power-of-two cache allocations. We open-source the full implementation and discuss its implications for future long-context model deployment.
format Preprint
id arxiv_https___arxiv_org_abs_2506_07311
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Paged Attention Meets FlexAttention: Unlocking Long-Context Efficiency in Deployed Inference
Joshi, Thomas
Saini, Herman
Dhillon, Neil
Martin, Antoni Viros i
Maghraoui, Kaoutar El
Machine Learning
Artificial Intelligence
Large Language Models (LLMs) encounter severe memory inefficiencies during long-context inference due to conventional handling of key-value (KV) caches. In this work, we introduce a novel integration of PagedAttention with PyTorch's FlexAttention, addressing internal fragmentation and inefficiencies associated with monolithic KV cache allocations. Implemented within IBM's Foundation Model Stack (FMS), our fused attention kernel efficiently gathers scattered KV data. Our benchmarks on an NVIDIA L4 GPU (24GB) demonstrate significantly reduced inference latency, growing only linearly (~2x) with sequence length from 128 to 2048 tokens when utilizing a global KV cache, compared to exponential latency increases without caching. While peak memory usage remains largely unchanged for single-step evaluations (dominated by model weights and activations), paged attention causes minimal incremental memory usage, observable only at sequence lengths exceeding 2048 tokens due to its power-of-two cache allocations. We open-source the full implementation and discuss its implications for future long-context model deployment.
title Paged Attention Meets FlexAttention: Unlocking Long-Context Efficiency in Deployed Inference
topic Machine Learning
Artificial Intelligence
url https://arxiv.org/abs/2506.07311