Skip to content

vllm.benchmarks.forward.profile

GPU kernel profiles of vllm bench forward cases.

With --profile-dir, each case's graph is replayed a few more times under torch.profiler after timing. Each rank writes a Perfetto trace and a kernel summary (<case>.rank<r>.kernels.json): per-kernel time per forward, sorted.

Summarize one file or compare two (e.g. before/after a change): python -m vllm.benchmarks.forward.profile A.kernels.json [B.kernels.json].

The same replays run between cudaProfilerStart/Stop in an NVTX range per case (with or without --profile-dir), so Nsight Systems can record just them: nsys profile --capture-range=cudaProfilerApi --capture-range-end=repeat --cuda-graph-trace=node vllm bench forward ....

Functions:

  • profile_graph –

    Replay replays times between cudaProfilerStart/Stop, in an NVTX

  • short_name –

    void ns::foo<T, 4>(args) -> ns::foo: return type, template and

  • summarize –

    Per-forward kernel times from the GPU activities of replays replays.

_match_back(text, end, open_ch, close_ch)

Index of the bracket opening the one closing at end, skipping brackets of the other kind nested inside parentheses.

profile_graph(graph, name, prefix, skip, replays=3)

Replay replays times between cudaProfilerStart/Stop, in an NVTX range named after the case, for nsys --capture-range=cudaProfilerApi.

With prefix, also trace them with torch.profiler and write prefix.trace.json.gz and prefix.kernels.json. Every rank must call this (replays may contain collectives).

short_name(name)

void ns::foo<T, 4>(args) -> ns::foo: return type, template and function arguments dropped. Generic launchers (e.g. cutlass::device_kernel<Op<...>>) keep their first template argument.

summarize(events, replays, skip)

Per-forward kernel times from the GPU activities of replays replays.

Each replay first runs skip activities that aren't part of the timed forward (the KV state restore and the rank rendezvous); they are reported separately as pre_forward_us.