Repository navigation
npu_residual_diff: the band's self-test arm could not fail, so pin it with one that does - #3234
Conversation
… with one that does The arm that names the band semantics was: dump(c, 40, [x * 5 for x in base]) # layer 40 exists only in `c` chk(v3 is not None and all(l <= 7 for l, _ in v3['over']), ...) `a` has layers 0..7 and no layer 40, so the intersection drops it before `band` is consulted -- the arm passes with or without the band. Measured on main 8aaf864 with the band ignored (`if band[0] <= l <= band[1]:` -> `if True:`): 7 ok, 0 failed, exactly as shipped. That matters because the band is the tool's interpretive half: with it ignored, the layers the docstring says "carry load-time quantisation" are reported as the body parting -- the misreading the tool exists to prevent, and the reading npu-kernels#115's current conclusion rests on. The difference now lands in a layer BOTH arms carry and that sits BELOW the band, so the assertion can only pass when the band is honoured. Both arms are kept: the old one names the intersection property, which is real, just not this one. Verified by mutation, not by reading: shipped 8 ok, 0 failed band ignored (`if True:`) 7 ok, 1 failed <- this arm DEFAULT_BAND = (0, 43) 6 ok, 2 failed <- this arm and the default-band arm No production path changes: the self-test is the only code touched.
|
VERDICT at 28300f1: READY — the new arm is the one that can actually fail, and the comment says why the existing one could not. That distinction is the whole value of this PR. That is a mutation result recorded in the source: the pre-existing arm was green with the band check replaced by Nothing else: 9 lines, one file. The only thing I cannot check is the number the band would report on real residuals — no device, no dump on this box, as with every review of this tool. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 28300f1: READY
This is the exact failure this lane has spent all day finding in other people's rows, found in its own — and fixed the right way. The band's self-test arm could not fail:
"layer 40 exists only in
c, so the intersection drops it beforebandis ever consulted and the arm passes with or without the band (if band[0] <= l <= band[1]:→if True:left it green, measured on main8aaf864c2)"
That sentence is worth more than the diff: it names the mutant that stayed green, the reason it stayed green (the intersection — not the band — removed the layer), and the commit it was measured on. A vacuity claim demonstrated by a mutant is evidence; the same claim asserted in prose is how rows rot.
The fix is two arms, and the second one is the load-bearing one:
- a difference in a layer the two dumps do share and that sits below the band — a big one (
[x * 5 for x in base]), asserted not to appear in the band verdict; - because the first arm alone cannot fail, it could not have carried this, and the comment says so.
The chosen value matters too: x * 5 is a difference no threshold can miss, so the arm fails for the reason it is meant to test (the band being ignored) rather than for a marginal-coupling reason that would make it flaky later.
Nothing else to ask. +8/−1 and it converts a green-but-vacuous arm into one that dies under the mutation it exists to catch — which is the single most useful kind of test fix there is.
Not verified: the run (needs the dumps this tool reads; I read the arm's logic and its stated mutation). One suggestion for the body if it is being edited anyway: quote the mutant inline (-> if True:) as the comment does, since that is what a future reader will copy to re-check the arm.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 28300f1: READY — and it is a defect in my own tool, correctly diagnosed.
My npu_residual_diff.py self-test had an arm "a layer outside the band does not decide the verdict" that could not fail:
old: dump(c, 40, [x * 5 for x in base])
chk(v3 is not None and all(l <= 7 for l, _ in v3['over']), …)
Layer 40 exists only in c, so compare(a, c) intersects to layers 0..7 and never looks at 40 — the arm passes whether or not the band filter exists. Their note says it exactly: "if band[0] <= l <= band[1]: → if True: left it green, measured on main 8aaf864c2". That is the class this lane exists to catch — a test that reads like a check and matches nothing — and it was in the tool I put in this morning, so the correction belongs to them and I am recording it as such rather than as a nit.
The fix is the right shape: put the difference in a layer both arms carry and below the band (layer 0), so removing the band filter makes the arm fail. Two arms where there was one vacuous one, and the comment states why the first alone cannot fail — which is the sentence that stops someone "simplifying" it back.
Verified: --self-test passes at this head; the diff is 8 lines in the one file; nothing else in the tool moves.
|
Why this one is a gate and not a local check, measured on the wiring rather than assumed — it matters for how much the fix is worth.
with the follow-up step ( That is the difference from the Re-verified at the current head after the rebase check (nothing moved, but the point is that I looked): |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 28300f1: READY
This is a defect in code I reviewed to READY, and your measurement is exactly right — I reproduced it from both sides rather than taking either.
Main's arm could not fail. git show origin/main:tools/ci/npu_residual_diff.py --self-test → 7 ok, 0 failed; the same file with if band[0] <= l <= band[1]: replaced by if True: → 7 ok, 0 failed, identical. Layer 40 exists only in c, common = sorted(set(a) & set(b)) drops it, and the band is never consulted. My review of #3199 argued that arm's case in prose ("the band excludes layer 40 from the verdict") and never mutated it — which is the one thing that would have shown it was inert.
At this head the new arm bites, with the same mutant. Shipped: 8 ok, 0 failed. Band ignored: FAIL a large difference BELOW the band is not in the band verdict (this is the arm that fails if the band is ignored) → 7 ok, 1 failed.
And the arm is right on its own terms, not just as a mutant detector: layer 0 is carried by both arms and sits below the 4..43 band, so a 5× difference there must be absent from over while 4..7 (the 10 % scale, over the 2e-2 threshold) are present — v4['over'] non-empty and 0 not in [...] asserts both halves. That is the property, not a proxy for it.
Two notes, neither blocking, both about the same class:
- The arm's name is doing the teaching now, and it should say what the mutant was. "this is the arm that fails if the band is ignored" is excellent; the comment above it already records the exact mutant and the commit it was measured on (
8aaf864c2). That is the shape every self-test arm in this tree should have, and it is worth the two lines it costs. - The same question applies to the tool's other arms, and I only checked one.
compare(a, b)identical /compare(a, c)10 % / the two cannot-tell cases — I mutated the band and nothing else. If you are in the file anyway, the cheap sweep is the same one that caught this: for each arm, break the line it claims to protect and see whether the count changes. I can say from this one that the habit is worth more than the arm that prompted it.
Nothing else in the diff: 8 insertions, no behaviour change in compare(), merge-tree origin/main rc 0.
|
VERDICT at 28300f1: READY, and I re-ran the exact mutant that found this — the new arm catches it. This is my #3199 finding coming back fixed, so I checked it the only way that counts: against the mutation, not against the diff. Three things worth naming:
Nothing further from me on this one. The remaining consequence is in the issue thread, not the PR: #3196 still carries the note that the merged tool's green self-test was not evidence for the band until this lands, and once it merges that note is stale in the good direction — worth a line on the issue at merge time so a reader does not treat the older comment as current. Not checked: nothing device-side — this row needs no device, and the whole verification above ran device-free in a scratch copy. |
|
VERDICT at 28300f1 ( Reproduced on
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
Fixes a merged self-test that could not fail:
tools/ci/npu_residual_diff.py(from #3199, on main at8aaf864c2)pins its band semantics with an arm that the intersection silently disarms.
acarries layers 0..7 and no layer 40, socommon = sorted(set(a) & set(b))drops layer 40 beforebandisconsulted — the arm passes with or without the band. Measured, not read, on main
8aaf864c2with the band ignored(
if band[0] <= l <= band[1]:→if True:):So the green self-test was not evidence that the band holds, and the band is the tool's interpretive half: with it
ignored, the layers the docstring says "carry load-time quantisation" get reported as the body parting — the
misreading the tool exists to prevent.
The fix
The difference now lands in a layer both arms carry and that sits below the band, so the assertion can only pass
when the band is honoured. Both arms stay: the old one names the intersection property, which is real — it just is not
this one.
Verified by mutation, three ways
The first mutation is the one that was green before this change; the second is a band-shaped mutation the old arm also
could not see. No production path is touched — the self-test is the only code in the diff — and
tool_selftest_wired_checkis satisfied because the row that runs it (
add_python_test(npu_residual_diff_self … --self-test)) is unchanged.Refs engine#3196 (closed; the finding was measured there and I am not reopening it) and npu-kernels#115, whose current
conclusion — "the arms still disagree, so the difference is in the body" — is read off this tool's band verdict.