/who-ate-my-flops:torch-profilefrom who-ate-my-flops
Profiles PyTorch training or inference jobs using torch.profiler, analyzes bottlenecks, and traces root causes to specific file:line locations. Produces a diagnosis report without modifying the code.
Ships in who-ate-my-flops. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
How is the time distributed? Where is the bottleneck? What is not the problem? Every finding gets chased to a file:line.
torch.profiler.① capture ② views ③ findings
one plain run + → how the wall → ranked, anchored,
a profiled window actually splits costed, handed off
Two runs.
First, unprofiled: torch.profiler adds overhead, so take the honest clock
with the cheap APIs instead, such as torch.cuda.Event(enable_timing=True) and
torch.cuda.max_memory_allocated(). This is also the only run that sees startup,
which no profiling window covers: dataset preprocessing, checkpoint loading,
first-step compilation, and anything else paid once. Time every step, and save
both that series and those startup numbers under commits/<sha>/.
Then profiled, over about 3 steady-state steps, with the window chosen from
the step-time series the first run produced. Steps 3-4-5 is a default, not a law:
if records/execution_schedule.json marks a periodic phase, the window must not straddle
it, and if step time trends, the window has to sit in the regime the run actually
spends its steps in. Traces go under commits/<sha>/trace/, which
workspace.py candidate <ws> <sha> creates.
One profiled step can hold a million events, and nobody reads a million events.
A view is a reshaping that makes one kind of anomaly stand out and hides the
rest. tools/view/ loads the traces into a store, then renders all five from it,
one numbered file each:
export PYTHONPATH=<plugin root> # you are standing in the target, not here
python -m tools.view load <ws>/commits/<sha>/trace/*.json -o <ws>/commits/<sha>/store.db
python -m tools.view render <ws>/commits/<sha>/store.db -o <ws>/commits/<sha>/views --capacity-gb <GB>
load wants rank<N> in each trace filename. torch.profiler's own export name
has none, so name them at capture time or the rank becomes sort order and every
per-rank row below is labelled with a rank that may not have produced it.
tools/view/common.py documents the schema, and each view is also a module with
a render(con) if you want one on its own.
1_runtime_decomposition.txt). wall = busy + idle, per step and per rank, with the spread across steps and the slowest
rank. Read it first: it forks the whole diagnosis into waiting against busy
but inefficient.2_lost_time.txt). Every gap where nothing ran and
every run of tiny kernels, ordered by what it costs in wall clock, each
stamped with its offset from the step start so the same one lines up across
steps. Each one arrives with what the machine was doing instead, which you
then name as an entry in records/execution_schedule.json rather than as a symptom.3_kernel_table.txt). Cumulative time bucketed into
attention, GEMM, communication, element-wise and transfer, with bytes moved
and achieved bandwidth wherever the event carries a size.
Copies are in here on purpose: a device-to-host copy counts as GPU-busy, so it
sits in no gap, and it disappears from every view at once if this one drops
it.4_overlap_exposure.txt). Per collective, how much
hid behind compute and how much was exposed. Only the exposed part lengthens
the step, so a large communication share that is fully hidden is not a
finding.5_memory.txt). Allocated and reserved, the peak, and
the headroom per GPU. Nothing else says whether a fix that spends memory is
available at all. Pass --capacity-gb or the headroom column comes back
unknown.Read all five before you conclude anything. They are where to start rather than the limit: the store is an ordinary database, so query it directly for whatever this particular job makes you suspect.
Every finding carries all of these, or it is not one yet:
| evidence | the number, and where in the views it came from |
code_anchor | out of records/computation_graph.json, or the records/execution_schedule.json entry for a wait |
| root cause | why the code does this, not what the device did |
| cost | as a ceiling, and against the whole run rather than one step |
| in scope | whether the reader is allowed to edit that code |
| confidence | and what would raise it |
Include the negative results. Half of what a reader needs is the list of things that looked expensive and were not.
Write it to commits/<sha>/report.md. Inside optimize, that report is what the
loop reads to decide whether the candidate is kept.
Three sections, in this order, and nothing may appear in section 3 that was not established in sections 1 and 2:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub openperfagent/who-ate-my-flops --plugin who-ate-my-flops9 skills in this plugin
/clean-upDeliver a finished optimization run as a branch the user can merge. Cherry-pick the commits that changed the workload onto the base, hardcode the A/B flags, re-verify on the shipped code, strip the checkpoint calls in a last commit, and leave the user standing on that branch with a handover./convert-to-benchmark-scriptTurn the script a user really runs into a benchmark script an optimization loop can run over and over. Same shape as the real job, a few minutes long, repeatable, and leaving nothing behind. It produces the script and a table of what changed, and it does not run it./diagnoseProfile the job defined in contract.md, name the one thing it loses most time to, and propose a single fix with a measured number behind it. It stops at the first finding. optimize is this same work repeated until nothing worth doing is left./extract-computation-graphRead a PyTorch job's code into two files in the workspace’s records/ directory. records/computation_graph.json says what is computed: the module tree down to op level, with a code anchor and a repeat count on every entry. records/execution_schedule.json says when and where it is computed and what moves between devices: phases, the data path onto the GPU, host to device copies and their sync points, the collectives between GPUs, and which overlaps are intended. It reads code and runs nothing. Use it to build either file, and to rebuild one when the code has moved under it./initWork with the user to pin down which PyTorch job gets optimized, write contract.md, and put the correctness instrumentation in place. The optimize skill later reads the contract.md written here and optimizes on its own. Every piece of alignment with the user happens in init, all of it./optimizeOptimize the torch job defined in contract.md with no further input. Profile, edit, and check correctness in a loop, then hand back one clean optimized branch.Other plugins' skills for the same job