You need to enable JavaScript to run this app.
导航
veMLP xLLM 推理引擎PD分离部署DeepSeek R1,最高吞吐提升5倍
最近更新时间:2025.03.06 15:24:10首次发布时间:2025.02.20 22:04:11
我的收藏
有用
有用
无用
无用

本文将为您介绍如何基于最少2台Hopper架构服务器,通过xLLM 推理引擎 PD分离部署 DeepSeek R1,将吞吐率提升最高5倍。

简介

xLLM 是火山方舟全自研的高效推理框架,支持PD分离( Prefiling、Decoding)、弹性扩缩等特性,性能显著领先开源框架。
在火山引擎机器学习平台(veMLP)的推理服务中,已产品化支持使用xLLM推理引擎实现PD分离部署功能。通过本文,您可使用 xLLM 预置镜像,部署方舟同款的 DeepSeek-R1 模型推理服务;同时这里会给出 xLLM 镜像相较于 SGLang 社区开源版的性能数据对比。

前置条件

模型文件下载到本地 vePFS

预置模型信息

为了方便使用 DeepSeek 模型,我们为您提前在火山的TOS中准备了常用模型,您可以直接通过tosutil工具拉取模型文件到自己的文件系统中。相关预置模型信息包括:

模型名称

TOS路径

模型说明

DeepSeek-R1 方舟版

tos://preset-models-cn-beijing/deepseek-ai/vemlp-deepseek-r1-enc/

DeepSeek R1 模型,xLLM框架需配合使用此版本

DeepSeek-R1

tos://preset-models-cn-beijing/deepseek-ai/DeepSeek-R1/

DeepSeek R1 模型

DeepSeek-V3

tos://preset-models-cn-beijing/deepseek-ai/DeepSeek-V3/

DeepSeek V3 模型

Tips:
1、目前PD分离部署处于preview状态,需要功能开白名单使用。您可以联系火山引擎机器学习平台产品解决方案或者销售、售后技术支持同学沟通开白。
2、请留意镜像、模型路径需要根据Region位置适当调整。例如示例DeepSeek-R1文件位于cn-beijing Region,TOS路径为tos://preset-models-cn-beijing/deepseek-ai/DeepSeek-R1/ ;如果DeepSeek-R1文件位于cn-beijing2 Region,TOS路径调整为tos://preset-models-cn-beijing2/deepseek-ai/DeepSeek-R1/。镜像地址同理。

模型下载

这里是要将火山预置的 DeepSeek 模型下载到用户自身的 vePFS 桶中,作为后续模型推理服务的基础模型,具体操作步骤如下:

Image

  • 登陆上一步创建的开发机下 DeepSeek 模型权重文件到 vepfs 目录:

整个下载预期耗时 10 分钟

export AK=xx
export SK=xx
export VEPFS_MODEL_PATH=/testphi3/models
cd $VEPFS_MODEL_PATH
tosutil config -i $AK -k $SK  -e tos-cn-beijing.ivolces.com -re cn-beijing
tosutil cp tos://preset-models-cn-beijing/deepseek-ai/vemlp-deepseek-r1-enc/ . -r -u -j=32 -p=4 -nfj=16
  • 确认模型文件存在:

模型路径:$VEPFS_MODEL_PATH/vemlp-deepseek-r1-enc/vemlp-deepseek-r1-enc/

ls $VEPFS_MODEL_PATH/vemlp-deepseek-r1-enc/vemlp-deepseek-r1-enc/ | wc
#  19      19     508

准备 GPU 资源

您需准备至少两台 Hopper架构整机,并创建资源队列,并提前在机器学习平台(veMLP)的全局配置模块中,新建VPC,vePFS,API网关,VMP,TLS等基础组件,并确认安全组、ACL放通后续在线服务涉及到的监听、调用、指标采集端口

部署在线服务

1.创建服务

创建服务

  • 正确填写【服务名称】,【私有网络】,【API 网关】,8000 服务推理端口,8080 监控指标采集端口等信息。

注意

目前POC指定8000、8080,请勿更改端口,并再次检查安全组、ACL是否提前放开所有端口。

创建 API 网关(第一次创建服务时)

  • 正确填写 VPC开启 VMP

Image

2.创建部署

