Skip to content

Commit 7473047

Browse files
shihaobainiushengxiao
authored andcommitted
static cost
1 parent fe9cdac commit 7473047

6 files changed

Lines changed: 1509 additions & 812 deletions

File tree

docs/CN/source/getting_started/benchmark.rst

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,18 @@ Prompt Cache 测试
133133
静态推理性能测试 (Static Inference Benchmark)
134134
----------------------------------------------
135135

136-
静态推理测试用于评估模型在固定输入条件下的推理性能, 主要评估算子的优劣
137-
模型推理测试 (model_infer.py)
138-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
136+
静态推理测试用于评估模型在固定输入条件下的推理性能, 主要评估算子的优劣。
137+
统一入口为 ``test/benchmark/static_inference/test_model.py``,核心实现集中在
138+
``test/benchmark/static_inference/static_benchmark.py``。
139+
140+
模型推理测试
141+
~~~~~~~~~~~~
139142

140143
**主要特性:**
141144

142145
- 支持 prefill 和 decode 阶段性能测试
146+
- 支持 prefill 静态 TPS 的多输入长度、多 batch size 和 chunked prefill
147+
- 支持 decode 静态 TPS 的多 batch size、多上下文长度和多输出长度
143148
- 支持 microbatch overlap 优化
144149
- 支持多 GPU 并行推理
145150
- 提供详细的吞吐量统计
@@ -150,23 +155,28 @@ Prompt Cache 测试
150155
151156
python test/benchmark/static_inference/test_model.py \
152157
--model_dir /path/to/model \
153-
--batch_size 32 \
154-
--input_len 1024 \
155-
--output_len 128 \
158+
--benchmark all \
159+
--batch_sizes 8,16,32 \
160+
--input_lens 1024,2048 \
161+
--context_lens 1024,4096 \
162+
--output_lens 128 \
163+
--chunked_prefill_sizes 512 \
156164
--tp 2 \
157165
--data_type bf16
158166
159167
**主要参数:**
160168

161169
- ``--model_dir``: 模型路径
162-
- ``--batch_size``: 批次大小
163-
- ``--input_len``: 输入序列长度
164-
- ``--output_len``: 输出序列长度
170+
- ``--benchmark``: 测试阶段,可选 ``all``、``prefill``、``decode``
171+
- ``--batch_size`` / ``--batch_sizes``: 单个或多个批次大小
172+
- ``--input_len`` / ``--input_lens``: prefill 输入序列长度
173+
- ``--context_lens``: decode 阶段上下文长度
174+
- ``--output_len`` / ``--output_lens``: decode 输出长度
175+
- ``--chunked_prefill_sizes``: prefill chunk 大小,默认 ``4096``;使用 ``full``、``none`` 或 ``0`` 表示不分块
165176
- ``--tp``: Tensor Parallel 并行度
166177
- ``--data_type``: 数据类型 (bf16/fp16/fp32)
167-
- ``--enable_prefill_microbatch_overlap``: 启用 prefill microbatch overlap,仅适用于DeepSeek模型的EP模式
168-
- ``--enable_decode_microbatch_overlap``: 启用 decode microbatch overlap,仅适用于DeepSeek模型的EP模式
169-
- ``--torch_profile``: 启用 torch profiler 进行性能分析
178+
- ``--enable_prefill_microbatch_overlap``: 启用 prefill microbatch overlap,仅适用于 DeepSeek 模型的 EP 模式
179+
- ``--enable_decode_microbatch_overlap``: 启用 decode microbatch overlap,仅适用于 DeepSeek 模型的 EP 模式
170180

171181
.. note::
172182
这里没有列举完整的启动参数,静态测试脚本也共享lightllm的启动参数,更多启动配置可以参考 :ref:`tutorial/api_server_args_zh` 。
@@ -177,30 +187,36 @@ Prompt Cache 测试
177187
- Decode 阶段吞吐量 (tokens/s)
178188
- 各阶段延迟统计
179189

