SGLang · Torch Profiler

Separate prefill from decode

Use this workflow to read an SGLang Torch Profiler export in Perfetto. Record the model, commit, GPU, precision, batch size, prompt length, parallelism and CUDA Graph settings alongside the trace.

Pick comparable windows

  1. Run a warmup, then collect a short measured window. Capture prefill and several decode steps. Record request settings so you can match annotations to the workload.
  2. Locate the first model forward over the prompt and the repeated decode forwards. Use scheduler or model annotations where present. Check shapes or source when names alone are ambiguous.
  3. For a decode comparison, pick steady-state steps with comparable batch size and KV length. If the graph state changes, record that in the comparison.

Attribute GPU time

Attention and cache
Check the configured attention backend against the kernel names. Include KV writes, metadata preparation and split reductions when they are on the same path.
GEMMs and collectives
Look for the recurring per-layer sequence. Distinguish projection, MLP and LM-head work. Inspect NCCL and compute on separate streams for overlap.
Launch gaps
Compare wall-clock windows with summed kernel duration. Concurrent kernels can inflate that sum. CPU work and synchronization can leave gaps.

Report a comparison

Record the trace window, kernel count, total GPU duration by category, and the relevant source entry point. Re-run the same workload after changing one setting.

SGLang benchmark and profiling guide · LMSYS profiling workflow