benchmark-model
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBenchmark a model on MAX
在MAX上对模型进行基准测试
max benchmarkmax serveEvery run reports both throughput and latency, so there's no mode to select.
Decide what you want to learn first, then pick the workload that measures it.
Single-stream latency and peak throughput come from different workloads, so the
workload you choose is the measurement. Get that right and a clean number
falls out.
Use this skill when you want a performance number for a model on MAX:
tokens/sec, TTFT / TPOT, a concurrency or request-rate sweep, a
latency-vs-throughput tradeoff, or deployment sizing.
Don't use this skill when no server is running yet. is a client,
so start a server with the skill first. To find out where
inference time goes at the kernel level, use . To check whether
the output is correct, treat it as a parity task (, then
) rather than a benchmark.
max benchmarkserve-modelprofile-modelimport-modeldebug-modelThis skill works anywhere MAX is installed (pip or pixi). Add in a
pixi project.
pixi runmax benchmarkmax serve每次运行都会同时报告吞吐量和延迟,因此无需选择模式。先确定你想了解的内容,再选择对应的测量工作负载。单流延迟和峰值吞吐量来自不同的工作负载,因此你选择的工作负载就是测量方式。选对工作负载,就能得到准确的数值。
当你需要获取MAX上模型的性能数值时,可使用此技能:每秒令牌数、TTFT/TPOT、并发或请求率扫描、延迟与吞吐量的权衡,或部署规模规划。
如果尚未启动服务器,请勿使用此技能。是客户端,因此需先使用技能启动服务器。若要从内核层面了解推理时间的去向,请使用。若要检查输出是否正确,请将其视为一致性任务(,然后),而非基准测试。
max benchmarkserve-modelprofile-modelimport-modeldebug-model此技能可在任何安装了MAX的环境中使用(pip或pixi)。在pixi项目中添加。
pixi runReferences
参考资料
The following table lists the reference files and when to read each one:
| File | Read when |
|---|---|
| references/flags.md | Choosing any flag or dataset beyond the ones below |
| references/metrics.md | Turning the throughput and latency numbers into a conclusion |
| references/troubleshooting.md | A run won't connect, requests fail, or the numbers look wrong |
Read the reference for what you're doing, not all of them upfront.
下表列出了参考文件及其适用场景:
| 文件 | 适用场景 |
|---|---|
| references/flags.md | 选择以下未提及的任何标志或数据集时 |
| references/metrics.md | 将吞吐量和延迟数值转化为结论时 |
| references/troubleshooting.md | 运行无法连接、请求失败或数值异常时 |
按需阅读对应参考资料,无需预先通读全部内容。
1. Check the server and read its model name
1. 检查服务器并读取其模型名称
bash
curl -s http://localhost:8000/v1/health # 200 = ready
curl -s http://localhost:8000/v1/models # note the served model nameBoth checks matter before you spend a run:
- The benchmark's must equal the server's
--modelexactly, or every request fails. Take the value from--served-model-namerather than guessing it./v1/models - If that served name is an alias rather than a Hugging Face ID (no in it),
/defaults to it and can't resolve, and the run dies with "not a valid model identifier." Pass the model's real Hugging Face ID as--tokenizer.--tokenizer
If nothing is serving, start a server with (for a custom
architecture, use the skill). One more server setting matters:
caps real concurrency. A sweep to
against a server started with queues requests instead of
batching them, so raise the server's batch size to match the sweep or the
high-concurrency points mean nothing.
max serveserve-model--max-batch-size--max-concurrency 32--max-batch-size 1Wait for then benchmark. Benchmarking during compile or warmup
produces garbage first-token times.
Server readybash
curl -s http://localhost:8000/v1/health # 200 = 就绪
curl -s http://localhost:8000/v1/models # 记录部署的模型名称在开始运行前,这两项检查都至关重要:
- 基准测试的参数必须与服务器的
--model完全一致,否则所有请求都会失败。请从--served-model-name获取该值,而非猜测。/v1/models - 如果部署的名称是别名而非Hugging Face ID(名称中不含),
/会默认使用该别名,但无法解析,导致运行失败并提示“不是有效的模型标识符”。此时需传入模型真实的Hugging Face ID作为--tokenizer参数。--tokenizer
如果没有服务器在运行,请使用启动服务器(对于自定义架构,请使用技能)。还有一项服务器设置很重要:会限制实际并发量。若针对以启动的服务器执行扫描,请求会被排队而非批量处理,因此请将服务器的批量大小调整为与扫描值匹配,否则高并发点的数值毫无意义。
max serveserve-model--max-batch-size--max-batch-size 1--max-concurrency 32等待服务器显示后再进行基准测试。在编译或预热阶段进行基准测试会导致首令牌时间数值无效。
Server ready2. Pick the workload for your question
2. 根据你的问题选择工作负载
The workload is the measurement. Match it to what you want to learn:
| What you want to know | Workload |
|---|---|
| Best-case single-request latency (TTFT, TPOT) | |
| Peak throughput and where latency degrades | |
| Performance under a realistic mix | |
| Behavior at a target load | |
A sweep answers the first two rows at once: the concurrency-1 point is the
best-case latency number, and the peak across the sweep is the throughput
number. Reach for a dedicated concurrency-1 run when you only want the latency
figure and don't want to pay for the rest of the curve.
The key knobs are the following ( has the full catalog):
references/flags.md- : pick
--dataset-name(synthetic, shape it withrandomand--random-input-len),--random-output-len(real chat), orsharegpt(long context).arxiv-summarizationworks best for clean, reproducible micro-measurements.random - and
--max-concurrency: take a single value or a comma-separated sweep (--request-rate). A sweep is how you find the throughput knee.1,2,4,8 - : use
--endpointfor base LMs, which need no chat template, or/v1/completionsfor instruct and chat models, which must have a chat template or the requests return 400./v1/chat/completions - : sets the decode length, which dominates how long the run takes.
--max-output-len - : required for single-turn runs.
--num-prompts
工作负载即测量方式,请根据你想了解的内容选择:
| 你想了解的内容 | 工作负载 |
|---|---|
| 最佳单请求延迟(TTFT、TPOT) | |
| 峰值吞吐量及延迟劣化点 | |
| 真实混合场景下的性能 | |
| 目标负载下的行为 | |
一次扫描可同时回答前两行的问题:并发量为1的点是最佳延迟数值,扫描中的峰值是吞吐量数值。当你只需要延迟数值且不想为其余曲线付出成本时,可选择专门的并发量为1的运行。
关键参数如下(完整参数列表请见):
references/flags.md- :可选
--dataset-name(合成数据,通过random和--random-input-len调整形状)、--random-output-len(真实对话)或sharegpt(长上下文)。arxiv-summarization最适合用于清晰、可复现的微观测量。random - 和
--max-concurrency:可设置单个值或逗号分隔的扫描值(如--request-rate)。扫描是找到吞吐量拐点的方法。1,2,4,8 - :基础语言模型使用
--endpoint(无需聊天模板),指令型和对话型模型使用/v1/completions(必须有聊天模板,否则请求会返回400错误)。/v1/chat/completions - :设置解码长度,这是决定运行时长的主要因素。
--max-output-len - :单轮运行必填参数。
--num-prompts
3. Run it, save results, add GPU stats
3. 运行测试、保存结果并添加GPU统计信息
For best-case single-request latency, pin concurrency to 1 and keep the shape
fixed:
bash
pixi run max benchmark --backend modular --base-url http://localhost:8000 \
--model <served-model-name> --endpoint /v1/completions \
--dataset-name random --random-input-len 128 --random-output-len 128 \
--max-output-len 128 --num-prompts 32 --max-concurrency 1 \
--result-filename results/latency.json --collect-gpu-statsFor peak throughput and the latency knee, sweep concurrency and send more
prompts:
bash
pixi run max benchmark --backend modular --base-url http://localhost:8000 \
--model <served-model-name> --endpoint /v1/completions \
--dataset-name random --random-input-len 512 --random-output-len 128 \
--max-output-len 128 --num-prompts 200 \
--max-concurrency 1,2,4,8,16,32 \
--result-filename results/throughput.json --collect-gpu-statsNote these three things about saving and instrumenting a run:
- : writes metrics to JSON and creates the directories it needs. Set it whenever you want to track or compare runs; without it, MAX saves nothing.
--result-filenamestamps the JSON, for example--metadata key=value. A sweep also drops a--metadata tp=1 gpu=b200per step underresults-<N>-median.json.--log-dir - : adds GPU utilization and peak memory. This works only when the benchmark runs on the same machine as the server (NVIDIA).
--collect-gpu-stats - For version-controlled configs, put options under a key in a YAML file and pass
benchmark_config:. Keys use--config-file file.yaml, and CLI flags override the file.snake_case
如需获取最佳单请求延迟,请将并发量固定为1并保持形状不变:
bash
pixi run max benchmark --backend modular --base-url http://localhost:8000 \
--model <served-model-name> --endpoint /v1/completions \
--dataset-name random --random-input-len 128 --random-output-len 128 \
--max-output-len 128 --num-prompts 32 --max-concurrency 1 \
--result-filename results/latency.json --collect-gpu-stats如需获取峰值吞吐量和延迟拐点,请扫描并发量并发送更多提示语:
bash
pixi run max benchmark --backend modular --base-url http://localhost:8000 \
--model <served-model-name> --endpoint /v1/completions \
--dataset-name random --random-input-len 512 --random-output-len 128 \
--max-output-len 128 --num-prompts 200 \
--max-concurrency 1,2,4,8,16,32 \
--result-filename results/throughput.json --collect-gpu-stats关于保存和监控运行,请注意以下三点:
- :将指标写入JSON文件,并自动创建所需目录。当你需要跟踪或对比运行结果时请设置该参数;若未设置,MAX不会保存任何内容。
--result-filename可为JSON文件添加标记,例如--metadata key=value。扫描还会在--metadata tp=1 gpu=b200下为每个步骤生成--log-dir文件。results-<N>-median.json - :添加GPU利用率和峰值内存统计。此功能仅在基准测试与服务器运行在同一台机器(NVIDIA)上时生效。
--collect-gpu-stats - 对于版本控制的配置,可在YAML文件的键下设置参数,然后通过
benchmark_config:传入。键名使用--config-file file.yaml,CLI标志会覆盖文件中的设置。snake_case
4. Read the metrics
4. 解读指标
The run prints throughput and latency, and a sweep prints one row per point. The
headline numbers are the following:
- Output token throughput (tok/s): the main throughput number.
- TTFT (time to first token): prefill responsiveness. Watch p50 and p99.
- TPOT and ITL (time per output token and inter-token latency): decode speed.
- GPU utilization and peak memory: reported with .
--collect-gpu-stats
For how to turn these numbers into a conclusion, and the latency-vs-throughput
tradeoff a sweep reveals, see .
references/metrics.md运行会打印吞吐量和延迟,扫描会为每个点打印一行数据。核心指标如下:
- 输出令牌吞吐量(tok/s):主要的吞吐量数值。
- TTFT(首令牌时间):预填充响应速度。请关注p50和p99数值。
- TPOT和ITL(每个输出令牌的时间和令牌间延迟):解码速度。
- GPU利用率和峰值内存:启用后会报告这些指标。
--collect-gpu-stats
如需了解如何将这些数值转化为结论,以及扫描揭示的延迟与吞吐量权衡关系,请查看。
references/metrics.mdTroubleshooting
故障排除
Match the symptom against , which covers
connection failures, model-name mismatches, tokenizer-alias errors,
chat-template 400s, flat throughput from a batch-size cap, and warmup-skewed
first-token times. Confirm that returns 200 before you check
anything else.
references/troubleshooting.mdcurl /v1/health请根据症状参考,其中涵盖了连接失败、模型名称不匹配、分词器别名错误、聊天模板导致的400错误、批量大小限制导致的吞吐量停滞,以及预热阶段导致的首令牌时间异常等问题。在检查其他内容之前,请先确认返回200。
references/troubleshooting.mdcurl /v1/health