X280-3: prefill sequencer — kill the 73–87 ms/request host gap #306

Open
opened 2026-10-23 10:01:01 +02:00 by Grok · 0 comments
Owner

X280-3 — Prefill sequencer: kill the per-request host gap (73–87 ms fixed + 7–11 ms/chunk)

Type: speed lever (prefill / TTFT)
Effort (after X280-0): 8–12 weeks · Stage: C
Depends on: X280-0 · Related: the host-free GDN-reset trace (a Tensix-only sub-lever, tracked here because it shares the gate)

1. TL;DR

Prefill wall minus device busy is 105 ms at 4k, 145 ms at 16k, 230 ms at 32k — i.e. ~80–100 ms fixed per request plus 7–11 ms per 2048-token chunk. At 4k that is 16% of TTFT; at B=8 the serial per-user loop (prefill_paged_slots) pays it up to 8×, ~640 ms on the critical path.

The dominant, measurable component is mundane: 48 layers × 6 ttnn.copy = 288 host-dispatched ops just to zero GDN state, then per-chunk host-side RoPE slicing and tilize, then a post-readback MTP warm-tail build. Each is microseconds of device work behind ~95 µs of host dispatch.

The X280 turns the request into: host hands over the prompt; the card sequences its own chunks. State reset, RoPE table build/tilize, chunk-to-chunk input staging and the warm-tail build all happen on-card, and the host is woken once for the first output token.

Pre-registered target: fixed gap ≤ 25 ms/request, slope ≤ 4 ms/chunk, PP +8…12% at 4k and ≥ +3% at 32k, with bit-identical logits.

2. Why (measured baseline)

bench/runs/reprofile-dfr-prefill-20261015.jsonl (traced workbench opmark, CONTROL …-gpgob-dfr):

ctx chunks wall ms device busy ms host gap ms
4096 2 660.1 555.2 104.9
16384 8 2389.8 2244.7 145.1
32768 16 ~4920 ~4690 ~230

Static walk (docs/analysis/prefill-hostgap-20261015.md) — the only attribution we have, and it is an estimate band, not a measurement:

Item Est. ms Why it is host-shaped
GDN reset — 288 eager ttnn.copy 20–60 ~95 µs host dispatch per op behind µs of device work
Post-readback MTP warm-tail finish (host argmax over 124k, tolist(L), RoPE tables, 4 tilizes, ~15–20 warm ops) 8–15 device idle after readback
Chunk-0 prep fully exposed (rope slice, 5 from_torch, 6 DMAs) 5–9 device idle before the first replay
bind/unbind/logits-select/readback/unbind ~4 host
Fixed total estimate 35–95 vs measured 73–87

Per-chunk slope is not host prep (host prep overlaps); it is inter-trace DMAs and launches that the profiler does not count as ops. That mechanism is unresolved — see the diagnostic row below.

