nsys

ref: https://docs.vllm.ai/en/stable/contributing/profiling/#openai-server_1

在pd分离case下,需要在P或者D起服务的时候增加:

...
export VLLM_WORKER_MULTIPROC_METHOD=spawn
 
TS=$(TZ=Asia/Shanghai date +%Y-%m-%d-%H-%M-%S)
 
nohup nsys profile \
    --trace-fork-before-exec=true \
    --cuda-graph-trace=node \
    -t cuda,nvtx,osrt \
    --capture-range=cudaProfilerApi \
    --capture-range-end=repeat \
    -o nsys/prefill_nixl_${TS} \
    vllm serve /inspire/hdd/global_public/public_models/Qwen/Qwen3-30B-A3B-Instruct-2507/ \
        ...
        --profiler-config.profiler cuda \
        ...

然后在 router.py 内增加(原因见下面):

@app.post("/start_profile")
async def start_profile():
    return await _handle_profile_control("/start_profile")
 
@app.post("/stop_profile")
async def stop_profile():
    return await _handle_profile_control("/stop_profile")

然后在测试增加

vllm bench serve \
  ...
  --profile

--profile 会发送/start_profile和/stop_profile的请求,server收到这个请求才会开始捕获nsys,但是现在这个请求通过router.py中转了一下。