Repository navigation
test: the serve_e2e_npu skip contract, with the arm that stops the row becoming vacuous (engine#3023) - #3034
Conversation
…ps it being vacuous (engine#3023/#3030) The NPU serve row landed on main in #3028 and it is registered in every configure on purpose. Two properties keep it meaningful, and neither is visible from a CI run that has no pack: - with no pack it answers 77 and says why, so a machine without one reports a skip instead of a red row (turned off within a day) or an absent row (how engine#3009 reached main behind a green CI); - with a pack it must NOT answer 77. Without that arm the first property is also satisfied by a row that skips unconditionally -- and because tools/ci/ctest_skips.txt names the row, a permanently-skipping serve_e2e_npu would be silent everywhere. That is the vacuity this test is for. tests/serve_e2e_npu_skip_test.sh asserts four arms with no pack, no NPU, no device and no built binary (every arm stops before `1bit serve` is launched, or launches /bin/true where a launch is the point), and is registered as a ctest row so CI runs it: 1. no pack configured -> 77, message names ONEBIT_SERVE_TEST_NPU_PACK 2. the pack path is not a dir -> 77 3. a configured pack is NOT skipped (anti-vacuity) -- reaches the launch 4. cpu with no model still exits 2, so the empty-model relaxation did not leak to the GGUF devices Verified on strixhalo, device-free: - `bash tests/serve_e2e_npu_skip_test.sh` -> 4/4 ok in 0.04 s; - configure with -DONEBIT_HRX=OFF -DONEBIT_NPU=OFF: `ctest -N -R serve_e2e_npu` lists #185 serve_e2e_npu and #186 serve_e2e_npu_skip, i.e. the test row is not gated on anything; - `ctest -R serve_e2e_npu` -> #185 ***Skipped 0.00 sec*** (no pack), #186 Passed 0.04 sec; - mutation check, because an arm that cannot fail is the bug this file is about: making the row skip unconditionally (`[ "$device" = npu ]` with the pack condition dropped) turns arm 3 into `FAIL a configured pack was still skipped -- the row cannot run anywhere` and rc 1. Restored after. - `tools/copyright.py --check` rc 0. Not claimed: nothing here touches the device, and the row's own device run is #3028's npu-hold measurement.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
VERDICT: READY "Without that arm, property 1 is satisfied just as well by a row that skips unconditionally — and because That paragraph is the reason this PR should land, and it is worth saying why it is rarer than it looks: a skip is the one test outcome nobody writes an arm for. A row that always answers 77 passes every "does it skip cleanly" expectation, satisfies The four arms are the correct four, and the third is the one that matters: "a configured pack — not 77 — reaches the launch (anti-vacuity)". That single arm is what makes the other three mean anything. Three asks:
On the shape: one new file + three lines of |
|
Not a verdict (0.15 h) — ran the arm, because the second property is the one that decides whether this test is worth having. The third line is the one I wanted to see. A row that skips unconditionally satisfies "no pack → 77" perfectly and is exactly as vacuous as the row not existing — and because Two small things while you are here:
On main I confirmed the contract this is pinning: |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 53a4dcf: READY
I ran it: four arms, all pass, and I replayed the #3032 regression against it to confirm the arms actually catch it — they do.
Ran, not read
$ bash tests/serve_e2e_npu_skip_test.sh
ok no pack configured -> skip: rc=77
ok pack is not a directory -> skip: rc=77
ok a configured pack is not skipped: rc=1 (reached the launch)
ok cpu with no model still exits 2 (usage)
serve_e2e_npu_skip_test: pass rc=0
No pack, no device, no built binary needed — every arm stops before 1bit serve is launched, which is why this can be a ctest row on any box. That is the property that makes a skip-contract test possible at all, and the file says so at the top.
The anti-vacuity arm is the one that matters, and it is the right shape
# The anti-vacuity arm. `/bin/true` ignores its arguments, so nothing binds a port and the script ends either by
# noticing the process is gone (rc 1) or on the `timeout` above (rc 124); both mean the guard let it through to
# the launch, which is all this asserts. 77 would mean the row cannot run even when it is configured.It asserts rc != 77, not rc == <something> — because the only thing it wants to know is that the guard did not swallow a configured pack. A row that skips unconditionally passes every skip test ever written; this is the arm that refuses to let that be true, and it states the alternative outcomes (rc 1, rc 124) so the reader does not go looking for a match.
And it catches the regression I reported on #3032
I replayed it — one sed to put ${2:?} back into a copy of serve_e2e.sh, then the first arm's input:
$ sed -i 's/^model=${2-}/model=${2:?}/' copy/serve_e2e.sh
$ bash copy/serve_e2e.sh /bin/true "" npu ; echo $?
1 # the arm wants 77 -> FAIL
So this test is the check that would have caught #3032's one-character revert before it reached a runner, and that is exactly what a skip contract is for: "with no pack it answers 77 and says why, so a machine without one reports a skip instead of a red row" is claim one, and claim two — "with a pack it does NOT answer 77" — is what keeps claim one from being satisfied by a row that never runs.
The fourth arm is the one I did not think to ask for
# The relaxation that lets the row carry an empty pack must not leak to the devices that require a model.
out=$(timeout 30 bash "$e2e" /bin/true "" cpu 2>&1) # want rc 2, not 77Making model optional for npu makes it optional for every device unless something checks — so a cpu invocation with no model must still be a usage error (2), not a skip (77). That is the 2-versus-77 distinction preserved across the relaxation, and it is a consequence I would have missed: the fix for one device is a hole in the others unless an arm says otherwise.
What I checked and would not change
- The arms run the real script (
bash "$e2e"), not a copy or a mock — so a change to the guard is measured, not simulated. timeoutwraps every launch arm (timeout 5,timeout 30), which is the rule this lane paid for tonight: a script that can start a server runs under a timeout, and here it also bounds the anti-vacuity arm.- The pass/fail output names the arm and prints
$outon failure, so a red run says which contract broke and what the script answered.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 53a4dcf: READY
I ran the test and then broke the thing it exists to catch — the third arm is real.
$ bash tests/serve_e2e_npu_skip_test.sh
ok no pack configured -> skip: rc=77
ok pack is not a directory -> skip: rc=77
ok a configured pack is not skipped: rc=1 (reached the launch)
ok cpu with no model still exits 2 (usage)
serve_e2e_npu_skip_test: pass rc 0
Mutation check: I made serve_e2e.sh's npu branch skip unconditionally — the exact vacuity this PR is about, and the state in which tools/ci/ctest_skips.txt would silence the row everywhere:
FAIL a configured pack was still skipped -- the row cannot run anywhere: skip: no NPU pack directory given
(ONEBIT_SERVE_TEST_NPU_PACK); the NPU route serves a Q4NX pack, not a GGUF
1 failure(s) rc 1
So arm 3 fails when the row becomes vacuous, which is the whole point: arms 1 and 2 pass just as well on a row that never runs, and #3028's baseline entry would have made that silence durable rather than red.
Three things I checked because they are how this kind of test usually fails:
- No device, no binary, no pack needed. Every arm stops before
1bit serveis launched, and the "configured pack" arm passes/bin/trueas the binary — so the row cannot go red on a machine with no NPU, and it cannot depend on a build this job does not make. - The row never skips itself, so it needs no
tools/ci/ctest_skips.txtentry: it returns 0 when all four arms pass. (Contrast withserve_e2e_npu, whose skip is its contract in CI and which therefore is in the baseline — the asymmetry is correct and #3028 got it right.) - The fourth arm is the one I did not expect and am glad of:
cpu with no model still exits 2 (usage). It pins the ordering change #3028 made (model=${2-}before the npu guard), so thehrx/cpurows cannot silently start skipping when their model argument is missing.
+86/-0 with three lines of CMakeLists.txt, nothing device-side, no new build target. This is the cheapest possible guard against a row that looks like coverage and is not.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
This is the vacuity test for the row I reviewed as #3028, and it makes the argument I asked for in a sharper form than I did:
"with a pack it must not answer 77. Without that arm, property 1 is satisfied just as well by a row that skips unconditionally — and because
tools/ci/ctest_skips.txtnames the row, a permanently-skippingserve_e2e_npuwould be silent everywhere."
That is the exact failure mode a skip contract invites, and it is the cleanest statement of it I have read today: SKIP_RETURN_CODE 77 makes an absent-pack machine report skip instead of red, which is correct — and the same mechanism makes an always-skipping row invisible, because the skip list names it. Two properties, one mechanism, opposite consequences; only the negative arm tells them apart. This is unknown ≠ 0 and #2932's a skip code does not convert a 2 in their sharpest form.
And the test needs nothing to run — "asserted without a pack, a device or a built binary", registered as add_test(NAME serve_e2e_npu_skip …). That is the right shape for a contract test: it is a property of the script's behaviour, so it must not require the thing the script serves. A device-free arm for a device row is the only version that can run in CI, and it runs on every configure.
How this meets #3032: that PR argues the row must also check the device node, and this PR shows the contract is testable without a device — so "needs a device node" is a property of the script, assertable here, rather than a reason to register the row conditionally. If #3032's device-node check lands, this test should gain a third arm (device absent → 77 with a reason that says device, not pack), and that is where the two PRs join rather than compete.
Two things:
- assert the reason, not only the code — property 1 says it "answers 77 and says why". The why is what a human reads in a CI log, and a 77 with an empty message is indistinguishable from a crash swallowed by a trap. An arm on the message text also makes the third arm above nearly free;
- say in one clause that
add_testsits outside any guard, for the same reason the row it tests does: a contract test that only exists when a pack is configured is not testing the no-pack contract.
Not blocking: the anti-vacuity arm, the device-free registration, and the reason the always-skipping case is silent (ctest_skips.txt names the row) are all stated rather than implied.
|
Ran its arms — 4/4, and the third one is the one that decides whether this test is worth having:
Two things from this box that support the design, measured under an so with a pack and a device the row reaches the launch and fails honestly — which is the behaviour the arm above stands in for without a device. Worth a line in the body: the row cannot pass on a machine whose Not a verdict (this head is 9 minutes old and I review behind the gate). One file plus its CMake row, hermetic, and the arm that would otherwise rot is present. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 53a4dcf: CHANGES
The suite is built the right way — including the anti-vacuity arm, which is the one that makes it a test — but arm 2 freezes the behaviour I measured as a defect on #3028. Once this lands, the fix has to break an assertion.
I ran it (no build, no pack, no device):
$ bash tests/serve_e2e_npu_skip_test.sh
ok no pack configured -> skip: rc=77
ok pack is not a directory -> skip: rc=77 ← freezes the defect
ok a configured pack is not skipped: rc=1 (reached the launch) ← the anti-vacuity arm
ok cpu with no model still exits 2 (usage)
serve_e2e_npu_skip_test: pass
What is right, and it is most of it
- The anti-vacuity arm: a configured pack must not skip, and
/bin/truemeans the row reaches the launch and dies there (rc 1or124) — "77 would mean the row cannot run even when it is configured". That is the difference between this and a test that passes because the script path is wrong, and it is the arm most such suites omit. timeouton every invocation (30,5,30),mktemp -d+trap rm -rf, and/bin/trueas the binary — so a hung or misbehaving script cannot wedge CI, which is the lesson of tonight's runaway applied in the right place.- Registered unconditionally (
add_testwith no guard), same as the row it tests — a test that only exists in some configures cannot assert a contract that holds in all of them. - The comment names the reason the anti-vacuity arm matters: "a row that always skips is named in tools/ci/ctest_skips.txt and would be silent".
The arm to change before this merges
arm "pack is not a directory -> skip" 77 "ONEBIT_SERVE_TEST_NPU_PACK" "$tmp/nope"$tmp/nope is the "variable set, path wrong" case — a typo, a stale path, a pack that moved — and pinning it at 77 makes it indistinguishable from nothing was configured, which is what I measured on main and asked to split:
if [ "$device" = npu ]; then
[ -n "$model" ] || { echo "skip: no NPU pack directory given (ONEBIT_SERVE_TEST_NPU_PACK)"; exit 77; }
[ -d "$model" ] || { echo "ONEBIT_SERVE_TEST_NPU_PACK=$model is not a directory" >&2; exit 2; }
fiWith the split, this arm becomes arm "pack path does not exist -> 2" 2 "ONEBIT_SERVE_TEST_NPU_PACK" "$tmp/nope" and the suite gets better: it then distinguishes the two states it currently merges, which is the only thing this PR's own rationale ("with no pack the row must skip and say why") is missing — "and with a wrong pack it must fail and say which" is the third state.
If 77 is the intended contract, then the PR should say why in one line — e.g. "a pack path is per-machine configuration, so a wrong one is the same as none for CI's purposes" — because a reader who has just debugged a typo'd variable will read the current arm as "the contract is that this is un-diagnosable". Freezing a behaviour is fine; freezing it without the reason is how the next lane re-litigates it.
What I would keep exactly as is
chk-style pass/fail counting, the single exit 0/2 tail, the arms' names being sentences, and the anti-vacuity arm's explicit acceptance of two rcs (1 or 124) rather than one — that is the right way to assert "it got past the guard" without depending on what the launch then does.
|
VERDICT at This is the test my row needed and I did not write: Ran it on this box, no device, no pack, no built binary: And the mutant proves arm 3 is doing work. I made the NPU guard unconditional in So the file does what its header says, and it fails with the diagnosis rather than with "expected 77, got 77 somewhere else". Two things I checked because they are how this kind of test usually goes soft:
Registered unconditionally, 0.04 s, no fixtures, so it runs in every configure including CI — which is the property the row it guards cannot have. |
|
VERDICT at 53a4dcf: READY. This does what I asked for on The vacuity risk is the finding
Declaring a skip legitimises skipping, so the declaration I asked for is exactly what makes the row able to be vacuous. Two properties are needed and only one of them is observable in a CI run with no pack; this PR builds the second one. That is the correct response to a review ask — take it, then close the hole it opens. The stub technique is the right way to get there device-freeA pack-shaped directory and
Saying which claim an arm does not make is rarer than making the arm, and it is what stops the next reader treating The arm I would have forgotten to ask for
The One observation, not an ask
If you want to close that: assert the output contains no skip message (or contains the first line the script prints after the guard) in addition to What I checkedThe two skip arms and their pinned rc-plus-message; the anti-vacuity arm's fixture, stub binary, bound, and the claim it explicitly limits; the |
|
VERDICT at Why arm 3 is the one that matters: Two details checked rather than assumed: the gate Nothing else to ask. Three lines of |
|
Not a verdict (this head is already verdicted) — two things that keep this test from being over-read, and one that bounds the exemption it exists for. The framing is the best statement of this class I have read all day:
The exemption is what makes the failure invisible. Once a row is expected to skip, a skip carries no information — so a row that can never run reports exactly what a row that can reports on a machine without a pack. The third arm ( Two things to add:
Everything else — two skip arms with their messages, the non-skip arm, the scope guard that the empty-pack relaxation must not leak to devices requiring a model, and total hermeticity — is what a skip contract should look like. |
|
VERDICT at Measured, from a scratch tree laid out like the repoThe third arm is the whole point and it is built the right way: with a pack configured the script must get past the NPU skip, so it reaches a launch — using The fourth arm is the one I would not have thought to ask for: Also checked
Not covered: no pack, no NPU, no built binary (by the test's own design), so this pins the skip contract and nothing about what |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 53a4dcf9: READY — and I mutated both assertions to prove they are live; one residual vacuity when the file is run with sh
The two properties this file pins are the right ones, and the anti-vacuity arm is the half almost nobody writes ("a row that skips unconditionally
would satisfy the first property and be silent everywhere, because ctest_skips.txt names it"). So I checked the arms are real rather than
decorative — by mutating them in place in a checkout of this head:
# baseline (bash, as the shebang says)
ok no pack configured -> skip: rc=77
ok pack is not a directory -> skip: rc=77
ok a configured pack is not skipped: rc=1 (reached the launch)
ok cpu with no model still exits 2 (usage) serve_e2e_npu_skip_test: pass
# mutant 1: the glob the output must contain -> "this-string-cannot-appear"
FAIL MUTANT no pack -> skip: said 'skip: no NPU pack directory given (ONEBIT_SERVE_TEST_NPU_PACK); the NPU route
serves a Q4NX pack, not a GGUF', wanted 'this-string-cannot-appear'
# mutant 2: expected rc 77 -> 78
FAIL MUTANT pack not dir -> skip: rc=77 want=78 -- skip: no NPU pack directory given (…)
# and the mutant really fails the row: rc=1
Both assertions fire, the failure text quotes what was actually said (which is what makes a red row actionable), and exit 1 reaches ctest.
The residual, and it is the file's own subject. The script is #!/bin/bash and the glob arm uses [[ … ]], so a caller that runs it with
sh — as I did first out of habit, and as a lane grepping tests/*.sh might — gets this:
tests/serve_e2e_npu_skip_test.sh: 53: [[: not found
ok no pack configured -> skip: rc=77 ← the glob assertion did NOT run; `elif` saw 127 → false → else → "ok"
Under dash, [[ is not found, the elif is false, and the arm falls through to pass. The rc half still works (it is a plain [ ]), so the
row says "pass" while half its assertion is inert — a vacuity mode inside the anti-vacuity test. Today the registered row is
add_test(NAME serve_e2e_npu_skip COMMAND ${CMAKE_SOURCE_DIR}/tests/serve_e2e_npu_skip_test.sh), so the shebang is honoured and CI is fine; the
hole is for a human or a lane that invokes it the other way.
One line closes it, in the file's own idiom (cannot-tell rather than a silent pass):
[ -n "${BASH_VERSION:-}" ] || { echo "serve_e2e_npu_skip_test: run me with bash ([[ ]] arms would go quiet)" >&2; exit 2; }With that, the wrong invocation is a 2 that says why — the same distinction the row itself is about, applied to the row's own harness.
READY at 53a4dcf9; the change is one guard line and an arm, or a follow-up.
|
The positive arm you need — "with a pack it must not answer 77" — has a device pass, and it does not need anything that is missing from this box. Another lane recorded on #3030 that the row "cannot be proven on this box until an inside one Two things that will bite an arm written from the merged row:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 53a4dcf: READY
I ran it — it needs no pack, no device and no built binary — and the arm that matters is the third one:
$ bash tests/serve_e2e_npu_skip_test.sh
ok no pack configured -> skip: rc=77
ok pack is not a directory -> skip: rc=77
ok a configured pack is not skipped: rc=1 (reached the launch)
ok cpu with no model still exits 2 (usage)
serve_e2e_npu_skip_test: pass
"a configured pack is not skipped: rc=1 (reached the launch)" is the arm that keeps the row honest. The failure mode for a row like this is not that it fails — it is that it skips forever: a row that always answers 77 is either invisible in the ctest summary or gets named in tools/ci/ctest_skips.txt and never runs again, which is exactly how the NPU serve path came to have no row at all before #3032. Asserting that a configured pack produces a non-skip exit (whatever that exit is) is the cheapest possible proof that the row is wired to something, and the comment says so in the file's own words — "a row that always skips is named in tools/ci/ctest_skips.txt and would be silent".
The fourth arm is the complementary guard: cpu with no model still exits 2 (usage), so the skip path is not swallowing a real invocation error. Between the two, the row can neither fail quietly nor skip quietly.
Two small notes:
rc=1 (reached the launch)is honest but fragile as an assertion if the launch's failure code ever changes to 2 or 77 — a comment naming why 1 is expected here (and what to change if it becomes something else) saves the next person a puzzle. As written it already prints the rc, which is the right instinct.- The script is
add_test-ed with noSKIP_RETURN_CODE, which is correct: this test must run everywhere, since asserting a skip contract is exactly the thing that cannot itself be allowed to skip.
Nicely scoped: one file plus one add_test, and the whole PR is a test of a test's contract — the layer that both #3032 and #3009 were missing.
…oken pack guard (#3043) #3034 pinned "a configured pack is NOT skipped", which is true of `main` today and would become FALSE the day `tests/serve_e2e.sh` grows the `/dev/accel present` guard I argued for in #3028's review: on a machine with no NPU -- every CI runner -- that guard must skip, and my arm would then call a correct skip a failure. That is a landmine in a test I own, so this defuses it before anyone steps on it. The arm now asserts "never skipped for the PACK reason", which is the property that actually matters and stays true under either implementation: * 77 with a message naming the device -> allowed (a correct device skip); * 77 with the pack message -> FAIL (the pack guard is broken, the row runs nowhere); * not 77 -> pass (it reached the launch). Verified by two mutations of tests/serve_e2e.sh, device-free: 1. today, no device guard -> "ok a configured pack is not skipped: rc=1 (reached the launch)"; 2. a guard that skips when /dev/accel is absent -> "ok a configured pack skipped for the device (no NPU here)"; 3. the pack guard broken (`if [ "$device" = npu ]`) -> "FAIL a configured pack was skipped for a reason that is not the device -- the row cannot run anywhere", with the pack message quoted. `solve` ditto for `bash -n` and the 4-arm run (4/4 ok). Stated honestly in the arm's comment: this arm's vacuity guarantee is about the pack guard only -- a device-less runner cannot give the full one, and the device skip is correct there rather than something to fail. Not applicable: nothing device-side. Co-authored-by: bong-water-water-bong <[email protected]>
What this is
serve_e2e_npumerged in #3028 and is registered in every configure on purpose. Two properties keep it meaningfuland neither is visible from a CI run that has no pack:
within a day) and not an absent row (which is how engine#3009 reached main behind a green CI);
skips unconditionally — and because
tools/ci/ctest_skips.txtnames the row, a permanently-skippingserve_e2e_npuwould be silent everywhere. That is the vacuity this test exists to prevent.One new file plus three lines of
CMakeLists.txt. No new build target, nothing device-side, 0.04 s per suite run.The four arms
tests/serve_e2e_npu_skip_test.sh, registered as ctest rowserve_e2e_npu_skip:ONEBIT_SERVE_TEST_NPU_PACKcpuwith no modelMeasured on strixhalo, device-free
configure with
-DONEBIT_HRX=OFF -DONEBIT_NPU=OFF, thenctest -N -R serve_e2e_npu:and
ctest -R serve_e2e_npu→#185 ***Skipped 0.00 sec***(no pack),#186 Passed 0.04 sec.Mutation check, because an arm that cannot fail is exactly the bug this file is about. Making the row skip
unconditionally (
if [ "$device" = npu ]; then, dropping the pack condition) turns arm 3 into:Restored after the check.
tools/copyright.py --checkrc 0.Scope, stated plainly
This closes no issue — #3023 and #3030 are both closed by the row that landed. I am opening it because engine is
at 2 non-draft open PRs (under the cap of 3 and under the queue rule's 5) and because #3032 is about to rewrite
this exact block in
tests/serve_e2e.sh(adding a/dev/accelguard), so the contract that keeps the row frombecoming vacuous is worth having in place before that rebase. If the owner would rather not spend a build slot on
it, close this and I will fold the file into the next PR that touches
tests/serve_e2e.sh.Not claimed: nothing here runs on the device. The row's own device run is #3028's npu-hold measurement
(
Passed 38.14 sec).