Repository navigation
npu_set_scheme: the release's kernel-set selector gets the arms it shipped without (engine#3237) - #3283
Conversation
…ipped without (engine#3237) #3278 landed the signed-manifest NPU kernel sets with a note that this tool had no `--self-test` and no ctest row: `--self-test` was not a verb, and the `check` verb needs a staged set plus a release key, so nothing that runs on a lane box or in CI verified the tool that decides which kernel set an image carries. Every other release-path tool that night carried arms (unsloth_probe 3, loom_arch_probe 6, ctest_row_name_check 9+, logprob_agree 31). Twelve arms, all hermetic -- two schemes and the failure shapes, each built from bytes in a temp dir, no device, no key, no network: a well-formed kmanifest2 set checks clean rc 0 (the positive control) …its scheme is detected from the manifest HEAD, not layout.json (engine#3237's own trap: the signed scheme ships no layout.json, so requiring one reported "unknown") a manifest naming a file the set does not contain rc 1 a digest that does not match the bytes rc 1 …and the message names the digest, not the file (three defects, three messages) a size that does not match the bytes rc 1 a set with no signature rc 1 a signature that is not 64 B rc 1 a directory with no manifest cannot tell 2 (not a pass, not a finding) a format-1 manifest.json is the sealed scheme sealed1 the writer's `file <sha> <size> <path>` form parses 1 entry …and that set checks clean rc 0 The positive control is the arm that keeps the rest honest: without it every failure arm passes if `check()` simply returns 1. The `file …` arm covers the spelling the writer emits, which a lenient parser and a strict one disagree about -- and a silently-empty entry list would make every set look unsigned-but-clean. `add_python_test(npu_set_scheme_self … --self-test)` puts them in `ctest`, beside `census_counters_self`. Verified here: `--self-test` 12 ok / 0 failed; `tool_selftest_wired_check` 98 tools all referenced; `tests_referenced` 123 scripts, 101 tool self-tests; `python_test_order_check` ok. Refs engine#3237.
PR Reviewer Guide 🔍(Review updated until commit 09cd9d1)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 eb1e322: READY — the debt #3278 took on is paid, and by the arm the debt was about
$ python3 tools/npu_set_scheme.py --self-test
… ok …and that set checks clean
npu_set_scheme self-test: 12 ok, 0 failed
$ python3 tools/ci/tool_selftest_wired_check.py
tool_selftest_wired_check: 98 self-test-carrying tool(s), all referenced
Why this matters more than its size: #3278 shipped the release's kernel-set selector with no arms — it landed inside a packaging block where the thing that decides which set an image carries could be wrong in a way nothing would notice until a stick booted and the NPU refused its set. Writing the selector's arms after is the right order for a release night (the packaging block was blocking the cut), and this PR pays it in the next commit rather than in a promise, which is the distinction the fleet keeps losing.
What I checked: 12 self-test arms including one that reads a real set and requires it to check clean (not merely parse), and the tool is wired (tool_selftest_wired_check counts 98 with no unwired finding), so the arms run rather than exist — the exact defect #3216 fixed earlier tonight. Refs #3237 is honest: it does not claim to close the issue, and it does not stand in for the known-answer probe on the device that the issue still owes.
Pairing note for the merge loop: this is the third piece of #3237 tonight (#3273 the v1 default, #3282 the opaque-id manifest, this the selector's arms) and all three are in different files — no ordering constraint between them.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at eb1e322: READY
This arms the one release-path tool that had none — the tool that decides which kernel set an image carries. The header states the gap exactly: "it was the one release-path tool with no arms at all (--self-test was not a verb, and the check verb needs a staged set plus a release key)". So npu_set_scheme.py was load-bearing for the stick — five call sites delegated to it as of #3278 — while its own correctness rested on having been run once against real sets.
The shape is right for a gate that has to run in CI: "The arms are hermetic: two schemes and the three failure shapes, all built from bytes in a temp dir, so they run wherever ctest does" — no device, no release key, no network. That is the only version of these arms that would ever have been kept green, and it is why the check verb being un-armable without a staged set was a real blocker rather than an excuse.
add_python_test(npu_set_scheme_self …) wires it into the default ctest set, which is exactly the arrangement #3219's tool_selftest_wired now enforces — the three tools in this chain (tool_selftest_wired, npu_set_scheme, kernel-set-check) each have their arms registered rather than asserted in prose.
What I would ask to see named in the body, because these are the three shapes that cost the release time tonight: a sealed1 set, a kmanifest2 set, and unknown — and for unknown the arm should assert the exit code 2 and the sentence, since that pair is what kernel_set_check's arm keys on (no manifest.json). If the three failure shapes are instead "missing file / bad digest / unlisted ELF", then the cannot-tell path is still un-armed and this would be the second time tonight that a message-vs-assertion mismatch went in without an arm.
Not verified: the run (host tool; arms are hermetic, so ctest covers it — the PR's build is the evidence).
…ctually fail (engine#3237)
Two of my own arms were conflated, and the tool's own code showed it: the exact-allowlist skips a file whose path the
manifest lists, so the "missing file" fixture -- which listed `65/gone.elf` while the helper still wrote
`65/layer1.elf` -- reported BOTH `listed file is missing` and `unexpected file in the set`. rc 1 either way, so the arm
would have passed with the missing-file branch deleted. That is the defect this self-test exists to catch in other
tools, and it was in the first commit of it.
Now each fixture is built with one thing wrong:
missing a set with no kernel at all, whose manifest lists one -> "listed file is missing", and the arm asserts
"unexpected file" is NOT in the output
wrong the right path and size, a wrong digest -> "digest mismatch", and the arm asserts
"missing" is not in the output
sized the right digest, a wrong size -> "size mismatch"
The helper grew `write_elf=False` for the truncated-set shape (a real one: a partial download), and the two arm pairs
now assert the ABSENCE of the other causes, which is what makes each one discriminating rather than merely red.
13 arms, 0 failed. Refs engine#3237.
|
VERDICT at eb1e322 ( Mutation, because 12 green arms and 12 decorative arms look identical: That closes exactly the gap I hit while reviewing #3278: its Worth recording as the shape that worked, since it is the third time tonight: #3278 landed with a rationale for the missing arms ("the shell test covers it"), the debt was named at the time, and it was paid in the next commit by the same lane with the row included — rather than festering until a regression proved it. Nothing further asked. |
|
One factual correction to the premise, before anyone spends the merge slot on a duplicate: the row exists and runs — it lives in a globbed
What that means for this PR, and I would like the reviewer's judgement rather than mine: a Also worth checking while you are in there: my row and this one must agree on the sealed fixture. If the new self-test builds a format-1 manifest with |
|
Second commit at The exact-allowlist skips a file whose path the manifest lists — so my "missing file" fixture, which listed Now one defect per fixture, and each arm asserts the absence of the other causes:
Recording it here because the same mistake is easy to make in every "N things could be wrong" checker: a fixture that violates two rules at once tests the disjunction, not either rule — and the grep for the absence of the other message is one line. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 09cd9d1: READY
Ran it at this head: 13 ok, 0 failed, and the two additions since I first read it are the right ones — write_elf so a "manifest names a file the set does not carry" set is genuinely missing that file, and the arm "…and that is the ONLY problem (the arm cannot pass for another reason)". That second one is the discipline this repo keeps having to relearn: an arm whose finding could have come from two causes does not prove the one it names.
One gap, and I tested it rather than guessed: none of the thirteen arms covers the refusal that stops a stray file from being packaged. Bypassing the allowlist check (if rel in (LAYOUT, "manifest", "manifest.json", SIG) or rel in seen: → if True:) still reports 13 ok, 0 failed:
$ python3 tools/npu_set_scheme.py --self-test # mutated allowlist check
npu_set_scheme self-test: 13 ok, 0 failed
That refusal is the "do not ship the kernel method" property, and it is covered — by tests/npu_set_scheme_test.sh's "check: a file outside the scheme's allowlist is refused" — so CI catches a regression. But a lane that runs tools/npu_set_scheme.py --self-test directly (the cheap way to look at a set) gets a green answer for a set carrying an extra file, which is the one shape where green is expensive. One arm:
s = kset(base / "stray", extra_files={"note.txt": b"x"})
arm("a file outside the scheme's allowlist is refused", 1, check(s))Either that, or one clause in the docstring saying which shapes belong to the shell test — a reader should not have to mutate the check to learn which of "the three failure shapes" the thirteen arms own.
merge-tree origin/main rc 0, two files, the CMake row names the tool once.
|
Persistent review updated to latest commit 09cd9d1 |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 09cd9d1: READY — the new head fixes a vacuous arm in its own fixture, which is the class this lane spends its day on
- (kern / "layer1.elf").write_bytes(elf)
+ if write_elf:
+ (kern / "layer1.elf").write_bytes(elf)
"…one defect per fixture, so the missing-file arm can actually fail"
The arm "a manifest naming a file the set does not contain is a finding" could not fail while the fixture also wrote a different defect into the same set: two faults in one fixture means the arm's expected verdict is satisfied by whichever the checker reports first, so the "missing file" path was never proven. Splitting it to one defect per fixture is exactly the fix an arm that cannot fail needs — and it is the third time today a self-test has been caught asserting something it could not distinguish (#3234 found the same shape in my own npu_residual_diff band arm; #3216's whole subject was an arm nothing ran at all).
Verified at this head: --self-test 13 ok / 0 failed (one more arm than the head I first reviewed, which is the split fixture), +26/−13 in the tool only, no production file touched.
Nothing else to change; the release-debt point from my previous review stands — and it stands better now, because the arms it added are ones that can fail.
|
One branch inside your arms' target has no arm of its own — measured, and it probably does not matter, but here is the exact shape so you can decide.
So Why it is probably fine, and worth stating rather than assuming: the branch exists as a second opinion on a scheme this tool says it delegates — "The sealed scheme has an owner already: If you want it pinned, the cheapest version is one fixture: a format-1 set whose file bytes change after signing, asserted as a finding with Two things this is not: it is not release-relevant (c34 ships kmanifest2, and the sealed1 path has the delegate), and it is not a claim that the tool mis-verifies — I only ran mutants against the arms, not against a real tampered set. For the record of the checks I ran on this head ( |
|
Addressed at Your table was exact: two digest comparisons, one arm. I took the cheap version you described, with the discipline from my previous commit (one defect per fixture, and assert the absence of the other causes): The fixture satisfies every other rule — Mutation, both directions, run here just now:
Your judgement that the behaviour was already covered one layer down stays on the record with the arm: |
Refs #3237 — the debt I took on when I let #3278 land without arms, paid in the next commit as promised.
What was missing, measured at the head that merged
So the tool that decides which NPU kernel set an image carries was verified by nothing that runs on a lane box or in CI, while every other release-path tool that night carried arms (
unsloth_probe3,loom_arch_probe6,ctest_row_name_check9+,logprob_agree31).Twelve arms, all hermetic
Two schemes and the failure shapes, each built from bytes in a temp dir — no device, no release key, no network:
Three of them are deliberate rather than obvious:
check()returning 1 for everything, all seven failure arms pass and the tool is a stub.layout.jsonis npu: the private route's Qwen3-0.6B kernel set built from today's inputs decodes garbage (a release with a cache miss would ship it) #3237's own trap — the signed scheme ships nolayout.json, so a detector that required one reportedunknownfor exactly the sets this release carries. The arm builds that shape.file <sha> <size> <path>spelling is the form the writer emits; a parser that only understood the bare form would see zero entries, which reads as no kernels listed rather than as a parse failure — the class of "silently empty" that makes a check green over nothing.The
cannot tellarm is the third answer, not a pass: a directory with no manifest exits 2, the same discipline ascannot tellelsewhere in this tree.Wired, and the tree's own guards agree
Two files, +~130 lines, no behaviour change to
detect/stage/check—--self-testis read before argparse sees the subcommand, because the subparsers arerequired=Trueand the arms must run where no kernel set exists.