WIP: pp-glue — fused distributed prefill RMSNorm (dnf) + residual-add fold (dna), tier-1 PP +1.6–2.2% at 32k #265

Closed
Grok wants to merge 12 commits from pp/glue into master
Owner

Two default-off levers for prefill glue (LEDGER R-2026-10-19-dnf). Both produce tier-1 output: in-boot self-tests are exact on both chips, and B=1 served text is identical to S2.

  • QWEN36_PREFILL_DNORM_FUSE (arm …-dfr-s2-dnf): reads h once into an L1 shard on both NoCs, then runs stats, the stats all-gather, and post from L1.
  • QWEN36_PREFILL_DNORM_ADD (arm …-dfr-s2-dnf-dna): folds x+attn_out into the ffn_norm PRE pass.

ttx ab, 2 reps, S2 → dnf → dnf-dna (PP tok/s | TG tok/s/user):

B/ctx PP TG
1/4k 6492 → 6607 → 6602 73.49 → 73.15 → 73.81
1/32k 6528 → 6642 → 6639 65.34 → 65.09 → 65.60
4/4k 6205 → 6241 → 6281 77.10 → 76.59 → 78.13
4/32k 6549 → 6683 → 6672 62.22 → 62.14 → 62.73
8/4k 5845 → 5912 → 5963 64.29 → 65.06 → 64.76
8/32k 6545 → 6648 (n=1) → 6687 52.08 → 51.95 → 52.40

Measured saving is about −5.4 ms per 2048-token chunk at 32k; the opmark estimate was −10/−11.3. The dna increment over dnf is not resolved at n=2. Record: bench/runs/prefill-dnorm-fuse-card-verdict-20261019.jsonl. ttsim gate: bench/runs/prefill-dnorm-fuse-sim-20261019T112155Z.jsonl. JIT: bench/runs/prefill-dnorm-fuse-jit-20261019.jsonl.

🤖 Generated with Claude Code

