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

上下文的代价:大语言模型中输入令牌的能耗足迹分析

The Cost of Context: Profiling the Energy Footprint of Input Tokens in Large Language Models

AXA AI Research(安盛人工智能研究院)

Boris Ruf, Marcin Detyniecki

AI总结:

该研究针对RAG与长上下文LLM预填充阶段能耗表征不足的问题,通过遥测Llama-3.1、Qwen-2模型在A100上的表现,揭示PagedAttention等优化可延迟缩放瓶颈,为可持续LLM部署提供实证框架。

摘要:

检索增强生成(RAG)和长上下文大语言模型(LLM)的快速普及,已将计算负担转移到预填充阶段——即模型在生成响应前并行处理所有输入令牌的初始阶段,但其能耗影响仍缺乏充分表征。我们研究了硬件级大规模功率峰值与系统级研究报告的输入令牌次线性边际成本之间的矛盾。通过在NVIDIA A100硬件上对Llama-3.1和Qwen-2模型进行高分辨率遥测,我们确定了$O(n^2)$注意力复杂度克服GPU并行化的效率阈值。结果量化了优化内存编排(PagedAttention)如何在三个数量级的上下文缩放中延迟该缩放瓶颈,与标准基线相比,在112000个令牌时可实现高达8.9倍的能效优势。此外,我们表征了输入与输出令牌之间的能耗差异,表明优化服务(vLLM)因解码效率高,随着上下文缩放该比值会缩小(从约850倍降至750倍),而未优化基线则显示出小得多且大致恒定的差距(约150-230倍),因为它们的预填充本身成本高昂。本研究建立了区分引擎级优化与固有模型约束的上下文缩放定律,为可持续LLM部署提供了实证框架。

英文摘要:

The rapid adoption of Retrieval-Augmented Generation (RAG) and long-context LLMs has shifted the computational burden toward the prefill phase---the initial stage where the model processes all input tokens in parallel before generating a response---yet its energy impact remains poorly characterised. We investigate the contradiction between massive hardware-level power spikes and the sub-linear marginal cost of input tokens reported in system-level studies. Through high-resolution telemetry of Llama-3.1 and Qwen-2 models on NVIDIA A100 hardware, we identify the efficiency threshold where $O(n^2)$ attention complexity overcomes GPU parallelisation. Our results quantify how optimised memory orchestration (PagedAttention) delays this scaling bottleneck across three orders of context scaling, yielding up to an 8.9$\times$ energy efficiency advantage at 112,000 tokens compared to standard baselines. Furthermore, we characterise the energy disparity between input and output tokens, demonstrating that optimised serving (vLLM) causes this ratio to narrow (from $\approx$850$\times$ to 750$\times$) as context scales due to high decode efficiency, whereas unoptimised baselines show a much smaller, roughly constant gap ($\approx$150--230$\times$) because their prefill is itself expensive. This work establishes context-scaling laws that differentiate engine-level optimisations from inherent model constraints, providing an empirical framework for sustainable LLM deployment.

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

↑