新增部署

  • 在上面创建服务的部署 tab 页面,点击新增部署。

Image

  • 正确填写8卡Hopper架构队列,高性能计算GPU型 等信息。

Image

  • Prefill 角色和 Decode 角色,都需要正确填写用户模型路径$VEPFS_MODEL_PATH/vemlp-deepseek-r1-enc/vemlp-deepseek-r1-enc/

说明

设置max tokens时,截断的 tokens 数量若需包括reason content中输出的内容,则设置环境变量XLLM_IGNORE_EOS=1。若仅需限制content中输出的 tokens 数量,则设置环境变量XLLM_IGNORE_EOS=0

  • 选择【子网】,【安全组】,并且点击创建后,等待实例排队运行中。

Image

  • 观察 【decode】 角色实例日志,无模型加载报错,等待模型加载运行【预计 30 分钟】。

Image

  • 从在线服务的调用指南 tab 页面,获取服务调用地址,若需使用token 加密,则在当前页面开启 token 访问。

注意

当前 token 默认有效期为 7 天,到期需更换。如需要更长有效期的 token ,请提交工单申请。

Image

监控页面

获取Grafana推理监控配置文件。
导入后,选择机器学习平台上创建的对应datasourceservice:

监控分为两个维度,服务(Service)维度与实例(Pod)维度。服务与实例指标面板分别为:
Image
Image
指标释义:

指标

解释

QPS

Query Per Second 每秒处理完成的请求数,反映处理能力

Inflight Requests

引擎中未处理完成的请求数

wTPM

Tokens Per Min(万) 每分钟处理的Token数量,反映处理能力

卡均TPS -- Prompt Tokens/Sec

平均每卡每秒处理的Prefill Tokens数量,反映处理能力

卡均TPS -- Generation Tokens/Sec

平均每卡每秒处理的Decode Tokens数量,反映处理能力

TTFT

首Token延迟,反映服务质量

TPOT

生成Token延迟,反映服务质量

E2E

请求端到端完成延迟,反映服务质量

Input Token Length

请求的输入长度的均值和统计值,反映请求特征

Output Token Length

请求的输出长度的均值和统计值,反映请求特征

KVCache 命中率

反映请求间Prompt重复度

请求成功率

服务端成功处理完请求的比率

模型调用

使用 OpenAI 兼容方式调用模型

部署完成后会自动创建公网服务 ,提供 HTTP OpenAI API 端点。可以按照 OpenAI 兼容 API 方式去调用。例如:

# 流式
curl -X POST https://scur1lll****.apigateway-cn-beijing.volceapi.com/mlp/s-20250220014946-lmddr/v1/chat/completions \
 -H "Content-Type: application/json" -d '{
    "model": "vemlp-deepseek-r1-enc",
    "messages": [
        {"role": "user", "content": "帮我设计北京三天的旅游行程"}
    ],
    "max_tokens": 20,
    "stream": true
}'

# 非流式
curl -X POST https://scur1****.apigateway-cn-beijing.volceapi.com/mlp/s-20250220014946-lmddr/v1/chat/completions \
 -H "Content-Type: application/json" -d '{
    "model": "vemlp-deepseek-r1-enc",
    "messages": [
        {"role": "user", "content": "帮我设计北京三天的旅游行程"}
    ],
    "max_tokens": 800
}'

流式输出样例

{"id": "chatcmpl-17399634109****", "choices": [{"index": 0, "delta": {"role": "assistant", "content": "", "reasoning_content": "Okay", "tool_calls": []}, "finish_reason": ""}], "created": 1739963410, "model": "vemlp-deepseek-r1-enc", "system_fingerprint": "fp", "object": "chat.completion.chunk", "usage": {"prompt_tokens": 9, "completion_tokens": 1, "total_tokens": 10, "completion_tokens_details": {"reasoning_tokens": 1}}}
{"id": "chatcmpl-17399634109****", "choices": [{"index": 0, "delta": {"role": "assistant", "content": "", "reasoning_content": ",", "tool_calls": []}, "finish_reason": ""}], "created": 1739963410, "model": "vemlp-deepseek-r1-enc", "system_fingerprint": "fp", "object": "chat.completion.chunk", "usage": {"prompt_tokens": 9, "completion_tokens": 2, "total_tokens": 11, "completion_tokens_details": {"reasoning_tokens": 2}}}
...

