Profiling in PyTorch (Part 1): A Beginner's Guide to torch.profiler

AI-generated summary of reporting by Huggingface Blog. Read the original for the full story.

Why it matters

PyTorch practitioners get a beginner-friendly walkthrough of torch.profiler that turns opaque GPU traces into actionable optimization signals.

Read this as

The Hugging Face blog opened a tutorial series teaching people how to profile PyTorch code, meaning measure where compute time actually goes. Part 1 shows how to run the profiler on a simple matrix-multiply-plus-add operation, read its two outputs (a statistics table and a visual timeline), and spot when the GPU sits idle waiting on the CPU. It ran on an NVIDIA A100 GPU and traces came from PyTorch 2.13.

Hugging Face published the first installment of a PyTorch profiling tutorial series targeting teams that underuse GPU hardware. Using an A100 GPU and PyTorch 2.13, it demonstrates that small matrices leave the GPU over 99% idle, a costly inefficiency for anyone running inference or training. Two more parts on kernel fusion and attention are planned. No tooling product is being sold; it is free educational material.

The tutorial covers torch.profiler's two artifacts: a table sorted by cuda_time_total to find hotspots, and a JSON trace viewable in Perfetto showing CPU and GPU lanes. It explains torch.profiler.schedule (wait/warmup/active), the ~228 µs dead window fixed by warmup, and a ~2.5 ms CPU-GPU offset caused by an Activity Buffer Request during profiling. It also shows the dispatch chain (record_function → aten::matmul → aten::mm, or aten::bmm with batch axes) and notes traces were generated on PyTorch 2.13 with an NVIDIA A100-SXM4-80GB.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

PyTorch torch.profiler Perfetto NVIDIA A100-SXM4-80GB cuBLAS Hugging Face Spaces

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading