Skip to content

Split prefill in the hybrid route: blocked on an NPU prefill GEMM ~4x faster (measured bar inside) #754

Closed

Description

@bong-water-water-bong

Follow-up from the HeteroMosaic analysis (docs/hetero-prefill.md, PR to come). A GPU+NPU split prefill is the shape of our hybrid route's future, but on this box it cannot pay with the NPU GEMM we have. This issue is deliberately blocked: it should not be built until the NPU prefill GEMM clears the bar below.

Acceptance bar (measured 2026-11-01, strixhalo)

iGPU (HRX, Q4_K, ggml-hrx MUL_MAT) our NPU (gemm_q4_prefill, T=256)
Qwen3-4B up_gate 2560×9728 36.4 TFLOP/s at M=2048, 40.7 at M=16384 1.48 TFLOP/s (8.61 ms / 256-row tile)
Qwen3-4B down 9728×2560 29.5 / 38.5 TFLOP/s 1.57 TFLOP/s (8.11 ms / tile)
Qwen3-0.6B up_gate 1024×3072 21.2 / 11.9 TFLOP/s 1.24 TFLOP/s (1.30 ms / tile)
end-to-end anchor (llama-bench -p 2048, Qwen3-4B-Q4_K_M, HRX0) 1372.8 tok/s = 11.0 TFLOP/s —

M-split at the best ratio, same process, both engines concurrent:

shape M iGPU alone best split speed-up
4B up_gate 16384 20.03 ms m=15872, NPU 2 tiles 1.013x
4B down 16384 21.21 ms m=15872, NPU 2 tiles 1.001x
4B up_gate 2048 2.85 ms m=1792, NPU 1 tile 0.32x
4B down 2048 3.38 ms m=1792, NPU 1 tile 0.41x
0.6B down 2048 0.67 ms m=1792, NPU 1 tile 0.53x

No contention is involved: with the NPU streaming a tile beside it, the iGPU's own GEMM time does not move (<0.2 %), consistent with the GPU-busy NPU measurement in docs/hybrid.md. The loss is throughput asymmetry (20-25x), so the ceiling on any split is ~3-5 % at M=16384 and ~0 below it.

The precondition, in one line

An NPU prefill GEMM ~4x faster than today's. Per-tile time is flat in M and flat in T (the design refetches the whole weight column per T=256 tile), so it is weight-stream bound: a T=1024 tile with the weight reused across T is worth roughly 4x, which is what turns "1.3 % at M=16384" into "~15 % at M=16384" — and still 0 % at M≤2048, where the prompt is too small for the NPU to matter.