非流式输出样例

{"id":"chatcmpl-1739963676****","object":"chat.completion","created":1739963676,"model":"vemlp-deepseek-r1-enc","system_fingerprint":"fp","choices":[{"index":0,"message":{"role":"assistant","content":"\n\n以下是为您设计的北京三日经典行程,涵盖历史古迹、皇家园林、现代地标及本地文化体验,行程紧凑但劳逸结合:\n\n🌟 **第一天:中轴线经典之旅**\n","reasoning_content":"嗯,用户让我帮忙设计一个北京三天的旅游行程。首先,我需要考虑用户可能的背景和需求。北京作为中国的首都,有很多经典的景点,比如故宫、天安门、长城之类的。用户可能第一次来北京,想看看这些必去的地方。不过也有可能他们已经去过一些景点,想更深入地体验。不过通常第一次设计的话,还是以经典景点为主比较保险。\n\n接下来,我要确定三天的行程安排是否合理。北京很大,景点之间可能需要考虑交通时间。比如长城在郊区,需要单独安排一天。第一天可能在市中心,安排天安门、故宫、景山这些比较集中的地方。第二天可以考虑颐和园和圆明园,这两个都在海淀区,离市中心稍远,但可以放在同一天。第三天可以安排一些文化体验,比如胡同、南锣鼓巷、798艺术区之类的。\n\n还要注意时间分配是否合理。比如故宫需要半天时间,如果加上天安门广场和毛主席纪念堂,可能需要一上午。下午去景山公园,然后晚上去王府井。这样的安排是否太赶?可能需要调整。另外,要考虑用户的体力,尤其是长城一天可能需要较多步行,所以第二天安排颐和园和圆明园,第三天相对轻松的文化景点可能更合适。\n\n饮食方面,用户可能想体验北京特色美食,比如烤鸭、炸酱面、涮羊肉等。所以在每天的行程里推荐附近的餐馆或小吃街是必要的。比如第一天午餐在故宫附近可能不太方便,但可以推荐王府井的小吃街或者附近的餐馆。晚餐在王府井的话,全聚德是经典选择,但可能需要提前预定。\n\n交通方面,北京地铁比较方便,但有些景点可能需要打车或者公交。比如长城通常需要坐公交或者旅游专线,或者参加一日游团。要提醒用户注意交通时间和方式,避免耽误行程。\n\n另外,季节因素也要考虑。如果是夏天,注意防晒和补水;冬天的话,保暖措施。但用户没有提到具体时间,可能需要一般性的提醒。\n\n还要注意景点开放时间和闭馆日。比如故宫周一闭馆,所以行程安排要避开周一。如果用户不知道这一点,可能会白跑一趟。所以在注意事项里需要提醒。\n\n可能用户还想体验北京的文化,比如胡同、四合院,所以第三天安排了南锣鼓巷和后海,还有798艺术区,这样既有传统文化,又有现代艺术,比较全面。\n\n最后,检查行程是否覆盖了北京的主要景点,三天时间是否足够。第一天:天安门、故宫、景山、王府井。第二天:长城、鸟巢水立方。第三天:颐和园、圆明园、南锣鼓巷、后海。或者可能需要调整,比如第二天如果去长城的话,可能下午回来比较累,晚上安排鸟巢水立方的夜景不错。第三天颐和园和圆明园可能比较紧凑,但可以安排上午和下午分别游览。或者是否应该把颐和园和圆明园放在第二天,而长城单独一天?需要再考虑路线是否合理。\n\n可能第二天去长城,回到市区后去鸟巢水立方,这样比较顺路,因为长城在北部郊区,而鸟巢也在北边,可能更合适。而颐和园和圆明园在西郊,所以第三天安排那里,然后下午去南锣鼓巷和后海。或者反过来?需要查地图确认地理位置。\n\n另外,用户可能有兴趣看升旗仪式,所以第一天早上可以建议早起看升旗,但需要提前查好时间,并且可能需要很早起床,比如夏天升旗很早,用户是否愿意?\n\n总之,需要综合考虑景点分布、时间安排、交通、饮食和用户的体力,确保行程合理可行,不要太赶,又能覆盖主要景点。\n","tool_calls":[]},"finish_reason":"length"}],"usage":{"completion_len":799,"prompt_len":12,"total_len":811,"completion_tokens_details":{"reasoning_tokens":758}}}

