grill: per-hot-kernel geometry-sweep harness (Tracy/op-gate matrix + cost-model pick, modelled on upstream #58891 calibration/), wired into ttx #209

Open
opened 2026-10-08 21:36:07 +02:00 by tenstorrent · 1 comment
Member

Grill

  • Call: GRILL. This is design review first. No code until the open questions below have answers.
  • Problem: We find geometry wins (core roles, grid shape, producer/receiver balance, subblocks, chunking) only when upstream publishes them. We do not search for them. Our screen loop is one lever per CI A/B, so a per-op geometry gain of a few percent sinks into the ~1% cell noise or is never tried.
  • Proposal: a per-hot-kernel geometry-sweep harness. For each hot op at the served shape, it runs a pinned-geometry matrix under Tracy / the device profiler on one card, using the workbench and op gate. A cost model is fitted to that matrix and picks the geometry. The pick is then re-checked on the card and handed to ttx as an arm (env/program-config knob), so the normal CI A/B judges it. The model for this is upstream tt-metal #58891's calibration/ loop. Grill-first: the problem, evidence, design, open questions and desk vs card cost are below. No code yet.

Evidence

  1. Upstream #58891, GDN fused prefill producer pool. https://github.com/tenstorrent/tt-metal/pull/58891 [third-party numbers, one p150, Tracy device time per 2048 chunk]

    • At our shape (BH=24, the 27B at TP=2) the op's own pick was NV=1 NP=3 on 96 of 110 cores, 454.5 µs. The pool pick is NV=1 P=86 on 110 cores, 371.7 µs.
    • The win came from a calibration loop, not new math: a "measurement matrix built from the tree's own picks", a capture driver, a batch runner (device lock, private JIT cache, timeout plus board reset), a zone collector (item period, fill, step, pace, skew, tail), a Python port of the C++ model checked through the binding, and a picks tool that lists near-ties with their measurements. Model error is 3.1% mean on 93 rows.
  2. We had the data and never swept it (docs/PROCESS-REVIEW-2026-10-02.md §6):

    • Every prefill chunk logs cost-model pick NV=1 NP=3: 1,056 lines per boot in c156a.
    • Patch 0025b re-exports ChunkGdnFusedProgramConfig(num_receivers, num_producers), and we never swept it.
    • Our scan was 0.71 ms/layer [c127] against upstream's before number of 0.45 ms.
    • Root causes listed there: ops treated as black boxes, the wrong roofline for the op class, no occupancy metric, no per-op upstream baseline, and geometry logs nobody reads.
  3. The port paid off once someone else had done the search.

    • #197 (patch 0048, the #58891 pool port) was screened in CI run #7303 and closed out in #202. gpool: PP +0.76…+2.00% in all 6 cells, mean TG +0.35%. WIN alone, now in combo #200.
    • #207 (opened today by the upstream scout) is the next layer of the same upstream stack. We are still porting their geometry results one PR at a time.
  4. One-lever card A/Bs cannot see small geometry deltas. Each of these spent a CI card slot, and each closed inert inside the ~1% band:

    • #174: SDPA decode k_chunk=512.
    • #175: GDN scan mcast.
    • #176: GDN_FUSED_MAX_BH=192. Its verdict was "upstream cost-model choice at BH>32 was right", made without ever looking at the model's inputs.
    • #177: cph32 re-test. B1/4k TG −5.20%, B1/32k +1.04%, other cells within ±0.7%.
    • #178: 1D_GRID_ATTN_QKV=11x6.

    #170–#173 (AGMM 11x9 re-test, LOO attributions) are still open with the same shape of question. STATUS c160c: in-boot deltas are ~1% tighter than cross-boot, but a 1–3% single-op gain is still ≤0.5% of a B8 cell. The served-model A/B is the right ship gate and the wrong search instrument.

  5. Under-filled grids are already listed. docs/OP-DATASHEETS.md §10:

    • P1 AGMM: 90/110 busy.
    • P2 GDN fused: 96 (fixed by gpool).
    • P4 SDPA prefill: 96.
    • P6 distributed norm: 64.
    • D4 decode SDPA: 96.
    • P5a w2: 100, ~91 effective. w2t (R-2026-10-07-w2t, PP +1.17%) was this kind of fix, found by hand.

    §9's ranked list is mostly geometry experiments that nobody has run as a matrix.

Proposed design (for grilling)

Scope is the hot kernels, at served shapes, TP=2 per-chip shapes on one card:

op knobs to matrix (examples, to be confirmed per datasheet) shape(s)
GDN fused chunk (P2) num_receivers, num_producers/pool, pool_extra_share, handoff_depth, row_local BH=24, NC per 2048 chunk
AGMM prefill (P1) grid (11x8/11x9/11x10, transposed), in0 block/subblock, K_block cap, chunks per role qkvzab, attn qkv, gate|up, gdn out, attn out @ 2048
decode DRAM MR matmuls (D1/D1′): w2, out, qkv(zab), lm_head readers per bank / cores_per_bank (#58922), in0 block, per-role CPB, fidelity B=8 T=3 (M=24), B=1
SDPA decode (D4) cores_per_head, k_chunk, KV dual-NoC mode B=8/B=1 at 4k and 32k

The loop, per op:

  1. Matrix. Enumerate the legal geometries from the op's own factory constraints. Seed the matrix with the op's current pick and its neighbours, the same way #58891 builds its matrix from the tree's picks. Record the pick line from the served boot with tools/ttx/op-configs.py.
  2. Capture. On one card, through ttx wb (workbench) and the existing slot protocol. The harness never boots by hand. Tracy device zones go through tools/ttx/op-anatomy.py into per-core, per-RISC timelines: occupancy (busy/110), critical path, fill/step/tail. Every row is checked bit-exact against the current pick (the op gate, like #197's 1-card gate), and a must-fail row is required.
  3. Model. A small per-op-class cost model (matmul: DRAM/NoC/FPU floors; chain op: fill + NC × max(step, supply), per PROCESS-REVIEW §6 root cause 2), fitted on the matrix. It reports error per row and lists near-ties.
  4. Pick, then confirm. Re-measure the model's top-k against the current pick on the card (the #58891 "picks tool"). The output is a record bench/runs/geomsweep-<op>-<utc>.jsonl plus an arm emitted by tools/ttx/arm-derive.py with the knob as env.
  5. Ship gate unchanged. The pick goes to CI as one arm, or as a combination screen with other picks (MAX_SCREEN=8, ci-pick-winner.py). Only the served A/B and the gates decide shipping.
  6. ttx wiring. Either ttx geom {matrix,capture,fit,pick} <op> or a tools/ttx/geom-sweep.py driven by ttx queue. Records carry the pin, the overlay hash and the shape, so a pin move invalidates the model (OP-DATASHEETS §11).

Open questions

  1. Which ops expose their geometry as a runtime knob today, and which need a patch first? GDN: 0025b re-exports the config. AGMM: env grid flags. MR: CPB env. SDPA decode: cores/head env. Any op without a knob needs a JIT/C++ overlay before it can be swept at all.
  2. Should we port #58891's calibration/ tooling as-is (GDN only) and generalise from it, or write one generic harness? Upstream's version is GDN-specific and depends on its kernel zones.
  3. Workbench fidelity: does a 1-card wb op time at the TP=2 per-chip shape predict the served delta? We need one calibration point: gpool's wb delta against its #7303 served PP delta.
  4. Tracy-ON build cost. Device-profiler CSVs need a Tracy build (op-anatomy docstring). Is that a separate cached image or overlay, and how much host RAM does it use? cfx-llm2 has 15.9 GB, and the boot guard is 4 GB MemAvailable.
  5. Card budget and scheduling. Does the sweep run as a low-priority ttx queue standby on one card (bench/queues/standby.txt) without blocking the CI mesh job, or does it need the mesh slot? It should never take the mesh for 1-card work.
  6. Model class per op: one fitted model per op class (matmul, chain/pipeline, SDPA), or a pure empirical argmin over the matrix with no model? Without a model, near-ties and transfer to new shapes are lost.
  7. Search budget: how many rows per op before the model must explain them? Upstream used 93 rows for one op.
  8. Does this replace or feed #110 (adopt every lever conditionally) and the OP-DATASHEETS §9 ranking? Proposed answer: it feeds §9 and emits arms, and it does not ship anything by itself.

Desk vs card cost (estimates, not measurements)

  • Desk (no card):
    • Matrix enumerators from factory constraints for the 4 op families.
    • A model port and fit (#58891's model as the template for GDN).
    • Wiring for op-configs.py, op-anatomy.py and arm-derive.py, plus unit tests on recorded CSVs.
    • ttsim correctness only, for any new knob plumbing.
    • Order of a few agent-days. No card time.
  • Card (one card via the slot protocol, never the mesh):
    • Per op: matrix rows × (compile + a few launches).
    • Exact minutes per row are unknown until the first GDN capture. That capture is the first measurement this issue asks for, and it also gives the wb→served calibration point (Q3).
    • Mesh and CI time only for the final picks: one CI combination screen per batch of picks (~30 min per arm boot, per the CI comments on run 418).
  • What the harness replaces: one-lever CI A/Bs that land inert (#174–#178: five card slots, zero ships).

Out of scope

New math or new kernels. Wholesale upstream syncs (that is the upstream scout's lane: #64, #154, #207). Any served-arm change without the normal CI A/B and gates.

Refs

upstream tt-metal #58891 (and #58925–#58929, #58959, #58972, #58974) · #197 / #202 (run #7303) · #207 · #170–#178 · #110 · #151 · #109 · #154 · #90 · docs/PROCESS-REVIEW-2026-10-02.md §6 · docs/OP-DATASHEETS.md §9–§11 · tools/ttx/op-configs.py, tools/ttx/op-anatomy.py, tools/ttx/arm-derive.py

Duplicate check (2026-10-08): no existing issue covers a per-op geometry sweep or a cost-model pick loop.

  • #90 is the perf-loop c1 PR.
  • #154 is an upstream-kernel WATCH.
  • #135 is a prefill chunk policy.
  • #151 covers AGMM instrumentation only.
  • #109 is the upstream GEMM recipe.

This issue links them rather than duplicating them.

## Grill - **Call:** GRILL. This is design review first. No code until the open questions below have answers. - **Problem:** We find geometry wins (core roles, grid shape, producer/receiver balance, subblocks, chunking) only when upstream publishes them. We do not search for them. Our screen loop is one lever per CI A/B, so a per-op geometry gain of a few percent sinks into the ~1% cell noise or is never tried. - **Proposal:** a **per-hot-kernel geometry-sweep harness**. For each hot op at the served shape, it runs a pinned-geometry matrix under Tracy / the device profiler on one card, using the workbench and op gate. A cost model is fitted to that matrix and picks the geometry. The pick is then re-checked on the card and handed to `ttx` as an arm (env/program-config knob), so the normal CI A/B judges it. The model for this is upstream tt-metal #58891's `calibration/` loop. Grill-first: the problem, evidence, design, open questions and desk vs card cost are below. No code yet. ## Evidence 1. **Upstream #58891, GDN fused prefill producer pool.** https://github.com/tenstorrent/tt-metal/pull/58891 [third-party numbers, one p150, Tracy device time per 2048 chunk] - At our shape (BH=24, the 27B at TP=2) the op's own pick was NV=1 NP=3 on **96 of 110 cores, 454.5 µs**. The pool pick is NV=1 P=86 on **110 cores, 371.7 µs**. - The win came from a **calibration loop**, not new math: a "measurement matrix built from the tree's own picks", a capture driver, a batch runner (device lock, private JIT cache, timeout plus board reset), a zone collector (item period, fill, step, pace, skew, tail), a Python port of the C++ model checked through the binding, and a picks tool that lists near-ties with their measurements. Model error is 3.1% mean on 93 rows. 2. **We had the data and never swept it** (`docs/PROCESS-REVIEW-2026-10-02.md` §6): - Every prefill chunk logs `cost-model pick NV=1 NP=3`: 1,056 lines per boot in c156a. - Patch 0025b re-exports `ChunkGdnFusedProgramConfig(num_receivers, num_producers)`, and we never swept it. - Our scan was 0.71 ms/layer [c127] against upstream's *before* number of 0.45 ms. - Root causes listed there: ops treated as black boxes, the wrong roofline for the op class, no occupancy metric, no per-op upstream baseline, and geometry logs nobody reads. 3. **The port paid off once someone else had done the search.** - #197 (patch 0048, the #58891 pool port) was screened in CI run #7303 and closed out in #202. gpool: **PP +0.76…+2.00% in all 6 cells**, mean TG +0.35%. WIN alone, now in combo #200. - #207 (opened today by the upstream scout) is the next layer of the same upstream stack. We are still porting their geometry results one PR at a time. 4. **One-lever card A/Bs cannot see small geometry deltas.** Each of these spent a CI card slot, and each closed inert inside the ~1% band: - #174: SDPA decode k_chunk=512. - #175: GDN scan mcast. - #176: GDN_FUSED_MAX_BH=192. Its verdict was "upstream cost-model choice at BH>32 was right", made without ever looking at the model's inputs. - #177: cph32 re-test. B1/4k TG −5.20%, B1/32k +1.04%, other cells within ±0.7%. - #178: 1D_GRID_ATTN_QKV=11x6. #170–#173 (AGMM 11x9 re-test, LOO attributions) are still open with the same shape of question. STATUS c160c: in-boot deltas are ~1% tighter than cross-boot, but a 1–3% single-op gain is still ≤0.5% of a B8 cell. The served-model A/B is the right **ship** gate and the wrong **search** instrument. 5. **Under-filled grids are already listed.** `docs/OP-DATASHEETS.md` §10: - P1 AGMM: 90/110 busy. - P2 GDN fused: 96 (fixed by gpool). - P4 SDPA prefill: 96. - P6 distributed norm: **64**. - D4 decode SDPA: 96. - P5a w2: 100, ~91 effective. w2t (R-2026-10-07-w2t, PP +1.17%) was this kind of fix, found by hand. §9's ranked list is mostly geometry experiments that nobody has run as a matrix. ## Proposed design (for grilling) Scope is the hot kernels, at served shapes, TP=2 per-chip shapes on **one card**: | op | knobs to matrix (examples, to be confirmed per datasheet) | shape(s) | |---|---|---| | GDN fused chunk (P2) | `num_receivers`, `num_producers`/pool, `pool_extra_share`, `handoff_depth`, row_local | BH=24, NC per 2048 chunk | | AGMM prefill (P1) | grid (11x8/11x9/11x10, transposed), in0 block/subblock, K_block cap, chunks per role | qkvzab, attn qkv, gate\|up, gdn out, attn out @ 2048 | | decode DRAM MR matmuls (D1/D1′): w2, out, qkv(zab), lm_head | readers per bank / `cores_per_bank` (#58922), in0 block, per-role CPB, fidelity | B=8 T=3 (M=24), B=1 | | SDPA decode (D4) | cores_per_head, k_chunk, KV dual-NoC mode | B=8/B=1 at 4k and 32k | The loop, per op: 1. **Matrix.** Enumerate the legal geometries from the op's own factory constraints. Seed the matrix with the op's current pick and its neighbours, the same way #58891 builds its matrix from the tree's picks. Record the pick line from the served boot with `tools/ttx/op-configs.py`. 2. **Capture.** On one card, through `ttx wb` (workbench) and the existing slot protocol. The harness never boots by hand. Tracy device zones go through `tools/ttx/op-anatomy.py` into per-core, per-RISC timelines: occupancy (busy/110), critical path, fill/step/tail. Every row is checked bit-exact against the current pick (the op gate, like #197's 1-card gate), and a must-fail row is required. 3. **Model.** A small per-op-class cost model (matmul: DRAM/NoC/FPU floors; chain op: `fill + NC × max(step, supply)`, per PROCESS-REVIEW §6 root cause 2), fitted on the matrix. It reports error per row and lists near-ties. 4. **Pick, then confirm.** Re-measure the model's top-k against the current pick on the card (the #58891 "picks tool"). The output is a record `bench/runs/geomsweep-<op>-<utc>.jsonl` plus an arm emitted by `tools/ttx/arm-derive.py` with the knob as env. 5. **Ship gate unchanged.** The pick goes to CI as one arm, or as a combination screen with other picks (MAX_SCREEN=8, `ci-pick-winner.py`). Only the served A/B and the gates decide shipping. 6. **ttx wiring.** Either `ttx geom {matrix,capture,fit,pick} <op>` or a `tools/ttx/geom-sweep.py` driven by `ttx queue`. Records carry the pin, the overlay hash and the shape, so a pin move invalidates the model (OP-DATASHEETS §11). ## Open questions 1. Which ops expose their geometry as a runtime knob today, and which need a patch first? GDN: 0025b re-exports the config. AGMM: env grid flags. MR: CPB env. SDPA decode: cores/head env. Any op without a knob needs a JIT/C++ overlay before it can be swept at all. 2. Should we port #58891's `calibration/` tooling as-is (GDN only) and generalise from it, or write one generic harness? Upstream's version is GDN-specific and depends on its kernel zones. 3. Workbench fidelity: does a 1-card wb op time at the TP=2 per-chip shape predict the served delta? We need one calibration point: gpool's wb delta against its #7303 served PP delta. 4. Tracy-ON build cost. Device-profiler CSVs need a Tracy build (op-anatomy docstring). Is that a separate cached image or overlay, and how much host RAM does it use? cfx-llm2 has 15.9 GB, and the boot guard is 4 GB MemAvailable. 5. Card budget and scheduling. Does the sweep run as a low-priority `ttx queue` standby on one card (`bench/queues/standby.txt`) without blocking the CI mesh job, or does it need the mesh slot? It should never take the mesh for 1-card work. 6. Model class per op: one fitted model per op class (matmul, chain/pipeline, SDPA), or a pure empirical argmin over the matrix with no model? Without a model, near-ties and transfer to new shapes are lost. 7. Search budget: how many rows per op before the model must explain them? Upstream used 93 rows for one op. 8. Does this replace or feed #110 (adopt every lever conditionally) and the OP-DATASHEETS §9 ranking? Proposed answer: it feeds §9 and emits arms, and it does not ship anything by itself. ## Desk vs card cost (estimates, not measurements) - **Desk (no card):** - Matrix enumerators from factory constraints for the 4 op families. - A model port and fit (#58891's model as the template for GDN). - Wiring for `op-configs.py`, `op-anatomy.py` and `arm-derive.py`, plus unit tests on recorded CSVs. - ttsim correctness only, for any new knob plumbing. - Order of a few agent-days. No card time. - **Card (one card via the slot protocol, never the mesh):** - Per op: matrix rows × (compile + a few launches). - Exact minutes per row are unknown until the first GDN capture. That capture is the first measurement this issue asks for, and it also gives the wb→served calibration point (Q3). - Mesh and CI time only for the final picks: one CI combination screen per batch of picks (~30 min per arm boot, per the CI comments on run 418). - **What the harness replaces:** one-lever CI A/Bs that land inert (#174–#178: five card slots, zero ships). ## Out of scope New math or new kernels. Wholesale upstream syncs (that is the upstream scout's lane: #64, #154, #207). Any served-arm change without the normal CI A/B and gates. ## Refs upstream tt-metal #58891 (and #58925–#58929, #58959, #58972, #58974) · #197 / #202 (run #7303) · #207 · #170–#178 · #110 · #151 · #109 · #154 · #90 · `docs/PROCESS-REVIEW-2026-10-02.md` §6 · `docs/OP-DATASHEETS.md` §9–§11 · `tools/ttx/op-configs.py`, `tools/ttx/op-anatomy.py`, `tools/ttx/arm-derive.py` Duplicate check (2026-10-08): no existing issue covers a per-op geometry sweep or a cost-model pick loop. - #90 is the perf-loop c1 PR. - #154 is an upstream-kernel WATCH. - #135 is a prefill chunk *policy*. - #151 covers AGMM instrumentation only. - #109 is the upstream GEMM recipe. This issue links them rather than duplicating them.
Author
Member

Cross-links added after filing:

  • #208 (metal bump: the pin is a ~Sep 3 fork; lists merged upstream wins we lack). A pin move invalidates every fitted geometry model and every pinned-geometry row here (OP-DATASHEETS §11). So the harness records must carry the pin, and the first GDN matrix should run on whichever pin #208 lands on.
  • #207 (port of the GDN prep stack #58928 + #58925/#58929 onto gpool for BH=24). This is the next upstream geometry/schedule result arriving by port, the pattern this issue argues we should also find ourselves.
  • Joint CONTROL candidate …-dx-w2t-b8k3-cph48 won its CI A/B in #206 (run #7499). Any harness pick is screened against that control once the owner moves it.
Cross-links added after filing: - **#208** (metal bump: the pin is a ~Sep 3 fork; lists merged upstream wins we lack). A pin move invalidates every fitted geometry model and every pinned-geometry row here (OP-DATASHEETS §11). So the harness records must carry the pin, and the first GDN matrix should run on whichever pin #208 lands on. - **#207** (port of the GDN prep stack #58928 + #58925/#58929 onto gpool for BH=24). This is the next upstream geometry/schedule result arriving by port, the pattern this issue argues we should also find ourselves. - Joint CONTROL candidate `…-dx-w2t-b8k3-cph48` won its CI A/B in #206 (run #7499). Any harness pick is screened against that control once the owner moves it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitpartner/tt-stack#209
No description provided.