S-LoRA: 数千の並行LoRAアダプターを効率的に提供するシステム
S-LoRA: Serving Thousands of Concurrent LoRA Adapters
November 6, 2023
著者: Ying Sheng, Shiyi Cao, Dacheng Li, Coleman Hooper, Nicholas Lee, Shuo Yang, Christopher Chou, Banghua Zhu, Lianmin Zheng, Kurt Keutzer, Joseph E. Gonzalez, Ion Stoica
cs.AI
要旨
大規模言語モデルの展開においては、「事前学習-ファインチューニング」パラダイムが一般的に採用されています。Low-Rank Adaptation(LoRA)は、パラメータ効率の良いファインチューニング手法であり、ベースモデルを多様なタスクに適応させるために頻繁に使用され、1つのベースモデルから派生した多数のLoRAアダプターが生成されます。このパラダイムは、推論時のバッチ処理に大きな機会を提供していることが観察されます。この機会を活用するために、我々はS-LoRAを提案します。S-LoRAは、多数のLoRAアダプターをスケーラブルに提供するためのシステムです。S-LoRAは、すべてのアダプターをメインメモリに保存し、現在実行中のクエリで使用されるアダプターをGPUメモリにフェッチします。GPUメモリを効率的に使用し、フラグメンテーションを減らすために、S-LoRAはUnified Pagingを提案します。Unified Pagingは、異なるランクを持つ動的なアダプター重みと、異なるシーケンス長を持つKVキャッシュテンソルを管理するために、統一されたメモリプールを使用します。さらに、S-LoRAは、新しいテンソル並列化戦略と、高度に最適化されたカスタムCUDAカーネルを採用し、LoRA計算の異種バッチ処理を実現します。これらの機能を組み合わせることで、S-LoRAは、単一のGPUまたは複数のGPU上で、数千のLoRAアダプターを小さなオーバーヘッドで提供することが可能です。HuggingFace PEFTやvLLM(LoRA提供のナイーブなサポートを含む)などの最先端のライブラリと比較して、S-LoRAはスループットを最大4倍向上させ、提供されるアダプターの数を数桁増加させることができます。その結果、S-LoRAは、多数のタスク固有のファインチューニングモデルをスケーラブルに提供し、大規模なカスタマイズされたファインチューニングサービスの可能性を提供します。
English
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.