grill: tt-metal #59965 fp32 chunk_gated_delta_rule scan state (19-bit truncation bias) — our fused scan, long-ctx state/acceptance #214

Open
opened 2026-10-09 08:47:35 +02:00 by tenstorrent · 0 comments
Member

Pickup (same day from the upstream watch, 2026-10-09)

Grill first. Desk only: no card runs and no code until this grill is answered.
Tree read: master f30ab09 (CONTROL …-kvfold-dx-w2t-b8k3-cph48). Branch grill/metal-59965-gdn-scan-fp32 is cut from master, with no commits.

Upstream: https://github.com/tenstorrent/tt-metal/pull/59965, [Bug fix] chunk_gated_delta_rule: carry the scan state update in fp32 (no 19-bit FPU truncation of S and dl), by nkapreTT.

  • State on 2026-10-09: draft. Filed 05:08 UTC (07:08 Prague). Head 7bc2d832, base main f7618bbc.
  • Size: 1 commit, 7 files, +169/−30.

What it claims (theirs, not ours)

  • The prefill chunk scan carries S ← dl·S + k_dec_t @ v_new once per 32-token chunk.
    • Upstream formed it on the FPU as (dl·I) @ S.
    • The unpacker truncates fp32 S and dl into the 19-bit srcA/srcB registers every chunk.
    • Truncation is a bias toward zero, not noise, so it compounds with the chunk count.
  • Measured by them on Blackhole:
    • slow-decay heads' final state shrinks ~10% in norm at 8K (chunk 32 → 256 chunks);
    • state PCC 0.992 on real Qwen3.x GDN inputs;
    • invisible at 2K, so the existing T=2048 test passes;
    • it failed a 32-lane qualification on Qwen3.6-27B (one lane at 0.9878).
  • The fix:
    • S is unpacked into fp32 DEST from an exact copy (UnpackToDestFp32), scaled by dl on the SFPU (mul_unary_tile), and added on the SFPU (add_binary_tile).
    • dl is written bit-exact as an fp32 fill tile and read back as a scalar.
    • k_dec_t @ v_new stays on the FPU. Its operands are per-chunk, so they do not compound.
    • It is unconditional on every scan_step path (phased, fused). The mono path is unchanged.
  • Cost (theirs, qualitative):
    • three extra state-sized fp32 CBs per scan core (3·Kt·Vtl tiles);
    • the state update goes per tile with a few SFPU ops instead of the batched GDN_DST_TILES matmul.
    • Perf numbers are pending. Validated as a backport on c05df925 (+ #59201), on BH p150. Not yet built or run on current main.
  • New test: test_state_carry_8k_vs_fp64_reference (T=8192, BH=12, per-head log-spaced decay; PCC ≥ 0.9999 and norm ratio within 2e-3 per head).

Prefill-only or decode-relevant?

  • The kernel change is prefill-only (chunk_gated_delta_rule scan). Decode decode_gated_delta_rule / fused_recurrent and our MTP verify/commit kernels are untouched.
  • The effect is decode-relevant through state hand-off:
    1. Decode and the MTP verify start from the prefill's final recurrent state. A long-memory head that shrank in prefill is wrong for the rest of the request. Verify defines truth, so this moves the target trajectory: quality first, then acceptance (#212 §2.5).
    2. The MTP warm KV is built from prefill-path hiddens (#212 §2.2). With full warm (#212 L1), about 99% of the drafter's context at 128k would come from prefill numerics, including this scan.
  • The bias scales with total chunks, not with a single call. Our fused op runs C=32 (gdn/fused_chunk.py). gdn/tp.py passes self.rec_state as initial_state across prefill calls, so the carry passes through the truncating update every chunk:
    • 4,096 chunks at 128k and 2,048 at 64k, against their 256 at 8K;
    • this regime is unmeasured anywhere.

Our served path (checked in the tree, not on card)

  • Served prefill GDN is our fused prep→scan prim: patches/tt-metal/0025 (#53790/#57440 era, kernels_fused/compute/chunk_gdn_math.hpp scan_step) at HiFi2 (QWEN36_GDN_SCAN_FID=hifi2, sh2; HiFi2 admitted by 0031).
  • Our state update is not upstream's (dl·I)@S matmul. It is two FPU passes:
    • bcast_scalar_mul(cur_S, dl): mul_tiles_bcast_scalar, S on srcA, dl on srcB;
    • then ew(stmp, supd): add_tiles, the scaled S on srcA again.
  • So S passes the 19-bit unpack twice per chunk, and the multiply runs at HiFi2.
  • Hypothesis (unmeasured): our bias is at least upstream's, possibly larger. Whether HiFi2's reduced multiply phases add to it is a desk/LLK question, not a claim.
  • The recurrent state between prefill calls and in decode is bf16 (QWEN35_GDN_STATE_BF16=1, required by the decode fused op's single-dtype check).
    • That is a separate per-call rounding of the carried state (one round per prefill call: 64 calls at 128k with the shipped 2048 chunk; the exact cast point is to be confirmed on desk). Its rounding mode (nearest vs truncation) is unverified, and it sits in the same place.
    • #59965 does not touch it.
  • Not portable as a patch:
    • upstream's kernel files were restructured (Device 2.0 port #59431, fused path #57440, SFPU WY #57445);
    • our 0025/0037/0038/0041/0048 stack is pre-Device-2.0.
    • The change would be re-expressed on our scan_step: an exact-state CB copy plus SFPU mul/add.
    • It touches the same receivers as gpool #197/#202 (patch 0048, all 110 cores: 86 producers + 24 receivers at BH=24) and the #207 prep-stack port (#58928/#58925/#58929 on #58891).

Cost on our cards (to estimate on desk; no numbers yet)

  • L1: 3 extra fp32 state CBs per scan receiver, each Kt·Vtl tiles of 4 KiB (Kt=Vt=4 at K=V=128, Vtl per our NV split). Check against the receiver CB budget after gpool (0048) and the #207 prep-read flight. The fused path is CB-tight (chunk 128 already exceeds L1 → C=32).
  • Compute: per-tile SFPU mul + add replaces the batched FPU eltwise. Our P2 GDN fused scan is 9.5% (34.0 ms) of the measured prefill (OP-DATASHEETS c158). Any slowdown of st_decay + st_snew lands on PP/TTFT.
  • Decode TG cost: none directly (prefill-only). The TG effect is through acceptance and trajectory.

Grill questions

  1. Quantify ours first. Do we run a desk/ttsim probe of our scan_step (bcast-mul + add at HiFi2) vs an fp64 recurrence at T ∈ {2k, 8k, 32k, 128k} with log-spaced decays, mirroring their test?
    • Does ttsim model the unpacker's fp32→19-bit truncation? If not, the probe must be a card op-test, which needs the owner's OK.
  2. Is this a quality gate (32k/128k retrieval, long-ctx gsm8k) or an acceptance lever for #212? Proposed: treat it as #212 L9-adjacent (GDN precision) and add it to LC0's precision story, but only after LC0 gives a baseline curve.
  3. Port as unconditional (like upstream) or as a flag (QWEN36_GDN_SCAN_EXACT_STATE) with must-fail, so the PP cost is screenable? Proposed: flag + must-fail, because our scan is on the PP critical path.
  4. Sequence vs #207 / gpool: land the exact-state CBs before or after the prep stack, given they share receiver L1? And vs #208: wait for the bump, where upstream's version applies directly?
  5. Does bf16 inter-call state (QWEN35_GDN_STATE_BF16=1) need its own probe in the same harness, so we do not fix one compounding source and miss the other?

Measure first (when approved; not now)

  • Desk: L1 budget per receiver with +3 CBs; op-count delta of st_decay + st_snew.
  • Probe: final-state norm ratio and PCC per head vs fp64 at 2k/8k/32k/128k on our kernel (sim if truncation is modelled, else 1-card op-test).
  • Then (if the bias reproduces): arm …-gdnx vs CONTROL. Gates:
    • PP at 4k/32k;
    • LC0 acceptance cells at 64k/128k (#212);
    • retrieval at 32k/128k;
    • must-fail (exact copy dropped → fails the state test).

Out of scope

  • No code, no card boots, no pushes to the branch until the grill is answered.
  • Upstream numbers are theirs. Do not bank them as ours.
## Pickup (same day from the upstream watch, 2026-10-09) Grill first. **Desk only: no card runs and no code** until this grill is answered. Tree read: master `f30ab09` (CONTROL `…-kvfold-dx-w2t-b8k3-cph48`). Branch `grill/metal-59965-gdn-scan-fp32` is cut from master, with no commits. Upstream: https://github.com/tenstorrent/tt-metal/pull/59965, **[Bug fix] chunk_gated_delta_rule: carry the scan state update in fp32 (no 19-bit FPU truncation of S and dl)**, by nkapreTT. - State on 2026-10-09: **draft**. Filed 05:08 UTC (07:08 Prague). Head `7bc2d832`, base main `f7618bbc`. - Size: 1 commit, 7 files, +169/−30. ### What it claims (theirs, not ours) - The **prefill** chunk scan carries `S ← dl·S + k_dec_t @ v_new` once per 32-token chunk. - Upstream formed it on the FPU as `(dl·I) @ S`. - The unpacker **truncates** fp32 S and dl into the 19-bit srcA/srcB registers every chunk. - Truncation is a bias toward zero, not noise, so it compounds with the chunk count. - Measured by them on Blackhole: - **slow-decay heads' final state shrinks ~10% in norm at 8K** (chunk 32 → 256 chunks); - state PCC 0.992 on real Qwen3.x GDN inputs; - invisible at 2K, so the existing T=2048 test passes; - it failed a 32-lane qualification on Qwen3.6-27B (one lane at 0.9878). - The fix: - S is unpacked into fp32 DEST from an exact copy (`UnpackToDestFp32`), scaled by dl on the SFPU (`mul_unary_tile`), and added on the SFPU (`add_binary_tile`). - dl is written bit-exact as an fp32 fill tile and read back as a scalar. - `k_dec_t @ v_new` stays on the FPU. Its operands are per-chunk, so they do not compound. - It is unconditional on every `scan_step` path (phased, fused). The mono path is unchanged. - **Cost (theirs, qualitative):** - three extra state-sized fp32 CBs per scan core (`3·Kt·Vtl` tiles); - the state update goes per tile with a few SFPU ops instead of the batched `GDN_DST_TILES` matmul. - **Perf numbers are pending.** Validated as a backport on `c05df925` (+ #59201), on BH p150. **Not yet built or run on current main.** - New test: `test_state_carry_8k_vs_fp64_reference` (T=8192, BH=12, per-head log-spaced decay; PCC ≥ 0.9999 and norm ratio within 2e-3 per head). ### Prefill-only or decode-relevant? - **The kernel change is prefill-only** (`chunk_gated_delta_rule` scan). Decode `decode_gated_delta_rule` / `fused_recurrent` and our MTP verify/commit kernels are untouched. - **The effect is decode-relevant through state hand-off:** 1. Decode and the MTP verify start from the prefill's **final recurrent state**. A long-memory head that shrank in prefill is wrong for the rest of the request. Verify defines truth, so this moves the target trajectory: quality first, then acceptance (#212 §2.5). 2. The **MTP warm KV is built from prefill-path hiddens** (#212 §2.2). With full warm (#212 L1), about 99% of the drafter's context at 128k would come from prefill numerics, including this scan. - The bias scales with **total chunks**, not with a single call. Our fused op runs C=32 (`gdn/fused_chunk.py`). `gdn/tp.py` passes `self.rec_state` as `initial_state` across prefill calls, so the carry passes through the truncating update every chunk: - **4,096 chunks at 128k and 2,048 at 64k**, against their 256 at 8K; - this regime is unmeasured anywhere. ### Our served path (checked in the tree, not on card) - Served prefill GDN is **our** fused prep→scan prim: `patches/tt-metal/0025` (#53790/#57440 era, `kernels_fused/compute/chunk_gdn_math.hpp` `scan_step`) at **HiFi2** (`QWEN36_GDN_SCAN_FID=hifi2`, sh2; HiFi2 admitted by 0031). - Our state update is **not** upstream's `(dl·I)@S` matmul. It is two FPU passes: - `bcast_scalar_mul(cur_S, dl)`: `mul_tiles_bcast_scalar`, S on srcA, dl on srcB; - then `ew(stmp, supd)`: `add_tiles`, the scaled S on srcA again. - So S passes the 19-bit unpack **twice** per chunk, and the multiply runs at HiFi2. - **Hypothesis (unmeasured):** our bias is at least upstream's, possibly larger. Whether HiFi2's reduced multiply phases add to it is a desk/LLK question, not a claim. - The **recurrent state between prefill calls and in decode is bf16** (`QWEN35_GDN_STATE_BF16=1`, required by the decode fused op's single-dtype check). - That is a separate per-call rounding of the carried state (one round per prefill call: 64 calls at 128k with the shipped 2048 chunk; the exact cast point is to be confirmed on desk). Its rounding mode (nearest vs truncation) is unverified, and it sits in the same place. - #59965 does not touch it. - **Not portable as a patch:** - upstream's kernel files were restructured (Device 2.0 port #59431, fused path #57440, SFPU WY #57445); - our 0025/0037/0038/0041/0048 stack is pre-Device-2.0. - The change would be re-expressed on our `scan_step`: an exact-state CB copy plus SFPU mul/add. - It touches the same receivers as **gpool #197/#202** (patch 0048, all 110 cores: 86 producers + 24 receivers at BH=24) and the **#207** prep-stack port (#58928/#58925/#58929 on #58891). ### Cost on our cards (to estimate on desk; no numbers yet) - L1: 3 extra fp32 state CBs per scan receiver, each `Kt·Vtl` tiles of 4 KiB (Kt=Vt=4 at K=V=128, Vtl per our NV split). Check against the receiver CB budget after gpool (0048) and the #207 prep-read flight. The fused path is CB-tight (chunk 128 already exceeds L1 → C=32). - Compute: per-tile SFPU mul + add replaces the batched FPU eltwise. Our P2 GDN fused scan is 9.5% (34.0 ms) of the measured prefill (OP-DATASHEETS c158). Any slowdown of `st_decay` + `st_snew` lands on PP/TTFT. - Decode TG cost: none directly (prefill-only). The TG effect is through acceptance and trajectory. ### Grill questions 1. **Quantify ours first.** Do we run a desk/ttsim probe of our `scan_step` (bcast-mul + add at HiFi2) vs an fp64 recurrence at T ∈ {2k, 8k, 32k, 128k} with log-spaced decays, mirroring their test? - Does ttsim model the unpacker's fp32→19-bit truncation? If not, the probe must be a card op-test, which needs the owner's OK. 2. Is this a **quality gate** (32k/128k retrieval, long-ctx gsm8k) or an **acceptance lever** for #212? Proposed: treat it as #212 **L9-adjacent** (GDN precision) and add it to LC0's precision story, but only after LC0 gives a baseline curve. 3. Port as **unconditional** (like upstream) or as a flag (`QWEN36_GDN_SCAN_EXACT_STATE`) with must-fail, so the PP cost is screenable? Proposed: flag + must-fail, because our scan is on the PP critical path. 4. Sequence vs **#207 / gpool**: land the exact-state CBs before or after the prep stack, given they share receiver L1? And vs **#208**: wait for the bump, where upstream's version applies directly? 5. Does bf16 inter-call state (`QWEN35_GDN_STATE_BF16=1`) need its own probe in the same harness, so we do not fix one compounding source and miss the other? ### Measure first (when approved; not now) - Desk: L1 budget per receiver with +3 CBs; op-count delta of `st_decay` + `st_snew`. - Probe: final-state norm ratio and PCC per head vs fp64 at 2k/8k/32k/128k on our kernel (sim if truncation is modelled, else 1-card op-test). - Then (if the bias reproduces): arm `…-gdnx` vs CONTROL. Gates: - PP at 4k/32k; - LC0 acceptance cells at 64k/128k (#212); - retrieval at 32k/128k; - must-fail (exact copy dropped → fails the state test). ### Out of scope - No code, no card boots, no pushes to the branch until the grill is answered. - Upstream numbers are **theirs**. Do not bank them as ours. ### Links - Upstream: https://github.com/tenstorrent/tt-metal/pull/59965 (draft); context https://github.com/tenstorrent/tt-metal/pull/57440, https://github.com/tenstorrent/tt-metal/pull/57445, https://github.com/tenstorrent/tt-metal/pull/59431 - Ours: #212 (long-ctx acceptance, LC0, L1/L9), #207 (GDN prep stack port), #197 / #202 (gpool), #154 (upstream BH kernels, #58635 GDN prep / #57445 WY), #208 (metal bump), #90
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#214
No description provided.