性能测试

性能对比

以 3500: 1500 为例:

  • 火山 xLLM 版 DeepSeek 推理性能比 SGLang 版(不开MTP)极限吞吐大致相同,大约为1800 tokens/s
  • 在相同的吞吐水平下(大约900 tokens/s),火山 xLLM 版 AVG TPOT 为26 ms比 SGLang (MPT)版低 78%,TTFT 为1073 ms低 42 %
  • 限定 TTFT < 600 ms ,TPOT < 30 ms 的 SLO 下,火山 xLLM 版吞吐比 SGLang 高 100 %

以 2500: 1500 为例:

  • 火山 xLLM 版 DeepSeek 推理性能比 SGLang 版极限吞吐高 60%,为1612 tokens/s
  • 在相同的吞吐水平下(大约500 tokens/s),火山 xLLM 版 AVG TPOT为21 ms 比 SGLang 版低 21%,TTFT 为573 ms低 50%
  • 限定 TTFT < 600 ms ,TPOT < 30 ms 的 SLO 下,火山 xLLM 版吞吐比 SGLang 高 500 %

输入输出 3500 : 1500

xLLM

Request Rate (reqs/s)

max-concurrency

input_len

output_len

mean E2E Latency(ms)

Request throughput (req/s)

throughput(output tokens/s)

Total token throughput (tok/s)

Total token throughput (tok/s/单卡)

Mean TTFT(ms)

P99 TTFT(ms)

Mean TPOT(ms)

P99 TPOT(ms)

1

1

3500

1500

23953.39

0.04

62.62

208.72

13.04

528.13

719.97

15.63

16.37

4

4

3500

1500

32044.15

0.12

181.05

603.48

37.72

773.37

1377.75

20.86

23.22

8

8

3500

1500

40851.36

0.19

284.93

949.76

59.36

1073.12

3524.93

26.54

29.25

16

16

3500

1500

42173.29

0.37

548.62

1828.72

114.3

1790.02

7123.8

26.94

29.94

SGLang v0.4.3 MTP

Request Rate (reqs/s)

max-concurrency

input_len

output_len

mean E2E Latency(ms)

Request throughput (req/s)

throughput(output tokens/s)

Total token throughput (tok/s)

Total token throughput (tok/s/单卡)

Mean TTFT(ms)

P99 TTFT(ms)

Mean TPOT(ms)

P99 TPOT(ms)

1

1

3500

1500

52746.71

0.02

28.44

94.79

5.92

580.44

596.18

34.8

44.51

4

4

3500

1500

59667.4

0.07

98.41

328.03

20.5

790.48

1729.88

39.28

47.38

8

8

3500

1500

77055.98

0.1

148.82

496.06

31

1141.76

4027.89

50.64

61.7

16

16

3500

1500

113699.01

0.14

203.33

677.78

42.36

1818.16

8657.87

74.64

87.47

32

32

3500

1500

176652.66

0.18

262.6

875.34

54.71

3105.7

17596.39

115.78

145.02

SGLang v0.4.2 火山优化版

Request Rate (reqs/s)

max-concurrency

input_len

output_len

mean E2E Latency(ms)

Request throughput (req/s)

throughput(output tokens/s)

Total token throughput (tok/s)

Total token throughput (tok/s/单卡)

Mean TTFT(ms)

P99 TTFT(ms)

Mean TPOT(ms)

P99 TPOT(ms)

1

1

3500

1500

73067.18

0.01

20.53

68.43

4.28

756.43

817.75

48.24

48.37

4

4

3500

1500

78122

0.05

76.73

255.78

15.99

2467.48

3789.51

50.47

52.33

8

8

3500

1500

86411.57

0.09

138.78

462.6

28.91

4583.25

5601.21

54.59

57.64

16

16

3500

1500

112645.2

0.14

212.94

709.8

44.36

7668.19

11117

70.03

74.73

32

32

3500

1500

152704.8

0.21

314.15

1047.16

65.45

13326.75

22025.72

92.98

101.45

48

48

3500

1500

191965.54

0.25

374.85

