← All questions
LLMOps & ProductionMedium· Profiling· PyTorch· Optimization

How would you use the PyTorch Profiler to identify whic...

Wrap the training step in a torch.profiler.profile context manager with CPU and CUDA activities enabled. After execution, call key_averages().table(sort_by=‘cuda_time_total’) to rank operations by their total GPU time. Focusing on the top entry, such as aten::mm, ensures you optimize the most impactful operations rather than wasting time on minor ones.

Code playground (Python)