[Performance]: trtllm-serve's default of 8 HTTP frontends is ~20% slower than 4 at 128–512 concurrent streams (Qwen3-8B, GB200)

未关闭
#22,130 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python, pytorch

调研方向

Start by reading the frontend-count change in #19379 and the worker batching path in tensorrt_llm/executor/base_worker.py, especially handle_for_ipc_batched. Reproduce the throughput sweep with Qwen3-8B on a GB200, varying --num_serve_frontends from 1 to 8 at 128–512 concurrent streams. Done means identifying whether the default causes the reported slowdown and providing measured results that support a default or implementation change.

由索引模型根据 Issue 内容生成。

描述

General perf
Report of performance regression

Since #19379, trtllm-serve serve starts 8 HTTP frontend processes by default. On one GB200 with Qwen3-8B BF16 and 256 concurrent streaming /v1/completions requests, 8 frontends delivered about 19% fewer tokens per second than 4. The server command is the same in every run except --num_serve_frontends; each load wave uses its own random prompts.

CPUs available to the server 8 frontends (default), tok/s 4 frontends, tok/s
12 17,351 / 16,170 / 15,863 · 17,519 / 16,152 / 16,399 20,989 / 21,002 / 21,858 · 20,302 / 18,995 / 20,257
24 20,192 / 18,712 / 19,129 · 19,755 / 17,337 / 19,942 23,533 / 24,188 / 23,467 · 22,964 / 23,965 / 23,239

Each cell is two server launches (separated by ·) with three load waves each, run in the order 8, 4, 8, 4 (12 CPUs) and 4, 8, 4, 8 (24 CPUs). In both settings every 4-frontend wave was faster than every 8-frontend wave of the same launch pair, by at least 8% (12 CPUs) and 15% (24 CPUs). In a separate run on 12 CPUs, 2 frontends averaged 20,260 tok/s and 1 frontend 17,387 tok/s; with 1 frontend, in two of three waves the GPU went idle about 5 s before the last token reached the client. In two other runs of the 8-frontend server without streaming, the same load reached 23,344 and 25,479–25,624 tok/s.

A concurrency sweep on 12 CPUs (CUDA graphs extended to batch 512 so that 512-stream decode is not eager; two launches per frontend count in the order 8, 4, 4, 8; two waves per concurrency per launch) gave:

concurrent streams 8 frontends, mean tok/s 4 frontends, mean tok/s 4 / 8
64 9,234 10,246 1.11
128 12,485 15,197 1.22
256 15,440 19,566 1.27
512 18,530 22,807 1.23

At 128, 256 and 512 streams every 4-frontend wave was faster than every 8-frontend wave of the same launch pair, by at least 8%; at 64 the second launch pair overlapped.

A py-spy sample (100 Hz, 6 s inside one streaming wave per configuration, 12 CPUs) is consistent with an overhead that grows with the number of frontend processes. The numbers below are sampled time divided by an estimated step count (wave time / 1,024), so they are approximate, and py-spy on this platform does not separate GIL waits from running:

py-spy time per estimated decode step 8 frontends 4 frontends
worker executor loop thread 12.7 ms 9.8 ms
worker await_response_thread (per-lane pickle, HMAC, send) 3.9 ms 2.8 ms
all frontend processes together 21.2 ms 15.1 ms

Total server CPU in top was 2.7–2.8 of the 12 allocated cores in both runs. One possible explanation is the per-lane work in the worker, which groups each batch of responses by frontend and sends one IPC message per non-empty group (handle_for_ipc_batched); this was not isolated.

Is 8 the intended default at these concurrencies? The description of #19379 motivates the change with c ≥ 512 on a DSv4 disaggregated generation worker. In these runs 4 frontends gave higher throughput than 8 from 128 to 512 streams, and 2 frontends did as well at 256.

