In this article
Map profiler.step to a defined application unit, separate profiler warmup from model readiness, and preserve every intended active trace cycle.
A PyTorch profile contains initialization or no useful kernels even though the intended question concerns repeated inference. The schedule advances through explicit profiler steps, not automatically through requests or GPU completions. Define what a step means and align the wait, warmup and active phases with the work that should enter the trace.
Define a logical profiler step
Choose one repeatable application unit, such as the bounded inference iteration under investigation. Place profiler.step consistently at its boundary. A request can contain many iterations, while several requests can overlap one host loop. Preserve that mapping. The method changes the profiler’s schedule state; it is not itself proof that every asynchronously submitted GPU operation has completed.
Distinguish warmup meanings
The schedule’s warmup phase prepares profiling before active collection. It does not automatically complete the application’s model loading, compilation or cache preparation. Establish those application milestones separately when the question concerns steady execution. A trace that begins after profiler warmup can still contain first-use model work if the application has not exercised that path beforehand.
Read phase and repeat controls
The API defines wait, warmup, active and repeat behavior, with additional skip controls in supported versions. Write the expected phase sequence for the installed configuration before running it. Check that enough application steps occur to reach an active cycle. A short loop can finish before recording begins without indicating a failure of CUDA activity collection.
Preserve each completed trace
Use the documented trace-ready callback or export mechanism appropriate to the schedule. Keep distinct outputs for repeated cycles rather than overwriting one filename and assuming it contains every observed step. Record activity selection and expensive detail options. Shape and stack collection can add overhead or retain references, so the observed profile is not automatically an uninstrumented serving measurement.
Verify captured work before analysis
Include a recognizable bounded operation and check that its intended active steps appear with the expected device and application context. Then interpret the relevant operator and device relationships. Acceptance establishes trace selection and schedule boundaries. It does not prove that a missing unrecorded operation never ran, predict request latency from table totals or make profiler step count identical to the number of completed model tokens.
Primary references
PyTorch Profiler Schedule API.
PyTorch Scheduled Profiling Recipe.
Related reading: GPU profiling: sampling and instrumentation observe different events; CUDA events and request time: different measurement boundaries.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.