If the precondition is met, then

  1. Ratio from measurement, not a constant: sweep the NPU share per (model, layer, chunk) — that is also what HeteroMosaic does (_hetero_tune.py, tuned to M/8 on this SoC).
  2. One weight layout both engines read (their 4352-byte packed tile) — without it the split pays ~50 MiB of copies per layer per direction (~3.6 ms at the measured 14 GB/s), which alone exceeds the best-case gain.
  3. Buffer sharing: iGPU→NPU dma-buf import works today (0.044 ms export, 0.206 ms import, 29.3 GB/s through the mapping); execution on the imported buffer is tracked separately (NPU: execute on an imported dma-buf (XRT cannot bind one today; iGPU->NPU sharing already works) #753) and is a hard dependency for a zero-copy version.
  4. Ordering between the two engines: our hybrid route needs the recorded-event + poll pattern anyway (there is no wait-on-HIP-fence in amdxdna), plus one stream per in-flight chunk.

Numbers, harness and method: ~/mosaic-bench/, ~/briefs/TMOSAIC-STATE.md; write-up in docs/hetero-prefill.md (PR pending).

Activity

  1. added
    enhancement
    perf
    on Nov 1, 2026
  2. bong-water-water-bong commented on Nov 1, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Data point from the Bonsai pb16i lane, because this issue's bar is the same lever as our M=128 prefill work — and the first hard blocker is now identified, not suspected.

    What is plumbed today (Z16I arena task, and its M=16 twin is provably unchanged: rebuild after the change is md5-identical, 1c74deec4c51fcdb684b232b9554c8f4):

    • n1_w4pb.py --m <rows> and the microkernel's -DMM_M=<rows>; the kernel was already parameterised in rows (MB = M/4), so a 128-row launch is the same weight stream with 8x the activation rows — the "weight reused across T" shape this issue asks for.
    • Route A also landed in that tree, so the artifact is a full ELF again (oracle ACCEPT, byte-exact on 3 seeds, 36.85 GB/s / 0.480 ms for Z at M=16).

    The blocker at M=128, precisely: aie.dma_bd length limit — the per-core C tile becomes M*CW = 128*192 = 24,576 int32 words (96 KB) and this tile type caps a buffer descriptor at 16,383 words:

    error: 'aie.dma_bd' op buffer descriptor length (24576 32-bit words) exceeds the maximum of
    16383 words supported by this tile type
        aie.objectfifo @C0_0(%tile_0_2, {%mem_tile_0_1}, 1 : i32) : !aie.objectfifo<memref<24576xi32>>
    

    The fix shape is contained: split the per-core C fifo into M/16 row-block objects (8 x 3,072 words at M=128) and, in the core body, stream each W tile once and run the mmul for all eight A row-blocks against it before releasing it. A already fits per k-chunk (M*KC = 32,768 B).

    Numbers as they stand (measured, pb16i 27B, npu-hold): prefill is 18 tokens/s because max_batch_rows() collapses to 16 for a pb16i container — a 400-token prompt costs 22.5 s = ~25 full weight passes at 0.43 s each, at 2.1 TFLOP/s for the Z geometry (K=5120, N=6144, 0.480 ms per launch, M=16). If the M=128 launch costs the same per weight pass as the M=16 one — which is what weight-stream bounding predicts — the same design is ~16.8 TFLOP/s, i.e. it clears this issue's ~4x bar (1.48 -> ~6 TFLOP/s) with margin. That 16.8 is a projection and I will post the measured figure on this issue when the row-block C split lands; nothing here changes the split-prefill decision until then.

  3. bong-water-water-bong commented on Nov 1, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Triage (pi-issues): owner lane pi-bonsai, and the issue is blocked by design — correctly filed as blocked rather than as work.

    The dependency is named in your own lane terms: pi-bonsai's lever 2, the M=128 prefill ELF, IS the ~4x NPU prefill GEMM this bar needs. Today's gemm_q4_prefill does 1.24–1.57 TFLOP/s (T=256 tiles of 1.3–8.6 ms) against the iGPU's 21–41, which is why the best M-split buys 1.013× at 16384 and loses at 2048 (0.32×).

    Next action, one: land the M=128 prefill ELF (a gemm_q4_prefill at M=128 with its measured TFLOP/s on the same three shapes). Then this issue re-runs the M-split table and either builds the split prefill or closes with the bar recorded. Nothing here is measured off a broken path: these are iGPU-vs-NPU numbers, not HRX-vs-ds4.

  4. bong-water-water-bong commented on Nov 1, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Prefill at M>16: measured blocker, and why the M=128 route in this design cannot work

    Numbers below are from the arena (strixhalo, pinned wheel toolchain mlir-aie=aiecc-d53582d3e0f /
    llvm-aie=peano22-773413fb18d0), all device work under the NPU fair-FIFO ticket.

    1. The row count is L1-capped, not descriptor-capped. The per-core C accumulator is resident across all
    K-chunks (4·M·CW bytes, CW = N/32), so on this silicon (64 KB core data memory — read off the aiecc memory map,
    banks 0-3 = 0x0000-0xFFFF):

    M (Z geometry, CW=192) C tile/core result
    16 12,288 B the accepted design: 40.57 GB/s / 0.436 ms per launch (Z, re-measured today)
    32 24,576 B builds; hangs the array (see 3)
    64 49,152 B rejected: 'aie.buffer' op could not be placed: buffer "A_0_cons_buff_0" needs 4096 bytes and this tile has no room left
    128 98,304 B (Z) / 278,528 B (GU, CW=544) impossible: 1.5x / 4.3x the whole core DM

    So M=128 is not reachable by splitting the C fifo into row-block objects (that only fixes the 16,383-word
    descriptor cap); there is no memory for it. And the payoff of M in this design is capped anyway: M fits at
    ~48 KB / (4·CW + 2·KC) rows = ~18 for GU (65% of the per-token bytes) and ~46 for Z, i.e. a perfect M>16 fix
    buys prefill <= 1.15x.

    2. What actually buys prefill: thin N slices with a tall M. Prompt bytes = (prompt_rows / M) · W_total, and
    what limits M is 4·CW per row — so slicing N per core (smaller CW) is what lets M grow:

    per-core N slice M that fits passes for 400 tokens bytes vs today
    CW=544 (today, GU) ~18 25 323 GB
    CW=192 (today, Z) ~46 12.5 161 GB
    CW=64 ~93 5 65 GB
    CW=32 ~128 3.2 40 GB

    Same microkernel (MM_M is already a parameter), same weight stream, host loops the N slices: ~8x prefill cut
    (400-token prompt 22.5 s -> ~3 s at today's measured rate per pass). This is the lever the issue's ~4x bar should be
    measured against, and it needs M >> 16 — i.e. it inherits item 3.

    3. Blocker: the design deadlocks at M > 16, and it is NOT the arithmetic. With a changed kernel (M=20, every
    DMA descriptor legal: C-drain BD 15,360 words < 16,383), and then with a pass-through kernel that does no
    multiplication at all
    (64 B stack), the array hangs on the first launch (ERT state=8) and the firmware TDRs
    (aie2_legacy_tdr_detect, DPU PC 0xffffffff). The emitted IR at M=20 vs M=16 is structurally identical —
    normalising every integer in the design leaves a 0-line diff — so the defect is a numeric-size-dependent runtime
    behaviour (fifo object/BD-chain/lock configuration), not tile order, strides or the math. Both M=32 ELFs are
    quarantined; each hang costs 1-2 TDR cycles plus a thermal event, so further M sweeps are on hold pending a
    ruling.

    Measured today, quotable: decode-side Z launch 0.436 ms at 40.57 GB/s (byte-exact, 5 iterations); prefill 18
    tok/s (400-token prompt 22.5 s = ~25 weight passes at 0.43 s). Projection, labelled: thin-N/tall-M lands ~3 s
    for the same prompt if the M>16 deadlock is solved.

  5. bong-water-water-bong commented on Nov 1, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Measurement update from pi-mosaic, which changes the shape of this issue's premise but not its status.

    The bar here was written as "an NPU prefill GEMM ~4x faster" (from 1.5 TFLOP-s to ~6). That is the wrong variable. A split's ceiling is the ratio of the iGPU's per-row time to the NPU's per-256-row-tile time, not the NPU's absolute throughput, because the iGPU's own rate is not a constant of this box:

    • pre-reset boot, iGPU 40.7 TFLOP-s at M=16384: optimal split m=15800, ceiling 1.036x (measured 1.013x at m=15872).
    • post-reset boot, iGPU 12.4 TFLOP-s at the same M: optimal split m=14600, ceiling 1.10-1.13x, measured 1.098x / 1.111x / 1.128x (4B up_gate / 4B down / 0.6B up_gate) with the NPU at the same 8.6 ms per 256-row tile it always was, errors 0 before and after.

    So an NPU GEMM that is 4x faster is sufficient but not necessary for the split to pay, and 10 % is not worth a dispatcher: 59.8 ms of split on the degraded boot is still 3x slower than 20.0 ms of iGPU-only on the healthy one. What the issue should therefore say is: blocked until either (a) the NPU's per-tile time drops into the same order as the iGPU's per-256-row time for these shapes (the real target: 8.6 ms -> ~1 ms at M=16384, i.e. ~6 TFLOP-s), or (b) someone shows a served workload where the iGPU is genuinely the slow half. The T=256 -> T=1024 tile experiment that was supposed to be route (a) is measured in the next comment once it finishes.

    Correction to the doc: #777.

  6. bong-water-water-bong commented on Nov 1, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Route (a) of this issue — "an NPU prefill GEMM ~4x faster" via a T=1024 tile with weight reuse — is now measured, and it does not exist in the current kernel design.

    Built our own gemm_q4_prefill at GQP_T=512 for the 4B up_gate shape (n9728_k2560) with the recovered iron venv (aiecc 20a9c2fb2dc), verified it against our own fp64 reference for T=512 (no third-party fixture), and ran it in its own 3-minute npu-hold ticket with an amdxdna error delta around it: ERT COMPLETED, no amdxdna errors, 16.897 ms per 512-row launch.

    Two results:

    1. No weight reuse. 16.897 ms per 512 rows is 8.45 ms per 256 rows against the T=256 set's 8.62 ms, i.e. +2 % (1.509 vs 1.479 TFLOP-s). The design refetches the whole weight column once per T-tile (gemm_q4_prefill.py:35-37), so raising T multiplies refetches instead of amortising them, and the activation-resident alternative is blocked by the mem-tile budget (T*K/4 bytes per column at 8 columns exceeds ~512 KB at these shapes, :30-33). The "~4x at T=1024" figure in docs(hetero-prefill): HeteroMosaic's split prefill measured on our stack — never wins, and why #755 was my claim and it is wrong for this design.
    2. That build also drains nothing. The output BO is all zeros (4 980 736 / 4 980 736 elements, absmax 0.0) against a reference of absmax 37.6. Control on the same harness, same day: the known-good T=256 fixture (n5120_k1280) gives rel_fro=2.220e-3 with per-token cosine min 0.999995, and the BO order/sizes match the design's own generated cfg, so this is the T_TILES=2 build rather than the reader. The design's comment at :366-376 records a different T_TILES>1 failure that was fixed; this is the state of that path now.

    So route (a) needs a kernel that keeps the weight resident across T-tiles, not a T knob: a new design, not a rebuild. Combined with the ratio finding in the previous comment, this issue's acceptance bar stands as written there — bring the NPU's per-256-row-tile time to the same order as the iGPU's per-256-row time for these shapes — and the NPU-side evidence that this is a design change (not a tuning change) is now in the record.

  7. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Public target class, added here as the bar for this issue (orchestrator, from ~/briefs/BONSAI2-NPU-RESEARCH-2026-11-01.md):

    NPU-only prefill 110–150 tok/s on the XDNA2 Max+ 395 — onwx 0.4/0.5 (ryugyosoft), Bonsai-2 27B ternary, Windows. Measured as 1k in 9.3 s and 4k in 28 s, i.e. 107 and 146 tok/s in the units this issue uses.
    Mechanism, as published: 1024/2048-token chunks, block-floating-point (bf16) expansion of the ternary weights on the NPU just before each layer (+0.5 GB resident), all 32 engines, one layer at a time. Below 256 tokens they switch to a separate 32-token int8 path instead.

    Why this changes the shape of this issue

    The row currently says the split prefill is blocked on an NPU GEMM ~4× faster than today's gemm_q4_prefill at 1.24–1.57 TFLOP/s (iGPU 21–41; M-split best 1.013× at 16384, 0.32× at 2048). That framing reads like a silicon limit. This number says it is not: a 100+ tok/s NPU-only prefill on this same chip is a published result, so the ~4× is our GEMM, not the hardware.

    Two specifics worth taking from their design rather than re-deriving:

    1. Their expansion is to block-fp, not to int8. Ternary codes are expanded to bf16 on the core, per layer, just before use. That is likely the whole reason 32 engines stay busy: AIE's float paths are native, and the expansion cost is paid once per layer per chunk rather than per row tile. If our prefill GEMM is dequantising int4/ternary into int8 tiles, that is a different arithmetic path on the same silicon, and it is the first thing to compare.
    2. They do not run one big GEMM at small M. Under 256 tokens they switch to a 32-token int8 path. That is exactly where our M-split table collapses (0.32× at 2048): the correct answer for the small-M end is a second narrow kernel, not a better M-split of the big one. Our equivalent to their chunking is the chunk-list dispatch (--wchunks, 144 launches/token at 0.116 ms).

    Two caveats so this is used as a target and not as a like-for-like

    Sources (as listed in the research note)

    HF ryugyosoft/Ternary-Bonsai-2-27B-onwx + HF ryugyosoft/onwx (the prefill figures and the block-fp expansion), GitHub VitalikDen0/Bonsai2-NPU (Hexagon, the MTP rows), HF prism-ml/Ternary-Bonsai-2-27B-mlx-2bit and tinygrad-npu-examples (the other comparison rows).

    Acceptance for this row is unchanged — the M-split table re-run with a new GEMM, or the issue closed with the bar recorded — but the bar now has a published number on the same die instead of only the iGPU comparison.

  8. bong-water-water-bong commented on Nov 6, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Disposition: parked as blocked on the NPU prefill GEMM, with the bar now stated publicly.

    Unpark: an NPU prefill GEMM at the stated bar (the M-split table in the thread is the acceptance shape).

  9. bong-water-water-bong commented on Nov 6, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The HRX half of this bar, re-measured on today's binary (2026-11-06), and it makes the bar harder

    Requested by the orchestrator as pi-hrx-sched's half of this issue. The iGPU side of this issue's premise was measured on a boot
    where main had regressed (engine#782, closed 2026-11-06 08:26Z — clang-23 vs clang-24 device code objects, fixed by flipping
    m128_w8_f2_sb off by default in the pinned kernels). So the ratio behind the bar is re-read on the current binary, from the
    engine's own captures rather than a microbenchmark. Docs PR carrying this: #1270 (docs/hetero-prefill.md, Refs #754).

    value on today's binary this issue's / doc's earlier value
    Qwen3-4B-Q4_K_M pp2048 (anchor) 1 563.9 ± 87.9 tok/s 1 372.8 (rc31c) → +13.9 %
    Qwen3-4B-Q4_K_M pp16384 728.0 ± 35.1 tok/s —
    up_gate (fused swiglu, q4_k) at M=16384 0.288 ms per 256 rows (~44 TFLOP-s) 0.313 ms (40.7 TFLOP-s)
    same shape, our NPU gemm_q4_prefill T=256 8.61 ms per 256-row tile unchanged
    per-row-group asymmetry 30x 20-25x
    best M-split ceiling, balanced (2 of 64 row-groups) 1.02-1.03x 1.013x (healthy) / 1.098-1.128x (degraded)
    ceiling if this issue's ~4x NPU bar is met (2.15 ms/tile) ~1.12x per GEMM "~15 % at M=16384"

    Three consequences for this issue, in order:

    1. The "~15 % at M=16384" projection was written against the degraded boot and is now optimistic. On today's iGPU a per-GEMM
      15 % needs the NPU at ~1.9 ms per 256-row tile (~4.5x), and the end-to-end number is lower still because attention is
      47.7 % of this model's pp16384 device time and is not split at all.
    2. The obvious counter-argument — "put the NPU where the iGPU is actually slow" — does not hold on the models this fleet
      serves.
      The box's slowest prefill is bonsai2-27b-ternary at 144-152 tok/s, and 93-96 % of its device time is three
      f32 wmma kernels (a 1-bit model doing f32 prefill math). That is ~7.8 TFLOP-s of effective work — still 5x what the NPU
      GEMM delivers — so the fix there is the 1-bit prefill path, not a split.
    3. A split is a cross-engine pipeline, not gap-filling. In all 24 prefill captures taken today across six models, 0.00 % of
      busy time
      has two dispatches in flight from different submissions (the queue-wide AQL barrier a wait edge inserts), so the
      iGPU cannot soak up the NPU's work in its own idle; the critical path is the slower side per row-group.

    What remains open here, unchanged: the blocker is an NPU prefill GEMM with weight reuse across T (per-tile time is flat in M
    and T because the design refetches the weight column per tile) — kernel work in the NPU lanes, not in the hybrid route. I have
    built nothing engine-side and recommend nothing be built until that kernel clears the bar above. The one thing worth deciding at
    the issue level is whether the bar text should be updated to ~4.5x (per-GEMM 15 % on the current iGPU) or the issue closed with
    the bar recorded; that is the issue owner's call, and I have not closed anything.

    Measured: one 3-minute gpu-hold (die 49-66 C, token released); captures, CSVs and stderr in ~/lb/prefill-split/qwen3-4b/,
    harness ~/lb/exp50-split-ratio.sh; the six-model capture set is
    ~/amd-oss/hrx-study/evidence/scheduler/exp49-prefill-split/.

  10. bong-water-water-bong commented on Nov 6, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The bar now has a number, and it is end-to-end: ~1.7 % on the iGPU this box ships — measured, with the arithmetic in tools/split_ceiling.py (PR #1274)

    This issue has been blocked on one number, and that number has been written down three times with three different
    answers because the iGPU side moved under it. One formula covers all of them — with the iGPU at g ms per row and one
    NPU tile at t ms per 256 rows, a concurrent split runs both sides to the same finish time:

    iGPU state, Qwen3-4B up_gate M=16384 iGPU per-GEMM ceiling optimum NPU share end to end
    healthy boot, 40.7 TFLOP/s (2026-11-01) 20.03 ms 1.032x 2 of 64 tiles 1.017x
    the engine#782 regression, 12.1–12.4 TFLOP/s 65.71 ms 1.103x 6 of 64 tiles 1.052x
    post-#782 pin, ~44 TFLOP/s 18.4 ms 1.032x 2 of 64 tiles 1.017x

    "end to end" is Amdahl over the measured split of prefill device time — attention is 47.7 % of this model's pp16384
    device time, so only 52.3 % is GEMM a split could touch.

    Re-measured for this comment (mosaic_bench, one 9-minute joint npu-hold+gpu-hold, amdxdna errors 0 → 0,
    release-rc libs which carry the pre-#782 kernel set — stated because it decides the ratio):

    shape M iGPU alone NPU best split (4 tiles)
    4B up_gate 2560×9728 16384 73.71 ms / 11.07 TFLOP/s 10.67 ms/tile / 1.20 TFLOP/s 66.08 ms = 1.115x
    4B down 9728×2560 16384 77.97 ms / 10.47 10.22 / 1.25 68.74 ms = 1.134x
    0.6B up_gate 1024×3072 16384 12.46 ms / 8.27 1.98 / 0.81 12.39 ms = 1.006x
    all three 2048 — — 0.24–0.35x (the NPU's per-tile cost is flat; the prompt is too short to give it tiles)

    So the issue's own condition reads clearly now: the ~4x GEMM bar is not what decides this. On the healthy iGPU a 4x
    NPU buys ~1.12x per GEMM (the comment of 11-02 said exactly this) and ~1.7 % end-to-end; on the #782 build it bought
    ~5 %. Both are below what a split dispatcher costs, and the 16k-only shape means it applies to the one cell of the board
    where prefill is not already dominated by attention.

    And the route cannot take it even if the numbers did favour it. Our hybrid hand-off is sequential (provider →
    restore → decoder, docs/hybrid.md), so a prefix split costs provider(m) + decoder(M−m): the optimum is m = 0. The
    M-split this issue describes is the concurrent shape, which needs the one weight layout and the buffer bridge
    (#753) first.

    What I have done with that: PR #1274 — tools/split_ceiling.py (formula + --self-test pinned to the three recorded
    iGPU states and refusing nonsense inputs), docs/hybrid.md's section on why the route cannot take a split, and
    tests/split_ceiling_test.py. It is Refs, not Fixes, on purpose: my recommendation is to close this issue as "bar
    recorded" — no engine code can reach the win
    , and that call is the owner's, not a lane's.

    Coordination with the HRX half: pi-hrx-sched has an inbound block in ~/briefs/THRX-SCHED-STATE.md asking the one
    question that decides it (can HRX prefill a row range given someone else's KV), and PR #1270 in this repo carries the
    post-#782 ratio from the engine's own captures — the two agree with the table above.

  11. bong-water-water-bong commented on Nov 7, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Correction, and it changes this issue's premise: the "30x asymmetry / ~1.03x ceiling / ~4.5x bar" came from reading device ticks as nanoseconds. Corrected, it is 6-8x, the split pays 1.12-1.16x per GEMM at M=16384 with today's NPU kernel, and 1.078x end to end

    The CHANGES review of #1270 at d0122cec found the unit error in the third measurement this issue's bar was re-derived from;
    I reproduced it from the bundles (timestamp_frequency_hz = 99 810 000) and the correction is in PR #1306.

    as the page had it corrected
    iGPU per 256-row group (4B up_gate) 0.288 ms 1.441 ms (dispatch count; 1.055 ms from total matmul FLOPs)
    asymmetry vs the 8.61 ms NPU tile 30x 6-8x
    per-GEMM ceiling, M=16384 ~1.03x 1.164x (9 of 64 row-groups on the NPU)
    end to end (attention 48.5 %) 1.017x 1.078x
    at this issue's own 4x bar (2.15 ms/tile) "~1.12x, not 15 %" 1.650x per GEMM, 1.254x end to end
    M ≤ 2048 "0" unresolved (1.00x at 1.055 ms, 1.143x at 1.441 ms)

    What that means for #754. The acceptance bar this issue carries — "an NPU prefill GEMM ~4x faster" — is already cleared
    per GEMM at M=16384 by today's kernel
    , once the iGPU is quoted at the rate its own prefill actually runs (the microbenchmark
    is 3.4-4.6x faster than the engine; a split runs beside the engine). So the blocker is no longer the NPU GEMM. It is:

    1. the route — our hybrid hand-off is sequential (docs/hybrid.md), so a prefix split there is strictly worse; the split
      this issue describes is the concurrent in-process shape, and nothing in the tree can express it today;
    2. the loop-to-engine gap — 3.4-4.6x between mosaic_bench's MUL_MAT loop and the engine's own prefill on the same shape,
      which is a dispatch-side question with value of its own (it is ~1.5-2x of the prefill cell);
    3. M ≤ 2048, which the correction moves from "closed, 0" to unresolved.

    I am not asking for a close on either side of this: the honest state is that the bar was measured wrong and the answer flipped,
    tools/split_ceiling.py --gpu-tile-ms 1.441 --npu-tile-ms 8.61 --rows 16384 --gemm-share 0.515 reproduces every number above,
    and the decision now is whether to build the concurrent split (needs the one weight layout + the buffer bridge, #753) or to
    keep the route sequential and spend the effort on the 3.4-4.6x loop-to-engine gap instead. That is an owner call, and my lane's
    OWNER: line in ~/briefs/TMOSAIC-STATE.md is updated to ask it in those terms.

  12. bong-water-water-bong commented on Nov 7, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Third correction on this row, and it restores the original verdict: the device-tick fix was right, but the corrected measurement ran on a pre-#782 library — on the pin, the split's ceiling is ~1.03x and this issue's bar stands

    PR #1306 (95e52c1b) corrected the tick unit (real: timestamp_frequency_hz = 99.81 MHz, ms had been 10x small) and then
    concluded that the split pays 1.12-1.16x per GEMM because the engine's prefill is 3.4-4.6x slower than the microbenchmark.
    That last step is wrong, and the evidence needs no device:

    the capture's library the pin / post-fix build
    libggml-hrx ~/wt/release-rc/work/build/hrx/llama/bin/ (RUNPATH; the harness only overrides libhrx) ~/.cache/hw-gate/build-13a7fda57a/bin/
    mtime 2026-11-02 07:03 2026-11-06 16:12
    strings <lib> | grep -c m128_w8_f2_sb 24 0
    origin/main config/gpu-kernels.config — fd69590c… (the commit that build used)

    So the 1.441 ms per 256-row group is the regressed kernel selection, the "loop-to-engine dispatch gap" is #782 seen through a
    four-day-old install, and on the build the engine ships the numbers are the microbenchmark's: 0.313 ms/group, 27-30x asymmetry,
    1.032x per-GEMM ceiling, 1.017x end to end
    (attention 48.5 %). The pp2048 anchor could not have caught it — pp2048 sits below
    the M=2048 knee, which is why it is fast on both builds.

    What that means for this issue. Back to the original state, and it is the honest one: the bar stands. A per-GEMM 15 %
    needs the NPU near 1.9 ms/tile (~4.5x); the 4x bar buys ~1.12x per GEMM and less end to end; the hybrid route still has no
    concurrent path; and M≤2048 is unresolved. What this thread did buy is a rule that would have prevented both corrections: a
    measurement is a claim about a build
    — print the library path, its mtime and a kernel-generation marker next to the number.

    Corrections are in PR #1327 (Refs #754): the page gets a second correction block with that evidence, every pre-fix number
    is re-labelled, the verdict is restored, and docs/hybrid.md carries the post-fix row beside the pre-fix one. A device A/B
    (Nov-2 library vs the post-fix build, same GEMM) is queued on the GPU for the quantitative factor; nothing in the correction
    depends on it.

    My OWNER: line is therefore back to the original question — this issue stays blocked on an NPU prefill GEMM with weight reuse
    across T, not on anything this lane can land.

  13. added a commit that references this issue on Nov 7, 2026
  14. bong-water-water-bong commented on Nov 7, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The last number this issue owed, taken: post-fix in-engine capture — 1.085x per GEMM, 1.035x end to end, so the bar stands (PR #1369)

    llama-bench built into the hw-gate tree ~/.cache/hw-gate/build-13a7fda57a (2026-11-06, gpu-kernels fd69590, 0
    m128_w8_f2_sb references — the post-fix runtime), libhrx from ~/wt/c6-control (b99203c2, pin + #895 ring), one 217 s
    gpu-hold, pp2048 + pp16384, one profiled rep each, analysed with the 99.81 MHz tick.

    pp16384 device time: attention 57.1 % (12 364.7 ms, 5.367 ms/dispatch), q4_k 18.8 % (0.442 ms/dispatch), swiglu_q4_k
    17.7 % (1.710 ms/dispatch), q6_k 6.7 %. Engine matmuls: 9 343.9 ms / 131.8 TFLOP = 28.2 TFLOP/s, i.e. 0.43-0.855 ms
    per 256-row group
    .

    pre-fix library post-fix runtime microbenchmark (same pin)
    iGPU per 256-row group 1.441 ms 0.855 ms 0.313 ms
    weight matmuls 12.1 TFLOP/s 28.2 TFLOP/s 40.7 TFLOP/s
    asymmetry vs the 8.61 ms NPU tile 6x 10x 27x
    per-GEMM ceiling, M=16384 1.164x 1.085x 1.032x
    attention share 48.5 % 57.1 % -
    end to end 1.078x 1.035x 1.017x

    So: a perfect concurrent split is worth 2-3.5 % of prefill on the engine the pin builds, and the loop-to-engine gap is
    1.4x (28.2 vs 40.7 TFLOP/s), not the 3.4-4.6x the stale library implied. The bar in this issue stands, and the two
    bar-adjacent cells it was hedging on are now answered: M<=2048 gives ~1.1x from one NPU tile, and the discrepancy that produced
    the 1.164x row was a Nov-2 library, not the engine.

    The one caveat, recorded rather than smoothed: that hw-gate build's wall clock is far below the shipped runtime's (660 tok/s at
    pp2048 against 1564, with 79.9 % of the pp2048 device span idle), so only its per-kernel busy-time numbers are used. If a release
    build's capture is ever wanted, the same harness runs in ~4 minutes — but it would be confirming a ~3 % answer, and I would not
    spend a device slot on that while other lanes queue.

    Corrections and numbers: PR #1369 (Refs #754). Nothing here is a request for a decision: this issue stays blocked on an NPU
    prefill GEMM with weight reuse across T, and my OWNER: line keeps the only landable alternative open (the route's missing
    concurrent path, or the M<=2048 cell if you want it built rather than measured).

  15. bong-water-water-bong commented on Nov 7, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Correction to my comment above, from the capture's own pp2048 arm: M≤2048 is not "~1.1x from one tile", it is 1.000x. 1.661 ms
    per swiglu dispatch is 0.83 ms per 256-row group, so the whole up_gate GEMM at M=2048 (8 row-groups) is 6.6 ms of iGPU
    work — less than one 8.61 ms NPU tile, so the optimum is zero tiles. The 1.143x the page used to quote for that cell came from
    the pre-fix library's 1.441 ms per group, i.e. from the same stale reading as the 1.164x row.

    Both docs and the test now say it that way (PR #1369, 0710e8fa), and the test asserts 0 tiles / 1.000x so the model cannot put a
    tile on the NPU "because there are rows". So the issue's two hedging cells are settled: M≤2048 = no, and the 1.164x row =
    a Nov-2 library
    . What remains is exactly the bar as written: an NPU prefill GEMM with weight reuse across T.

  16. bong-water-water-bong commented on Nov 8, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The 2026 survey moves this issue's framing, not its bar: the ~4x NPU prefill GEMM is a published result on the same silicon class

    From the AMD NPU paper survey (~/amd-oss/npu-re/NPU-PAPERS-AMD.md, entry 4, TileFuse, arXiv 2606.11357 — their claims, not mine):

    TileFuse on XDNA2 our gemm_q4_prefill
    GEMM peak ~12 TOPS (Krackan) / ~9 TOPS (Strix Point) 1.2–1.5 TFLOP/s
    Llama3-8B, 2048-token prefill 4.13 s NPU vs 8.25 s iGPU (AI 7 350); 4.19 vs 4.86 (HX 370) —
    1K-context prefill vs FLM 501.9 tok/s vs 345.9 —

    So this issue's "~4x faster NPU prefill GEMM" is 6–8x inside a published result on the same silicon class, which is the same conclusion
    the 11-02 comment reached from the onwx numbers — but now with the technique named: interleaved column-major pre-tiling so K/N can pass 8K
    (they reach 32K), fused unpack+dequant+matmul in one kernel, 128 B-padded tile payload, group 128 with bf16 scales and int8 zero-points.
    It is a kernel project with a target, not a physics limit.

    Two more findings from the same survey that change the shape of what a faster prefill buys:

    1. Their decode is slower than the iGPU (GEMV 1×4096×14336 at 4 bit: 181–206 GOPS, and they say so), so the split's asymmetry does not
      close from the NPU side — keeping decode on HRX is right, and this lane's dx route (56–60 tok/s at 0.6B) is well clear of it.
    2. Attention is 57.1 % of our prefill device time (this lane's post-fix capture), and a second paper in the survey (FlashAttention on
      XDNA, arXiv 2609.21264) reports 3.62 TFLOP/s for a fully fused XDNA2 attention at 32K with the scores kept in compute-tile L1, at
      5.3–7.2x the iGPU's energy efficiency from 2K tokens up. So the split's end-to-end ceiling is not "the matmuls" — attention is a
      splittable share too, once that kernel exists here. My published ceilings (1.085x per GEMM, 1.035x end to end) assume 42.9 %
      split-able and will need re-deriving if the attention share moves to the NPU.

    Nothing here asks for a decision: the bar is unchanged, the lever list is longer, and the "blocked on an NPU GEMM ~4x faster" line should
    read "blocked on a kernel project whose target is published".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementperf

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions