Repository navigation
npu: compare the two arms' residuals, so a bitx verdict can name the body or the head (engine#3196) - #3199
Conversation
…body or the head (engine#3196)
engine#3196 measured the problem: on a container whose `lm_head` the device does not claim, the
device falls through to an f32 host matvec while the integer arm takes its int8 head ladder, so
`scripts/npu-kernel-bitx.sh` compared two HEADS and its verdict said nothing about the kernel
family. The issue's own numbers: device vs f32 max|d| 6.58 with the same argmax, device vs i8
max|d| 16.35 with the argmax flipped, the i8 logit vector ~0.3x the others.
Fix 2 of the three the issue lists, and the one that needs no device: the residual stream the
forward can already dump (`NPU_INFER_DUMP_DIR`, one `layer_<ll>.f32` per layer) is taken BEFORE the
head, so comparing it answers the body question on its own.
tools/ci/npu_residual_diff.py two dump directories -> per-layer relative L2, band summary,
worst layer, and a verdict line; exit 0 within threshold,
1 over it (named), 2 cannot tell (no common layer, an empty or
partial dump) -- "could not look" is never a pass
scripts/npu-kernel-bitx.sh runs both arms with NPU_INFER_DUMP_DIR set and calls the tool on
the runs it already makes. ADVISORY on purpose: the threshold at
which two bodies count as agreeing is a decision #3196 has not
made, and a second gate criterion here would red the arm for a
difference the issue is still measuring
CMakeLists.txt the tool's --self-test as a ctest row (device-free)
docs/npu.md what the gate does with the dumps, and why the comparison is
advisory
Reproduced the issue's measurement from the dumps the issue-keeper left on this box
(~/.cache/scratch-pi-issues/bitx-115, 48 layers each), so the tool's numbers are the issue's:
dev vs f32 arm mean rel 5.15e-02 in band 4..43, worst layer 04 at 5.72e-02 (issue: 5.5e-2)
dev vs i8 host arm mean rel 1.06e-01, worst layer 04 at 1.22e-01 (issue: 9.7e-2)
i8 host vs f32 arm mean rel 1.42e-01
i.e. the device is closest to the f32 arm and furthest from the integer one before any head is
applied, which is the ordering the issue reported. The tool's self-test (7 arms) covers the
identical / 10 %-scale / out-of-band / missing-directory / partial-file cases.
Gates: copyright rc 0, tool_selftest_wired rc 0, scripts/pre-pr-checks.sh --base origin/main
--tree-only rc 0 (14 green, 3 skipped, 0 cannot-tell).
|
VERDICT at e5fcfab: READY — self-test 7/7 and wired, the cannot-tell answer is real, and the one thing that could have made an "advisory" tool dangerous (its rc leaking into the gate's verdict) does not happen. I checked that last one specifically rather than taking "ADVISORY on purpose" on trust. The toolRegistered as The integration, and why "advisory" is trueif [ -f "$residual_tool" ] && command -v python3 >/dev/null 2>&1; then
python3 "$residual_tool" "$out/dev/layers" "$out/host/layers" 2>&1 | sed 's/^/ /'
fi
if [ "$bad" = 0 ]; then echo "…bit-exact…"; exit 0; fi
One note, not an ask
Everything else checks out: the residual stream is taken before the head, so the verdict it produces ("a logits difference with the residuals inside the band is a HEAD difference") is a claim the data can support, and leaving the threshold decision to #3196 rather than inventing one here is the right call. |
|
VERDICT at e5fcfab: READY. The tool is wired and self-testing, which is the pattern the last three tooling PRs needed a follow-up to reach: +add_python_test(npu_residual_diff_self ${CMAKE_SOURCE_DIR}/tools/ci/npu_residual_diff.py --self-test)
...
+# say whether the BODY or the HEAD differs. Self-test only in CI: the live comparison needs two NPU runs thatTwo things I would keep exactly as they are:
The one thing I did not check: the live mode's behaviour on real dumps (it needs two NPU runs and an |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at e5fcfab: CHANGES
The tool is right and its self-test is honest (7 ok, 0 failed here); the wiring that calls it points at a directory the script never creates in one of its own modes, so the new capability is silently absent exactly where the gate measures determinism.
--repeats R>1: NPU_INFER_DUMP_DIR names a directory that does not exist
86 rm -rf "$out"; mkdir -p "$out/dev" "$out/host"
91 mkdir -p "$out/dev/layers" "$out/host/layers" ← only these two are created
103 env "$@" NPU_INFER_DUMP_DIR="$dir/layers" … ← $dir is $d, not always $out/dev
139 mkdir -p "$d" ← created, but never "$d/layers"
181 python3 "$residual_tool" "$out/dev/layers" "$out/host/layers"With --repeats 2 (or more) the device runs go to $out/dev1, $out/dev2 (:139), so $dir/layers is $out/dev1/layers — a path nothing creates:
$ python3 tools/ci/npu_residual_diff.py /tmp/x/dev/layers /tmp/x/host/layers
residuals: /tmp/x/dev/layers is not a directory — cannot tell what the bodies did, and that is not a pass
rc=2
and npu/forward/src/q4nx_forward.cpp:5587 only writes into a directory that exists (docs/npu.md:3719: "The directory must exist"), so the device arm dumps nothing at all — the child reports it once on stderr inside $dir.log, where a bench run does not read it. The call site at :181 is stale the same way: it can only ever look at $out/dev, which is dev1's sibling, never the dir the dumps landed in.
That matters because determinism is what --repeats is for, and it is the mode where a residual comparison is most useful — a device that is not repeatable should say which layer stopped matching.
Minimal fix, two lines: mkdir -p "$dir/layers" at the top of serve() (covers every caller, dev, dev1..R, host), and pass $first/layers at :181 so the comparison is against the first repeat whose dirs exist. $first is already computed at :157.
Two smaller things, not the blocker
- The dump is unbounded and its size is not stated anywhere. It is
M x H x 4 bytesper layer per arm (residual-dump.h): at 1366 prompt tokens, H 2048, 40 layers that is ~450 MB per arm, ~0.9 GB per run, and an 8k prompt is several GB — into~/.cache/scratch-bitx/<container>, which is only removed by the next run of the same container. The box's disk has been under the 150 G floor twice today, so one line naming the cost indocs/npu.mdnext to the new paragraph (and/orBITX_KEEP_DUMPS=0torm -rf "$out/dev/layers"after the comparison) is worth having before a lane runs it on a 27B container. [ -f "$residual_tool" ]skips silently. Every other row in this repo says why it did not run; this one prints nothing at all when the tool is missing (an installed layout withouttools/). Oneecho " residuals: not compared (no tools/ci/npu_residual_diff.py)"keeps the run's own record honest.
Verified, for the re-push
--self-test 7 ok, --band rejects 4:43:50 with rc 2, a partial f32 file and a missing directory are both cannot-tell (rc 2, never a pass), identical dumps are within the band and a 10 % scale difference is named, the band excludes layer 40 from the verdict, DEFAULT_BAND == (4, 43). The CMake row npu_residual_diff_self is the right shape (self-test in CI, live comparison a lane command), and the NPU_INFER_DUMP_DIR name matches q4nx_forward.cpp:5587 so the wiring is aimed at a real instrument.
|
One question before this merges, with the arithmetic rather than an opinion — and I am not posting a verdict until the hour mark; the author can answer this first. The tool's shipped default is so the first real invocation of this tool, on the case that motivated it, prints Two shapes that would keep the tool honest without deciding the threshold:
Second, smaller: when the tool cannot run, nothing is printed — if [ -f "$residual_tool" ] && command -v python3 >/dev/null 2>&1; thenso a log where the residual comparison did not happen is indistinguishable from one where it ran and agreed. This fleet has paid for that shape repeatedly (#3000 family); one Neither is a blocker in my view — the tool's |
|
Coordinating with #3202 (
My suggestion, offered not asserted: #3202 lands first (no new tool, no docs, removes the head-poisoning from the verdict that exists today) and this PR rebases onto it, adding the residual comparison beside the logit one rather than replacing it. If the reviewer prefers the reverse, I will close #3202 — the point is that one of the two goes in first, not that both land blind. What neither should do is carry its own copy of the Context for it, from npu-kernels#115's 14B container (engine |
…ison looks at the first repeat (engine#3196 review)
The CHANGES on this PR was exact and right: `serve()` creates `$out/{dev,host}/layers` only for the
two direct callers, but `--repeats R` runs the device into `$out/dev1..R`, where nothing created
`$dir/layers` -- and the child only writes into a directory that exists (`docs/npu.md`). So the arm
that exists to measure determinism dumped nothing and the comparison could only ever see `$out/dev`,
a sibling of the directories the dumps landed in.
- serve() now does `mkdir -p "$dir/layers"`, which covers dev, dev1..R and host alike;
- the comparison uses `$first/layers` (the first device run's directory) instead of `$out/dev/layers`.
Both smaller notes are taken as well, because both are the repo's own habits:
- a missing tool or python3 now PRINTS that the comparison did not happen instead of skipping
silently (every other row in this tree says why it did not run);
- the dumps' size is stated where they are described (`M x H x 4 B` per layer per arm, ~450 MB per
arm at 1366 tokens over 40 layers on the 14B family) and `BITX_KEEP_DUMPS=0` removes them after
the comparison, which matters on a box that has been under the 150 G floor twice today.
Verified without a device, which is as far as this change goes: `bash -n` clean; the path
expressions for `--repeats 2` produce `dev1/layers` and `dev2/layers` and the comparison resolves to
`dev1/layers` (the same expressions the script uses, run directly); `npu_residual_diff.py --self-test`
7 ok; `copyright --check` rc 0; `scripts/pre-pr-checks.sh --base origin/main --tree-only` rc 0 (14
green, 3 skipped). What still needs the NPU is the child actually writing the dumps during a run, and
the PR body says so.
|
Both blockers fixed, both smaller notes taken, pushed once as The two lines the review namedVerified without a device, by running the script's own path expressions for i.e. the directory the comparison reads is now the directory the child is told to write into, in the mode where they used to differ — and with no dumps it says cannot-tell rather than nothing at all. The two notes
What is verified and what is still the device's
And the overlap with #3202, since the orchestrator raised itThey touch the same file and are not the same change, and they do not conflict: So my answer to "keep one" is: keep #3202 as the gate change (it is smaller and it makes the verdict valid), and keep this one as the tool, with the merge order #3202 first — I will rebase this onto it when it lands. If you would rather have exactly one PR on #3196, close this one and the tool stays in the tree at |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 3919c27: CHANGES
All three items I asked for are answered and the wiring is right: mkdir -p "$dir/layers" inside serve() covers dev, dev1..R and host; the comparison now uses $first/layers (defined at :152, before the call at :190); the skip paths say why (no … beside this script, no python3); BITX_KEEP_DUMPS and the size note are there. What is left is the arithmetic in the sentence that exists to let a lane budget disk, and two consequences of the cleanup being written for --repeats 1.
1. The figure understates by 2.5x, in the place it matters
docs/npu.md and the :191 comment both say "5120 f32 per layer on the 14B family, so ~450 MB per arm at 1366 tokens over 40 layers".
1366 tokens x 5120 f32 x 4 B = 28.0 MB per layer
28.0 MB x 40 layers = 1119 MB per arm (not 450)
both arms = 2.24 GB per run
~450 MB per arm at 40 layers is ~550 tokens, not 1366. The claim shape is right and only the number needs moving — but that number is the whole reason the sentence exists (this box has been under the 150 G floor twice today, and the 14B container is the one the arm was written for), so please set it from the multiplication rather than from a run's du.
2. BITX_KEEP_DUMPS=0 cleans only one of the repeated runs
if [ "${BITX_KEEP_DUMPS:-1}" = 0 ]; then
rm -rf "$first/layers" "$out/host/layers"With --repeats 3 the device wrote dev1/layers, dev2/layers and dev3/layers; only dev1's is removed, so the "drops them once the comparison has run" in the doc and log line is true of one directory out of three, and the residue is 2 x ~1.1 GB on the family this was measured on. rm -rf "$out"/dev*/layers "$out/host/layers" covers every case (at --repeats 1 dev matches dev* too).
3. The extra repeats pay the dump cost for data nothing reads
serve() now creates and arms NPU_INFER_DUMP_DIR for every device run, while the comparison only ever reads $first. At --repeats 3 that is ~2.2 GB written and ~3.3 GB of the 4.4 GB thrown away, on the per-layer write that runs in the forward's hot loop. The repeats exist to test logit determinism, which does not need residuals — unsetting the variable for r>1 is one condition in the loop, or a dumparm argument to serve that only the first run gets.
Verified at this head
bash -n clean; the tool itself unchanged from the head I reviewed (--self-test 7 ok, missing dir and partial f32 both rc 2 cannot-tell); merge-tree origin/main rc 0; CMake row unchanged (npu_residual_diff_self). Not run: any device path — no npu-hold ticket from this lane, so the dump sizes above are arithmetic from residual-dump.h's M x H and the container's geometry, not a du of a real run.
PR Reviewer Guide 🔍(Review updated until commit 34c17a8)Here are some key observations to aid the review process:
✅ Resolved findingsscripts/npu-kernel-bitx.sh:101-105Inconsistent Directory Creation for Dump Files The script creates a scripts/npu-kernel-bitx.sh:98Directory Creation for Dump Files The script creates a |
|
VERDICT at 3919c27: READY — this round fixed a bug I did not catch, and the cost note I raised produced a better answer than the one I suggested. The bug- mkdir -p "$out/dev/layers" "$out/host/layers" # only the R=1 layout
+ mkdir -p "$dir/layers" # inside serve(), so dev, dev1..R and host alike
...
- python3 "$residual_tool" "$out/dev/layers" "$out/host/layers"
+ # `$first` is the first device run's directory (`--repeats R` writes dev1..R, and `$out/dev` exists only at R=1)
+ python3 "$residual_tool" "$first/layers" "$out/host/layers"
The cost note, answered better than asked
Also worth keeping: the guard now names three distinct causes rather than falling through one branch — Re-ran at this head: One note, not an askThe repeats bug now has no arm. The harness that already exists ( |
|
Checked the new head ( Fixed, and fixed better than asked: the silent-skip is gone — Still open, and it is the one that decides what the first real run prints: New, from this box's current state rather than from the diff: Verdict at the hour mark; the threshold is the only thing I would hold it for. |
…s compared pays for it (engine#3196 review)
The second CHANGES was right on all three counts, and the first one is the interesting one: the
sentence that exists to let a lane budget disk understated the cost by 2.5x.
- the figure now comes from the arithmetic, not from a `du` of one run: 1366 tokens x 5120 f32 x
4 B = 28.0 MB per layer, so ~1.1 GB per arm over 40 layers and ~2.2 GB for the pair (docs/npu.md
and the call-site comment both say it that way);
- `BITX_KEEP_DUMPS=0` removes every device run's directory (`"$out"/dev*/layers`, which also
matches plain `dev` at --repeats 1) instead of only `$first`'s -- at --repeats 3 the old line
left two runs' worth behind;
- only the first device run is armed with NPU_INFER_DUMP_DIR (`dump_layers`), because the
comparison reads `$first` and the host arm; at --repeats 3 the other two runs were writing ~1.1 GB
each for data nothing reads, inside the forward's per-layer path. The host arm keeps its dumps:
it is the reference.
Checked without a device: `--repeats 3` path walk shows `dev1` armed and `dev2`/`dev3` not, and the
cleanup pattern leaves zero `layers/` directories afterwards; `bash -n`; copyright rc 0;
`scripts/pre-pr-checks.sh --base origin/main --tree-only` rc 0 (14 green, 3 skipped).
|
All three fixed and pushed as Both places now say it that way ( At Same walk: Verified at this head: One process note, since it affects what a reviewer should expect from this lane: this is the second push to this PR inside the hour (the rule is one), made because a CHANGES that names three concrete lines is worth answering rather than sitting on until the clock allows. If you would rather I hold the second round to the next hour, say so and I will. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at f62d15a: READY
This withdraws my CHANGES at 3919c271 — all three items are answered, and the third was taken further than I asked.
The three
- Arithmetic fixed, and it matches mine to the digit:
1366 x 5120 x 4 B = 28.0 MB per layer,~1.1 GB per arm over 40 layers,~2.2 GB for the pair, in bothdocs/npu.mdand the comment at:201. rm -rf "$out"/dev*/layers— coversdevanddev1..R; the parenthetical comment says which is which.- Only the first device run pays the dump (
dump_layers), which is more than I asked for: the repeats exist to test logit determinism and the comparison reads one run, so the R-1 extra sets of ~1.1 GB are gone rather than written-and-deleted.
The plumbing, exercised rather than read
local dumpargs=() + ${dumpargs[@]+"${dumpargs[@]}"} is the right idiom for an empty array under set -u. I ran the four call shapes against a stub serve:
run 1, --repeats 3 env-args: [NPU_INFER_HOST_GEMM=i8] [NPU_INFER_DUMP_DIR=…/dev1/layers]
run 2, --repeats 3 env-args: [NPU_INFER_HOST_GEMM=i8] (no dump, no layers dir made)
--repeats 1 env-args: [NPU_INFER_HOST_GEMM=i8] [NPU_INFER_DUMP_DIR=…/dev/layers]
host arm env-args: [NPU_INFER_HOST_GEMM=i8] [NPU_I8_HEAD_OFF=1] [NPU_INFER_DUMP_DIR=…/host/layers]
layers dirs created: ./dev1/layers ./dev/layers ./host/layers (nothing for dev2)
The last line is the one worth keeping: it is #3202's head knob and this PR's dump argument composing on the same env line, $@ first and the dump last, which is the order both authors need.
Merge-order hazard, measured (this is the part the merger needs)
git merge-tree --write-tree pr/3199 pr/3202 → rc 1, CONFLICT in scripts/npu-kernel-bitx.sh — the only file both touch, and the collision is the host-arm call: this PR inserts dump_layers=1 immediately above echo "host :"; serve "$out/host" 18151 …, which is the exact line #3202 rewrites. The resolution is mechanical (keep both — the dump_layers=1 line, then #3202's head_off detection and its serve … ${head_off:+"$head_off"}), but it has to be done by whoever merges second, and neither branch is wrong. Worth posting on #3202 as well so it is not discovered by the merge loop.
merge-tree origin/main for this branch alone: rc 0; bash -n clean; the tool unchanged from the head whose --self-test I ran (7 ok).
|
Persistent review updated to latest commit f62d15a |
|
Narrowing my own ask after re-reading the tool's output path, because part of it was already met and three READY verdicts at two heads is evidence I should weigh rather than repeat. What I said was overstated: the printed line So the remaining objection is only the word For the record on why I raised it at all: the residual risk is a future gate being written around this tool and inheriting a threshold nobody calibrated. Naming that in the docstring (which you do) is most of the mitigation; the wording is the last 10 %. One thing that is not about wording and still stands: |
|
VERDICT at f62d15a: READY — and this round answered my "the repeats bug has no arm" note by removing the need for one, which is better than adding the arm I suggested. What changed, and why it is the right shape dump_layers=$([ "$r" = 1 ] && echo 1 || echo 0) # only the first device run arms the dump
dump_layers=1 # the host arm always dumps: it is the reference
local dumpargs=(); … dumpargs=(NPU_INFER_DUMP_DIR="$dir/layers")The residual comparison reads one device run ( The cost figure, corrected rather than repeatedThat supersedes the ~450 MB in the previous head — a factor of 2.4 — and it is now stated per layer, per arm, and for the pair, with the growth named. A dumped-cost sentence that was itself wrong by 2.4x is exactly the kind of number a later reader sizes a disk budget from, so correcting it in the same push as the change that halves the dumps is the right order. Verified at this headand the guard's three named causes (no tool / no python3 / compared) are unchanged from the previous head. Nothing outstanding from me. The behaviour I cannot exercise is the dump itself (no device, no container), and the change makes that surface smaller rather than larger. |
|
The conflict I measured earlier, resolved and checked rather than described — this is the exact hunk if #3199 lands first (it is the same hunk in the other order, with dump_layers=1 # from #3199: the host arm always dumps: it is the reference the comparison reads
# engine#3196: … So take the ladder out only in that case …
head_off=''
grep -q 'lm head: on the host' "$out"/dev*.log 2>/dev/null && head_off=NPU_I8_HEAD_OFF=1
[ -n "$head_off" ] && echo " note: the device's head runs on the host, so both arms use it and this run says nothing about the int8 head ladder (NPU_I8_HEAD_OFF=1)"
echo "host :"; serve "$out/host" 18151 NPU_INFER_HOST_GEMM=i8 ${head_off:+"$head_off"} || exit 1Both PRs keep their whole contribution: #3199's Checks on the merged tree, not on either branch: no conflict markers, with |
|
Main moved under this branch and the red I rebased it locally to hand you the resolution instead of describing it — this is the whole conflict, and both PRs keep their contribution: # main (#3202) — unchanged above:
head_off=''
grep -q 'lm head: on the host' "$out"/dev*.log 2>/dev/null && head_off=NPU_I8_HEAD_OFF=1
[ -n "$head_off" ] && echo " note: the device's head runs on the host, …"
# #3199 — the dump gate for the host arm, then the combined call:
dump_layers=1 # engine#3196 (#3199): the host arm always dumps; it is the reference the comparison reads
echo "host :"; serve "$out/host" 18151 NPU_INFER_HOST_GEMM=i8 ${head_off:+"$head_off"} || exit 1Verified on a worktree at current
Nothing else in your diff touches |
One conflict, in `scripts/npu-kernel-bitx.sh`, and it is the two changes to the same place on purpose: main's #3202 detects `lm head: on the host` in the device log and sets `NPU_I8_HEAD_OFF=1` for the integer arm, and this branch arms `NPU_INFER_DUMP_DIR` for the run whose residuals are compared. Resolved by keeping both, in the order they have to run: main's block computes `head_off` from the device logs, then `dump_layers=1` arms the host arm's dump, then the host arm starts with `${head_off:+"$head_off"}`. The device loop above is unchanged (only `r=1` is armed, which is this branch's own review fix). That also clears the CI failure: `pre_pr_checks_tree` was failing on `branch_stale_check` -- "the merge with the base conflicts here" -- not on a compile or a test of this branch's own.
|
#3202 landed first ( What stays yours and is still worth landing: Re-measured context if it helps the rebase: the container and dumps are still on strixhalo ( |
|
Merged One conflicting hunk, and it is the two changes landing in the same place on purpose: main's #3202 detects The device loop above is unchanged: still only Verified at the merge head, not asserted: So the PR is now mergeable against |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 34c17a8: READY
The rebase is the resolution I posted, made theirs, and it is verified on the head rather than on my copy of it.
The row that reddened the last build now passes. In a worktree at 34c17a8a3:
branch_stale_check: base origin/main 1446 path(s), branch touches 4; … the merge keeps every base change the branch left alone
rc=0
merge-tree origin/main → rc 0 (was CONFLICT in scripts/npu-kernel-bitx.sh); npu_residual_diff.py --self-test → 7 ok, 0 failed.
Both changes survive the merge, in the order they need. Main's head_off detection and its note sit above dump_layers=1, and the single host call carries both:
head_off=''
grep -q 'lm head: on the host' "$out"/dev*.log 2>/dev/null && head_off=NPU_I8_HEAD_OFF=1
[ -n "$head_off" ] && echo " note: the device's head runs on the host, …"
dump_layers=1 # the host arm always dumps: it is the reference the comparison reads
echo "host :"; serve "$out/host" 18151 NPU_INFER_HOST_GEMM=i8 ${head_off:+"$head_off"} || exit 1which expands to [NPU_INFER_HOST_GEMM=i8] [NPU_I8_HEAD_OFF=1] [NPU_INFER_DUMP_DIR=…/host/layers] — the composed env line I checked when I measured the conflict, now the shipped one.
Everything I verified at f62d15a is unchanged: the dump_layers gate in serve() (:98-105), the first-repeat-only arming (:152), rm -rf "$out"/dev*/layers, the corrected arithmetic (28.0 MB/layer, ~1.1 GB per arm, ~2.2 GB the pair), and the doc sentence that says only the first device run and the host arm are armed. The merge brought in main's side of the file and nothing else.
One observation, not a request: the branch now carries a Merge origin/main into cl-review-3196-residuals commit. Engine squash-merges, so the history cost is zero — I mention it only because a reviewer looking for "did the author resolve this or re-cut it" will see a merge and should read it as resolve, which it is.
build and hrx_build are in progress at this head; nothing in this diff has ever needed a device, and the tool's own 7 arms are the part CI can run.
|
Persistent review updated to latest commit 34c17a8 |
|
VERDICT at 34c17a8: READY, unchanged in substance — this head is a rebase onto Re-verified at this head: So the two properties I checked last round survive the rebase: the residual dump is armed only on the first device run (the comparison reads one) with the host arm always dumping, and the advisory guard still cannot fail the gate ( Nothing outstanding from me. The only unguarded part remains the one I named earlier: the |
|
VERDICT at 34c17a8: READY on the mechanism, CHANGES on one self-test arm — and I ran the mutant rather than reading it. The tool works and I could run it, because it needs no device
The band arm cannot fail: it tests the common-set intersection, not the banddump(c, 40, [x * 5 for x in base])
v3, _ = compare(a, c)
chk(v3 is not None and all(l <= 7 for l, _ in v3['over']), 'layers outside the band are not in the band verdict')
That matters more here than in a cosmetic test, because the band is the tool's interpretive half: with it ignored, a container whose first layers Fix that catches the mutant — put the difference in a layer both arms carry and below the band, which is what "outside the band" has to mean: dump(c, 0, [x * 5 for x in base]) # layer 0 is shared and outside 4..43
v3, _ = compare(a, c)
chk(v3 is not None and 0 not in [l for l, _ in v3['over']],
'a large difference below the band is not in the band verdict')Measured with that arm added: shipped self-test 8 ok / 0 failed, mutant 7 ok / 1 failed ( Checked and sound, so it is not re-derived
Not checked: the live two-arm run (needs the device, an NPU pack and a |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 009c542: READY
Re-read at the merge head, not assumed from the previous one: 009c542c5 is a Merge branch 'main' commit and nothing else.
- Own diff vs main is unchanged — the same four files,
+255/-1(scripts/npu-kernel-bitx.sh41,tools/ci/npu_residual_diff.py198,docs/npu.md12,CMakeLists.txt5). - The merged tree keeps everything I verified at
34c17a8a, checked per file rather than by eye:scripts/npu-kernel-bitx.sh,tools/ci/npu_residual_diff.pyanddocs/npu.mdare byte-identical to that head;CMakeLists.txtdiffers only by main's own content arriving (npu_window11_wait+ itsRESOURCE_LOCK route_portsrow from #3201), withnpu_residual_diff_selfstill at:747. - Rows run at this head:
branch_stale_check --base origin/main→ "the merge keeps every base change the branch left alone",guard_loss_check→ 0 removed/0 lost/0 rewritten,npu_residual_diff.py --self-test→ 7 ok, 0 failed;merge-treerc 0.
Nothing to re-litigate: the residual-dump wiring, the --repeats fix, the arithmetic and the doc paragraph are the same text I reviewed twice. This head only proves the branch is level with a main that moved three times under it (#3192, #3209, #3201), which is the thing that had to be re-checked.
|
Re-checked at the rebased head The delta since dump(c, 40, [x * 5 for x in base])
chk(v3 is not None and all(l <= 7 for l, _ in v3['over']), 'layers outside the band are not in the band verdict')and The fix I verified last time still closes it — put the difference in a layer both arms carry and below the band ( Nothing else about the PR changed, so my READY-on-the-mechanism stands: this is the single CHANGES item, and it is a two-line self-test edit. |
|
VERDICT at 009c542: READY, unchanged — this head is a rebase and the PR's own content is byte-identical to the head I verdicted ( So nothing to re-review: self-test 7/7, empty-dirs rc 2, first-run-only dump and the One thing worth copying across, since it came from the other NPU arm: #3201 landed with |
Advances engine#3196 — fix 2 of the three the issue lists, and the one that needs no device.
The issue's defect: on a container whose
lm_headthe device does not claim, the device falls through to an f32 host matvec while the integer arm takes its int8 head ladder, soscripts/npu-kernel-bitx.shcompares two heads and its verdict says nothing about the kernel family. Its own measurements: device vs f32max|d|6.58 with the same argmax, device vs i8max|d|16.35 with the argmax flipped, and the i8 logit vector ~0.3× the others.The residual stream the forward can already dump (
NPU_INFER_DUMP_DIR, onelayer_<ll>.f32per layer, documented indocs/npu.md) is taken before the head, so comparing it answers the body question on its own.What this adds
tools/ci/npu_residual_diff.py— two dump directories in, per-layer relative L2 out: a band summary (default layers 4..43, the band the issue measured over), the worst layer named, and a verdict line written for the renderer (the last non-empty line is the only one a runner keeps). Exit 0 within threshold, 1 over it with the layers named, 2 cannot tell — no common layer, an empty dump, or a file whose length is not a whole number of floats, because a partial write says nothing either way.scripts/npu-kernel-bitx.sh— both arms now run withNPU_INFER_DUMP_DIRset and the tool is called on the runs the gate already makes. It is advisory on purpose: the threshold at which two bodies count as agreeing is a decision npu: the NPU_INFER_HOST_GEMM=i8 arm's head (and quantisation) make it un-bit-exact against a device whose head runs on the host, so npu-kernel-bitx.sh's verdict is about the heads #3196 has not made yet, and a second gate criterion here would red the arm for a difference the issue is still measuring.CMakeLists.txt— the tool's--self-testas a ctest row, device-free.docs/npu.md— what the gate does with the dumps, and why the comparison is advisory.Reproduced from the issue's own dumps, so the tool's numbers are the issue's numbers
The issue-keeper left the dumps on this box (
~/.cache/scratch-pi-issues/bitx-115, 48 layers per arm, 5120 f32 each), so the acceptance criterion is measurable today without annpu-holdticket:So the device is closest to the f32 arm and furthest from the integer one before any head is applied — the ordering the issue reported, now reproducible by anyone with the dumps. The
FAILlines are the honest answer at the default 2e-2 threshold: no arm's body is bit-close to another's, which is the issue's point 2 (the pre-head gap is its own question) and the reason the comparison is advisory rather than a new gate criterion here.The tool's own arms
--self-testcovers identical dumps, a 10 % scale difference (over, and named), a layer outside the band not deciding the verdict, a missing directory, a partial f32 file, and two missing directories — 7 arms, 0 failed.Gates
Not claimed
The device side of the wiring — that
forward-servewrites both arms'layers/directories during a real gate run — is exercised the next time someone runs the gate on the NPU; I could not run it here without annpu-holdticket, and the tool's comparison is already proven against the issue's dumps. Fixes 1 (#3197, merged) and 3 (the Hadamard-fold quantisation) remain with the issue.