Profiling in PyTorch (Part 3): Attention is all you profile
The third Hugging Face PyTorch profiling instalment traces attention implementation with a profiler. Comparing naive attention with in-place masking shows replacing masked_fill with masked_fill_ removes one GPU Memcpy kernel per forward pass.