让大模型根据资源动态调整计算量,又快又省。
End-to-End Dynamic Sparsity for Resource-Adaptive LLM Inference

- 用输入和资源预算共同控制模型的计算路径。
- 在资源紧张时可跳过34%层,准确率仅低0.6%。
- 适合云上部署,能自动应对实例中断等波动。
大语言模型推理通常基于静态资源假设,执行固定计算图,但真实云环境存在资源波动(如竞价实例被抢占)和多级服务质量需求。静态模型在资源受限时易崩溃或浪费算力。为此,我们提出学习分配(L2A)框架,将推理建模为同时依赖输入和实时资源预算的约束分配问题。通过在模型中嵌入轻量级、预算感知且输入敏感的门控网络,联合优化任务性能、逻辑一致性和资源开销。该机制支持层跳过(缓解内存压力)、头剪枝(应对吞吐瓶颈)和推理令牌缩减(降低延迟),使模型能根据实时资源动态自适应调整计算量:资源充足时最大化推理深度,资源紧张时严格节制。单个L2A模型在Llama-3-8B和Qwen-3-4B上覆盖完整计算-精度帕累托前沿,在达到34%实际层稀疏度时,GSM8K测试准确率仅比密集基线低0.6%,零样本外分布任务表现一致;而所有静态或启发式基线需单独调参,且在相近推理时间下准确率下降5-10%。
原文摘要 · Abstract (English)
Large Language Models (LLMs) inference is typically deployed under a static resource assumption, where models execute a fixed computational graph regardless of the runtime environment. However, real-world cloud infrastructure is inherently dynamic, characterized by fluctuating availability (e.g., spot instance preemption) and tiered Quality-of-Service requirements. In such volatile settings, static models are inflexible: they either crash under resource constraints or waste compute on redundant operations. To bridge this gap, we propose Learning to Allocate (L2A), an end-to-end framework for resource-adaptive inference. Unlike prior methods that condition only on input difficulty, we formulate inference as a constrained allocation problem conditioned on both the input and the runtime resource budget itself. We introduce lightweight, budget-conditioned and input-aware gating networks integrated into the LLM. These gates are trained via a unified objective that jointly optimizes task performance, logical consistency, and resource costs along three axes matching how real-world dynamics manifest: layer skipping for memory and depth pressure, head pruning for throughput contention, and reasoning-token reduction for latency tightening. This lets the model learn a budget-aware policy beyond input difficulty alone: it adaptively configures its computational footprint with respect to real-time resource dynamics, maximizing reasoning depth when resources permit while enforcing strict frugality when budgets tighten. A single L2A model traces the entire compute-accuracy Pareto frontier on Llama-3-8B and Qwen-3-4B: at up to 34% realized layer sparsity, it stays within 0.6% of the dense baseline on GSM8K, with the same gap holding zero-shot on out-of-distribution tasks, while every static or heuristic baseline requires a separately tuned model and still drops by 5-10% at comparable inference time.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。