[论文解读] 98$ imes$ Faster LLM Routing Without a Dedicated GPU: Flash Attention, Prompt Compression, and Near-Streaming for the vLLM Semantic Router
论文提出多阶段优化(Flash Attention、提示压缩和近流式处理)以在共享GPU上实现几乎无专用加速器的接近100×更快的LLM路由。它展示了一个PCIe共享的AMD MI300X实现,支持8K–32K令牌路由,GPU占用不到800 MB。
System-level routers that intercept LLM requests for safety classification, domain routing, and PII detection must be both fast and operationally lightweight: they should add minimal latency to every request, yet not require a dedicated GPU -- an expensive resource better used for LLM inference itself. When the router co-locates on the same GPU as vLLM serving instances, standard attention's $O(n^2)$ memory makes long-context classification (8K--32K tokens) impossible: at 8K tokens, three concurrent classifiers need ${\sim}$4.5\,GB for attention masks alone, far exceeding the memory left by vLLM. We present three staged optimizations for the vLLM Semantic Router, benchmarked on AMD Instinct MI300X, that solve both the latency and the memory problem. \emph{Stage~1}: a custom CK Flash Attention operator for ONNX Runtime on ROCm reduces attention memory from $O(n^2)$ to $O(n)$ and end-to-end (E2E) latency from 4{,}918\,ms to 127\,ms ( extbf{38.7$ imes$}), enabling 8K--32K tokens where SDPA OOMs. \emph{Stage~2}: classical NLP prompt compression (TextRank, position weighting, TF-IDF, and novelty scoring) reduces all inputs to ${\sim}$512 tokens without neural inference, capping both latency and GPU memory at a constant regardless of original prompt length (E2E 127$ o$62\,ms, extbf{2.0$ imes$}). \emph{Stage~3}: near-streaming body processing with adaptive chunking and zero-copy JSON eliminates serialization overhead (E2E 62$ o$50\,ms, extbf{1.2$ imes$}). Cumulatively: extbf{98$ imes$} improvement (4{,}918\,ms to 50\,ms), 16K-token routing in 108\,ms, and a total router GPU footprint under 800\,MB -- small enough to share a GPU with LLM serving and removing the need for a dedicated accelerator. Stage~1 targets AMD ROCm (NVIDIA GPUs already have FlashAttention via cuDNN); Stages~2 and~3 are hardware-agnostic.
研究动机与目标
- 为LLM请求提供快速、轻量级的系统级路由,强制执行安全性、领域路由和PII检测,同时不消耗专用GPU。
- 在与LLM推理实例共用同一GPU时,克服二次注意力带来的内存和延迟瓶颈。
- 开发硬件无关的技术,在消费者级/企业级GPU上实现长上下文路由,同时保持准确性与吞吐量。
- 展示与Envoy ext_proc的集成如何在保持低延迟的同时允许复杂分类信号。
提出的方法
- 为ROCm上的ONNX Runtime引入CK Flash Attention,以将注意力内存从O(n^2)降至O(n),将8K–32K提示的端到端时延从4,918 ms降至127 ms。
- 使用经典NLP特征(TextRank、位置加权、TF-IDF、新颖性评分)实现提示压缩流水线,将输入减少到约512个令牌且不进行神经推理。
- 设计近流式的主体处理,采用自适应分块和零拷贝JSON,避免Envoy ext_proc中的序列化开销。
- 将路由器与vLLM服务实例共置于同一台MI300X GPU上,以提高GPU密度并避免需要专用加速器。
- 提供针对硬件的优化(在CK下的ROCm上使用FA)以及适用于GPU或CPU的硬件无关阶段(压缩与流式处理)。
实验结果
研究问题
- RQ1Flash Attention是否可以集成到ROCm上的ONNX Runtime中,从而在共置GPU上实现长上下文路由并避免OOM?
- RQ2经典NLP提示压缩在保持分类器精度的前提下能将延迟与内存压缩到多少?
- RQ3近流式主体处理是否能消除JSON序列化开销并进一步降低Envoy ext_proc路由的端到端延迟?
- RQ4将FA、压缩和近流式处理结合在8K–16K令牌提示时,累计延迟/内存影响如何?
- RQ5与LLM推理共置GPU是否适合无专用加速器的路由工作负载?
主要发现
- 通过自定义CK算子集成的Flash Attention将注意力内存从O(n^2)降至O(n),8K提示的端到端时延从4,918 ms降至127 ms。
- 对约512令牌的提示进行压缩且无神经推理,可实现约19 ms的压缩延迟并保持GPU内存不变,使8K–16K令牌路由在没有额外GPU压力的情况下实现。
- 采用自适应分块和零拷贝JSON的近流式处理将8K令牌的端到端时延从62 ms降至50 ms,16K令牌降至108 ms,从而实现共享GPU上的16K令牌路由。
- 总体来看,该栈实现了约98×的性能提升(4,918 ms降至50 ms),并且路由器GPU占用总量低于800 MB,可实现与vLLM服务的共置,无需专用加速器。
- 阶段1面向AMD ROCm;阶段2与阶段3为硬件无关,惠及任何后端。
- 在流式传输与压缩下,GPU+FA在8K令牌时达到50 ms端到端延迟,16K令牌时为108 ms;在内容ion下,16K+令牌仍然可实现。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。