[论文解读] S-LoRA: Serving Thousands of Concurrent LoRA Adapters
S-LoRA 是一种可扩展的系统,通过利用统一内存池、基于优化 CUDA 内核的异构批处理以及一种新颖的张量并行策略,可在单张 GPU 或多张 GPU 上高效服务数千个并发 LoRA 配置文件。与 HuggingFace PEFT 和 vLLM 等最先进系统相比,其吞吐量最高提升 4 倍,支持的配置文件数量达到数量级的提升。
The "pretrain-then-finetune" paradigm is commonly adopted in the deployment of large language models. Low-Rank Adaptation (LoRA), a parameter-efficient fine-tuning method, is often employed to adapt a base model to a multitude of tasks, resulting in a substantial collection of LoRA adapters derived from one base model. We observe that this paradigm presents significant opportunities for batched inference during serving. To capitalize on these opportunities, we present S-LoRA, a system designed for the scalable serving of many LoRA adapters. S-LoRA stores all adapters in the main memory and fetches the adapters used by the currently running queries to the GPU memory. To efficiently use the GPU memory and reduce fragmentation, S-LoRA proposes Unified Paging. Unified Paging uses a unified memory pool to manage dynamic adapter weights with different ranks and KV cache tensors with varying sequence lengths. Additionally, S-LoRA employs a novel tensor parallelism strategy and highly optimized custom CUDA kernels for heterogeneous batching of LoRA computation. Collectively, these features enable S-LoRA to serve thousands of LoRA adapters on a single GPU or across multiple GPUs with a small overhead. Compared to state-of-the-art libraries such as HuggingFace PEFT and vLLM (with naive support of LoRA serving), S-LoRA can improve the throughput by up to 4 times and increase the number of served adapters by several orders of magnitude. As a result, S-LoRA enables scalable serving of many task-specific fine-tuned models and offers the potential for large-scale customized fine-tuning services. The code is available at https://github.com/S-LoRA/S-LoRA
研究动机与目标
- 解决在有限 GPU 内存下并行服务数千个 LoRA 配置文件的可扩展性挑战。
- 通过减少因不同秩和序列长度的配置文件动态加载所导致的内存碎片化和 I/O 开销。
- 实现对具有非连续内存布局的异构配置文件进行高效批处理的 LoRA 计算。
- 设计一种低开销、可扩展的张量并行策略,用于 LoRA 配置文件在多 GPU 上的部署。
- 在大规模、定制化 LLM 服务中实现高推理吞吐量,同时最小化延迟和内存占用。
提出的方法
- S-LoRA 引入了统一分页(Unified Paging),即一个统一的内存池,可动态管理配置文件权重和 KV 缓存张量,以减少内存碎片化和 I/O 开销。
- 它采用基于自定义 CUDA 内核的异构批处理机制,直接在非连续内存上操作,从而实现对不同秩的配置文件进行高效批处理推理。
- S-LoRA TP 是一种新颖的张量并行策略,将 LoRA 计算与基础模型通信融合,最大限度降低多 GPU 之间的通信开销。
- 系统将基础模型计算(可批处理)与配置文件计算(不可批处理)分离,从而实现最优的调度与内存访问模式。
- 它采用基于主机内存的配置文件存储策略,仅在需要时按需将活跃的配置文件加载到 GPU 内存中。
- 系统集成了早期中止调度机制,并通过统一内存池支持动态序列长度处理。
实验结果
研究问题
- RQ1如何高效管理具有不同秩和动态序列长度的数千个 LoRA 配置文件的内存?
- RQ2如何对具有非连续内存布局的异构配置文件实现最优的 LoRA 计算批处理?
- RQ3在跨多张 GPU 扩展 LoRA 服务时,如何最小化通信和内存开销?
- RQ4与现有系统相比,统一内存池和优化内核是否能显著提升吞吐量和配置文件容量?
- RQ5动态配置文件加载与卸载对推理延迟和 GPU 利用率的性能影响如何?
主要发现
- 与 HuggingFace PEFT 和 vLLM 等最先进系统相比,S-LoRA 的推理吞吐量最高提升 4 倍,即使在采用朴素 LoRA 支持的情况下亦然。
- 它可在单张 GPU 上实现比现有系统高几个数量级的 LoRA 配置文件服务能力,展现出极高的可扩展性。
- 统一内存池减少了内存碎片化和 I/O 开销,从而支持对具有多样化秩和序列长度的配置文件进行高效动态加载。
- 通过自定义 CUDA 内核实现的异构批处理可在非连续内存上实现高效计算,显著降低在不同配置文件配置下的延迟开销。
- S-LoRA TP 通过将 LoRA 计算与基础模型通信融合,实现了极低的通信开销,从而有效支持多 GPU 扩展。
- 该系统在 A10G-24G 和 A100-80G GPU 上表现出高效率,消融实验验证了早期中止调度和内存管理策略的有效性。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。