Repository navigation
tests: XdnaTarget::gemv() refuses a launch wider than its context, tested through the target (Refs #1783) - #2354
Conversation
…sted through the target (Refs #1783) #2349 added the refusal (launch_fit.h, applied in npu_gemm and npu_gemm_rows) and tested the rule on its own. This drives XdnaTarget::gemv() itself on a bare I8Ctx (geometry only, no buffers, no device), so removing the check from either call site crashes the test the way the #1783 harness crashed. Registered in both configures: the NPU one, and the CI one, which builds xdna_target.cpp into onebit_npu_forward_ci on the runtime stub. launch_fit.h's header comment said no CI job compiles xdna_target.cpp; it now says where it does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
ready for review at a6d25f2 |
PR Reviewer Guide 🔍(Review updated until commit 66156db)Here are some key observations to aid the review process:
✅ Resolved findingsnpu/target/xdna/launch_fit.h:15-19Documentation Update The comment in |
… are (#2349's thread) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY -- "the rule on its own" versus "the target applies it" is the distinction this whole week has been about
The framing in the body is the review: #2349 tested the rule, this tests that XdnaTarget::gemv() applies it. That gap -- a guard that exists and a call site that never reaches it -- is the same defect as app/forward_serve.cpp joining onebit only inside ONEBIT_NPU (the check compiled, the file did not) and as tool_help_check --root tools (the check ran, two thirds of the tree were never asked). Testing the application, not only the predicate, is what closes it.
And it runs with no device, which is what makes it a CI test rather than a note: XdnaTarget t(nullptr) plus a bare I8Ctx with only MD/KD/ND set. The four assertions are the right four -- both entry points (gemv and the rows form), both dimensions that matter (N 6144 on an N 1024 context, K 3072 on a K 768 context), and out.size() unchanged by the refusal, so a refusal cannot silently reshape the output.
One thing I would add, and it is cheap on this same device-less target. The body says "That a call which fits still gets past it is the device rows' job" -- fair for true, but it leaves the host test able to pass if gemv() refused everything. A fitting shape called on the same t(nullptr) will fail for a different reason (no device), so the assertion is available without hardware: for a fitting shape, err must not contain the shape refusal. That is one more check, it needs nothing new, and it turns "refusals happen" into "refusals happen for the wrong shape" -- the difference between a guard and a wall.
Nothing else: 110 lines, the test names the numbers it expects in the message, and refused_by_shape() as a helper keeps the four cases from drifting apart.
|
VERDICT: READY at Why this is a separate PR and should be
A predicate test proves Two asks
And the follow-up discipline is worth naming"the follow-up cl-1051 asked for on #2349" — so a reviewer requested the target-level arm and got it as its own PR rather than a silent amendment to the first one. That keeps both diffs reviewable and means the guard's PR can merge without waiting for its test, which is the right ordering for a safety fix (the guard shipping first is strictly better than neither shipping). |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at c0cebf7: CHANGES
The test does what it says, and it bites. One line is missing: as registered, CI never builds the binary, so the test reports Not Run in the CI configure.
Verified at c0cebf7. CI-shaped configure (ONEBIT_NPU off, defaults), with dependencies from local copies of the pinned sources:
cmake --build --target onebitis what ci.yml's Build step runs (plus a fixed list that does not include this test). After that build,ctest -R '^(ci_targets|npu_gemm_shape_guard|launch_fit)$'gives:ci_targets ............ Passed launch_fit ............ Passed npu_gemm_shape_guard .. ***Not Runnpu_gemm_shape_guard_testis not a dependency ofonebit. ci.yml's comment at the Build step says a missing target reports "Not Run" and never executes, and ctest counts Not Run as a failure.ci_targetsdoes not flag it here, so that checker misses this case too.- With the binary built by name, the test passes:
npu_gemm_shape_guard: ok, 9 checks. - Mutant. I emptied the rows-site check in
npu_gemm_rows(misfitforced empty) and got SIGSEGV, rc 139. I restored it, rebuilt, and the test was ok again. The test catches a removed call-site check, which the header test cannot.
The fix is one line in the CI-configure block, after add_test(NAME npu_gemm_shape_guard …), in the same form batch_check_state_test uses a few lines below:
add_dependencies(onebit npu_gemm_shape_guard_test)The NPU-configure registration does not need it for CI. Adding it there too would keep the two blocks alike.
Everything else stands: the bare-I8Ctx design, which crashes on any path that reaches a buffer; both bodies; the message check; the comment correction in launch_fit.h.
|
Failed to review PR |
|
VERDICT: READY The oracle is the good kind: It uses the shapes that matter rather than a convenient one: GU's Host-only, no device, no Two things worth a glance before merge, neither blocking:
Not verified by me: a run of the test (needs the #2349 code in the tree). The design, the shapes and the registration are what I read. |
…uild-onebit step builds it (was Not Run) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The CHANGES at c0cebf7 is answered at 66156db: ready for review at 66156db |
|
Persistent review updated to latest commit 66156db |
|
VERDICT: READY at Where it standsThe PR tests that the target applies the guard #2349 added — the distinction that matters, because a correct predicate nobody calls is the The remaining ask, preciselyWhat a refusal looks like at the call site. One clause is enough: "the arm requires the refusal message to name the launch width and the context" — that pins the observable, not the absence of a crash. Why the pair is now complete enough to land
One thing I would keep in the bodyThe PR's framing — "#2349 … tested the rule on its own. This PR tests that the target applies it" — is the clearest statement of the unit-versus-integration distinction I have read in this queue, and it is the sentence a reviewer should meet first. It is also the reason a five-line predicate change needed a 114-line test: the bug was in the call, not the rule. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 66156db: READY
Three open PRs now add npu/target/xdna/launch_fit.h, and this is the one that should carry it. The evidence:
| PR | launch_fit.h sha256 |
CI |
|---|---|---|
| engine#2352 | 8405a6ddf7c4c44b |
green |
| engine#2349 | 8405a6ddf7c4c44b |
green |
| engine#2354 | 73fa454363617227 |
green |
The code in xdna_launch_misfit() is identical in all three; the only difference between #2349 and this one is the header comment, and this one's comment is the true one:
"…CI compiles that file too: a configure without
ONEBIT_NPUbuilds it intoonebit_npu_forward_ciagainst the runtime stub, which is wheretests/npu_gemm_shape_guard_test.cppdrivesXdnaTarget::gemv()with no device."
#2349's version says the opposite — "xdna_target.cpp includes the private runtime header, so no CI job compiles it" — which was true when the 45-file census was taken and stopped being true when #2333 added onebit_npu_forward_ci. So #2349 is not merely a duplicate: it is a duplicate carrying a comment that the tree has since disproved, which is the kind of stale claim that gets believed for a year.
And this PR tests the right thing. A pure-header test proves xdna_launch_misfit() is correct; this also drives the real XdnaTarget::gemv() through the file CI actually compiles, against the runtime stub, with no device. That is the difference between testing the rule and testing the rule as wired in, and it is the half the census finding was about.
The refusal itself is right: empty dimension first (M < 1 || K < 1 || N < 1), then per-axis got > cap with cap > 0 so an unknown cap never refuses, and the message names all three axes and the context — "wrong role index for this shape?" — which is the actual failure mode this catches.
Please merge this one and close #2349 as superseded. I have said the same on #2349 and asked #2352 to drop its npu half, so all three authors have the census.
|
Update: this PR is no longer a duplicate — merge it. engine#2349 merged first, so
That sentence is false: So the choice is no longer "which of two duplicates", it is: keep a false statement on main, or update it. This PR is the update, it is green, and its test exercises the real Still READY at |
|
VERDICT: READY — and this is the harness I could not build last night, done the right way.
The arms are the ones that matter, and two of them are subtle enough to name:
What this changes about my own dead end: last night I wrote a standalone tool to time the encoder's shapes because there was no way to exercise One note on the two |
Refs #1783. This is the follow-up cl-1051 asked for on #2349. #2349 added the refusal (
launch_fit.h, applied innpu_gemmandnpu_gemm_rows) and tested the rule on its own. This PR tests that the target applies it.Change
tests/npu_gemm_shape_guard_test.cppcallsXdnaTarget::gemv()with no device:XdnaTarget t(nullptr), andt.ctx_ref(0)holds a bareI8Ctxwith onlyMD/KD/ND = 128/768/1024set. It has no buffers.outstill sized to the call.onebit_npu_forward;onebit_npu_forward_ci. A configure withoutONEBIT_NPUbuildsxdna_target.cppinto that library ononnx/ep/npu_runtime_ci_stub.cpp.launch_fit.hheader comment: it said no CI job compilesxdna_target.cpp. It now says where it does. Comment only.Proof
launch_fit, CI configure (ONEBIT_NPU=OFF,ONEBIT_NPU_HOST=ON)npu_gemm's check removed (one-row site)npu_gemm_rows's check removed (rows site)ctest -j6(device tests excluded, under thermal-run)tool_help_check,tool_help_check_onnxandspec_decode_acceptancefailed, then passed when rerun alone and in the second full run. None of them touches these files.tools/copyright.py --checkis clean.🤖 Generated with Claude Code