측정 안 한 거 최적화 X
PyTorch profiler 가 op-level timing 을 CPU 와 GPU 에 capture, Chrome-trace JSON export, (profile_memory=True 면) tensor 할당 추적. '내 training time 이 실제로 어디로 가지' 와 '왜 OOM 나지' 답할 옳은 도구.
두 profiler, 두 목적
torch.profiler.profile— modern, 포괄적. CPU + CUDA timing, 메모리 추적, Chrome trace export. 옳은 default.torch.utils.bottleneck— 더 오래된, 가벼운 Python wrapper. 전체 profiler setup 없이 quick '뭐 느려' 답에 유용.
Chrome trace
profiler 가 Chrome 의 chrome://tracing viewer (또는 perfetto.dev) 에 로드되는 JSON export 가능. 모든 CPU 와 GPU op 의 timeline, duration 과 call relationship 와 함께 봐. '거대 cudaStreamSynchronize 있다' 또는 '이 작은 op 가 10,000 번 dispatch' 가 시각적으로 명백.
Reproducibility — orthogonal 이지만 알 가치
bit-for-bit deterministic run (디버깅 또는 paper-style ablation) 원하면 모든 RNG seed 설정 AND PyTorch 에 deterministic algorithm 사용 명령. 무료 X — 일부 op 가 deterministic 구현 없고, 다른 거 deterministic mode 에서 느림. 디버깅에 사용, production training 아님.