Przejdź do treści
Biblioteka skilli
Programowanie · Analiza

torch-profile

/torch-profile

Profiluje zadanie PyTorch torch.profilerem, znajduje przyczyny spowolnień aż do pliku i linii, bez wprowadzania poprawek.

Repozytorium
claude-plugins ↗
Licencja
MIT
Ostatnia zmiana repozytorium
26.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 26.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Profiluje zadanie PyTorch torch.profilerem, znajduje przyczyny spowolnień aż do pliku i linii, bez wprowadzania poprawek.

Oryginalny opis (EN)

Profile a PyTorch job, training or inference, with torch.profiler. Analyse the profile, read the surface symptoms, chase each root cause down to a file:line, and hand back a diagnosis. This skill produces no patch. Use when a PyTorch job is slow (low MFU, slow steps, idle GPU) and the user wants to know where the time goes, before any fix is attempted.

Jak działa

  1. ① Capture
  2. ② Views
  3. ③ Findings
  4. Output contract
Sekcje z nagłówków SKILL.md, w oryginale · 117 linii, 904 słów
Podgląd SKILL.md
---
name: torch-profile
description: "Profile a PyTorch job, training or inference, with torch.profiler. Analyse the profile, read the surface symptoms, chase each root cause down to a file:line, and hand back a diagnosis. This skill produces no patch. Use when a PyTorch job is slow (low MFU, slow steps, idle GPU) and the user wants to know where the time goes, before any fix is attempted."
---

How is the time distributed? Where is the bottleneck? What is not the problem?
Every finding gets chased to a file:line.

# torch-profile

- Profile the script at the current commit with `torch.profiler`.
- Add the profiler hooks yourself when the script has none.
- What you produce is **a diagnosis, not a patch**. Those hooks are the only edit
  you make: nothing here changes what the job computes or how long it takes, and
  nothing here measures a fix.

```
① capture                ② views                ③ findings
   one plain run +    →     how the wall      →    ranked, anchored,
   a profiled window        actually splits        costed, handed off
```

## ① Capture

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.

## ② Views

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:

```bash
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** (`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, ranked** (`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** (`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 and exposure** (`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 over time** (`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.

## ③ Findings

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.

## Output contract

Three sections, in this order, and nothing may appear in section 3 that was not
established in sections 1 and 2:

1. **Where the time went.** How this run divides into working and waiting, for
   the whole job *and* for a single step.
2. **Findings.** Ranked by how much wall clock each one actually costs, meaning
   the part not already hidden behind other work.
3. **Prescription.** Directions, each with a what-if bound stated as a
   **ceiling**, the effort it takes, whether numerics would change, and whether
   the code is the reader's to edit. **No predicted numbers for fixes you did not
   run.** Whoever runs the experiment writes the prediction.

Wersje

W bazie nie ma innych skilli o nazwie torch-profile.

Identyczna treść występuje jeszcze w 1 innych folderach na GitHubie. Tu pokazujemy jedną, najlepiej ocenioną kopię.

Migawka bazy z 13.11.2026 · wersja paczki 5a54b32893f0 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 1 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100torch-xpu-profile
    Profiluje model Hugging Face na karcie Intel GPU przez torch.profiler i Kineto, pokazując najgorętsze jądra i przerwy w pracy.
  • 100abi-stable
    Migruje kod rozszerzeń PyTorch w C++ i CUDA do stabilnego ABI PyTorch i API torch::stable.
  • 100profiling
    Ustala, gdzie idzie czas wnioskowania i dlaczego jądro jest wolne na NVIDIA, AMD ROCm, Apple Metal i CPU, bez obiecywania przyspieszenia.
  • 100xpu-profile-unitrace
    Profiluje obciążenia Intel XPU na poziomie jąder SYCL i Level Zero narzędziem unitrace, z czasami wywołań, transferami i zdarzeniami oneCCL.
  • 100profile-model
    Analizuje ślady profilera PyTorch: szuka wolnych kerneli, bezczynności GPU i narzutu komunikacji w treningu modelu.
  • 100performance-tuning
    Znajduje i naprawia główny koszt wolnej usługi JVM: mierzy, profiluje JFR lub async-profilerem i sprawdza GC oraz blokady.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.