180-
多结果预测性能测试 (model_infer_mtp.py)
181-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190+
多结果预测性能测试
191+
~~~~~~~~~~~~~~~~~~
182192

183-
多结果预测静态性能测试,默认百分百接受率,用来评估多结果预测的极限性能。目前只支持DeepSeek 系列模型
193+
多结果预测静态性能测试默认 ``--mtp_accept_rate 1.0``,即接受全部 draft token;
194+
可调低该值模拟更低接受率下的 MTP decode 吞吐。
195+
DeepSeek R1 可以使用 ``/mtc/models/DeepSeek-R1`` 和 ``/mtc/models/DeepSeek-R1-NextN`` 这类
196+
主模型/草稿模型结构。
184197

185198
**使用方法:**
186199

187200
.. code-block:: bash
188201
189202
python test/benchmark/static_inference/test_model.py \
190203
--model_dir /path/to/main_model \
191-
--mtp_mode deepseekv3 \
192-
--mtp_step 1 \
204+
--benchmark decode \
205+
--mtp_mode eagle_with_att \
206+
--mtp_step 2 \
193207
--mtp_draft_model_dir /path/to/draft_model \
194-
--batch_size 32 \
195-
--input_len 1024 \
196-
--output_len 128
208+
--mtp_accept_rate 0.8 \
209+
--batch_sizes 8,16 \
210+
--context_lens 1024,4096 \
211+
--output_lens 128
197212
198213
参数说明:
199214

200215
- ``--model_dir``: 主模型路径
201-
- ``--mtp_mode``: 指定多结果预测的模型,目前只支持deepseekv2/v3/r1
202-
- ``--mtp_step``: 每次forward step产生的token 数量,默认为1
216+
- ``--mtp_mode``: MTP 模式,如 ``eagle_with_att``、``vanilla_with_att``、``eagle_no_att``、``vanilla_no_att``
217+
- ``--mtp_step``: 每次 decode 额外预测的 draft token 数量
203218
- ``--mtp_draft_model_dir``: 草稿模型路径
219+
- ``--mtp_accept_rate``: 每个 draft token 的模拟接受概率,采样过程不计入 decode 耗时
204220

205221
Vision Transformer 测试 (test_vit.py)
206222
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -215,4 +231,4 @@ Vision Transformer 测试 (test_vit.py)
215231
--model_dir ./InternVL2/InternVL2-8B/ \
216232
--batch_size 1 \
217233
--image_size 448 \
218-
--world_size 2
234+
--world_size 2

docs/EN/source/getting_started/benchmark.rst

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,17 @@ Static Inference Performance Testing (Static Inference Benchmark)
132132
------------------------------------------------------------------
133133

134134
Static inference testing is used to evaluate model inference performance under fixed input conditions, mainly evaluating operator quality.
135+
The unified entry is ``test/benchmark/static_inference/test_model.py``. The
136+
core implementation lives in ``test/benchmark/static_inference/static_benchmark.py``.
135137

136-
Model Inference Testing (model_infer.py)
137-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138+
Model Inference Testing
139+
~~~~~~~~~~~~~~~~~~~~~~~
138140

139141
**Main Features:**
140142

141143
- Supports prefill and decode stage performance testing
144+
- Supports prefill static TPS with multiple input lengths, batch sizes, and chunked prefill sizes
145+
- Supports decode static TPS with multiple batch sizes, context lengths, and output lengths
142146
- Supports microbatch overlap optimization
143147
- Supports multi-GPU parallel inference
144148
- Provides detailed throughput statistics
@@ -149,23 +153,28 @@ Model Inference Testing (model_infer.py)
149153
150154
python test/benchmark/static_inference/test_model.py \
151155
--model_dir /path/to/model \
152-
--batch_size 32 \
153-
--input_len 1024 \
154-
--output_len 128 \
156+
--benchmark all \
157+
--batch_sizes 8,16,32 \
158+
--input_lens 1024,2048 \
159+
--context_lens 1024,4096 \
160+
--output_lens 128 \
161+
--chunked_prefill_sizes 512 \
155162
--tp 2 \
156163
--data_type bf16
157164
158165
**Main Parameters:**
159166