Two default-off levers for prefill glue (LEDGER R-2026-10-19-dnf). Both produce tier-1 output: in-boot self-tests are exact on both chips, and B=1 served text is identical to S2. - QWEN36_PREFILL_DNORM_FUSE (arm …-dfr-s2-dnf): reads h once into an L1 shard on both NoCs, then runs stats, the stats all-gather, and post from L1. - QWEN36_PREFILL_DNORM_ADD (arm …-dfr-s2-dnf-dna): folds x+attn_out into the ffn_norm PRE pass. ttx ab, 2 reps, S2 → dnf → dnf-dna (PP tok/s | TG tok/s/user): | B/ctx | PP | TG | |---|---|---| | 1/4k | 6492 → 6607 → 6602 | 73.49 → 73.15 → 73.81 | | 1/32k | 6528 → 6642 → 6639 | 65.34 → 65.09 → 65.60 | | 4/4k | 6205 → 6241 → 6281 | 77.10 → 76.59 → 78.13 | | 4/32k | 6549 → 6683 → 6672 | 62.22 → 62.14 → 62.73 | | 8/4k | 5845 → 5912 → 5963 | 64.29 → 65.06 → 64.76 | | 8/32k | 6545 → 6648 (n=1) → 6687 | 52.08 → 51.95 → 52.40 | Measured saving is about −5.4 ms per 2048-token chunk at 32k; the opmark estimate was −10/−11.3. The dna increment over dnf is not resolved at n=2. Record: bench/runs/prefill-dnorm-fuse-card-verdict-20261019.jsonl. ttsim gate: bench/runs/prefill-dnorm-fuse-sim-20261019T112155Z.jsonl. JIT: bench/runs/prefill-dnorm-fuse-jit-20261019.jsonl. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Grok added 11 commits 2026-10-19 19:35:56 +02:00
The 32k opmark (CONTROL dfr) charges the 128 decoder norms per chunk 18.4 ms: the image's
rms_norm_pre/post_all_gather each read h ([M,2560] bf16) from DRAM on 64 cores whose readers
barrier on every tile, so post runs at ~190 GB/s and h crosses DRAM twice. We believed the
stock 2D core grid would fix this (OP-DATASHEETS P6); in ttsim the 2D post corrupts M=2048
(#56908 row stride) and the 2D pre trips a packer-format UB, so that path is dead.

This lever replaces pre/post with two generic_ops on the same M/32 cores: PRE reads its tile
row on both NoCs (one barrier per 8-tile chunk) straight into an L1 height-sharded copy and
computes stats with the image's LLK sequence; the stats all-gather is unchanged; POST
normalises from the local shard (no DRAM read of h). Default off, flag-off byte-identical
(module-level env check), banners literal, self-test at boot on both chips with a gamma-shift
wrong-input branch; MUSTFAIL serves the shift and must be REFUSED.

Gates: ttsim 1-chip bitwise (stats, shard, output) at M 32..3072 x bf8/bf16 x L1/DRAM; ttsim
1x2 mesh with the real all-gather through the rmsnorm.py hook; JIT syntax check of all 10
RISC programs against vllm-tt:k2-mr-pk3r (scripts/jit-check-kernel.sh gains --src-dir,
--define, --descriptors and trisc0..2 for generic_op kernels). Arm: S2-dnf.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The first S2-dnf card boot passed the self-test on both chips (16 cells, bitwise vs the image
ops) but then died in warmup. A GDN op's static CBs clashed with an L1 buffer: "static circular
buffer region ends at 898048", buffer at 852928. The cause was ordering. y (the attention
norm's L1 output) was allocated while the 160 KB/core hs shard was alive, so it landed below
hs. Once hs was freed, y sat about 166 KB lower than the image path ever puts it.

y is now allocated before PRE. The 1x2 mesh probe gained an l1_placement check: from the same
allocator state, the fused y must not sit lower than the image path's y.
- On the old code the check fails: 1334528 vs 1500416.
- On the fixed code it passes: 1502464 vs 1500416.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Before this, every layer ran h = ttnn.add(x, attn_out) and then the ff norm read h back. At
32k the adds measure 55-60 us per call, which is 31.5 MB of traffic at DRAM roofline. With
dnf the PRE pass reads h once anyway. This change makes PRE read x and attn_out (both NoCs),
add them into the L1 shard, and write h to DRAM for the second residual add. That saves one
10.5 MB read of h and one op per layer. Estimate: about 20 us per layer, 1.3 ms per chunk
(not measured).

Bitwise first: in ttsim, add_tiles (fp32 or 16-bit DEST) matches ttnn.add exactly for
bf16+bf16 and bf16+bf8. The folded h and y match ttnn.add plus the image norm at M
32..2048, for b bf16/bf8, out bf8/bf16, L1/DRAM.

Lever contract:
- the flag needs QWEN36_PREFILL_DNORM_FUSE and is off by default; flag-off layer.py is the
  old code path;
- self-tested at boot for every M and both attn_out dtypes;
- the MUSTFAIL (gamma tile +1) is REFUSED in the 1x2 mesh probe;
- the layer hook is exercised verbatim in the mesh probe;
- 5 more RISC programs pass the card-image JIT check.

Arm: S2-dnf-dna.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
pp-glue: dnf/dna card verdict — tier-1 win, PP +1.6..2.2% at 32k (R-2026-10-19-dnf)
Some checks failed
tt-stack-ci / Build simulators and check the host module (pull_request) Failing after 2m0s
tt-stack-ci / Report upstream drift (pull_request) Successful in 1m22s
cards-fresh cards: PR does not merge cleanly onto base
tt-stack-ci / Plan card run (fingerprint, reuse, cards-fresh) (pull_request) Successful in 3m14s
tt-stack-ci / Serialized card gate (pull_request) Has been skipped
6e6237eda1
Before the screen, the fused norm was expected to save about 10 ms/chunk at 32k
(an opmark estimate: 144 -> 66 us/norm) and the add fold about 1.3 ms more. ttx ab,
2 reps, S2 vs dnf vs dnf-dna: PP rises in all 6 cells; at 32k it is +1.6..2.1% for
dnf and +1.9..2.2% for dnf-dna. TG/user stays within noise. B=1 served text is
identical to S2. The measured saving is ~5.4 ms/chunk, about half the estimate.
The dna increment is not resolved at n=2.

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

verdict: approve
tier: T1

rationale: Two default-off prefill levers (QWEN36_PREFILL_DNORM_FUSE / _DNORM_ADD) that are additive-only and byte-identical when unset. The fused path is proven bitwise-exact vs the image's pre/all-gather/post ops on every sim-gate cell (M 32–3072, bf16/bf8, L1/DRAM, both levers), with the gamma-tile+1 MUSTFAIL wrong-input branch differing (comparisons not blind) and flag-off parity holding. The card A/B (ttx ab, 2 reps, S2→dnf→dnf-dna) is a measured tier-1 WIN: PP +1.6–2.1% at 32k in all 6 cells, B=1 served text byte-identical to S2. The JIT gate caught a first-attempt DM-kernel compile failure on dnf (pre_dm/post_dm), fixed and re-gated OK before card time — the gate doing its job, not a defect.

concerns:

  • [warn] bench/arms/...-dfr-s2-dnf.toml + ...-dnf-dna.toml — the two new arms each add one [env] lever over their inherited parent (union arm: parent's dnf flag stays ON, new lever ON). That is the intended screen ladder, not a leak; confirm the union intent is deliberate at close-out (it is, per the PR body).
  • [warn] bench/runs/prefill-dnorm-fuse-card-verdict-20261019.jsonl — the dna increment over dnf is within n=2 rep spread (PP -0.1..+0.6% at 32k), i.e. the add-fold's marginal gain is not yet resolved; the measured dnf gain (~5.4 ms/chunk) is about half the opmark estimate with no dnf profile yet. Not blocking for the dnf lever; the dna lever's value is unproven at n=2.
  • [nit] patches/prod-local-metal/models/demos/blackhole/qwen36/tt/model.py — the raw master...head diff shows a large prefill_host deletion, but that is a stale-branch artifact (the branch forked at e705324e, before prefill_host landed on master). The true 3-way net delta is +28/-0 (two self._dnorm_fuse_selftest() calls + the method). Nothing is removed on merge.

WIP draft: approve is comment-only (no human-approved label, no un-draft). Re-dispatch when the WIP is lifted; the implementation PR gets the full T1 pass + card gate on merge.

**verdict:** approve **tier:** T1 **rationale:** Two default-off prefill levers (QWEN36_PREFILL_DNORM_FUSE / _DNORM_ADD) that are additive-only and byte-identical when unset. The fused path is proven bitwise-exact vs the image's pre/all-gather/post ops on every sim-gate cell (M 32–3072, bf16/bf8, L1/DRAM, both levers), with the gamma-tile+1 MUSTFAIL wrong-input branch differing (comparisons not blind) and flag-off parity holding. The card A/B (ttx ab, 2 reps, S2→dnf→dnf-dna) is a measured tier-1 WIN: PP +1.6–2.1% at 32k in all 6 cells, B=1 served text byte-identical to S2. The JIT gate caught a first-attempt DM-kernel compile failure on dnf (pre_dm/post_dm), fixed and re-gated OK before card time — the gate doing its job, not a defect. **concerns:** - [warn] `bench/arms/...-dfr-s2-dnf.toml` + `...-dnf-dna.toml` — the two new arms each add one `[env]` lever over their inherited parent (union arm: parent's dnf flag stays ON, new lever ON). That is the intended screen ladder, not a leak; confirm the union intent is deliberate at close-out (it is, per the PR body). - [warn] `bench/runs/prefill-dnorm-fuse-card-verdict-20261019.jsonl` — the dna increment over dnf is within n=2 rep spread (PP -0.1..+0.6% at 32k), i.e. the add-fold's marginal gain is not yet resolved; the measured dnf gain (~5.4 ms/chunk) is about half the opmark estimate with no dnf profile yet. Not blocking for the dnf lever; the dna lever's value is unproven at n=2. - [nit] `patches/prod-local-metal/models/demos/blackhole/qwen36/tt/model.py` — the raw `master...head` diff shows a large `prefill_host` deletion, but that is a stale-branch artifact (the branch forked at e705324e, before prefill_host landed on master). The true 3-way net delta is +28/-0 (two `self._dnorm_fuse_selftest()` calls + the method). Nothing is removed on merge. WIP draft: approve is comment-only (no human-approved label, no un-draft). Re-dispatch when the WIP is lifted; the implementation PR gets the full T1 pass + card gate on merge.
pp-glue: nix serving unit mounts dnorm_fuse.py and its kernels
Some checks failed
tt-stack-ci / Build simulators and check the host module (pull_request) Failing after 2m55s
tt-stack-ci / Report upstream drift (pull_request) Successful in 3m32s
cards-fresh cards: PR does not merge cleanly onto base
tt-stack-ci / Plan card run (fingerprint, reuse, cards-fresh) (pull_request) Successful in 9m7s
tt-stack-ci / Serialized card gate (pull_request) Has been skipped
886c32358b
test_prod_matches_nix::test_mounts failed: prod.toml's overlay carries the dnf/dna files, the unit did not mount them.
All 8 prod-vs-nix tests pass now.

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

test_mounts fixed (886c3235): the nix unit now mounts dnorm_fuse.py and its six kernels; all 8 tools/ttx/tests/test_prod_matches_nix.py tests pass.

test_mounts fixed (886c3235): the nix unit now mounts dnorm_fuse.py and its six kernels; all 8 tools/ttx/tests/test_prod_matches_nix.py tests pass.
Author
Owner

Superseded by #272 (S3 shipped to master, CONTROL = …-gpgob-dfr-s3, R-2026-10-20-s3). Closing unmerged.

Superseded by #272 (S3 shipped to master, CONTROL = …-gpgob-dfr-s3, R-2026-10-20-s3). Closing unmerged.
Grok closed this pull request 2026-10-20 05:58:18 +02:00
Author
Owner

agent-gateway closeout (closed): cleared agent:* labels.
Hermes kanban card (if any) is left for Hermes to archive/complete.

agent-gateway closeout (closed): cleared `agent:*` labels. Hermes kanban card (if any) is left for Hermes to archive/complete.
Some checks failed
tt-stack-ci / Build simulators and check the host module (pull_request) Failing after 2m55s
tt-stack-ci / Report upstream drift (pull_request) Successful in 3m32s
cards-fresh cards: PR does not merge cleanly onto base
tt-stack-ci / Plan card run (fingerprint, reuse, cards-fresh) (pull_request) Successful in 9m7s
tt-stack-ci / Serialized card gate (pull_request) Has been skipped

Pull request closed

Sign in to join this conversation.
No reviewers
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!265
No description provided.