Your current environment (if you think it is necessary)
  • 1× NVIDIA GB200 (Grace, aarch64), Slurm job with 12 or 24 CPUs (half on each Grace socket); the server uses one GPU
  • nvcr.io/nvidia/tensorrt-llm/release:1.4.0rc3.dev202611050315 (arm64), PyTorch backend
  • Qwen3-8B BF16, TP 1

Server (8 frontends is the default; the 4-frontend runs add --num_serve_frontends 4; the concurrency sweep used cuda_graph_config.max_batch_size: 512):

cat > cfg.yaml <<'EOF'
cuda_graph_config:
  enable_padding: true
  max_batch_size: 256
kv_cache_config:
  host_cache_size: 8589934592
EOF
trtllm-serve serve Qwen/Qwen3-8B --served_model_name m --host 127.0.0.1 --port 8000 --config cfg.yaml

The CUDA graph settings follow the server's own startup warning for decode batches above 32; host_cache_size keeps the KV host tier inside the job's memory limit.

Load (simplified from the harness used): after wave 9 16 128 as a warm-up, send 256 requests at once (64 to 512 in the sweep), each with 256 random prompt token ids, max_tokens 1024, ignore_eos and streaming with usage; a wave counts only if every request returns HTTP 200 with curl exit code 0, [DONE] and 1,024 completion tokens. Throughput = requests × 1024 / wall time from the first request to the last response; three waves per server launch (two per concurrency in the sweep).

wave() {  # wave <seed> [n] [max_tokens]
  rm -rf bodies out && mkdir -p bodies out
  n=${2:-256}; m=${3:-1024}
  python3 - "$1" "$n" "$m" <<'EOF'
import json, random, sys
rng = random.Random(int(sys.argv[1]))
for i in range(int(sys.argv[2])):
    body = {"model": "m", "prompt": [rng.randrange(1000, 100000) for _ in range(256)], "max_tokens": int(sys.argv[3]),
            "ignore_eos": True, "stream": True, "stream_options": {"include_usage": True}}
    json.dump(body, open(f"bodies/r{i:03d}.json", "w"))
EOF
  t0=$(date +%s.%N)
  ls bodies/*.json | xargs -P "$n" -I{} sh -c 'curl -s -N -o out/$(basename {}).resp -w "%{http_code} %{exitcode}\n" -H "Content-Type: application/json" --data-binary @{} http://127.0.0.1:8000/v1/completions' > codes.txt
  t1=$(date +%s.%N)
  python3 - "$t0" "$t1" "$n" "$m" <<'EOF'
import glob, json, sys
n, m = int(sys.argv[3]), int(sys.argv[4])
codes = [ln.split() for ln in open("codes.txt") if ln.strip()]
ok = 0
for f in glob.glob("out/*.resp"):
    parts = [p.strip() for p in open(f).read().split("data: ")]
    usage = [json.loads(p)["usage"] for p in parts if p.startswith("{") and '"usage"' in p and json.loads(p).get("usage")]
    ok += "[DONE]" in parts and bool(usage) and usage[-1]["completion_tokens"] == m
good = sum(c == ["200", "0"] for c in codes)
assert len(codes) == n and good == n and ok == n, (len(codes), good, ok)
print(round(n * m / (float(sys.argv[2]) - float(sys.argv[1]))), "tok/s")
EOF
}
wave 9 16 128; wave 1; wave 2; wave 3

For the concurrency sweep, cfg.yaml sets max_batch_size: 512 under cuda_graph_config, and each launch runs wave SEED N twice for each n in 64, 128, 256, 512.

Not run: concurrency above 512, other models, x86 hosts, or a full GB200 node (all runs used 12 or 24 CPUs and one GPU).

Before submitting a new issue...
  • Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.
主要语言
Python
星标
15.2k
派生
3k
平均合并
2 天 21 小时
30 天内合并 PR
477

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NVIDIA/TensorRT-LLM 的其他 Issue

查看 NVIDIA/TensorRT-LLM 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。