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
초록
"사전 학습 후 미세 조정(pretrain-then-finetune)" 패러다임은 대규모 언어 모델 배포에서 흔히 채택됩니다. LoRA(Low-Rank Adaptation)는 파라미터 효율적인 미세 조정 방법으로, 하나의 기본 모델을 다양한 작업에 맞게 조정하여 다수의 LoRA 어댑터를 생성하는 데 자주 사용됩니다. 우리는 이 패러다임이 서비스 중 배치 추론(batched inference)에 상당한 기회를 제공한다는 점을 관찰했습니다. 이러한 기회를 활용하기 위해, 우리는 많은 LoRA 어댑터를 확장 가능하게 서비스하기 위한 시스템인 S-LoRA를 제안합니다. S-LoRA는 모든 어댑터를 메인 메모리에 저장하고 현재 실행 중인 쿼리에서 사용되는 어댑터를 GPU 메모리로 가져옵니다. GPU 메모리를 효율적으로 사용하고 단편화를 줄이기 위해, S-LoRA는 통합 페이징(Unified Paging)을 제안합니다. 통합 페이징은 다양한 순위를 가진 동적 어댑터 가중치와 다양한 시퀀스 길이를 가진 KV 캐시 텐서를 관리하기 위해 통합 메모리 풀을 사용합니다. 또한, S-LoRA는 새로운 텐서 병렬화 전략과 LoRA 계산의 이기종 배치(heterogeneous batching)를 위한 고도로 최적화된 맞춤형 CUDA 커널을 사용합니다. 이러한 기능들은 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.