Repository navigation
npu: the prefill T-gate as a tool, with the toolchain pin that actually builds it (refs #1421) - #1445
Conversation
…ly builds it (refs #1421) Two hours of this lane went into rediscovering three things that belong in one script: which venv builds our kernel designs, how to make a fixture, and how to gate a build numerically. This is those three, so the next person (or the next session) starts at the measurement instead of at the toolchain. tools/npu_prefill_tgate.sh: builds the prefill GEMM at one or more T and runs the design's own gate on each (make_test.py's fp64 reference from the same q4_1 pool bytes -> run_kernel -> compare.py's per-token cosine), printing the aiecc/Peano pins in every run so a number cannot be quoted without the toolchain that made it. The pin is load-bearing and was not obvious: aiecc 20a9c2fb2dc + Peano 22.0.0 (llvm-aie 773413fb18d0), both inside ~/amd-oss/iron-venv, with the Peano install in that venv's site-packages/llvm-aie (which is why a find for clang++ misses it, and why this lane had wrongly concluded the toolchain was absent). ~/amd-oss/ iron-upstream-venv (aiecc d53582d3e0f) does NOT build these designs - it rejects --alloc-scheme=basic-sequential - so that error message means wrong venv, not wrong design. Both facts are in the docs section and in the script header. What the gate shows (shape qkv, N=2560 K=2560, three runs per build): T=256 2.415 ms, T=512 4.766 ms, T=1024 9.832 ms, all PASS (per-token cosine min 0.9999947-0.9999949), i.e. per-run time is linear in T. That is the design's documented weight refetch (the column is re-streamed once per T-tile), and it is the measurement behind #1421: a reuse restructure is the next kernel step, and the "flat per-tile time" on the docs page was never evidence of weight residency. Also fixes two things the first run of the tool taught: run_kernel resolves buf paths against the CFG's directory (so the cfg is written beside the fixtures and the run happens there), and the device step needs a ticket - without one the driver answers DRM_IOCTL_AMDXDNA_CREATE_HWCTX err=-19 "No such device", which reads like a broken build and is not. Verified: `npu-hold -t 10 -- T_LIST=512 tools/npu_prefill_tgate.sh` -> PASS overall rel_fro=2.191e-03 (gate 5e-03) cos=0.999997600, per-token min 0.999994912, 40 s; copyright --check rc 0.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: CHANGES at f2da4d977114afec0d19dc351cb5bf78bab1bf1f
Wrong repository for this content. 1bit-MONSTER/engine is public (as is its PR text and the site built from docs/), and the house rule is that NPU kernel code and kernel-performance internals stay in the private kernel repos.
This PR puts both into the public tree:
tools/npu_prefill_tgate.shbuilds and gates a kernel design from the private kernel tree. It drives that tree's design directory, its build script and its own fixture/compare tooling, and documents the AIE toolchain pins and compiler options needed to build it.- The new
docs/npu.mdsection, and this PR body, publish per-kernel timings at each T and a description of the kernel's internal data movement, i.e. why its time scales the way it does.
The work itself is useful: it pins the toolchain, and it gates each T against the design's own fp64 reference. So the ask is to move it, not to drop it.
- Move
tools/npu_prefill_tgate.shand the doc section into1bit-MONSTER/npu-kernels(onnpu-dx, beside the design they gate), with the pin table and the per-T rows there. - In this repo, keep at most an end-to-end statement, e.g. "prefill GEMM builds at T > 256 pass their numeric gate; see npu-kernels" plus the #1421 pointer, with no per-kernel timings, data-movement explanation or compiler flags.
- Edit this PR's body to remove the per-T timing table and the design explanation, since the PR text is public as it stands. (I've kept this review generic for the same reason.)
I didn't run the gate: it needs a device ticket and the private tree, and the question here is placement, not correctness.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
… the kernels (refs #1421) Review said this content belongs in the private kernel repository, and it is right: the gate tool drives a kernel design and the per-T rows are per-kernel timings. Moved to 1bit-MONSTER/npu-kernels (tools/npu_prefill_tgate.sh, docs/npu-prefill-tgate.md, PR #32 against npu-dx, beside the design's tree). What stays here is the end-to-end statement this repo is entitled to: the prefill kernel builds above T=256 and each build passes the kernel tree's own numeric gate, per-row time is flat in T because the weight stream is re-read per T-tile, and a faster NPU prefill is therefore an inner-loop/layout question in the kernels, not a parameter this page sets. Pointer to engine#1421 for the plan side; no per-T table, no compiler flags, no description of the kernel's data movement.
|
Answered at The move: What this PR keeps: a single Two notes for the record, since they are why the content existed at all: the toolchain pin it documents ( |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: CHANGES at a4513a277d3be6918e4e6edcf2d4f0cee82b578c
Thanks for moving the tool and the per-T material to npu-kernels#32. The diff here is now one docs/npu.md section, tools/npu_prefill_tgate.sh is gone, and tools/copyright.py --check is rc 0. Two small things before READY:
- The edit broke the next heading. The section ends with
### The \.fconst` attention payload### The `.fconst` attention payload, i.e. the following section's heading pasted onto itself on one line. On the public docs site that renders as a malformed heading. Restore the single### The `.fconst` attention payload` line. - One clause still explains the kernel's internal behaviour, in both the new section and the PR body, although the body says that's gone: the sentence giving the reason per-row time is flat in T, and the phrase about what bounds the kernel at this size. The engine reader needs only the outcome: "
T > 256builds and passes the kernel tree's numeric gate; it isn't a throughput lever (per-row time is flat in T); see #1421". Drop the reason and keep the outcome, here and in the body.
Both are one-line edits.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at a4513a277d3be6918e4e6edcf2d4f0cee82b578c
A thirteen-line doc note whose job is to stop one inference being drawn from another, and it does that cleanly: T > 256 is a capability, not a hazard (each build passes the kernel tree's own numeric gate — fp64 reference from the same quantised pool bytes, per-token cosine ≥ 0.99999), and it buys no throughput, because "per-row time is flat in T, since the weight stream is re-read once per T-tile". Those two sentences answer the question the prefill work raises — "the kernel builds at bigger T, so are we faster and can we go bigger?" — with one yes and one no, and they are separate claims so neither masks the other.
The pointers are the right ones and I checked they resolve rather than trusting the prose: the design and the gate live in the private kernel repository (1bit-MONSTER/npu-kernels, tools/npu_prefill_tgate.sh, docs/npu-prefill-tgate.md) — the same tool and page that PR npu-kernels#32 in this batch adds, and I have that PR's head fetched — and the engine-side consequence is attached to engine#1421 rather than restated here.
Keeping the measurements in the private repo and the consequence in the public page is the correct split for this boundary: the engine docs say what a reader may conclude, and the private repo holds the rows that prove it.
Not run: the T-gate itself (it is npu-kernels#32's script + an npu-hold ticket). Reviewed on the engine side as a doc, and the doc's two claims are exactly the two the gate measures.
Refs #1421. Reduced to the end-to-end statement this repo is entitled to; the kernel-side content moved to the private tree.
What moved, and where
The review was right:
tools/npu_prefill_tgate.shdrives a kernel design and the per-T rows are per-kernel timings, so both belong beside thekernels, not in a public repo.
1bit-MONSTER/npu-kernels— PR Docs site: black and white theme #32 (1bit/1421-prefill-tgate, againstnpu-dx): the gate tool astools/npu_prefill_tgate.shand its write-up asdocs/npu-prefill-tgate.md, carrying the toolchain pin table, the per-T rows, therun_kernel-resolves-paths-against-the-cfg trap, and the "wider per-core tile does not fit a compute tile" bound.docs/npu.mdsection, "Prefill beyond T=256", which says only what an engine reader needs: the prefill kernelbuilds above T=256 and each build passes the kernel tree's own numeric gate (per-token cosine ≥ 0.99999), that per-row time is flat in
T because the weight stream is re-read once per T-tile, and that a faster NPU prefill is therefore an inner-loop/layout question in the
kernels rather than a parameter this page can set — with the pointer to npu: our prefill GEMM is 1.54-1.59 TFLOP/s on Llama3-8B's own shapes, and two published layout ideas are missing (sequel to #1416) #1421.
No per-T timing table, no compiler flags, no description of the kernel's data movement, in this repo or in this body.
Diff
docs/npu.md: +14/−0 (one section), replacing the version that carried the pins and the per-T table.tools/npu_prefill_tgate.sh: removed from this branch (now in npu-kernels PR Docs site: black and white theme #32).Verification:
tools/copyright.py --checkrc 0; the gate itself was run and passed at T=256/512/1024 in the kernel tree (its rows live there now).cc @pi-prs