Skip to content

J: roofline attainment — % of peak as the hot-path bar (W7) - #313

Merged
gstoner merged 2 commits into
mainfrom
j-roofline-attainment
Jul 8, 2026
Merged

gstoner merged 2 commits into
mainfrom
j-roofline-attainment

Conversation

@gstoner

@gstoner gstoner commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Workstream J / W7 — absolute roofline attainment. The E2 latency ratchet is a relative bar (did a hot path get slower?). J adds the absolute bar the plan asks for: % of peak.

benchmarks/roofline.py

  • Grounded per-device peak tablerocm:gfx1151 = 29.7 TF fp32 / 59.4 TF fp16 / 256 GB/s, each with a source string deriving it from rocminfo (40 CU × 2 SIMD32 × 32 lanes @ 2.9 GHz × 2 FMA × 2 dual-issue; fp16 WMMA 2×; LPDDR5X-8000 256-bit) — auditable/correctable in one place (Decision Apple GPU MLA: multi-sequence block-paged cache (vLLM-style paged attention) #27), not a guessed marketing number.
  • FLOP/byte models — matmul 2·M·N·K, flash_attn 4·B·H·S²·D.
  • achieved_tflops / pct_peak / evaluate_attainment.

Gate + baseline

  • The committed gfx1151 ratchet rows now carry pct_peak + achieved_tflops + an attainment_floor (= pct_peak / margin, symmetric with the latency cap), computed from the existing medians — no re-timing, so the latency caps are unchanged.
  • perf_gate --attainment gates a row that regresses below its floor (the absolute analog of the latency ratchet). record_hot_path_baseline annotates future baselines automatically.

Honest scope

The ratchet median is end-to-end wall-clock (H2D/launch/D2H + tessera-opt shell-out), so pct_peak is an end-to-end attainment — a lower bound on kernel efficiency. The current gfx1151 lanes sit at ~0.3–2.9% of peak, so the metric's immediate value is making that headroom visible and ratchet-able (2048³ matmul is the best at 2.9% — compute dominates overhead at scale).

Proof

test_roofline_attainment.py (12) — FLOP/peak/attainment model, gate pass/fail/coverage, and the committed baseline self-passes perf_gate --attainment. ruff clean; generated-doc drift gate green.

Still open (J)

Kernel-isolated attainment (strip host overhead); [NV] sm_120 + Apple peak rows; floors that ratchet upward as the lanes optimize.

🤖 Generated with Claude Code

The E2 latency ratchet is a relative bar (did it get slower?). J adds the
absolute bar the plan asks for: % of peak.

- benchmarks/roofline.py: a grounded per-device peak table (rocm:gfx1151 =
  29.7 TF fp32 / 59.4 TF fp16 / 256 GB/s, each with a `source` string deriving it
  from rocminfo CU/SIMD/clock + documented RDNA3 rates — Decision #27, auditable),
  FLOP/byte models (matmul 2*MNK, flash_attn 4*B*H*S^2*D), and
  achieved_tflops / pct_peak / evaluate_attainment.
- The committed gfx1151 ratchet rows gain pct_peak + achieved_tflops + an
  attainment_floor (= pct_peak / margin, symmetric with the latency cap),
  computed from the EXISTING medians (no re-timing — ratchet caps unchanged).
- perf_gate --attainment: gates a row that regresses below its floor (the
  absolute analog of the latency ratchet). record_hot_path_baseline annotates
  future baselines automatically.

Honest scope: the ratchet median is end-to-end wall-clock (H2D/launch/D2H +
tessera-opt shell-out), so pct_peak is an END-TO-END attainment — a lower bound
on kernel efficiency. The current gfx1151 lanes sit at ~0.3-2.9%, so the metric's
immediate value is making the headroom visible and giving it a ratchet floor.

Proof: test_roofline_attainment.py (12) — FLOP/peak/attainment model, gate
pass/fail/coverage, and the committed baseline self-passes `perf_gate
--attainment`. ruff clean; drift gate green.

Still open (J): kernel-isolated attainment (strip host overhead); NV sm_120 +
Apple peak rows; floors that ratchet upward as lanes optimize.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c37aabaf9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread benchmarks/roofline.py Outdated
Comment thread benchmarks/perf_gate.py Outdated
…fline import

- P1: measured ratchet-report rows carry latency_ms (as evaluate_ratchet reads),
  not median_ms — evaluate_attainment fell back to 0.0, so pct_peak returned None
  and every measured row false-failed on coverage. Read latency_ms with a
  median_ms fallback (baseline/self-check rows use median_ms).
- P2: `from roofline import` broke under `python -m benchmarks.perf_gate` and
  `from benchmarks import perf_gate` (package context — roofline not on sys.path).
  Try `from benchmarks.roofline import` first, fall back to the script-dir import.

Tests: a measured-row latency_ms gate case (pass at baseline latency, fail 10x
slower) and a package-import case (from benchmarks import perf_gate + main
--attainment on a latency_ms report). 14 pass; ruff clean; both script and
`-m benchmarks.perf_gate --attainment` invocations verified.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gstoner
gstoner merged commit 611bac6 into main Jul 8, 2026
17 checks passed
@gstoner
gstoner deleted the j-roofline-attainment branch July 8, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant