Profiling
LeanProfiler
When a Lean program gets slower, we want to know where the time went. With LeanProfiler, we can name the parts we care about, such as loading data, running a forward pass or taking a training step, and measure them as the program runs. We can open the timeline in Perfetto and compare the JSON reports from two runs.
We use it around an existing TorchLean model runner, but it works with other compiled Lean programs too. For asynchronous GPU work, we can wait for the work to finish before closing a measurement. That measures the time until completion; individual kernel timings need a device profiler.