InternLM / lmdeploy

LMDeploy is a toolkit for compressing, deploying, and serving LLMs.
https://lmdeploy.readthedocs.io/en/latest/
Apache License 2.0
3.11k stars 280 forks source link

[Docs] 多模态模型的api_server应该如何多卡部署? #1840

Open red-fox-yj opened 4 days ago

red-fox-yj commented 4 days ago

📚 The doc issue

如题,多卡部署的话直接在启动命令里面指定--tp就行了吗?另外文档里推荐的多模态模型liuhaotian/llava-v1.6-vicuna-7b部署时的推荐最低显卡配置是什么,大概能够实现多少的并发请求量。感谢回复。

Suggest a potential alternative/fix

No response

irexyc commented 4 days ago

fp16的版本,模型权重15G左右。

并发主要看kvcache的大小和每个请求的长度。按照每个请求输入+输出2048个token来算,64长度需要的kvcache为32MB,一个请求就是 2048 / 64 * 32 = 1G。

red-fox-yj commented 4 days ago

@irexyc 感谢回复,如下所示是我部署lmdeploy之后的显卡占用情况(我启动时--tp指定为4) image 按照您刚才提供的公式,是否意味着我的服务器可以接受大约(3+5+5+5)/ 1=18个输入+输出2048个token的并发请求?

irexyc commented 4 days ago

启动服务的时候设置 --log-level INFO 之后,启动时会打印一个block_size的大小,每个模型是不一样的,跟tp也会有关系。这个值的含义是长度为64的kvcache占用的显存大小。max_block_count 表示有这么多个kvcache块。然后根据输入+输出的token数量可以算最多支持的请求。

[TM][INFO] [BlockManager] block_size = 32 MB
[TM][INFO] [BlockManager] max_block_count = 1671
red-fox-yj commented 4 days ago

@irexyc image 7987/(2048/64)=250 相当总共可以接受250个输入+输出的token数量等于2048的并发请求?还是说这里打印四次指的是每张卡上都可以接收250个并发请求,总共1000个请求?

irexyc commented 4 days ago

应该是250。不过默认的max-batch-size是128,需要调整一下,不然会限制。