1249.51

78.09

18942.63

33179.09

115.43

127.43

64

64

3500

1500

220016.54

0.29

436.09

1453.65

90.85

24463.15

44384.46

130.46

145.56

80

80

3500

1500

246107.09

0.32

487.34

1624.45

101.53

29875.5

55652.09

144.25

162.76

128

128

3500

1500

338296.45

0.35

529.77

1765.92

110.37

70625.67

357620.25

178.57

246.56

输入输出 2500 : 1500

xLLM

Request Rate (reqs/s)

max-concurrency

input_len

output_len

mean E2E Latency(ms)

Request throughput (req/s)

throughput(output tokens/s)

Total token throughput (tok/s)

Total token throughput (tok/s/单卡)

Mean TTFT(ms)

P99 TTFT(ms)

Mean TPOT(ms)

P99 TPOT(ms)

1

1

2500

1500

24852.24

0.04

60.35

160.94

10.06

394.39

530.74

16.32

17.05

4

4

2500

1500

32088.48

0.12

178.37

475.64

29.73

573.84

935.18

21.02

25.28

8

8

2500

1500

39355.71

0.2

294.19

784.52

49.03

766.48

2456.25

25.74

28.45

16

16

2500

1500

40876.41

0.38

563.23

1501.94

93.87

1227.04

5024.98

26.45

30.07

18

18

2500

1500

43335.67

0.4

604.77

1612.71

100.79

1303.45

5798.67

28.04

31.91

SGLang v0.4.3 MTP

Request Rate (reqs/s)

max-concurrency

input_len

output_len

mean E2E Latency(ms)

Request throughput (req/s)

throughput(output tokens/s)

Total token throughput (tok/s)

Total token throughput (tok/s/单卡)

Mean TTFT(ms)

P99 TTFT(ms)

Mean TPOT(ms)

P99 TPOT(ms)

1

1

2500

1500

45172.48

0.02

33.21

88.55

5.53

344.03

353.08

29.91

33.69

4

4

2500

1500

55608.83

0.07

103.99

277.31

17.33

472.99

848.48

36.78

42.67

8

8

2500

1500

61904.59

0.13

187.5

500.01

31.25

725.7

2253.81

40.81

45.19

16

16

2500

1500

89486.59

0.17

255.01

680.02

42.5

1216.71

4552.25

58.89

69.56

32

32

2500

1500

132389.41

0.23

348.11

928.31

58.02

2412.81

10893.85

86.71

107.96

48

48

2500

1500

198236

0.23

346.82

924.85

57.8

3353.08

19873.77

130.01

162.63

64

64

2500

1500

241460.59

0.25

382.03

1018.75

63.67

4231.3

26655.71

158.26

195.83

80

80

2500

1500

310641.77

0.15

217.99

581.32

36.33

9358.43

33755.17

200.99

240.58

准确度测试

基于 SGLang 的 MMLU 准确度测试工具评测xLLM DeepSeek的准确度为 89.5%