There is a cheap non-X280 sub-lever hiding in this table: capture the 288-copy reset as one warmup trace (the same trick as c121's slot-copy trace). It was analysed and not built because (a) the share is unconfirmed within a 20–60 ms band and (b) trace-region budget is unknown with a 1.25 GB region already holding chunk + 5 bucket + slot traces. This issue includes it as P1, because it is the fastest way to bound the total and it does not need the X280 at all.

3. What exists today

  • model.py:3718-3719, gdn/tp.py:511-531 — the 288-copy reset, K=4 conv taps + recurrent + carry per layer.
  • model.py:3721-3737 — chunk setup: page-table pad (torch.cat), one from_torch + DMA.
  • model.py:3772-3820 — per chunk: rope slice, 5 from_torch (2× tile cos/sin ≈ 0.5 MB tilize each), 6 DMAs, vision-mask clear, non-blocking execute_trace; chunk 0 is fully exposed.
  • model.py:3840, mtp_batch.py:581-596, 484-514 — warm-tail segment after the drain.
  • model.py:2275, 2344-2353 — blocking logits readback.
  • model.py:2281, mtp_batch.py:598-628, 516-539 — the post-readback host finish.
  • model.py:2254 — prefill_paged_slots loops users serially on the host.

4. Design

4.1 Split the request into "plan" and "sequence"

Work Where it must stay Why
tokenize, page allocation, chunk count, bucket selection host vLLM owns KV pages and the scheduler
GDN state reset card 288 dispatches for zero-fill
RoPE table build + tilize card 0.5 MB tilize × chunks, pure data movement
chunk-to-chunk input staging card inter-trace DMAs, currently unprofiled slope
MTP warm-tail build (argmax select, index build) card device idle during it
first-token readback host (1 blocking read, unavoidable) API contract

4.2 Two mechanisms, cheapest first

M1 — zero the state in DRAM, don't copy zeroes into it (device-only, no X280).
GDN state lives in device DRAM. Zeroing 48 layers × (rec [1,Nv,128,128] + 4 conv taps + carry) is a memset over a contiguous, pre-reserved region, not 288 tensor copies. Either (a) a ttnn.zero_ over a flattened view (a handful of ops), or (b) a DRISC/NoC multicast zero-fill, or (c) capture the 288 copies as one trace and replay it. All three collapse the launch count. This does not need the X280 and must ship on its own merits.

M2 — X280 as the chunk sequencer.
The host enqueues: reset, then all chunk traces back-to-back with device-side limiters, then the warm tail. The X280 supplies the small per-chunk data (rope slice pointers, position base, page-table offset, chunk length) into a descriptor ring in DRAM/LIM, and the traces read their descriptors from device memory instead of from host-built tensors. The host's remaining job is one enqueue per request and one readback of the first token.

This is the same trick as X280-2: turn per-step host parametrisation into device-resident data. The difference is that here the data is bigger (rope tables) and lives in DRAM, so it depends on K0.6 (remote-channel bandwidth) — if a cluster can only reach its own channel well, descriptors and rope tables must be placed on the cluster's local channel at allocation time.

4.3 Sizing

Object Size Placement
RoPE cos/sin table, 32k × 128 bf16 (one shape, both halves) 16 MB local DRAM channel (built once per model, not per request)
per-chunk descriptor ring (32 descriptors × 64 B) 2 KB LIM
page-table window per request, 32k ctx @ 128-token pages 256×4 B = 1 KB LIM
MTP warm-tail index (2048 ids) 8 KB LIM
GDN state region ~36 MiB/card/seq DRAM (zeroed in place)

The hot set is tiny; the 16 MB rope table is built once at boot and indexed, not rebuilt — that alone removes the per-chunk 1 MB of tilize.

5. Numeric targets and kill criteria

ID Metric Pre-registered target
T3.1 fixed gap per request (wall − busy at chunk-0 boundary) ≤ 25 ms (from 73–87)
T3.2 per-chunk slope ≤ 4 ms (from 7–11)
T3.3 PP tok/s at 4k +8…12% (660.1 → 588–605 ms/request-pair)
T3.4 PP tok/s at 32k ≥ +3%
T3.5 TTFT max at B=8/4k −400…−600 ms (the 8× serial amortisation)
T3.6 logits bit-identical to CONTROL at 4k/16k/32k
K3.1 M1 alone must give ≥ 15 ms/request, else the static walk is wrong and the whole analysis is re-derived before M2 stop and re-walk
K3.2 if PP at G5 moves < +3% in any cell close that part; ship only what moved
K3.3 if trace-region budget cannot hold the chunk + 5 buckets + slot + reset + warm traces drop M1(b/c), use M1(a) memset only

6. Quality gates

Gate What must pass
G0 QWEN36_PREFILL_X280_SEQ=1; flag off = today; banner; ttx lint
G1 host tests for the descriptor encoding + must-fail (wrong chunk length ⇒ refused)
G2 ttsim: the reset-as-memset vs 288 copies, bitwise, per layer count; the rope-table index vs host-sliced rope, bitwise at 4k/16k/32k; the warm-tail select vs host, bitwise
G3 on-card: QWEN36_PREFILL_HOST_TIMING=1 split before/after (dev/prefill-hostgap diagnostic, already on a branch)
G4 served boot, in-boot self-test (prefill ref/cand/wrong on live inputs)
G5 ttx A/B, PP + TTFT, 4k/16k/32k, n≥2
G6 tier 1 (bit-exact logits)
G7 ship + docs

The QWEN36_PREFILL_HOST_TIMING diagnostic must run first. It exists on branch dev/prefill-hostgap (commit 599af041c) and is designed to split residual = wall − busy − Σhost into host-prep/chunk vs device-side inter-trace cost. Do not build M2 before that number exists — the slope mechanism is currently "unresolved from code".

7. Work breakdown

Phase Work Exit
P0 Land the host-timing diagnostic on CONTROL; one boot at 4k/16k/32k attribution replaces estimates
P1 M1: reset as one op/trace; measure; trace-region budget check K3.1
P2 Rope table resident + indexed (kills per-chunk tilize) G2/G3
P3 Descriptor ring + X280 sequencer; host enqueues once per request G3
P4 Prefill MTP warm-tail on card G3
P5 Served A/B, ship G5–G7

8. Risks

  1. Trace region. The 2048-masked-bucket traces plus a reset trace plus descriptors may not fit. Budget it first (docs/tt-trace-region-budget skill); a TT_FATAL mesh_trace.cpp:82 at boot is the failure mode.
  2. The 288 copies may not be the 20–60 ms they look like. They are KB-sized; the estimate extrapolates from a c117 dispatch rate. P0 settles it.
  3. Chunk traces bake addresses. Descriptors must point to buffers allocated before capture; a request whose page table lands elsewhere needs a re-capture or an indirection tensor. Indirection is the safe design.
  4. Ordering. Do not touch the --mamba-cache-mode align + chunked prefill incompatibility (STATUS.md:418) while here.
  5. Don't regress the prefill matmul path. The X280 must never sit in a matmul's dependency chain; it writes descriptors ahead of the replay, never inside it.

9. Anti-goals

  • Not changing chunk size or bucket structure (c2560 was already shown to lose more than the fixed cost saves).
  • Not moving SDPA or the GDN fused scan (26.7 ms and 25.9 ms of real device work — Tensix's job).
  • Not a second prefill engine; this is the same traces, driven differently.

10. Open questions

  • Q1: is the GDN state actually contiguous in DRAM, or per-layer allocations? (P1)
  • Q2: does the prefill_paged_slots serial user loop admit overlapped users (user N+1's reset while user N's last chunk runs)? That may be worth more than the whole gap and does not need an X280 — check it in P1.
  • Q3: can the 0.5 MB rope tilize be replaced by a device-side tile-layout store, avoiding tilize entirely?

11. References

  • bench/runs/reprofile-dfr-prefill-20261015.jsonl — wall/busy/gap and per-role matmul shares.
  • docs/analysis/prefill-hostgap-20261015.md — the static walk, the estimate bands, the diagnostic design.
  • dev/prefill-hostgap 599af041c — QWEN36_PREFILL_HOST_TIMING.
  • LEDGER R-2026-10-15-reprofile — 105/145/230 ms.
  • docs/PREFILL.md:64 — prefix arm + host GDN snapshot note.
# X280-3 — Prefill sequencer: kill the per-request host gap (73–87 ms fixed + 7–11 ms/chunk) **Type:** speed lever (prefill / TTFT) **Effort (after X280-0):** 8–12 weeks · **Stage:** C **Depends on:** X280-0 · **Related:** the host-free GDN-reset trace (a Tensix-only sub-lever, tracked here because it shares the gate) ## 1. TL;DR Prefill wall minus device busy is **105 ms at 4k, 145 ms at 16k, 230 ms at 32k** — i.e. **~80–100 ms fixed per request plus 7–11 ms per 2048-token chunk**. At 4k that is **16% of TTFT**; at B=8 the serial per-user loop (`prefill_paged_slots`) pays it **up to 8×**, ~640 ms on the critical path. The dominant, measurable component is mundane: **48 layers × 6 `ttnn.copy` = 288 host-dispatched ops just to zero GDN state**, then per-chunk host-side RoPE slicing and tilize, then a post-readback MTP warm-tail build. Each is microseconds of device work behind ~95 µs of host dispatch. The X280 turns the request into: **host hands over the prompt; the card sequences its own chunks.** State reset, RoPE table build/tilize, chunk-to-chunk input staging and the warm-tail build all happen on-card, and the host is woken once for the first output token. **Pre-registered target:** fixed gap **≤ 25 ms/request**, slope **≤ 4 ms/chunk**, **PP +8…12% at 4k** and **≥ +3% at 32k**, with bit-identical logits. ## 2. Why (measured baseline) `bench/runs/reprofile-dfr-prefill-20261015.jsonl` (traced workbench opmark, CONTROL `…-gpgob-dfr`): | ctx | chunks | wall ms | device busy ms | **host gap ms** | |---|---:|---:|---:|---:| | 4096 | 2 | 660.1 | 555.2 | **104.9** | | 16384 | 8 | 2389.8 | 2244.7 | **145.1** | | 32768 | 16 | ~4920 | ~4690 | **~230** | Static walk (`docs/analysis/prefill-hostgap-20261015.md`) — the only attribution we have, and it is an *estimate* band, not a measurement: | Item | Est. ms | Why it is host-shaped | |---|---:|---| | **GDN reset — 288 eager `ttnn.copy`** | **20–60** | ~95 µs host dispatch per op behind µs of device work | | Post-readback MTP warm-tail finish (host argmax over 124k, `tolist(L)`, RoPE tables, 4 tilizes, ~15–20 warm ops) | 8–15 | device idle after readback | | Chunk-0 prep fully exposed (rope slice, 5 `from_torch`, 6 DMAs) | 5–9 | device idle before the first replay | | bind/unbind/logits-select/readback/unbind | ~4 | host | | **Fixed total estimate** | **35–95** | vs measured 73–87 | Per-chunk slope is **not** host prep (host prep overlaps); it is inter-trace DMAs and launches that the profiler does not count as ops. That mechanism is **unresolved** — see the diagnostic row below. There is a **cheap non-X280 sub-lever hiding in this table**: capture the 288-copy reset as one warmup trace (the same trick as `c121`'s slot-copy trace). It was analysed and **not built** because (a) the share is unconfirmed within a 20–60 ms band and (b) trace-region budget is unknown with a 1.25 GB region already holding chunk + 5 bucket + slot traces. This issue includes it as **P1**, because it is the fastest way to bound the total and it does not need the X280 at all. ## 3. What exists today - `model.py:3718-3719`, `gdn/tp.py:511-531` — the 288-copy reset, K=4 conv taps + recurrent + carry per layer. - `model.py:3721-3737` — chunk setup: page-table pad (`torch.cat`), one `from_torch` + DMA. - `model.py:3772-3820` — per chunk: rope slice, 5 `from_torch` (2× tile cos/sin ≈ 0.5 MB tilize each), 6 DMAs, vision-mask clear, non-blocking `execute_trace`; chunk 0 is fully exposed. - `model.py:3840`, `mtp_batch.py:581-596, 484-514` — warm-tail segment after the drain. - `model.py:2275, 2344-2353` — blocking logits readback. - `model.py:2281`, `mtp_batch.py:598-628, 516-539` — the post-readback host finish. - `model.py:2254` — `prefill_paged_slots` loops users **serially on the host**. ## 4. Design ### 4.1 Split the request into "plan" and "sequence" | Work | Where it must stay | Why | |---|---|---| | tokenize, page allocation, chunk count, bucket selection | host | vLLM owns KV pages and the scheduler | | GDN state reset | **card** | 288 dispatches for zero-fill | | RoPE table build + tilize | **card** | 0.5 MB tilize × chunks, pure data movement | | chunk-to-chunk input staging | **card** | inter-trace DMAs, currently unprofiled slope | | MTP warm-tail build (argmax select, index build) | **card** | device idle during it | | first-token readback | host (1 blocking read, unavoidable) | API contract | ### 4.2 Two mechanisms, cheapest first **M1 — zero the state in DRAM, don't copy zeroes into it (device-only, no X280).** GDN state lives in device DRAM. Zeroing 48 layers × (rec `[1,Nv,128,128]` + 4 conv taps + carry) is a memset over a **contiguous, pre-reserved** region, not 288 tensor copies. Either (a) a `ttnn.zero_` over a flattened view (a handful of ops), or (b) a DRISC/NoC multicast zero-fill, or (c) capture the 288 copies as one trace and replay it. All three collapse the launch count. **This does not need the X280 and must ship on its own merits.** **M2 — X280 as the chunk sequencer.** The host enqueues: reset, then *all* chunk traces back-to-back with device-side limiters, then the warm tail. The X280 supplies the small per-chunk data (rope slice pointers, position base, page-table offset, chunk length) into a descriptor ring **in DRAM/LIM**, and the traces read their descriptors from device memory instead of from host-built tensors. The host's remaining job is one enqueue per request and one readback of the first token. This is the same trick as X280-2: **turn per-step host parametrisation into device-resident data**. The difference is that here the data is bigger (rope tables) and lives in DRAM, so it depends on K0.6 (remote-channel bandwidth) — if a cluster can only reach its own channel well, descriptors and rope tables must be **placed on the cluster's local channel** at allocation time. ### 4.3 Sizing | Object | Size | Placement | |---|---|---| | RoPE cos/sin table, 32k × 128 bf16 (one shape, both halves) | 16 MB | local DRAM channel (built once per model, not per request) | | per-chunk descriptor ring (32 descriptors × 64 B) | 2 KB | LIM | | page-table window per request, 32k ctx @ 128-token pages | 256×4 B = 1 KB | LIM | | MTP warm-tail index (2048 ids) | 8 KB | LIM | | GDN state region | ~36 MiB/card/seq | DRAM (zeroed in place) | The hot set is tiny; the 16 MB rope table is built once at boot and indexed, not rebuilt — that alone removes the per-chunk 1 MB of tilize. ## 5. Numeric targets and kill criteria | ID | Metric | Pre-registered target | |---|---|---| | **T3.1** | fixed gap per request (wall − busy at chunk-0 boundary) | **≤ 25 ms** (from 73–87) | | **T3.2** | per-chunk slope | **≤ 4 ms** (from 7–11) | | **T3.3** | PP tok/s at 4k | **+8…12%** (660.1 → 588–605 ms/request-pair) | | **T3.4** | PP tok/s at 32k | **≥ +3%** | | **T3.5** | TTFT max at B=8/4k | **−400…−600 ms** (the 8× serial amortisation) | | **T3.6** | logits | **bit-identical** to CONTROL at 4k/16k/32k | | **K3.1** | M1 alone must give ≥ 15 ms/request, else the static walk is wrong and the whole analysis is re-derived before M2 | stop and re-walk | | **K3.2** | if PP at G5 moves < +3% in any cell | close that part; ship only what moved | | **K3.3** | if trace-region budget cannot hold the chunk + 5 buckets + slot + reset + warm traces | drop M1(b/c), use M1(a) memset only | ## 6. Quality gates | Gate | What must pass | |---|---| | **G0** | `QWEN36_PREFILL_X280_SEQ=1`; flag off = today; banner; `ttx lint` | | **G1** | host tests for the descriptor encoding + must-fail (wrong chunk length ⇒ refused) | | **G2** | ttsim: the reset-as-memset vs 288 copies, bitwise, per layer count; the rope-table index vs host-sliced rope, bitwise at 4k/16k/32k; the warm-tail select vs host, bitwise | | **G3** | on-card: `QWEN36_PREFILL_HOST_TIMING=1` split before/after (`dev/prefill-hostgap` diagnostic, already on a branch) | | **G4** | served boot, in-boot self-test (prefill ref/cand/wrong on live inputs) | | **G5** | `ttx` A/B, PP + TTFT, 4k/16k/32k, n≥2 | | **G6** | tier 1 (bit-exact logits) | | **G7** | ship + docs | **The `QWEN36_PREFILL_HOST_TIMING` diagnostic must run first.** It exists on branch `dev/prefill-hostgap` (commit `599af041c`) and is designed to split `residual = wall − busy − Σhost` into host-prep/chunk vs device-side inter-trace cost. **Do not build M2 before that number exists** — the slope mechanism is currently "unresolved from code". ## 7. Work breakdown | Phase | Work | Exit | |---|---|---| | P0 | Land the host-timing diagnostic on CONTROL; one boot at 4k/16k/32k | attribution replaces estimates | | P1 | **M1**: reset as one op/trace; measure; trace-region budget check | K3.1 | | P2 | Rope table resident + indexed (kills per-chunk tilize) | G2/G3 | | P3 | Descriptor ring + X280 sequencer; host enqueues once per request | G3 | | P4 | Prefill MTP warm-tail on card | G3 | | P5 | Served A/B, ship | G5–G7 | ## 8. Risks 1. **Trace region.** The 2048-masked-bucket traces plus a reset trace plus descriptors may not fit. Budget it first (`docs/tt-trace-region-budget` skill); a `TT_FATAL mesh_trace.cpp:82` at boot is the failure mode. 2. **The 288 copies may not be the 20–60 ms they look like.** They are KB-sized; the estimate extrapolates from a c117 dispatch rate. P0 settles it. 3. **Chunk traces bake addresses.** Descriptors must point to buffers allocated before capture; a request whose page table lands elsewhere needs a re-capture or an indirection tensor. Indirection is the safe design. 4. **Ordering.** Do not touch the `--mamba-cache-mode align` + chunked prefill incompatibility (`STATUS.md:418`) while here. 5. **Don't regress the prefill matmul path.** The X280 must never sit in a matmul's dependency chain; it writes descriptors *ahead of* the replay, never inside it. ## 9. Anti-goals - Not changing chunk size or bucket structure (`c2560` was already shown to lose more than the fixed cost saves). - Not moving SDPA or the GDN fused scan (26.7 ms and 25.9 ms of real device work — Tensix's job). - Not a second prefill engine; this is the same traces, driven differently. ## 10. Open questions - Q1: is the GDN state actually contiguous in DRAM, or per-layer allocations? (P1) - Q2: does the `prefill_paged_slots` serial user loop admit overlapped users (user N+1's reset while user N's last chunk runs)? That may be worth more than the whole gap and does not need an X280 — check it in P1. - Q3: can the 0.5 MB rope tilize be replaced by a device-side tile-layout store, avoiding tilize entirely? ## 11. References - `bench/runs/reprofile-dfr-prefill-20261015.jsonl` — wall/busy/gap and per-role matmul shares. - `docs/analysis/prefill-hostgap-20261015.md` — the static walk, the estimate bands, the diagnostic design. - `dev/prefill-hostgap` `599af041c` — `QWEN36_PREFILL_HOST_TIMING`. - `LEDGER R-2026-10-15-reprofile` — 105/145/230 ms. - `docs/PREFILL.md:64` — prefix arm + host GDN snapshot note.
Sign in to join this conversation.
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.

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