160167
- ``--model_dir``: Model path
161-
- ``--batch_size``: Batch size
162-
- ``--input_len``: Input sequence length
163-
- ``--output_len``: Output sequence length
168+
- ``--benchmark``: Benchmark stage, one of ``all``, ``prefill``, or ``decode``
169+
- ``--batch_size`` / ``--batch_sizes``: Single or multiple batch sizes
170+
- ``--input_len`` / ``--input_lens``: Prefill input lengths
171+
- ``--context_lens``: Decode context lengths
172+
- ``--output_len`` / ``--output_lens``: Decode output lengths
173+
- ``--chunked_prefill_sizes``: Prefill chunk sizes, default ``4096``; use ``full``, ``none``, or ``0`` for unchunked prefill
164174
- ``--tp``: Tensor Parallel degree
165175
- ``--data_type``: Data type (bf16/fp16/fp32)
166176
- ``--enable_prefill_microbatch_overlap``: Enable prefill microbatch overlap, only applicable to DeepSeek model EP mode
167177
- ``--enable_decode_microbatch_overlap``: Enable decode microbatch overlap, only applicable to DeepSeek model EP mode
168-
- ``--torch_profile``: Enable torch profiler for performance analysis
169178

170179
.. note::
171180
Complete startup parameters are not listed here. Static testing scripts also share Lightllm's startup parameters. For more startup configurations, please refer to :ref:`tutorial/api_server_args_zh`.
@@ -176,24 +185,34 @@ Model Inference Testing (model_infer.py)
176185
- Decode stage throughput (tokens/s)
177186
- Latency statistics for each stage
178187

179-
Multi-Token Prediction Performance Testing (model_infer_mtp.py)
180-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
188+
Multi-Token Prediction Performance Testing
189+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
181190

182-
Multi-token prediction static performance testing with 100% acceptance rate by default, used to evaluate the ultimate performance of multi-token prediction. Currently only supports DeepSeek series models.
191+
Multi-token prediction static performance testing defaults to
192+
``--mtp_accept_rate 1.0``, which accepts all draft tokens. Lower values simulate
193+
MTP decode throughput with lower acceptance. DeepSeek R1 can use a main/draft
194+
model pair such as ``/mtc/models/DeepSeek-R1`` and
195+
``/mtc/models/DeepSeek-R1-NextN``.
183196

184197
**Usage:**
185198

186199
.. code-block:: bash
187200
188201
python test/benchmark/static_inference/test_model.py \
189202
--model_dir /path/to/main_model \
190-
--mtp_mode deepseekv3 \
191-
--mtp_step 1 \
203+
--benchmark decode \
204+
--mtp_mode eagle_with_att \
205+
--mtp_step 2 \
192206
--mtp_draft_model_dir /path/to/draft_model \
193-
--batch_size 32 \
194-
--input_len 1024 \
195-
--output_len 128
207+
--mtp_accept_rate 0.8 \
208+
--batch_sizes 8,16 \
209+
--context_lens 1024,4096 \
210+
--output_lens 128
196211
197212
Parameter Description:
198213

199-
- ``--model_dir``: Main model path
214+
- ``--model_dir``: Main model path
215+
- ``--mtp_mode``: MTP mode, for example ``eagle_with_att``, ``vanilla_with_att``, ``eagle_no_att``, or ``vanilla_no_att``
216+
- ``--mtp_step``: Number of extra draft tokens predicted per decode step
217+
- ``--mtp_draft_model_dir``: Draft model path
218+
- ``--mtp_accept_rate``: Simulated per-draft-token accept probability; sampling is excluded from decode timing

0 commit comments

Comments
 (0)