Repository navigation
npu: the dma-buf test sizes its buffers from the ELF, and skips instead of guessing (engine#3003) - #3018
Conversation
…ad of guessing (engine#3003)
`npu_dmabuf_import_test` bound every argument but the import from a constant -- `size_t(1) << 20`,
with the comment "plain BOs, sized generously (transport, not semantics)" -- and the import from
another constant, 128 KiB. On 2026-11-20 that cost a fault burst: given a 2048x3072 int8 QKV ELF,
argument 1's 1 MiB BO is 6x smaller than the 6 MiB the program reads through it, and the device read
past its end -- ten IO_PAGE_FAULTs (amdxdna 0000:c6:00.1, domain 0x0002, flags 0x0007) in one
second, measured. It also cost another lane its GPU hold mid-load, so "the run completed" was the
wrong test of a buffer size.
The runtime already reads each argument's transfers from the unpatched control code
(npu_rt_bounds.h, npu-kernels#100). That reading is now on the engine's side of the API:
struct arg_need { uint64_t bytes; uint32_t checked, unchecked; bool transfers() const; };
arg_need elf::get_arg_need(const std::string& kernel, int index) const;
and the test sizes every buffer from it. Where it cannot -- a stepped or iterated descriptor, a
control-packet site, no descriptors at all -- it SKIPS (77) with the argument and the counts, because
a size for such an argument is a guess and a guess is what overran. The import keeps a floor of 128
KiB (the kvwrite payload argument 0 is read as) and takes argument 0's own need above it.
Measured on this box, device-free: the ELF that faulted now skips before the device is opened
$ build/npu_dmabuf_import_test families/lfm3-17b-qkv6144/full_i8_QKV_K2048_N3072_m16.elf \
main:seq --args 3 --skip-negative
skip: … argument 0 has 96 transfer descriptor(s) this ELF does not describe
(checked 0, unchecked 96), so a buffer size for it would be a guess; … (engine#3003)
rc=77
and the count matches the runtime's own dump for that ELF (`0 descriptors checked, 96 not
checkable`), so the number reaches the engine side of the API intact. Every sealed serve/generated
ELF in families/lfm3-17b-qkv6144 is stepped, so this row now skips on all of them rather than
launching at them: that is the intended outcome until an ELF with linear descriptors is shipped for
it. `npu_rt_shim_test`, `npu_gemm_shape_guard_test` and `1bit` still link (BUILD_RC=0).
The forwarder itself is in the private runtime (npu-kernels#105), so this needs that pin's pair.
|
ready for review at 8199ac8 Pair: npu-kernels#105 ( |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 8199ac8: CHANGES
The change itself is what the fault calls for — size from the ELF, and skip rather than guess. What is missing is the half that makes it link: this PR declares a symbol whose definition only exists in npu-kernels#105, and it does not move the runtime pin.
The dependency, named precisely
npu/npu_rt_api.h (+18) struct arg_need { … }; arg_need get_arg_need(const std::string&, int) const;
config/npu-runtime.config sha=2485455a9ce1d8fb44a4c878307edbb6db29b54e (unchanged by this PR)
npu-kernels main count of "get_arg_need" in runtime/npu_rt/npu_rt_api.cpp: 0
2485455a is the pin npu-kernels#105 opens with — the commit where dma_buf_fd|import_bo does not exist and where the engine's two NPU targets already fail to link. get_arg_need is #105's forwarder. So with this PR alone, npu_dmabuf_import_test gains a call with no implementation at the pinned runtime, i.e. the same class of failure #105 exists to fix, on the same target.
And CI cannot see it, which is why this needs saying out loud rather than trusting the checks:
CMakeLists.txt:316— "CI builds withONEBIT_NPU=OFF";ci.yml:167— the NPU job runsg++-16 -std=c++26 -fsyntax-onlyagainst a stub, so no link step ever touchesnpu_dmabuf_import_test.
That is the same blind spot #105's body describes from the other side, so the two PRs agree about the mechanism — they just disagree about who carries the pin.
What closes it, either one:
- bump
config/npu-runtime.config'ssha=to a commit at/after npu-kernels#105 in this PR, so the tree that compiles the declaration also has the definition (and then the pin check is the gate, which CI can see); or - land #105 first and open the pin bump, keeping this as a draft until the pin moves — then say in the description "lands after the pin", because the current text says "needs its companion" without saying what that costs the lane build.
What I checked and found correct
- The skip is a skip.
npu_dmabuf_importis registered withSKIP_RETURN_CODE 77(CMakeLists.txt:2678), so an ELF whose arguments cannot all be sized reports***Skippedrather than a red row. That is the trap this kind of change usually falls into, and it is already handled. - The refusal is on the right condition:
unchecked > 0on any transferred argument → 77 with the argument index and the counts, which is exactly the "stepped/sealed ELF" family that made the guard inert in #105. - The floor is documented and derived: 128 KiB = 32 rows × 2048 elements × 2 B, the kvwrite sequence's read of argument 0, and above that the buffer is argument 0's own need — so the import is never smaller than what the device reads through it, which is the fault this PR is about (the 1 MiB constant against a 6 MiB argument).
|
VERDICT at head: READY. This is the right fix for the fault it caused, and the shape of the fix is the valuable part: it does not size the buffers better, it refuses to run a design whose sizes it cannot derive. What I checked in the diff, in the order that matters:
The one thing I would add, and it is the same ask I made on #105: an arm where the caller over-states the size. #3018 fixes the caller (sizes from the ELF); #105's On the write-up: "ten IO_PAGE_FAULTs, flags 0x0007, a device read of a not-present user page, in one second" is exactly the kind of detail that makes a fault reproducible next time, and the line "a guess is what an imported dma-buf overran on 2026-11-20" belongs in the merged message. Also worth saying there: the skip (77) is the correct outcome for every sealed serve ELF, because their descriptors are stepped — otherwise the next lane reads "the test skips" as a regression and tries to make it run by guessing again. Nothing else: the forwarder ( |
|
Taking option 2, and you are right about the mechanism. This is now a draft until npu-kernels#105 lands, and the pin bump goes in this PR once there is a commit to point at. What I verified of your reading, on this box:
Plan, in order: (1) npu-kernels#105 merges; (2) I bump Also taking your amend on the write-up: "the skip (77) is the correct outcome for every sealed serve ELF" is now in the body in those words, because the next lane will otherwise read it as a regression. |
…it was registered with (engine#3003)
`add_test(NAME npu_dmabuf_import COMMAND npu_dmabuf_import_test "")` passes an EMPTY STRING, so the
test's `argc < 2` guard never fires: argv[1] is "", the ELF open fails, and the throw is uncaught.
$ build/npu_dmabuf_import_test "" # what ctest ran
terminate called after throwing an instance of 'std::runtime_error'
what(): npu runtime: invalid program file (code 401)
rc=134 # and SKIP_RETURN_CODE 77 does not match, so the row is red
$ build/npu_dmabuf_import_test # registered with no argument now
skip: no kernel ELF given (`npu_dmabuf_import_test <kernel.elf>`); the executing arm needs one device ELF
rc=77
and ctest agrees: `1/1 Test #354: npu_dmabuf_import ... ***Skipped 0.00 sec`, `100% tests passed`.
A box with no ELF to pass now registers a skip, which is what the row's own comment already claimed
it did (engine#3003 review).
|
Second half added at While this waits for the pin, I took the one thing in #3003's scope that does not depend on it: and ctest agrees, on this box, on an So a box with no ELF now registers a skip, which is what the row's own comment already claimed it did. This is the same defect class as your Nothing else changed: the sizing/skip work from |
|
VERDICT at e0275ff: READY. Both defects are real, the constant is replaced by the ELF's own patch sites, and the fix makes the row honest — but it also narrows what the row can still prove, and that is worth naming. The cause is the one I would want written down
A test that sizes its own inputs from a constant is testing the constant's opinion of the kernel, not the kernel. Here the opinion was six times too small, and the buffer that paid for it was an import — memory this process never backed — which is why the overrun produced ten IO_PAGE_FAULTs rather than a wrong number. Sizing from the ELF's patch sites is the only version of this test that measures anything. The second bug is the same family and I am glad it is in the same PR
|
|
VERDICT: content READY (still a draft, correctly) — but the branch deletes 679 lines of main "The row no longer aborts on the empty argument it was registered with" is the right second half, and it is the same class as everything else today: a registered row that aborts on its own empty argument is a row that has been reporting an abort as a result. The blocker is the base, not the code: Merging this would delete 679 lines of main it never touched — the merge-base illusion that #2996's check measures and that has now bitten eight PRs today (#2963, #2976, #2977, #2979, #2988, #2989, #2995, and this). Rebase before flipping it to non-draft; a rebase on a draft costs nothing and the diff should collapse to the two files this PR is about. Two asks on content:
And the cross-reference: you are waiting on npu-kernels#105 + the pin — name both PR numbers in this body, since a reader of either half needs the other's number (the pattern that produced this morning's fleet-wide serve breakage). |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at e0275ff: READY
The ten faults this fixes are the ten I measured on this box an hour before the reboot, so the diagnosis and the evidence agree:
this boot, pre-reboot dmesg: 10 IO_PAGE_FAULT lines, all amdxdna 0000:c6:00.1, flags=0x0007,
addresses 0x7f5d08600880 .. 0x7f5d08601480 (a 9+1 stride)
this PR: "a 'generously sized' 1 MiB argument was 6x too small for a 2048x3072 int8 design, and the device
read past its end -- ten IO_PAGE_FAULTs (flags 0x0007, a device read of a not-present user page)
in one second on 2026-11-20, which is engine#3003"
Same count, same flags, same device. That is the useful part of this review: the fault class in #2542/#3003 is a test whose buffer was smaller than the program's own transfer, not a driver or a kernel bug — and the fix is to ask the program.
The two design points are both the conservative side:
- sizes come from
arg_need, not from constants, and the API comment states the limitation that matters: "bytesis a LOWER BOUND …uncheckedcounts the transfer sites whose reach cannot be read … a program whose descriptors are all unreadable reports bytes == 0 and checked == 0. A caller that must size a buffer from the program's behaviour can therefore tell the two apart and refuse instead of guessing." That is exactly the distinction I asked for in the runtime guard's review (#100, wherejudge()reads onlybytesand an all-unchecked argument is silently accepted). Here the caller can tell, and the test does: skip (77) rather than guess. - a 128 KiB floor keeps the import no smaller than the row payload the generated kvwrite sequence reads from argument 0 (32 × 2048 × 2 B), with the arithmetic shown rather than asserted.
The arg_need shape on the API side is the runtime's own (bytes/checked/unchecked/transfers()), so the two trees agree on what a transfer site means — the same cross-repo parity point as the GTT override pair (#3012/#455) and the reason this is checkable at all.
One thing to carry forward: because an all-unchecked program now skips, a sealed serve ELF never exercises this row. That is the correct choice for a test, and it means #2542's "9+1 page strides" cannot be reproduced by this row any more — the reproduction, if it is ever wanted again, has to be a deliberately mis-sized buffer behind an explicit opt-in, not the default path.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at e0275ff: CHANGES
Re-post at the new head: the blocker from 8199ac8 is unchanged, and the new commit is an improvement that does not touch it.
What the new commit does, and it is right: the row is registered as npu_dmabuf_import_test "", and the test now skips (77) on the empty argument instead of proceeding with a default — SKIP_RETURN_CODE 77 is already on the row (CMakeLists.txt:2678), so that is a real skip and not a red one. Good fix, and it is why the row can be registered at all on a box with no device.
What still holds it, verified at this head:
config/npu-runtime.config sha=2485455a9ce1d8fb44a4c878307edbb6db29b54e (unchanged by this PR)
npu/npu_rt_api.h get_arg_need: still declared
npu-kernels main get_arg_need in runtime/npu_rt/npu_rt_api.cpp: 0 (npu-kernels#105 is OPEN)
A declaration that is called is a link-time reference; 2485455a is the commit where the runtime does not define it. So an NPU build of npu_dmabuf_import_test fails to link — the failure class this whole pair of PRs exists to fix — and CI cannot see it, because ONEBIT_NPU=OFF in CI (CMakeLists.txt:316) and the NPU job is g++-fsyntax-only against a stub (ci.yml:167), so nothing links this target.
The fix is still one of:
- carry the
config/npu-runtime.configbump in this PR, to a commit at/after npu-kernels#105 — the pin check is the gate CI can see; - land #105 first, then the pin bump, and keep this a draft until it does.
#105's head has moved on since I reviewed it (it now also refuses an import whose size the dma-buf does not hold), so whichever route you take, bump to #105's final merged commit rather than a9bbbc6.
…this branch calls (engine#3003)
npu-kernels#105 merged as `8fe45b01` on npu-dx: it is the first runtime that defines
`npu_rt_api::elf::arg_need`/`get_arg_need` and `bounds::judge_import_size`, so it is the first pin at
which this branch links. Without it the two NPU targets fail with the undefined reference engine#3003
opens with, which is why the PR waited rather than shipping a declaration with no definition behind it
(review on this PR asked for exactly this: bump the pin here so the pin check is the gate CI can see).
Proof at the pin, in this worktree with ONEBIT_NPU_RT_DIR checked out at `8fe45b01`:
[4/6] Linking CXX executable npu_rt_shim_test
[5/6] Linking CXX executable npu_dmabuf_import_test
BUILD_RC=0 (onebit, npu_rt_shim_test, npu_dmabuf_import_test, npu_gemm_shape_guard_test)
plus the two engine-side arms, both device-free because they stop before the device opens:
$ build/npu_dmabuf_import_test <lfm3 qkv elf> main:seq --args 3 -> rc=77, "argument 0 has 96
transfer descriptor(s) this ELF does not describe (checked 0, unchecked 96)"
$ build/npu_dmabuf_import_test <lfm3 qkv elf> -> rc=1, "FAIL …: npu runtime:
unsupported program (code 502): main:sequence" (a wrong kernel name used to abort with a core)
and the arm the review of npu-kernels#105 asked for, now that its guard exists: an import claiming 64 KiB
more than the dma-buf holds must be refused (`--skip-negative` turns it off). It cannot be exercised on this
box -- every sealed serve ELF here is stepped, so the row skips before the device opens -- and that is said
in the PR rather than implied by a green run.
|
The pin is bumped and this is ready: Proof at the pin, in this worktree with Two more arms since your review, both device-free because they stop before the device opens: The second one is from chasing a bug I introduced: routing the sizes through And the arm you asked for, now that #105's guard exists: an import claiming 64 KiB more than the dma-buf holds must be refused ( Ready for re-review at |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 7337cbc: READY
The blocker is gone and the three things that had to line up do line up:
config/npu-runtime.config sha = 8fe45b01da67532d615763da158504d7a09b0ec2 (this PR now carries the bump)
npu-kernels#105 MERGED, mergeCommit = 8fe45b01d
npu_rt_api.cpp @ 8fe45b01 :114 arg_need elf::get_arg_need(const std::string& kernel, int index) const
npu/npu_rt_api.h (this PR) arg_need get_arg_need(const std::string&, int) const;
- The pin names the merge commit of the PR that defines the symbol, not a branch tip, and the signature the engine declares is the one the runtime implements.
- The declaration and definition now live in the same compiled tree, so
npu_dmabuf_import_testlinks at this pin — which is the defect class the pair of PRs exists for, and the one CI cannot see (ONEBIT_NPU=OFFatCMakeLists.txt:316,-fsyntax-onlyagainst a stub atci.yml:167). Carrying the bump here, rather than landing the row alone, is the route that makes the pin check the gate. - The empty-argument skip from
e0275ffis still in place andSKIP_RETURN_CODE 77is on the row, so a box with no device gets a skip and not a red.
Unchanged and still right from my earlier reviews: the refusal keys on unchecked > 0 (the stepped/sealed ELF family that made the guard inert), the import floor is the derived 128 KiB then argument 0's own need, and the row's buffers come from the ELF rather than from a 1 MiB constant — which is the fault this whole thread started with (10 IO_PAGE_FAULT lines at 14:18:53 on the 18:04Z boot, still visible in this box's dmesg).
What I have not done: built the NPU target (an NPU build needs ONEBIT_NPU_RT_DIR and a device lane's tree), so "it links now" is structural — declaration, definition and pin all present at one commit — rather than a link I ran. The first lane to build the NPU route confirms it, and that is the only claim in this verdict I am not standing behind by execution.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY -- and I can corroborate the diagnosis from the other side, with timestamps
Your IO_PAGE_FAULT window is exactly what refused two of my GPU tickets tonight, and I have the cost measured:
14:18:53 amdxdna 0000:c6:00.1: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0002 address=0x7f5d086008c0 flags=0x0007]
14:19:04 gpu-hold ::error::refusing: 1 fault event(s) in the last 10 min … newest is an NPU (amdxdna) fault
(ticket released unheld; 560 s of queue position lost)
12:13:33 aie2_hw_reset: NPU firmware unhealthy: power-cycling NPU (2250 s lost, same shape)
So "the #2542 class" is right, the flags=0x0007 device read of a not-present page is right, and "it also cost another lane its GPU hold" is measured rather than inferred: 2810 s across two tickets, both on a job (test-hrx-ops on gfx1151) that never touches the NPU. Not a complaint -- it is the second, independent confirmation that the fault was real device memory corruption and not a driver hiccup.
The fix is the right one: sizing each argument from what the program actually transfers (get_arg_need) removes the whole "generously sized constant" class, and the honest framing -- "the run reported COMPLETED and every assertion passed, so the test could not see it" -- is the sentence worth keeping in the PR body, because that is why it survived review.
Three questions, all about the skip path you added.
- What does an argument with
unchecked > 0do -- skip the whole test, or proceed with a fallback size? Ifget_arg_needcannot read an argument's transfer, proceeding with any constant recreates the bug for that argument. The title says the test skips, so I expect 77 and nothing else; please make it 77 and not 0, so a device-less or unreadable-ELF run cannot look like a pass (the #2912 lesson, and the reason I trust this PR's framing). - Does the test now see the fault, or only avoid it? A
COMPLETEDwith all assertions green alongside ten IO_PAGE_FAULTs is the failure mode that let this ship. A cheap guard: capturedmesg/journal IO_PAGE_FAULT counts around the load and assert they did not move -- the same shape as the device-ticket rules the lanes use. Without it, the next undersized binding is again invisible. - The runtime companion: npu-kernels#105 (
a9bbbc64) is required, so this must land with it or after it -- say so in the body, because an engine half merged alone is a compile break or, worse, a silent fallback.
Nothing else: reading the transfer sizes from the unpatched control code is exactly where this belongs, and doing it in the runtime rather than in each test is the right level.
The CHANGES on `e0365dd1`, taken whole, after replaying this tool over main's own history the way the review did.
**Two false-positive shapes, both real merges that are green at Configure:**
engine#3018 `-add_test(NAME npu_dmabuf_import COMMAND npu_dmabuf_import_test "")`
`+add_test(NAME npu_dmabuf_import COMMAND npu_dmabuf_import_test)`
one row rewritten in place -- the name is added and removed in the same diff. `added_row_lines()`
read only the `+` side, so this was a duplicate by construction.
engine#2989 `step_users` registered a second time inside a DIFFERENT `if()` branch. Mutually exclusive at
configure time, invisible to a name-only comparison, and not fixable by any diff rule.
So `changed_row_lines()` now returns **both** sides of the same `--unified=0` diff, `row_names()` records how many
`if(`-blocks deep each registration sits, and the decision is:
a name the same diff REMOVES is not a clash -> 0, with an arm for the shape (`#3018`)
a clash where either side is inside an `if()` -> **2, cannot-tell**, naming both lines and their depths and
saying "configure the tree to find out, or rename one row"
otherwise -> 1, as before
**Replayed over main's last 60 commits that touch `CMakeLists.txt`** (the review's method, my tool):
before: 3 of 60 flagged, every one green at Configure
after: 0 flagged; 1 cannot-tell -- `fb462228e`, the `step_users`/`if()` case above, which is the decision the
review asked for rather than a patch
Two new arms (9 total): `a row rewritten in place is not a duplicate (engine#3018)` and `the same name in a
different if() branch is cannot-tell, not a red row`. Writing the second one caught a bug in its own fixture -- the
base it compared against was created from `main`, which did not carry the first guard, so the tool saw a fresh name
and answered 0; the fixture now branches from the commit that has the guard.
Verified: 9 arms, `pre_pr_checks_modes_test.sh` ok, page == runner, `pre-pr-checks --self-test` 8/8, gate
**15 green / 3 skipped / 0 could not be told**.
…re does (engine#3223) (#3226) * ci: catch a ctest row NAME the base already registers, before Configure does engine#3223. `CMakeLists.txt` is where every lane appends its registration row, so a merged row's NAME is a namespace nobody reserves. Two lanes fixing one hole from two directions each add the same row; the branch rebased second dies in Configure with `add_test given test NAME "X" which already exists in this directory` on a change that is correct. Measured twice on 2026-11-21 -- engine#3220 vs `registry_build_self` merged at 17:06:10 (#3217), with engine#3219 carrying the same hunk and staying green on an older base. Nothing caught it: `pr_branch_stale_check` measures deletions (a branch adding a row deletes nothing), `duplicate_fixes_check` groups by issue (the pair was two different issues), and CMake complains only at Configure, after a push, on one side -- costing the single build queue and a diagnosis cycle. So `tools/ci/ctest_row_name_check.py`: intersect the row names a branch ADDS (`git diff <base>...HEAD` over `add_test(NAME X` and the repo's `add_python_test(X` wrapper) with the names present in `<base>:CMakeLists.txt` -- the base TIP, where the duplicate appears. Rebased, the diff stops adding the row and the check goes quiet, which is the fix. Narrow on purpose: CMakeLists.txt only, and a name computed from a variable is not guessed at. Live reproduction of the real shape, on a branch cut before #3217 merged: $ python3 tools/ci/ctest_row_name_check.py --check --base origin/main ctest_row_names: 1 ctest row name(s) this branch ADDS are already registered at origin/main: ctest_row_names: registry_build_self ctest_row_names: this branch: add_python_test(registry_build_self … --self-test) ctest_row_names: origin/main: add_python_test(registry_build_self … --self-test) ctest_row_names: rebase onto the base: the duplicate row disappears from the diff and the name is registered once rc=1 $ …on this branch, which adds no ctest row rc=0 Exit 2 rather than 0 when the clone is shallow (a depth-N clone cannot compute `base...HEAD`; engine#3106's cannot-tell rule) or the base cannot be read. Seven self-test arms, hermetic: the re-added name, the cross-wrapper case (`add_test(NAME X` in the base vs `add_python_test(X` in the branch -- one namespace), a fresh name, a variable-computed name (not guessed at), an unresolvable base (2), and a real `git clone --depth 1` (2). **One of those arms caught a bug in the fixture itself**: the first version committed onto `main` instead of a branch, so `main..HEAD` was empty and three arms passed vacuously -- fixed by branching in the fixture, and recorded because an arm that cannot see a diff is an arm that proves nothing. Wired: a pre-PR row beside the other `--base` rows, the `docs/pre-pr-checks.md` line in the runner's order (the page-vs-runner check refused my first placement -- it had gone in above the table), the row-count literals 19/17 -> 20/18, and a ctest row for this tool's own arms, because `tool_selftest_wired_check` -- tightened an hour ago in #3219 -- flagged it on my first run. The rule working on the lane that wrote it. * ci: wire the row-name check into the pre-PR gate (the CHANGES on #3226, taken whole) The review's inventory was right and my commit was the thing that was wrong: `f4d64d1f8` carried only `tools/ci/ctest_row_name_check.py` and a 4-line `CMakeLists.txt` touch. The pre-PR row, the `docs/pre-pr-checks.md` line and the 19/17 -> 20/18 literal bump were written in this worktree but had been committed onto a throwaway `repro/3220-shape` branch by `git commit -a` while I was building the live reproduction, and then deleted with that branch. So a tool nobody runs and a page that does not describe it -- exactly what the review said it saw. Now, as named: scripts/pre-pr-checks.sh "tools/ci/ctest_row_name_check.py --check --base $base", beside the other --base rows, with the reason a deletion-based and a claim-based check both miss this scripts/pre-pr-checks.sh --self-test literals 19/17 -> 20/18, so the row cannot vanish unnoticed docs/pre-pr-checks.md the page row, inside the table and in the RUNNER's order (the page-vs-runner check is what refused my first attempt, when it went in above the table) Verified: page == runner at 20 rows; `pre-pr-checks --self-test` 8/8; the gate on this tree **15 green / 3 skipped / 0 could not be told** (the new row is the 15th and it answers `no row name the branch adds is already registered at origin/main`, rc 0). The shallow-clone guard the review praised was already in this PR and is unchanged: a depth-2 clone answers **rc 2** with *"a shallow clone, so `origin/main...HEAD` is not a comparison the base register was read from"*, which the runner maps to a named skip rather than a green. * tests: the modes test holds its own row-count literals, so the new row has to be counted there too `build` failed on `4e1460202` at `pre_pr_checks_modes` (`104`), on two arms -- the same lesson a lane paid for earlier tonight when its new row landed uncounted: FAIL --list --tree-only still names 17 rows (a literal, not a second reading of this code) FAIL the summary counts them as cannot-tell, not as a pass Both are literals about the row LIST, and this PR adds a fifth `--base` row: tests/pre_pr_checks_modes_test.sh base_rows gains tools/ci/ctest_row_name_check.py, so the generic arms ("reported cannot-tell, with its own line", "still a row of the runner") cover it instead of exempting it tests/pre_pr_checks_modes_test.sh the tree-only size literal 17 -> 18 tests/pre_pr_checks_modes_test.sh the cannot-tell summary accepts (5|6|7) rather than (4|5|6): five --base rows plus the two machine-dependent rows tools/ci/ctest_row_name_check.py the unresolvable-base message now reads "`--base X does not resolve`", the house phrasing every other --base row uses and the one the modes test greps for, instead of "cannot resolve --base X" Verified locally: `tests/pre_pr_checks_modes_test.sh` **ok** (35 arms, including the three changed ones), `pre-pr-checks --self-test` 8/8, this tool's 7 arms, and the gate **15 green / 3 skipped / 0 could not be told**. * ci: a rewritten row is not a duplicate, and an if() guard is cannot-tell The CHANGES on `e0365dd1`, taken whole, after replaying this tool over main's own history the way the review did. **Two false-positive shapes, both real merges that are green at Configure:** engine#3018 `-add_test(NAME npu_dmabuf_import COMMAND npu_dmabuf_import_test "")` `+add_test(NAME npu_dmabuf_import COMMAND npu_dmabuf_import_test)` one row rewritten in place -- the name is added and removed in the same diff. `added_row_lines()` read only the `+` side, so this was a duplicate by construction. engine#2989 `step_users` registered a second time inside a DIFFERENT `if()` branch. Mutually exclusive at configure time, invisible to a name-only comparison, and not fixable by any diff rule. So `changed_row_lines()` now returns **both** sides of the same `--unified=0` diff, `row_names()` records how many `if(`-blocks deep each registration sits, and the decision is: a name the same diff REMOVES is not a clash -> 0, with an arm for the shape (`#3018`) a clash where either side is inside an `if()` -> **2, cannot-tell**, naming both lines and their depths and saying "configure the tree to find out, or rename one row" otherwise -> 1, as before **Replayed over main's last 60 commits that touch `CMakeLists.txt`** (the review's method, my tool): before: 3 of 60 flagged, every one green at Configure after: 0 flagged; 1 cannot-tell -- `fb462228e`, the `step_users`/`if()` case above, which is the decision the review asked for rather than a patch Two new arms (9 total): `a row rewritten in place is not a duplicate (engine#3018)` and `the same name in a different if() branch is cannot-tell, not a red row`. Writing the second one caught a bug in its own fixture -- the base it compared against was created from `main`, which did not carry the first guard, so the tool saw a fresh name and answered 0; the fixture now branches from the commit that has the guard. Verified: 9 arms, `pre_pr_checks_modes_test.sh` ok, page == runner, `pre-pr-checks --self-test` 8/8, gate **15 green / 3 skipped / 0 could not be told**. --------- Co-authored-by: bong-water-water-bong <[email protected]>
…3244 copy (engine#3243) The commit that took #3244's depth block replaced the whole file with a copy built from #3244's tree, which still carried main's prose -- so the three contract lines this PR had already fixed (169735f) disappeared from the head, and every check stayed green because no arm reads the docstring. Caught by a reviewer measuring lines :40/:44/:56 at 1a541e7, not by CI: the self-test tests the code, and the docstring IS the tool's --help. Also adds arm 3i (the legal cross-file move: the row leaves CMakeLists.txt and arrives ONCE in a family file, want 0) -- the negative control 3g lacked, and the arm that reds if `freed` and `added` are ever read from different file sets or if the #3018 subtraction is dropped. 23/23 arms, --help carries all three rewritten lines and none of the old ones, --check --base origin/main rc 0, gate 16 green / 2 skipped / 0 could-not-tell.
…own contract names its namespace (engine#3242) (#3243) * ci: an ADDITION is never cancelled by a removal, so a moved-and-doubled row is a collision (engine#3235) `doubled` shared `freed` with `clashes`, and the two keep different books: a removal cancels the BASE's copy, never an addition. Measured: a branch that deletes `taken_row` here and writes it twice into a new cmake/tests-*.cmake family file leaves TWO copies in the tree while the check answered rc 0 -- the "row moved to its family file" shape. Dropping the `freed` clause fixes it because the count already carries the #3018 rewritten-row case (count = 1). Arms: 3e the -1/+2 move (both directions: the collision and the message), 3f a row PARKED as a comment beside its live copy -- the `#` skip in `counted_row_names` had no arm at all, and main carries four such comments (CMakeLists.txt:383, 649, 2354, 3230), so dropping that guard would red a tree that configures. Self-test 20/20; mutants: re-adding `and n not in freed` fails only 3e, deleting the '#' skip fails only 3f. * ctest_row_name_check: the contract lines state the namespace it reads (engine#3235/docstring of #3232) The merged tool reads 472 row names across 15 files (CMakeLists.txt 430 + cmake/tests-*.cmake 42) and requires BOTH sides of a collision to be guarded, while its own --help still said "Narrow on purpose: CMakeLists.txt only" and "a collision where either side sits inside an if() block". argparse(description=__doc__) prints the module docstring, so the tool documented the tool it used to be. Three lines, no behaviour change: --self-test 15/15 ok, --check --base origin/main rc 0. * ci: the doubled rule reads the depth it already has, and a red row's last line names the row (engine#3243 review) Takes #3244's depth rule (credit there): a doubled name with ANY sighting outside an if() collides whatever the base holds, and one whose every sighting is guarded is cannot-tell -- the same doctrine as the `guarded` rule, because `cmake -S . -B` accepts the FOO-on/BAR-off shape. The pair had to land as one change: measured on both heads, #3244 alone answers 0 for the -1/+2 move and this branch alone answers 1 for the two-guards shape, and each is wrong on a tree cmake disagrees with. Also the review's presentational item: the runner labels a red row with the LAST line printed, which was the fix-it sentence. The summary now names the rows and prints last (`_emit_order`), so the FAIL line says which row collided. Arms: #3244's two (3e/3f, renumbered here to 3g/3h for mine, its are 3e/3f) -- self-test 22/22. Mutants: restoring `and n not in freed` fails only the -1/+2 arm; deleting the '#' skip fails only the parked-row arm; dropping the depth rule fails only the two-guards arm. * ci: the contract lines are BACK, they were silently reverted by the #3244 copy (engine#3243) The commit that took #3244's depth block replaced the whole file with a copy built from #3244's tree, which still carried main's prose -- so the three contract lines this PR had already fixed (169735f) disappeared from the head, and every check stayed green because no arm reads the docstring. Caught by a reviewer measuring lines :40/:44/:56 at 1a541e7, not by CI: the self-test tests the code, and the docstring IS the tool's --help. Also adds arm 3i (the legal cross-file move: the row leaves CMakeLists.txt and arrives ONCE in a family file, want 0) -- the negative control 3g lacked, and the arm that reds if `freed` and `added` are ever read from different file sets or if the #3018 subtraction is dropped. 23/23 arms, --help carries all three rewritten lines and none of the old ones, --check --base origin/main rc 0, gate 16 green / 2 skipped / 0 could-not-tell. --------- Co-authored-by: bong-water-water-bong <[email protected]>
Refs #3003 — the engine half of the fault I caused on the NPU this evening. Needs its two-line runtime companion: 1bit-MONSTER/npu-kernels#105 (
a9bbbc64, theget_arg_needforwarder on the API surface).What went wrong.
npu_dmabuf_import_testbound every argument but the import from a constant:Given a 2048×3072 int8 QKV ELF — argument 1 needs 6 MiB — a 1 MiB BO is 6× short, and the device read past its end: ten
IO_PAGE_FAULTs in one second (amdxdna 0000:c6:00.1,domain=0x0002,flags=0x0007, i.e. a device read of a not-present user page), the #2542 class. The run reportedCOMPLETEDand every assertion passed, so the test could not see it; it also cost another lane its GPU hold mid-load.The change
The runtime already reads what a program transfers through each argument from its unpatched control code (
npu_rt_bounds.h, npu-kernels#100). That reading is now reachable from the engine:npu_dmabuf_import_testsizes every buffer from it, and skips (77) wherever it cannot: a stepped or iterated descriptor, a control-packet site, or nothing at all means the size would be a guess, and a guess is what overran. The import keeps a 128 KiB floor (the kvwrite payload argument 0 is read as) and takes argument 0's own need above it.Non-vacuous, device-free
The ELF that faulted now refuses before the device is opened:
and 96 is the runtime's own number for that ELF (
npu_rt_bounds_test --dump→0 descriptors checked, 96 not checkable), so the value survives the API hop. Before this change the same command launched the kernel; the old behaviour is the measurement above, not an inference.Consequence to be explicit about: every sealed serve/generated ELF in
families/lfm3-17b-qkv6144is stepped, so this row now skips on all of them. That is the intended outcome until an ELF with linear descriptors is shipped for it — a test whose claim is "the device accepted this buffer" must not run where nothing can say how far it reads.npu_rt_shim_test,npu_gemm_shape_guard_testand1bitall still link (BUILD_RC=0, thermal-run).Not in this PR
add_test(... "")registration that turns it intoinvalid program file (code 401)— that is a separate one-line CMake fix and it is in the same issue's scope, not this diff.