Improving the End-to-End Efficiency of Offline Inference for Multi-LLM Applications Based on Sampling and Simulation
作者: Jingzhi Fang, Yanyan Shen, Yue Wang, Lei Chen
分类: cs.DC, cs.LG
发布日期: 2025-03-21
💡 一句话要点
提出SamuLLM框架,通过采样和模拟提升多LLM应用离线推理效率。
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 多LLM应用 离线推理 效率优化 采样模拟 贪婪调度
📋 核心要点
- 多LLM应用离线推理效率低,现有方法缺乏对模型运行时间的准确建模,难以做出最优调度决策。
- 提出采样-模拟方法,预估LLM输出长度,模拟推理过程,从而更准确地估计模型运行时间。
- 构建SamuLLM框架,包含规划和运行两个阶段,通过贪婪调度和动态调整,实现端到端加速。
📝 摘要(中文)
本文旨在提高单节点多GPU环境下多LLM应用的离线端到端推理效率。该问题涉及两个关键决策:(1) 每次并发运行哪些LLM(不必同时运行所有模型);(2) 为每个LLM选择哪种并行策略。这是一个NP-hard问题。朴素的解决方案效果不佳,因为模型完成一组请求的运行时间取决于请求工作负载和所选的并行策略,并且缺乏准确的运行时间模型。由于LLM输出长度在运行前未知,为了估计模型运行时间,我们提出了一种采样-模拟方法,该方法首先通过从预先从大型数据集中获得的经验累积函数中采样来估计输出长度,然后相应地模拟LLM推理过程。基于模拟,我们估计每次迭代的延迟以获得总延迟。提出了一种贪婪方法来优化应用程序中LLM在GPU上的调度。然后,我们提出了一个包含两个阶段的框架SamuLLM:规划阶段,调用贪婪方法来处理应用程序;运行阶段,运行应用程序并根据运行时信息动态调整模型调度。在3个应用程序和一个混合应用程序上的实验表明,与竞争对手相比,SamuLLM可以实现1.0-2.4倍的端到端加速。
🔬 方法详解
问题定义:论文旨在解决单节点多GPU环境下,多LLM应用离线推理的端到端效率问题。现有方法在并发运行哪些LLM以及为每个LLM选择何种并行策略上缺乏有效策略,原因是LLM的运行时间受请求负载和并行策略影响,且难以准确预测,导致调度效率低下。
核心思路:核心思路是通过采样和模拟来预测LLM的运行时间,从而优化LLM的调度和并行策略选择。由于LLM的输出长度在推理前未知,直接影响运行时间,因此首先预估输出长度,然后模拟推理过程,得到更准确的运行时间估计。
技术框架:SamuLLM框架包含两个阶段:规划阶段和运行阶段。在规划阶段,使用贪婪算法确定LLM的调度方案和并行策略。该算法基于采样-模拟方法预估的运行时间,选择使整体推理时间最短的方案。在运行阶段,根据实际运行时的信息,动态调整LLM的调度,以应对实际情况与预估之间的差异。
关键创新:关键创新在于提出了采样-模拟方法来预估LLM的运行时间。与直接使用经验规则或简单模型估计运行时间的方法相比,该方法考虑了LLM输出长度的影响,并通过模拟推理过程,更准确地反映了实际运行情况。
关键设计:采样-模拟方法中,首先从一个预先构建的经验累积分布函数(ECDF)中采样,得到LLM输出长度的估计。然后,基于该估计值,模拟LLM的推理过程,包括计算量、内存占用等,从而估计每次迭代的延迟。最后,将每次迭代的延迟累加,得到总的运行时间估计。贪婪调度算法则根据该运行时间估计,选择最优的LLM调度方案。
🖼️ 关键图片
📊 实验亮点
实验结果表明,SamuLLM框架在三个实际应用和一个混合应用上,相比于现有方法,实现了1.0到2.4倍的端到端加速。这表明采样-模拟方法能够有效预测LLM运行时间,贪婪调度算法能够找到较优的LLM调度方案,从而显著提升多LLM应用的离线推理效率。
🎯 应用场景
该研究成果可应用于各种需要同时运行多个LLM的离线推理场景,例如批量数据分析、内容生成、模型评估等。通过提高推理效率,可以降低计算成本,缩短分析周期,并支持更大规模的应用部署。未来,该方法可以扩展到在线推理场景,并与其他优化技术相结合,进一步提升LLM应用的性能。
📄 摘要(原文)
As large language models (LLMs) have shown great success in many tasks, they are used in various applications. While a lot of works have focused on the efficiency of single-LLM application (e.g., offloading, request scheduling, parallelism strategy selection), multi-LLM applications receive less attention, particularly in offline inference scenarios. In this work, we aim to improve the offline end-to-end inference efficiency of multi-LLM applications in the single-node multi-GPU environment. The problem involves two key decisions: (1) determining which LLMs to run concurrently each time (we may not run all the models at the same time), and (2) selecting a parallelism strategy to use for each LLM. This problem is NP-hard. Naive solutions may not work well because the running time for a model to complete a set of requests depends on the request workload and the selected parallelism strategy, and they lack an accurate model of the running time. As the LLM output lengths are unknown before running, to estimate the model running time, we propose a sampling-then-simulation method which first estimates the output lengths by sampling from an empirical cumulative function we obtained from a large dataset in advance, and then simulates the LLM inference process accordingly. Based on the simulation, we estimate the per-iteration latencys to get the total latency. A greedy method is proposed to optimize the scheduling of the LLMs in the application across the GPUs. We then propose a framework SamuLLM which contains two phases: planning, which calls the greedy method for an application and running, which runs the application and dynamically adjust the model scheduling based on the runtime information. Experiments on 3 applications and a mixed application show that SamuLLM can achieve 1.0-2.4$\times$ end-to-end speedups compared to the competitors.