decode: fused SwiGLU gate/up matmul on full grid — frees ~3 GiB/card DRAM #106

Closed
opened 2026-09-27 16:55:46 +02:00 by Grok · 4 comments
Owner

Desk research 2026-09-27 (no hardware, no new speed number). Note: docs/notes/sram-model-split-2026-09-27.md (branch serving-throughput).

Idea

Fused SwiGLU decode matmul (gate/up + SiLU + mul) on the w_gate_up weight we already load, spread across the full 11×10 grid instead of 11 readers. Removes per-matmul start-up and eltwise programs, and lets us drop the separate w1/w3 copies → frees ~3.0 GiB/card DRAM (offsets the +2.2 GiB/chip of the tensor-prefetcher issue; relevant to the K8V4/prefix-snapshot budget, #78).

Estimate

−0.7…−1.5 ms TG at B=1 and B=8 (estimate). Bit-exact: needs verifying.

History / risk

  • Fused gate/up via minimal_matmul was a measured loss (+27–33% TG) [c37/c38 records] — this lever is about grid placement, not the fusion per se.
  • LEDGER closed "removing programs doesn't speed decode" on the 09-13 tree; today's tree is out of that scope, but inter-program gap is only 1.34 µs, so the gain must come from per-matmul start-up cost.

First probe

Workbench profile sizing per-matmul start-up cost of gate/up/down at B=1/B=8; then an op probe of the fused matmul on the full grid vs today's path with torch.equal.

Small related items (same note): QB2-style concatenated gate/up on MR (−0.3…−0.7 ms); attn_qkv still on legacy 8×8 grid (model_config.py:211-212, try QWEN36_1D_GRID_ATTN_QKV=11x6, ≤0.3 ms); lm_head split or bf4 (−0.3…−1.2 ms).

Desk research 2026-09-27 (no hardware, no new speed number). Note: `docs/notes/sram-model-split-2026-09-27.md` (branch `serving-throughput`). ## Idea Fused SwiGLU decode matmul (gate/up + SiLU + mul) on the `w_gate_up` weight we already load, spread across the full 11×10 grid instead of 11 readers. Removes per-matmul start-up and eltwise programs, and lets us drop the separate w1/w3 copies → **frees ~3.0 GiB/card DRAM** (offsets the +2.2 GiB/chip of the tensor-prefetcher issue; relevant to the K8V4/prefix-snapshot budget, #78). ## Estimate −0.7…−1.5 ms TG at B=1 and B=8 (estimate). Bit-exact: needs verifying. ## History / risk - Fused gate/up via `minimal_matmul` was a measured loss (+27–33% TG) [c37/c38 records] — this lever is about grid placement, not the fusion per se. - LEDGER closed "removing programs doesn't speed decode" on the 09-13 tree; today's tree is out of that scope, but inter-program gap is only 1.34 µs, so the gain must come from per-matmul start-up cost. ## First probe Workbench profile sizing per-matmul start-up cost of gate/up/down at B=1/B=8; then an op probe of the fused matmul on the full grid vs today's path with `torch.equal`. Small related items (same note): QB2-style concatenated gate/up on MR (−0.3…−0.7 ms); attn_qkv still on legacy 8×8 grid (`model_config.py:211-212`, try `QWEN36_1D_GRID_ATTN_QKV=11x6`, ≤0.3 ms); lm_head split or bf4 (−0.3…−1.2 ms).
Author
Owner

Runbook: https://git.bitp.cz/donach/tt-stack/src/branch/serving-throughput/docs/runbooks/106-fused-swiglu-fullgrid.md. The gain hinges on the per-matmul ramp (the inter-program gap is 1.34 us); size it first from the ordered per-layer wb profile (pi-D adds oplist). Bit-exact route = 1D mcast_in0 on w_gate_up with a paired epilogue reproducing silu->bf16, up->bf16, bf16 mul; minimal_matmul(fuse_swiglu) is not that. The 3 GiB is only freed if prefill stops needing w1/w3 (it uses w_gate_up, so it should). attn_qkv 8x8 vs 11x6 both leave 56 cores with work: placement only, a free bundle line.

Runbook: https://git.bitp.cz/donach/tt-stack/src/branch/serving-throughput/docs/runbooks/106-fused-swiglu-fullgrid.md. The gain hinges on the per-matmul ramp (the inter-program gap is 1.34 us); size it first from the ordered per-layer wb profile (pi-D adds oplist). Bit-exact route = 1D mcast_in0 on w_gate_up with a paired epilogue reproducing silu->bf16, up->bf16, bf16 mul; minimal_matmul(fuse_swiglu) is not that. The 3 GiB is only freed if prefill stops needing w1/w3 (it uses w_gate_up, so it should). attn_qkv 8x8 vs 11x6 both leave 56 cores with work: placement only, a free bundle line.
Member

From an existing ordered per-layer workbench profile, size gate/up/down per-matmul startup. Pass: the ramp is large enough to matter at B=4 and B=8. Fail: the only cost is the 1.34 µs inter-program gap. No fused kernel and no card until that number exists. Do not repeat the old minimal_matmul fuse (it was a measured loss).

From an existing ordered per-layer workbench profile, size gate/up/down per-matmul startup. Pass: the ramp is large enough to matter at B=4 and B=8. Fail: the only cost is the 1.34 µs inter-program gap. No fused kernel and no card until that number exists. Do not repeat the old minimal_matmul fuse (it was a measured loss).
Member

Measured dead: fat_fuse +27–33% TG loss (c37/c38); the open form QWEN36_DECODE_MR_GATEUP inert on gdc-cpk (R-2026-10-03-gu); the 3 GiB DRAM claim dies with the fusion. Related shipped smalls: w13 concat (EFMG) in the prod arm. Verified 2026-11-18.

Measured dead: fat_fuse +27–33% TG loss (c37/c38); the open form QWEN36_DECODE_MR_GATEUP inert on gdc-cpk (R-2026-10-03-gu); the 3 GiB DRAM claim dies with the fusion. Related shipped smalls: w13 concat (EFMG) in the prod arm. Verified 2026-11-18.
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.
Sign in to join this conversation.
No milestone
No project
No assignees
3 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#106
No description provided.