decode: break the bf4 576 B/request weight-read wall — DRAM-core tensor prefetcher (or burst reader) on 1x2 #103

Open
opened 2026-09-27 16:55:44 +02:00 by Grok · 5 comments
Owner

Desk research 2026-09-27 (no hardware, no new speed number). Note: docs/notes/dram-prefetcher-tp2-2026-09-27.md (branch serving-throughput). Related: #58 (worker-core prefetcher hypothesis), MR arm QWEN36_DECODE_DRAM_SHARDED_MR (LEDGER R-2026-09-27-stack-EFMG).

Problem

Decode is weight-stream bound: matmul 26.4 ms/step flat in B and ctx (c67 perf-loop-c67-device-time-decomp-20260927T1320Z.jsonl). The 1D-mcast bf4 matmul sustains only 277–286 GB/s from 22 to 110 cores (n2 record): the limit is the 576 B one-tile DRAM request, not core count. Floor at 454 GB/s ≈ 15–17 ms.

Options (pick one — same wall)

  • (A) DRAM-core Tensor prefetcher (runs on DRISC, no Tensix/sub-device split): in our pin 60053f1 (#50681, #52384), feeds our existing mcast_in0 1D matmul via a 2-page global-CB window, trace-replayable, needs fw ≥19.12 (we run 19.14). Only the in1 reader changes → bit-exact plausible, unproven. Upstream single-device only.
  • (B) bank-aligned burst reader (SPLIT_DRAM_BANK path in the 1D mcast reader, LOWLEVEL L6).
  • Worker-core dram_prefetcher (#58) needs gather_in0 ring matmul → reorders K accumulation, not bit-exact; senders collide with 11-wide grids and fused GDN decode. Deprioritise.

Fit (A), per card TP=2, 2-page CB

w1/w3 34 recv (grid change from 39: 272/7 not whole) 74 KB bf4; w2 32 recv 46 KB; GDN qkvzab 43 recv 55 KB (receiver-contiguous layout only); GDN out / attn wo 32 recv 46 KB; attn qkv 56 recv 37 KB. Worst core ~210 KB across 4 CBs — fits (estimate). Skip lm_head (already ~381 GB/s).

Estimate

TG −3…−9 ms at B=1 (38.68 ms) and B=8 4k (42.98 ms); 0…−3 ms on top of MR. Estimate.

Blockers

  • High: DRAM-core prefetcher untested on a 1×2 mesh with fabric CCL.
  • High: needs DRAM-sharded weights; prefill mis-reads that layout for w2/out → decode-only copies ≈ +2.2 GiB/chip (competes with K8V4/prefix-snapshot budget).
  • Med: CBs resident in L1 through prefill (upstream #57171 clash); every trace variant (batch buckets, MTP) must drain exactly its pages or hang.
  • Low: DRAM contention (backport #57224 at next bump); check DRISC kernel file packaged in image.

Plan

  1. Op probe (w1, w2 shapes, bf4, M=1/8/32): 1D path vs prefetcher, torch.equal, then 1×2 smoke with trace replay. ~1 day desk + ~1 h cards. Stop if <330 GB/s on w1, hangs on 1×2, or neither exact nor faster than MR (387 GB/s).
  2. QWEN36_TENSOR_PREFETCH=mlp arm with banner → workbench → equiv gate → sweep32k (3–5 days).
  3. All projections, #57224 backport, trace-balance + prefill L1 audit (1–2 weeks).

Owner approvals: numerics if not bit-exact; +2.2 GiB/chip; card time.

Desk research 2026-09-27 (no hardware, no new speed number). Note: `docs/notes/dram-prefetcher-tp2-2026-09-27.md` (branch `serving-throughput`). Related: #58 (worker-core prefetcher hypothesis), MR arm `QWEN36_DECODE_DRAM_SHARDED_MR` (LEDGER R-2026-09-27-stack-EFMG). ## Problem Decode is weight-stream bound: matmul 26.4 ms/step flat in B and ctx (c67 `perf-loop-c67-device-time-decomp-20260927T1320Z.jsonl`). The 1D-mcast bf4 matmul sustains only 277–286 GB/s from 22 to 110 cores (n2 record): the limit is the 576 B one-tile DRAM request, not core count. Floor at 454 GB/s ≈ 15–17 ms. ## Options (pick one — same wall) - **(A) DRAM-core Tensor prefetcher** (runs on DRISC, no Tensix/sub-device split): in our pin 60053f1 (#50681, #52384), feeds our existing `mcast_in0` 1D matmul via a 2-page global-CB window, trace-replayable, needs fw ≥19.12 (we run 19.14). Only the in1 reader changes → bit-exact **plausible, unproven**. Upstream single-device only. - **(B) bank-aligned burst reader** (`SPLIT_DRAM_BANK` path in the 1D mcast reader, LOWLEVEL L6). - Worker-core `dram_prefetcher` (#58) needs gather_in0 ring matmul → reorders K accumulation, **not bit-exact**; senders collide with 11-wide grids and fused GDN decode. Deprioritise. ## Fit (A), per card TP=2, 2-page CB w1/w3 34 recv (grid change from 39: 272/7 not whole) 74 KB bf4; w2 32 recv 46 KB; GDN qkvzab 43 recv 55 KB (receiver-contiguous layout only); GDN out / attn wo 32 recv 46 KB; attn qkv 56 recv 37 KB. Worst core ~210 KB across 4 CBs — fits (estimate). Skip lm_head (already ~381 GB/s). ## Estimate TG −3…−9 ms at B=1 (38.68 ms) and B=8 4k (42.98 ms); 0…−3 ms on top of MR. **Estimate.** ## Blockers - High: DRAM-core prefetcher untested on a 1×2 mesh with fabric CCL. - High: needs DRAM-sharded weights; prefill mis-reads that layout for w2/out → decode-only copies ≈ **+2.2 GiB/chip** (competes with K8V4/prefix-snapshot budget). - Med: CBs resident in L1 through prefill (upstream #57171 clash); every trace variant (batch buckets, MTP) must drain exactly its pages or hang. - Low: DRAM contention (backport #57224 at next bump); check DRISC kernel file packaged in image. ## Plan 0. Op probe (w1, w2 shapes, bf4, M=1/8/32): 1D path vs prefetcher, `torch.equal`, then 1×2 smoke with trace replay. ~1 day desk + ~1 h cards. **Stop** if <330 GB/s on w1, hangs on 1×2, or neither exact nor faster than MR (387 GB/s). 1. `QWEN36_TENSOR_PREFETCH=mlp` arm with banner → workbench → equiv gate → sweep32k (3–5 days). 2. All projections, #57224 backport, trace-balance + prefill L1 audit (1–2 weeks). Owner approvals: numerics if not bit-exact; +2.2 GiB/chip; card time.
Author
Owner

Runbook: https://git.bitp.cz/donach/tt-stack/src/branch/serving-throughput/docs/runbooks/103-dram-prefetcher.md. Drill: the DRAM-core prefetcher and create_global_circular_buffer_for_matmul_1d are in the pin (tt_metal/impl/buffers/kernels/tensor_prefetcher.cpp, ttnn/core/global_circular_buffer.cpp:560), so this is a port, not a bump. Order: n8 (why MR is inexact, pi-F running) -> n9 (2D factory IN1_DRAM_WIDTH_SHARDED single-row = bank-aligned reader, pi-G running) -> n10 (this port; stage 0a = the upstream BH test on our image, 0b = our shapes with torch.equal; probe being written by pi on branch tensor-prefetch-n10). No hardware run yet.

Runbook: https://git.bitp.cz/donach/tt-stack/src/branch/serving-throughput/docs/runbooks/103-dram-prefetcher.md. Drill: the DRAM-core prefetcher and create_global_circular_buffer_for_matmul_1d are in the pin (tt_metal/impl/buffers/kernels/tensor_prefetcher.cpp, ttnn/core/global_circular_buffer.cpp:560), so this is a port, not a bump. Order: n8 (why MR is inexact, pi-F running) -> n9 (2D factory IN1_DRAM_WIDTH_SHARDED single-row = bank-aligned reader, pi-G running) -> n10 (this port; stage 0a = the upstream BH test on our image, 0b = our shapes with torch.equal; probe being written by pi on branch tensor-prefetch-n10). No hardware run yet.
Author
Owner

New third-party evidence from the 2026-09-27 decode paper scan (docs/notes/decode-papers-scan-2026-09-27.md): tenstorrent/tt-metal#55898 reports that reading the same DRAM bank on both NoCs lifts 576 B bfp4 tile reads from 62% to 95% of peak. That is the wall this issue targets, so a dual-NoC reader is a third option next to (A) and (B), and possibly the cheapest. Third-party, not measured here.

New third-party evidence from the 2026-09-27 decode paper scan (docs/notes/decode-papers-scan-2026-09-27.md): tenstorrent/tt-metal#55898 reports that reading the same DRAM bank on both NoCs lifts 576 B bfp4 tile reads from 62% to 95% of peak. That is the wall this issue targets, so a dual-NoC reader is a third option next to (A) and (B), and possibly the cheapest. Third-party, not measured here.
Author
Owner

dram_req_rate on hardware (#55898 direction): 1 card, image k2-mr-pk3m. Verdict record: bench/runs/perf-loop-c78-dram-req-rate-verdict-20260927T2150Z.jsonl.

stream GB/s
one RISC on NOC0, interleaved 243–326
one RISC on NOC1 212–237
RISCV_0/NOC0 + RISCV_1/NOC1, half each 387–454 (peak at 64 cores; falls at 110 cores)
our in-model multi-reader matmuls, bf4 (c41p) 340–399
  • Multi-page coalescing gives only +3 to +25%. The layout check passes (pages k and k+8 are contiguous), and its must-fail rung mismatches as it should.
  • Side finding: on the default matmul path, bf4 is not bandwidth-bound. 8704×5120 takes 176 µs at bf4 and at bf8. So bf4 weights only pay on the multi-reader path, which is why c79's bf4 lm_head runs on the multi-reader head.
  • Open question: is the gain from the second NoC or from the second issuing RISC, and does it survive the per-bank multi-reader pattern? run-bd.sh (a 2s arm plus bank-local part D) is queued to answer it before any kernel work.
  • A dual-NoC multi-reader reader could save about −12% on the decode weight stream. That is an estimate and ranks nothing yet.
dram_req_rate on hardware (#55898 direction): 1 card, image k2-mr-pk3m. Verdict record: bench/runs/perf-loop-c78-dram-req-rate-verdict-20260927T2150Z.jsonl. | stream | GB/s | |---|---| | one RISC on NOC0, interleaved | 243–326 | | one RISC on NOC1 | 212–237 | | RISCV_0/NOC0 + RISCV_1/NOC1, half each | **387–454** (peak at 64 cores; falls at 110 cores) | | our in-model multi-reader matmuls, bf4 (c41p) | 340–399 | - Multi-page coalescing gives only +3 to +25%. The layout check passes (pages k and k+8 are contiguous), and its must-fail rung mismatches as it should. - **Side finding:** on the default matmul path, bf4 is not bandwidth-bound. 8704×5120 takes 176 µs at bf4 and at bf8. So bf4 weights only pay on the multi-reader path, which is why c79's bf4 lm_head runs on the multi-reader head. - **Open question:** is the gain from the second NoC or from the second issuing RISC, and does it survive the per-bank multi-reader pattern? `run-bd.sh` (a 2s arm plus bank-local part D) is queued to answer it before any kernel work. - A dual-NoC multi-reader reader could save about −12% on the decode weight stream. That is an estimate and ranks nothing yet.
Member

Do not start prefetcher option A or B, and do not repeat dual-NoC. #153 is the served no-go for the dual-NoC weight stream. Option A stays blocked on an untested 1×2 mesh with fabric CCL. No kernel until a one-card no-model liveness gate exists and passes.

Do not start prefetcher option A or B, and do not repeat dual-NoC. #153 is the served no-go for the dual-NoC weight stream. Option A stays blocked on an untested 1×2 mesh with fabric CCL. No kernel until a one-card no-model liveness gate exists and passes.
Author
Owner

Knob check: Blackhole DRAM programmable cores are already auto-on. Do not card a flag flip.

Lottolabs' last step (dflash4 49.2 → dflash5 49.7 tok/s, greedy B=1, one card) is "the Blackhole DRAM prefetcher, which upstream tt-metal disables on Blackhole". On our pin 60053f1 that is not a missing env.

  • Flag: TT_METAL_ENABLE_BLACKHOLE_DRAM_PROGRAMMABLE_CORES (tt_metal/llrt/rtoptions.hpp, parsed in rtoptions.cpp). =1 force-enable, =0 force-disable, unset = auto-detect.
  • Auto-detect (tt_metal/impl/context/metal_env.cpp should_enable_blackhole_dram_programmable_cores, tt_metal/llrt/firmware_capability.cpp): DRAM programmable cores turn on when the firmware bundle is ≥ 19.12.0.0. Missing bundle version stays off. HAL comment in bh_hal.cpp: DRAM cores are opt-in and are registered only when that bool is true.
  • tt-stack does not set the env (no match under modules/, patches/prod-local-metal/, or the nix units). Documented firmware is 19.14, which is above the floor, so the HAL registers the cores without a force-enable. Prove it on a future boot by the log line TT_METAL_ENABLE_BLACKHOLE_DRAM_PROGRAMMABLE_CORES= (only printed when the override is set) versus Hal::has_programmable_core_type(DRAM) / the absence of a force-disable line. Do not SSH a card for this comment.
  • The model still does not launch a prefetcher (Qwen36Model.switch_mode is a no-op, "no prefetcher"). That port is this issue. A bare =1 does not start it and is not a card.
  • Must-fail if a later port moves logits. Worker-core ttnn.dram_prefetcher stays dead (#58, c116: w1 slower than MR and a later step hung). Do not reopen it.
  • Not this flag: BFP4 drafter, streaming fused FFN, more CB slots, temp>0 host sampling, L1-resident GDN.

No new issue. No card until this issue's existing desk recipe (DRISC prefetcher, bit-exact, 1×2 smoke) says the port is real.

## Knob check: Blackhole DRAM programmable cores are already auto-on. Do not card a flag flip. Lottolabs' last step (`dflash4` 49.2 → `dflash5` 49.7 tok/s, greedy B=1, one card) is "the Blackhole DRAM prefetcher, which upstream tt-metal disables on Blackhole". On our pin `60053f1` that is not a missing env. - Flag: `TT_METAL_ENABLE_BLACKHOLE_DRAM_PROGRAMMABLE_CORES` (`tt_metal/llrt/rtoptions.hpp`, parsed in `rtoptions.cpp`). `=1` force-enable, `=0` force-disable, **unset = auto-detect**. - Auto-detect (`tt_metal/impl/context/metal_env.cpp` `should_enable_blackhole_dram_programmable_cores`, `tt_metal/llrt/firmware_capability.cpp`): DRAM programmable cores turn **on** when the firmware bundle is **≥ 19.12.0.0**. Missing bundle version stays off. HAL comment in `bh_hal.cpp`: DRAM cores are opt-in and are registered only when that bool is true. - tt-stack does not set the env (no match under `modules/`, `patches/prod-local-metal/`, or the nix units). Documented firmware is 19.14, which is above the floor, so the HAL registers the cores without a force-enable. Prove it on a future boot by the log line `TT_METAL_ENABLE_BLACKHOLE_DRAM_PROGRAMMABLE_CORES=` (only printed when the override is set) versus `Hal::has_programmable_core_type(DRAM)` / the absence of a force-disable line. Do not SSH a card for this comment. - The model still does not launch a prefetcher (`Qwen36Model.switch_mode` is a no-op, "no prefetcher"). That port is this issue. A bare `=1` does not start it and is not a card. - Must-fail if a later port moves logits. Worker-core `ttnn.dram_prefetcher` stays dead (#58, c116: w1 slower than MR and a later step hung). Do not reopen it. - Not this flag: BFP4 drafter, streaming fused FFN, more CB slots, temp>0 host sampling, L1-resident GDN. No new issue. No card until this issue's existing desk recipe (DRISC prefetcher, bit-exact, 1×2 smoke) says the port is real.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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#103
No description provided.