(纸)
python examples/tui-multi-lora.py低等级适应(LORA)是为验证的LLM添加新知识的参数有效方法。尽管验证的LLM需要100秒的GB存储空间,但Lora Finetuned模型仅增加了1%的存储空间和内存开销。 Punica启用运行多个Lora Fineted Models的费用,而运行一个模型。
如何?
假设形状[H1, H2]是验证模型的W ,Lora添加了两个小矩阵A形状[H1, r]和[r, H2]的B在FINETUNED模型上运行输入x的是y := x @ (W + A@B) ,与y := x@W + x@A@B相同。
当有n Lora型号时,将有A1 , B1 , A2 , B2 ,..., An , Bn 。给定一个输入批次X := (x1,x2,...,xn) ,将每个lora模型映射到每个lora模型,输出为Y := X@W + (x1@A1@B1, x2@A2@B2, ..., xn@An@Bn) 。左侧计算验证模型上的输入批次。这是非常有效的。由于批处理的效果很强,延迟几乎与只有一个输入时相同。
我们找出了一种计算右侧(Lora插件)的有效方法。我们将此操作封装在CUDA内核中,称为分割的聚集矩阵矢量乘法(SGMV),如下所示。

在下面的微型基准图中,我们可以观察到预验证模型的强批量效应。如橙线所示,洛拉的幼稚实施很慢。通过SGMV实施的LORA是有效的,并保留了强大的分批效应。

下图显示了Punica和其他系统之间的文本生成吞吐量比较,包括拥抱面变压器,DeepSpeed,ForterTransFormer,VLLM。基准测试考虑了洛拉模型流行的不同设置。独特的意味着每个请求都是针对不同的洛拉模型。相同的意味着所有请求均适用于同一LORA模型。统一和偏斜介于两者之间。与最先进的系统相比,Punica达到了12倍吞吐量。

阅读我们的论文以了解更多信息:Punica:多租户Lora服务。
您可以从二进制包装安装Punica或从源构建。
8.0 8.6 8.9+PTX pip install ninja torch
pip install punica -i https://punica-ai.github.io/whl/cu121/ --extra-index-url https://pypi.org/simple
# Note: Change cu121 to your CUDA version. # Please install torch before punica
pip install ninja numpy torch
# Clone punica
git clone https://github.com/punica-ai/punica.git
cd punica
git submodule sync
git submodule update --init
# If you encouter problem while compilation, set TORCH_CUDA_ARCH_LIST to your CUDA architecture.
# export TORCH_CUDA_ARCH_LIST="8.0"
# Build and install punica
pip install -v --no-build-isolation . 请参阅上面的演示。
请参阅examples/finetune/
python -m benchmarks.bench_textgen_lora --system punica --batch-size 32 @misc { punica ,
title = { Punica: Multi-Tenant LoRA Serving } ,
author = { Lequn Chen and Zihao Ye and Yongji Wu and Danyang Zhuo and Luis Ceze and Arvind Krishnamurthy } ,
year = { 2023 } ,
eprint = { 2310.18547 } ,
archivePrefix = { arXiv } ,
primaryClass = { cs.DC }
}