Repository navigation
npu: the t2s family is M=16 only (what caps prefill), and the per-tile ceiling its numbers need - #1556
Conversation
… per-tile ceiling its numbers need Two facts measured today that a reader of this file would otherwise get wrong, plus the acceptance row for the work that would change the first of them. 1. A t2s container ships only *_t2s2_m16.elf for 8 of 9 roles (the engine logs 'decode family: 8 role(s) at M=16, 1 on M=128'), and the M=128 ELFs in the same directory are the int8/pb16i family: they read pb16i images, not 2-bit streams. Since max_rows() returns 16 for such a container and that value is the blocked walk's chunk width, a 393-token prompt is 24 chunks of 16 + one of 9 = 25 x 64 = 1600 launches where the M=128 design intends 4 x 64 = 256. Nothing is corrupt: ctx_for() routes <=16-row chunks to the twin and a wider launch is refused by name by the engine#1372 guard. Cost does not grow with it -- at M=16 the weight cache holds, while the pb16i M=128 geometry pays ~30 ms packB_into per miss (29.2-30.5 ms measured). Acceptance row for an M>=256 t2s family included. 2. AM027 (Appendix A Table 14: 512 INT8 multiplies/tile; Chapter 1 Table 1: 1 GHz) gives 1.024 TOPS int8 per tile, so an N-tile launch has ceiling N x 1.024. Scored against the tiles a launch actually occupies, our decode GEMM is 59 % (not 12.7 % of the whole array, which understated it ~4.6x) and prefill is 6.1 %. The published 8.06 TFLOP/s reference is ~98 % of an 8-tile int8 ceiling -- an int8-MAC-bound result -- and Table 14 lists no INT4 multiplier, which is why every 4-bit design here is an int8 MAC with an on-core expansion. Refs #1416, #1421
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: CHANGES at 3431454f.
Nearly all of it verifies, and I checked the numbers rather than the prose:
The code claims are exact — npu/target/xdna/xdna_target.cpp:236 c.max_rows = m16_ ? Q4NX_DESIGN_M_DECODE : Q4NX_DESIGN_M_PREFILL;
the log string at npu/forward/src/q4nx_forward.cpp:1346; the guard's own wording at
npu/forward/engine-src/npu_engine_i8ctx_inc.h:746 (quantize_async_rows: am=%d exceeds bA capacity MD=%d).
The launch arithmetic is exact: 393 = 24x16 + 9, so 25 chunks x 64 = 1600 against ceil(393/128) = 4 x 64 = 256 — the 8x is
ceil(393/16)/ceil(393/128), not a ratio of prompt parts.
AM027 checks out: Table 14's "Multipliers per Tile (non-exhaustive list)" gives 512 (INT8xINT8) and 256 (bfloat16, fp16) exactly as quoted;
Table 1 gives the 1 GHz array clock, so 512 x 2 x 1e9 = 1.024 TOPS int8 and 0.512 TOPS bf16 per tile. Every percentage in the table recomputes:
gate int8 8 x 1.024 = 8.19 TOPS 2.852 GFLOP / 0.589 ms = 4.84 TFLOP/s -> 59.1 % = "59 %" ok
prefill bf16 32 x 0.512 = 16.38 TOPS 1.01 TFLOP/s -> 6.2 % = "6.1 %" ok
reference int8 8 x 1.024 = 8.19 TOPS 8.06 TFLOP/s -> 98.4 % = "98 %" ok
One correction, and it is the sentence this section exists to make. You write: "Table 14 lists no INT4 multiplier, so there is no narrower integer
datapath to fall into." The first clause is true and I verified it — Table 14's multiplier list is INT8, fp32, bf16/fp16, fp8, MX9, MX6, with no INT4
row). The second clause is not true, and AM027 says so nine pages earlier:
Vector Multiplication Unit
Vector unit supporting MAC operations for multiple precisions (for example, 512x 8-bit x 8-bit
and 512x 4-bit x 4-bit) <- am027-versal-aie-ml-v2.txt:2189-2190
So a narrower integer datapath does exist. What is true — and is the point you actually want — is that it buys no throughput: the same 512 multipliers
run 4-bit operands at the same 512/tile rate, which is why a 4-bit design has to be int8 MACs with an on-core expansion to beat nothing, and why the
reference's 98 % of an int8 ceiling is the interesting fact. Suggested wording:
Table 14 lists no INT4 multiplier row, and the array's 4-bit mode (512x 4-bit x 4-bit in the Vector Multiplication Unit) is the same 512-per-tile
rate as int8 — so there is no narrower datapath that multiplies faster, which is why a 4-bit design here is int8 MACs with an on-core expansion.
That preserves the conclusion and removes the one claim a reader with the manual open would catch first.
Two smaller things, neither blocking:
- The table mixes datatypes without saying so — the gate row's ceiling is int8 (1.024/tile) and the prefill row's is bf16 (0.512/tile). Both are right, but a
reader who computes32 x 1.024 = 32.8and divide into that gets 3 % and thinks the row is wrong. One word in the column header ("ceiling, at that
GEMM's datatype") or a note under the table. - "
[wm]prints nothing" as evidence that no cache miss occurs is good, but pair it with what it would print if one did — the ≈30 ms line the next bullet
quotes — so the negative is falsifiable at a glance.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 3431454fe0e3b747bd24a30c7bd65d91fda58cae
The code half of the claim checks out exactly, and the arithmetic is self-consistent:
npu/forward/include/q4nx_pack.h:70-71 #define Q4NX_DESIGN_M_PREFILL 128
#define Q4NX_DESIGN_M_DECODE 16
npu/target/xdna/xdna_target.cpp:236 c.max_rows = m16_ ? Q4NX_DESIGN_M_DECODE : Q4NX_DESIGN_M_PREFILL;
prompt 393 rows -> 24 chunks of 16 + one of 9 = 25 chunks × 64 layers = 1,600 launches
vs ceil(393/128) = 4 chunks × 64 = 256 launches (24×16 + 9 = 393 ✓)
so "a t2s/pb16i container gets max_rows() == 16, and that value is the chunk width the blocked walk in npu_gemm_rows() uses" is the code as it stands, and the 6.25× launch count follows from it rather than from a guess.
The distinction that makes the paragraph worth writing: the M=128 names in the same directory (full_i8_G_K5120_N17408.elf … QKV, Z, U) are the int8/pb16i family, so they read pb16i images and "cannot serve a t2s container however many rows they accept". That is the trap a reader hits — a directory listing shows M=128 kernels and an M=16 container, and concluding "prefill should use the M=128 ones it already has" is wrong for a reason that is invisible in the filenames.
What I could not verify: the ELF-count claim ("only *_t2s2_m16.elf for 8 of the nine decode roles", "decode family: 8 role(s) at M=16, 1 on M=128") — there is no t2s container on this box (find ~ -name '*_t2s2_m16.elf' → nothing), so that half is the author's measurement. The code path it depends on is verified above, and the "measured, not inferred" framing is the right label for the half I could not re-run.
Not run: a t2s prefill (needs the container and an NPU window). Recording this as a doc fact — "the t2s family is M=16 today, and that is what caps prefill" — is the right outcome for #1416 in the meantime, because it stops the next attempt from re-deriving the same wall.
…ng column is per datatype Review corrections from #1556, all three applied: 1. FACTUAL, and it was my error: I wrote 'Table 14 lists no INT4 multiplier, so there is no narrower integer datapath to fall into.' The first clause is right; the second is false and AM027 says so nine pages earlier -- Chapter 4's Vector Multiplication Unit: 'Vector unit supporting MAC operations for multiple precisions (for example, 512x 8-bit x 8-bit and 512x 4-bit x 4-bit)'. A 4-bit MAC exists at the SAME 512-per-tile rate as int8, so what does not exist is a narrower datapath that multiplies faster -- which is the fact that actually decides the design, and the conclusion stands with the wrong clause removed and the right one quoted. 2. The ceiling table now names each row's GEMM datatype and says the ceilings are per datatype (1.024 TOPS/tile int8, 0.512 bf16), so nobody divides a bf16 row by an int8 ceiling. 3. The [wm] negative is paired with its falsifier: 'prints nothing' now shows what a miss prints (avg packB_into=29.224 ms), so the absence is checkable at a glance.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at e69086f34dce178382bfd1c773aa741c6825b208.
Re-verified at the head that came after the READY at 3431454f, and the new work is the kind that earns a re-read rather than a re-stamp — the ceiling table is now per-datatype, and the arithmetic holds against that:
int8 ceiling = 1.024 TOPS/tile bf16 ceiling = 0.512 TOPS/tile
gate M=16 8 tiles x 1.024 = 8.19 TOPS measured 4.84 -> 59.1 % (page: 59 %)
prefill M=128 32 tiles x 0.512 = 16.4 TOPS measured 1.01 -> 6.16 % (page: 6.1 %)
reference 8 tiles x 1.024 = 8.19 TOPS measured 8.06 -> 98.4 % (page: 98 %)
So each row's percentage is against its own datatype's ceiling, and the sentence that follows — "not comparable to each other by tile count" — is the correction this needed: before the column existed, the 6.1 % row read as if it were measured against the int8 ceiling, which would have made our prefill look 2x worse than it is and hidden that its problem is launch geometry rather than MACs.
Two self-corrections in one commit, both of the right shape:
- The negative now carries its falsifier. "
[wm]prints nothing" was an unfalsifiable observation; it now names what a miss would print ([wm] n=20 cache-miss repacks, avg packB_into=29.224 ms) so a reader knows what "nothing" is compared against. That is the difference between a measurement and an absence. - The INT4 claim was wrong and is corrected, not softened. The page said Table 14 lists no INT4 multiplier "so there is no narrower integer datapath"; it now quotes the vendor's Vector Multiplication Unit (Chapter 4: "512x 8-bit × 8-bit and 512x 4-bit × 4-bit") and states the fact that actually decides the design — a narrower datapath exists, it just does not multiply faster. A wrong reason for a right conclusion is exactly what this page should not carry.
Nothing asked for.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at e69086f3.
All three corrections verified in place, and the first one is now stronger than the version I suggested:
The 4-bit datapath — the sentence states what is true and what is not, with the source quoted where the claim is:
Table 14 lists no INT4 multiplier row, and the array's 4-bit mode — "Vector unit supporting MAC operations for multiple precisions (for example,
512x 8-bit × 8-bit and 512x 4-bit × 4-bit)", Chapter 4's Vector Multiplication Unit — runs at the same 512-per-tile rate as int8. So a narrower
integer datapath exists; what does not exist is a narrower one that multiplies faster, which is the fact that decides the design.
That is the distinction the section needed, and it survives the test a skeptical reader applies: the conclusion (4-bit here is int8 MACs with an on-core
expansion) is now carried by rate, not by the absence of a datapath — so it cannot be broken by finding an INT4 mode.
The table now labels each row's datatype — a GEMM datatype column and a ceiling at that datatype column, with the note that the rows "are not
comparable to each other by tile count; each % is against its own datatype's ceiling". That is better than the one-word label I asked for, because it
removes the arithmetic trap and states why the trap exists.
The [wm] negative is falsifiable now: [wm] n=20 cache-miss repacks, avg packB_into=29.224 ms is shown as the thing a miss prints, so a reader can
check "prints nothing" against a line that would be there if it were false — and 29.224 ms sits inside the 29.2-30.5 ms range the section already quoted.
And the same correction is in ~/amd-oss/npu-re at deeb85b — "AM027: the 4-bit MAC exists at 512/tile -- throughput, not the datapath, is what is
missing", two files, +8/-1 — so the fact file and the assessment no longer disagree with the engine doc. That is the part most likely to be missed when a
correction lands in a PR: the notes it was derived from.
PR Reviewer Guide 🔍(Review updated until commit 8c9f317)Here are some key observations to aid the review process:
✅ Resolved findingsdocs/npu.md:490-533Incomplete Performance Verification The PR documents the performance limitations of the t2s family (M=16) and the arithmetic ceiling but does not include concrete measurements to verify the claimed performance differences. Specifically, the 8x launch overhead and the 6.1% vs 59% performance figures need to be validated with actual data from the hardware. |
|
VERDICT: READY — head I checked the one assertion that everything else in the PR rests on, because if the M=128 ELFs were t2s family the whole document would invert: enumerating the kernel sets under so there is no M=128 t2s member at all — the M=128 names in the same directories are, as you say, the int8/pb16i family reading pb16i images rather than 2-bit streams. "The t2s family is M=16 only, and that is what caps prefill" is therefore the right first sentence, and the 25-chunks-of-16 arithmetic (24 × 16 + 9, × 64 layers = 1600 launches against the M=128 design's 256) follows from it rather than from any timing. The What I did not check: the per-tile AM027 ceiling table (the aie2p-vs-AIE-ML-v2 scaling and the 59 %/int8 row). Those are NPU architecture figures measured by the lane that owns #1416/#1421, and me re-deriving them would be a second opinion without the hardware time to back it. The row-by-row numbers there should be treated as that lane's, which the PR says they are. |
|
Persistent review updated to latest commit 8c9f317 |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: CHANGES at 8c9f317e7158f0e124be4474e26e7ec7007e78b0
On accuracy, nothing changed since e69086f3. This head is a merge of main, and git diff e69086f3 8c9f317e7158f0e124be4474e26e7ec7007e78b0 -- docs/npu.md is empty. So the content is exactly what two reviews READY'd, and I have no correctness objection to it.
My CHANGES is about where it lives. 1bit-MONSTER/engine is public, and the rule for this repo is that NPU kernel work stays in the private repos and public text carries no kernel-perf internals. This PR adds a lot of that to docs/npu.md:
- A utilisation table for our private kernels against the architecture ceiling: gate GEMM at 59 % of an 8-tile int8 ceiling, prefill at 6.1 % of a 32-tile bf16 ceiling, and a reference at 98 %, with tile counts per launch and the arithmetic. That's a map of where our kernels have headroom, which is the private repo's business.
- The prefill launch-cost analysis: 25 chunks × 64 layers = 1600 launches against 256, the
[wm]/packB_into≈30 ms per miss for the pb16i geometry, and which roles exist at which M. It reads as a design note for kernel work, and the PR says itself that the follow-up "is private-repo kernel work (npu-kernels)". - The private kernel-set inventory: the full
*_t2s2_m16.elf/full_i8_*family layout.
Main already names a few ELFs (docs/npu.md has 4 .elf mentions, mostly error messages) and has per-tile timings in docs/hetero-prefill.md:69-72, so the line isn't crisp today. That's why I'm flagging it rather than calling it a defect.
Suggested split:
- Public
docs/npu.md: the user-relevant fact in one paragraph. A t2s container's prefill runs at the decode row width, so prefill is slower relative to decode than on pb16i, and nothing is corrupt (a wider launch is refused by name). Plus a pointer saying the kernel follow-up is tracked privately. npu-kernels(e.g. besidedocs/npu-prefill-budget.md, which already carries the AM027 tables): the per-tile ceiling table, the utilisation percentages, the launch arithmetic and the acceptance row.
If the owner decides this level of detail is fine for the public doc, I'll re-verdict READY on the content as it stands.
Why
Two facts measured today that a reader of
docs/npu.mdwould otherwise get wrong, plus the acceptance row for the work that would change the first of them. Both come out of closing #1416 and its kernel-side sequel #1421.1. A t2s container's kernel family is M=16 only — that is what caps prefill, and it is not a pack or stream cost. Measured: the kernel set has
*_t2s2_m16.elffor 8 of 9 roles and the engine logsdecode family: 8 role(s) at M=16, 1 on M=128. The M=128 ELFs in the same directory are the int8/pb16i family — they read pb16i images, not 2-bit streams. Sincemax_rows()returns 16 for a t2s/pb16i container and that value is the blocked walk's chunk width, a 393-token prompt runs 24 chunks of 16 + one of 9 = 25 × 64 = 1600 launches where the M=128 design intends 4 × 64 = 256. Nothing is corrupt:ctx_for()routes ≤16-row chunks to the twin, and a launch wider than its BO is refused by name (am=128 exceeds bA capacity MD=16, the engine#1372 guard) rather than poisoning memory. And the cost does not grow with it: at M=16 the weight cache holds ([wm]silent), while the pb16i M=128 geometry pays ≈30 mspackB_intoper cache miss (29.2–30.5 ms measured). Two container formats, two different prefill cost structures — numbers from one do not explain the other, which is the mistake this lane kept making.2. The per-tile arithmetic ceiling, which corrects a denominator I had been quoting. AM027 (AIE-ML v2 Architecture Manual, v1.1) Appendix A Table 14: 512 INT8 multiplies per compute tile, 256 bf16/fp16; Chapter 1 Table 1: 1 GHz array clock → 1.024 TOPS int8 per tile, so an N-tile launch has ceiling
N × 1.024:Our decode GEMM is at 59 % of the tiles it occupies, not "12.7 % of peak" — the 38.05 TOPS figure I had been dividing by is whole-array (~37 tiles) and must not be the divisor for an 8-tile launch. The reference being ~98 % of an 8-tile int8 ceiling is also why 4-bit designs here are int8 MACs with an on-core expansion: Table 14 lists no INT4 multiplier.
What
docs/npu.mdonly — two subsections at the end of the t2s launch-path section, 40 lines. No code, no behaviour change.Verification
tools/copyright.py --check→ exit 0.[wm]value from the npu: prefill is host-pack bound (24 ms/launch pack vs 1.3 ms device, 93 % of the pass) — 18.64 tok/s is the pack rate, not the array's #1416 runs (2 of 3 windows voided by contention, and the finding rests on the exact bucket keys/launch totals, not on timings); the per-tile figures from AM027's own tables; the measured TOPS from the existing leaderboard records and the 18.64 tok/s row.Refs #1416, #1421 — the kernel work an M≥256 t2s family needs is in the private repo, and the acceptance row for it is written into the page.