arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.13784cs.LG
收藏

注意力一次就足够:高效的流式推断与状态化Transformer

Attention Once Is All You Need: Efficient Streaming Inference with Stateful Transformers

LayerScale, Inc.(LayerScale公司)

Victor Norgren

AI总结:

本文提出基于状态化会话的数据驱动计算模型,通过增量式KV缓存降低预填充成本,实现查询延迟与上下文长度无关。Flash Queries利用空闲GPU周期预处理问题,提升流式推断效率,实测在市场数据基准上达到5.9倍速度提升。

摘要:

传统Transformer推理引擎是请求驱动的,在每次查询中支付O(n)的预填充成本。在流式工作负载中,数据持续到达且查询探测不断增长的上下文,这种成本变得不可接受。我们引入以状态化会话为中心的数据驱动计算模型:一个持久化的KV缓存随着新数据的到来逐步推进,使预填充脱离关键路径,查询延迟变为O(|q|),与累积上下文大小无关。在此基础上,Flash Queries在数据到达之间回收空闲GPU周期预处理注册的问题并返回缓存答案,这种模式在无状态引擎中结构上不可能实现,因为它们在请求之间丢弃中间状态。一个多租户连续批处理调度器带有单元预算准入和前缀感知的分组预填充,使数十个状态化会话能够在单个GPU上共存,同时保持完整的二次自注意力。在流式市场数据基准上,参考实现相对于传统推理引擎(vLLM、SGLang、TensorRT-LLM、llama.cpp)达到最高5.9倍的速度提升,同时保持查询延迟恒定,即使累积上下文增长。

英文摘要:

Conventional transformer inference engines are request-driven, paying an O(n) prefill cost on every query. In streaming workloads, where data arrives continuously and queries probe an ever-growing context, this cost is prohibitive. We introduce a data-driven computational model centred on stateful sessions: a persistent KV cache advanced incrementally as new data arrives, so prefill is moved off the critical path and query latency becomes O(|q|), independent of accumulated context size. Building on this, Flash Queries reclaim idle GPU cycles between data arrivals to pre-evaluate registered questions and return cached answers before the user asks, a pattern that is structurally impossible in stateless engines because they discard intermediate state between requests. A multi-tenant continuous-batching scheduler with cell-budget admission and prefix-aware grouped prefill lets dozens of stateful sessions coexist on a single GPU while preserving full quadratic self-attention. On streaming market-data benchmarks the reference implementation achieves up to 5.9x speedup over conventional inference engines (vLLM, SGLang, TensorRT-LLM, llama.cpp), holding query latency constant as accumulated context grows.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