Average accuracy 0.920, latency 228.48, #q: 100 - abstract_algebra
Average accuracy 0.867, latency 169.80, #q: 135 - anatomy
Average accuracy 0.947, latency 196.47, #q: 152 - astronomy
Average accuracy 0.870, latency 77.30, #q: 100 - business_ethics
Average accuracy 0.928, latency 203.03, #q: 265 - clinical_knowledge
Average accuracy 0.979, latency 141.33, #q: 144 - college_biology
Average accuracy 0.730, latency 317.51, #q: 100 - college_chemistry
Average accuracy 0.890, latency 355.62, #q: 100 - college_computer_science
Average accuracy 0.890, latency 304.65, #q: 100 - college_mathematics
Average accuracy 0.908, latency 290.19, #q: 173 - college_medicine
Average accuracy 0.961, latency 174.44, #q: 102 - college_physics
Average accuracy 0.880, latency 105.63, #q: 100 - computer_security
Average accuracy 0.970, latency 157.97, #q: 235 - conceptual_physics
Average accuracy 0.842, latency 201.92, #q: 114 - econometrics
Average accuracy 0.876, latency 170.10, #q: 145 - electrical_engineering
Average accuracy 0.944, latency 228.55, #q: 378 - elementary_mathematics
Average accuracy 0.952, latency 243.86, #q: 126 - formal_logic
Average accuracy 0.660, latency 134.53, #q: 100 - global_facts
Average accuracy 0.948, latency 232.80, #q: 310 - high_school_biology
Average accuracy 0.897, latency 292.87, #q: 203 - high_school_chemistry
Average accuracy 0.960, latency 97.97, #q: 100 - high_school_computer_science
Average accuracy 0.885, latency 141.75, #q: 165 - high_school_european_history
Average accuracy 0.944, latency 97.97, #q: 198 - high_school_geography
Average accuracy 0.969, latency 115.37, #q: 193 - high_school_government_and_politics
Average accuracy 0.951, latency 319.19, #q: 390 - high_school_macroeconomics
Average accuracy 0.959, latency 469.05, #q: 270 - high_school_mathematics
Average accuracy 0.979, latency 171.25, #q: 238 - high_school_microeconomics
Average accuracy 0.887, latency 249.44, #q: 151 - high_school_physics
Average accuracy 0.967, latency 282.98, #q: 545 - high_school_psychology
Average accuracy 0.931, latency 240.87, #q: 216 - high_school_statistics
Average accuracy 0.951, latency 161.86, #q: 204 - high_school_us_history
Average accuracy 0.954, latency 217.05, #q: 237 - high_school_world_history
Average accuracy 0.839, latency 152.26, #q: 223 - human_aging
Average accuracy 0.947, latency 89.46, #q: 131 - human_sexuality
Average accuracy 0.917, latency 95.95, #q: 121 - international_law
Average accuracy 0.917, latency 81.23, #q: 108 - jurisprudence
Average accuracy 0.896, latency 139.88, #q: 163 - logical_fallacies
Average accuracy 0.812, latency 168.86, #q: 112 - machine_learning
Average accuracy 0.942, latency 75.59, #q: 103 - management
Average accuracy 0.949, latency 101.60, #q: 234 - marketing
Average accuracy 0.990, latency 104.15, #q: 100 - medical_genetics
Average accuracy 0.954, latency 356.24, #q: 783 - miscellaneous
Average accuracy 0.873, latency 240.59, #q: 346 - moral_disputes
Average accuracy 0.806, latency 999.57, #q: 895 - moral_scenarios
Average accuracy 0.935, latency 274.42, #q: 306 - nutrition
Average accuracy 0.897, latency 179.42, #q: 311 - philosophy
Average accuracy 0.926, latency 218.93, #q: 324 - prehistory
Average accuracy 0.826, latency 511.05, #q: 282 - professional_accounting
Average accuracy 0.760, latency 2197.88, #q: 1534 - professional_law
Average accuracy 0.963, latency 229.55, #q: 272 - professional_medicine
Average accuracy 0.928, latency 412.38, #q: 612 - professional_psychology
Average accuracy 0.800, latency 74.08, #q: 110 - public_relations
Average accuracy 0.861, latency 244.45, #q: 245 - security_studies
Average accuracy 0.965, latency 142.07, #q: 201 - sociology
Average accuracy 0.960, latency 74.24, #q: 100 - us_foreign_policy
Average accuracy 0.578, latency 170.61, #q: 166 - virology
Average accuracy 0.918, latency 90.26, #q: 171 - world_religions

{"task": "mmlu", "backend": "xllm", "num_gpus": 1, "latency": 20960.509, "accuracy": 0.895, "num_requests": 14042, "other": {"nsub": 57, "parallel": 16}}

附录

压力测试

SGLang的测试方法

压测方法

我们采用业界通用的方法压测 xLLM 和 SGlang 后端。来源于 vllm 的如下脚本:
https://github.com/vllm-project/vllm/blob/main/benchmarks/benchmark_serving.py
使用这个脚本通常有两种评测模式:

  • 方法一:是设置**--request-rate**

客户端会使用泊松过程(Poisson Process)来模拟请求的到达时间。request-rate 就是每秒发送的请求数量。比如设置为 10 表示一秒钟发送 10 个请求。通常也被称为RPS(Request Per Sec),表示每秒服务接受请求数。 使用 request-rate方式测试,从低到高逐渐增加 request rate,客户端不间断地发送请求,观察系统的每秒钟完成的 output request per sec,TTFT,TPOT。如果request rate 和 finished request per sec 大致相同, 则表示此时 RPS 在系统承载上限内。这时再观察 TTFT 和 TPOT 是否满足 SLA,找到恰好不满足 SLO 的临界点。此时就是系统承载能力的上限。

  • 方法二:是设置**--max-concurrency**

用于控制最大并发请求数,同时设置--request-rate inf。表示客户端同一时间只让系统同时处理 max-concurrency 个请求。**表示同时在等待请求完成的用户数。**比如max-concurrency为 10,那么客户端首先发送 10 个请求,让服务忙起来,只要结束一个请求就马上发送新的一个,保证服务端同时在忙于处理 10 个请求。 控制 request rate 和控制 max-concurrency 没有本质差别。request rate 还在系统承载范围内,增加 rps,就意味着增大 max-concurrency。
在评测 Qwen,Llama 等“小”模型的论文中,通常采用 request rate 方式。因为请求能承受的 max concurrency 非常高。比如 request rate为 4,系统的 concurrency 可以到 40; request rate为 10,系统的 concurrency 可以到 80。比如以 4,6,8,12,...方式采样 request rate,可以摸到上限。
而在评测 DeepSeek R1 这种“大”模型,推荐采用控制max-concurrency的方式。因为请求能承受的 max concurrency 比较低,相比控制 request rate,控制 max-concurrency 的粒度更精确。比如 request rate=2时候,系统的 concurrency 可能已经达到上限。 Request rate 可能需要以 0.1 为粒度采样,但是用4,6,8,12,...方式采样 max concurreny 则可以更精确控制负载。

SGLang环境配置

  • 镜像:可以在控制台选择**「预置镜像」-「SGLang」**,也可以直接输入如下地址
vemlp-cn-beijing.cr.volces.com/preset-images/sglang-edge:0.4.2.post4
  • 实例数:设置为2
  • 实例规格:选择「ml.hpcpni3l.48xlarge」
  • 入口命令:
MODEL_PATH=/amltest-stg/gw_test/DeepSeek-R1     #需要修改为当前模型的实际存储路径
IP_PORT=$MLP_ROLE_HEAD_IP:20000
NCCL_SOCKET_IFNAME=eth1 GLOO_SOCKET_IFNAME=eth1 python3 -m sglang.launch_server --model-path $MODEL_PATH --tp 16 --dist-init-addr $IP_PORT --nnodes 2 --node-rank $MLP_ROLE_INDEX --trust-remote-code --host 0.0.0.0 --port 8080 --enable-metrics #需要修改 port 为 http 协议放开的端口,并同样需要关注安全组放通

SGLang的测试脚本

#!/bin/bash

# 定义 input 和 output 长度
INPUT_LEN=3500
OUTPUT_LEN=1500

# 创建 logs 目录(如果不存在)
mkdir -p logs

# 定义 request-rate 和 max-concurrency
declare -a request_rates=(1 4 8 16 32 48 64 80 128 160)
declare -a max_concurrency=(1 4 8 16 32 48 64 80 128 160)
declare -a num_prompts=(4 16 32 64 128 192 256 320 512 640)

# 运行 benchmark 测试
for i in "${!request_rates[@]}"; do
    RATE=${request_rates[$i]}
    CONCURRENCY=${max_concurrency[$i]}
    PROMPTS=${num_prompts[$i]}

    echo "Running benchmark with request rate $RATE, concurrency $CONCURRENCY, prompts $PROMPTS"

    python3 -m sglang.bench_serving --backend sglang \
        --dataset-name random \
        --dataset-path ./ShareGPT_V3_unfiltered_cleaned_split.json \
        --random-input-len $INPUT_LEN \
        --random-output-len $OUTPUT_LEN \
        --random-range-ratio 1 \
        --request-rate $RATE \
        --max-concurrency $CONCURRENCY \
        --num-prompts $PROMPTS \
        --host 0.0.0.0 --port 40000 \
        > logs/${CONCURRENCY}_fp8_r1_${INPUT_LEN}_${OUTPUT_LEN}.txt 2>&1

    wait
done

xLLM 的测试方法

sglang-testing.zip
未知大小
# 修改 --base-url 为 模型部署端点
bash sglang-testing/bench.sh