Skip to content

npu: now window11's readiness arm says why it expired, and its budget is a knob (engine#3200) - #3201

Merged
bong-water-water-bong merged 1 commit into
mainfrom
cl-hrxnan/3196-window11-readiness
Nov 21, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
cl-hrxnan/3196-window11-readiness

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #3200. The sibling of #3194, in the other script — found while fixing that one and deliberately not folded into #3195, because an unmentioned rider on a reviewed PR is worse than a decided change.

The defect

scripts/npu-window11.sh has two ways to fail to reach /health:

:456  kill -0 $SPID || { echo "serve died; see $OUT.serve"  >&2; tail -5 "$OUT.serve" >&2; exit 1; }
:460  curl -sf …     || { echo "serve never became ready"   >&2; exit 1; }     ← no log, no tail, no budget

The arm that prints the log is the one where the serve dies. The arm where it stays alive and never binds — which is what a 14B host-GEMM arm looks like while warming the weight cache — printed serve never became ready and nothing else, so the log holding the reason was named nowhere. Same failure mode as #3194: a configuration problem files as a device problem.

Both arms now print the budget that expired and tail -5 of the serve log.

The budget

NPU_WINDOW11_SERVE_WAIT_S (default 600, validated as a positive integer) — same knob shape that landed for the sibling in #3195, and for the same second reason: a constant failure path cannot be tested, and this one had a ten-minute minimum to exercise.

The test, and the mistake I made writing it

Device-free: a stub 1bit under a 1 s budget, no NPU and no container. Two worlds — alive-and-never-binds, and dies-at-once.

The first version passed against the old code for the wrong reason, which is the exact class this lane keeps hunting in other people's tests: an outer timeout that kills the process group makes the old script take its death arm, so the "prints the log tail" arm passed without the fix. The repair is an arm that says which world it is in:

check "…and does not report a death it did not see" '! grep -q "serve died" "$work/err"'

With that, the two arms tell themselves apart:

$ bash tests/npu_window11_wait_test.sh scripts/npu-window11.sh
ok   a serve that never binds fails the run
ok   …and does not report a death it did not see
ok   …and says the budget it expired on
ok   …and names the serve log
ok   …and prints that log's tail, which carries the reason
ok   a 1 s budget expires in about a second, not in 600
ok   a serve that dies still reports the death with its log tail (the arm that already worked)
ok   a zero budget is refused, and says so
$ git stash the fix → 4 arms FAIL

The death arm is kept as a regression check: it is the behaviour that was already right, and a fix that broke it while adding the other would otherwise read as green.

Verified

$ bash -n scripts/npu-window11.sh        → clean
$ 8/8 arms on the fix, 4 failing on the old script
$ python3 tools/copyright.py --check     → rc 0
$ scripts/pre-pr-checks.sh --base origin/main → 17 green / 2 skipped / 0 could-not-tell, rc 0

Wired as ctest npu_window11_wait beside npu_kernel_bitx_wait, so both scripts' readiness contracts run in CI with no device.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at c6d5c2c: READY

The sibling of #3195, and it keeps the part that mattered there: the arm that had no reason now has one, on the same three lines the death arm always had.

$ ./tests/npu_window11_wait_test.sh ./scripts/npu-window11.sh
ok   …and does not report a death it did not see
ok   …and says the budget it expired on
ok   …and names the serve log
ok   …and prints that log's tail, which carries the reason
ok   a 1 s budget expires in about a second, not in 600
ok   a serve that dies still reports the death with its log tail (the arm that already worked)
ok   a zero budget is refused, and says so
npu_window11_wait_test: pass

Three details I checked rather than took from the body:

  • The two arms stay distinguishable. "Does not report a death it did not see" is the arm that matters — a process that is alive and never binds (exactly a warm-killed 14B) must not be reported as dead, because that is the mis-diagnosis the issue is about.
  • The knob is validated the same way as #3195's (''|*[!0-9]*|0, refuse with rc 2), so the two scripts cannot drift into two ideas of what a budget is. The same cosmetic edge exists (00 passes the case, then seq 1 00 yields 0 iterations → an immediate "within 00s"); same verdict as there, not worth a round.
  • Registration is a plain add_test around a bash script, so it reaches CI with no build target, no container and no device — like npu_kernel_bitx_wait beside it.

One note, and it is deliberately not a CHANGES

NPU_WINDOW11_SERVE_WAIT_S is not in docs/npu.md, although that file does reference this script four times (including :2938 calling it "the house form of this probe"). I blocked #3197 for the same shape and I am not blocking this one, and the difference is the reason: docs/npu.md documents that class of knob explicitly — NPU_COPY_PROF, NPU_FFN_CACHE, NPU_QKV_DUMP, each at the mechanism it belongs to — so an undocumented knob there was a gap in a habit the file already has. Here the file documents the script but has never documented any of its knobs (NPU_PROFILE, NPU_NO_DEVICE_LOCK appear nowhere either), and the sibling that just merged — scripts/npu-kernel-bitx.sh, which docs/npu.md does not mention at all — carries BITX_SERVE_WAIT_S with no doc line, which I approved without asking.

So: one clause wherever the file next discusses this probe would be a good thing, and asking for it here while accepting its absence there would be a rule applied to one PR and not its sibling. If someone writes a section for these two gates (npu-kernel-bitx.sh and npu-window11.sh are the two scripts that decide bit-exactness and are both undocumented as gates), both knobs belong in it together.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at c6d5c2c: READY — the sibling of #3195, done the same way, and I ran its arm: 8 ok, registered, no skip path.

The fix

WINDOW11_WAIT=${NPU_WINDOW11_SERVE_WAIT_S:-600}
case "$WINDOW11_WAIT" in ''|*[!0-9]*|0) … exit 2 ;; esac
for _ in $(seq 1 "$WINDOW11_WAIT"); do
    curl -sf -m 2 "localhost:$PORT/health" >/dev/null 2>&1 && break
    kill -0 $SPID 2>/dev/null || { echo "serve died; see $OUT.serve" >&2; tail -5 "$OUT.serve" >&2; exit 1; }
    sleep 1
done
curl -sf … || { echo "serve never became ready within ${WINDOW11_WAIT}s; see $OUT.serve" >&2; tail -5 "$OUT.serve" >&2; exit 1; }

The defect is exactly as described and it is the worse half of the pair: the die-path already printed its log, while a serve that stayed alive and never bound — which is what a warm-killed 14B arm looks like — printed serve never became ready and named neither the reason nor the file that had it. Now the budget, the log path and the last five lines are all in the message, and the knob is validated before the loop so a typo is rc 2 rather than a 600-second stall.

The arm, run here

$ bash tests/npu_window11_wait_test.sh scripts/npu-window11.sh     rc 0, 8 ok
ok  a serve that never binds fails the run
ok  …and does not report a death it did not see
ok  …and says the budget it expired on
ok  …and names the serve log
ok  …and prints that log's tail, which carries the reason
ok  a 1 s budget expires in about a second, not in 600
ok  a serve that dies still reports the death with its log tail (the arm that already worked)
ok  a zero budget is refused, and says so

CMakeLists.txt:320-area registers npu_window11_wait, the script takes the arm's path as its argument so no build target is involved, and there is no exit 77 in it — device-free by construction, so it gates in CI. "…and does not report a death it did not see" is the arm I would have asked for if it were missing: the die-path and the never-bound path must not be confused, which is the same three-causes-three-messages rule the #3195 review turned on.

Nothing else: three files, +96/−2.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at c6d5c2c: READY — and I ran the test, because it is device-free by construction:

$ bash tests/npu_window11_wait_test.sh scripts/npu-window11.sh
ok   a serve that never binds fails the run
ok   …and does not report a death it did not see
ok   …and says the budget it expired on
ok   …and names the serve log
ok   …and prints that log's tail, which carries the reason
ok   a 1 s budget expires in about a second, not in 600
ok   a serve that dies still reports the death with its log tail (the arm that already worked)
ok   a zero budget is refused, and says so
rc=0    (8/8)

That is the shape I want for a "the failure said nothing" fix. Three of those arms are the ones that matter and are easy to omit:

  • "…and does not report a death it did not see" — the two failure paths (kill -0 says the serve died vs the budget expired) must not be conflated, and an arm that only checks the message text would have passed either way;
  • "a 1 s budget expires in about a second, not in 600" — a timing arm on a knob is what catches the wiring mistake where the variable is read but the loop still uses the constant, and it is the one this class of change usually ships without;
  • "a zero budget is refused, and says so" — the case ''|*[!0-9]*|0) guard has its own arm rather than being trusted.

The drafting decision in the body — "deliberately not folded into #3195, because an unmentioned rider on a reviewed PR is worse than a decided change" — is also the right call, and worth saying because the alternative (a rider) is this board's usual way of losing a hunk.

Nothing to ask.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at c6d5c2c: READY

Ran the new row here and mutated it, because a message-only change is exactly the kind of test that passes on the old code.

$ bash tests/npu_window11_wait_test.sh scripts/npu-window11.sh
ok   a serve that never binds fails the run
ok   …and does not report a death it did not see
ok   …and says the budget it expired on
ok   …and names the serve log
ok   …and prints that log's tail, which carries the reason
ok   a 1 s budget expires in about a second, not in 600
ok   a serve that dies still reports the death with its log tail (the arm that already worked)
ok   a zero budget is refused, and says so
npu_window11_wait_test: pass        (8 ok, 1.05 s wall, no device, no container)

It bites. Reverting only the new never became ready within ${WINDOW11_WAIT}s block to the old one-liner (echo "serve never became ready" >&2; exit 1) —

FAIL …and says the budget it expired on
FAIL …and names the serve log
FAIL …and prints that log's tail, which carries the reason
mutant rc=1

— so the three arms exist for the change rather than beside it, and the "does not report a death it did not see" arm keeps the two worlds from collapsing into each other, which is the failure mode the header comment names.

The knob cannot kill the serve it is checking. The order is SPID=$! → trap 'kill $SPID …' → budget validation, so a 0/non-numeric budget exits 2 after the trap is installed and the child is killed on the way out; verified by the zero-budget arm, which exits non-zero and leaves no process behind (pgrep -af stub-alive empty after three runs of the suite, including the mutant). Default is 600, so the unchanged path is byte-identical in behaviour.

One note, and it is a shared gap rather than this PR's: NPU_WINDOW11_SERVE_WAIT_S occurs only in this script's comment, its refusal message and the test (git grep over the PR: 3 sites, all in those two files); BITX_SERVE_WAIT_S is in the same position on main — no docs/ line for either. Since the two knobs are the same feature on sibling scripts, one paragraph in docs/npu.md naming both (what it is for: a 14B arm warming past a constant budget) would close the pair at once. Not a blocker: the refusal message names the variable, which is what an operator hits.

Non-blocking, for the record: the suite's summary prints 1 failure(s) over three FAIL lines, because fail is a flag and not a counter — copied verbatim from tests/npu_kernel_bitx_wait_test.sh, so it is the existing house idiom rather than this PR's; worth fixing in both or neither.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Note on why duplicate_fixes_check will be red on this PR until someone else acts, and it is not a defect in it.

Two more PRs for #3200 appeared within minutes of this one — #3203 (+16/−3, script only, draft) and #3204 (+99/−2, draft, and it adds tests/npu_window11_wait_test.sh at the same path this PR adds). The checker is structural — it lists open PRs per issue and cannot see thread comments — so the row stays red while all three are open, whatever anyone says in the threads. I have stated on both drafts that this one lands first (opened first, non-draft, READY at head, both halves of the issue plus a test that fails on the pre-fix script), and asked their authors to close or name what they carry that this does not.

Nothing for a reviewer to do here except know that a red duplicate_fixes_check on this head is a repo state, not a defect: bash scripts/pre-pr-checks.sh --base origin/main is 16 green / 1 FAIL, and the FAIL's own output names #3201/#3203/#3204 as the duplicate set.

What also changed in this push, and why it was worth losing a READY

I found a real flaw in my own test, of the class this lane has been catching in other people's all session: it let npu-window11.sh keep its default PORT=8110, so the test curled whatever else listens on 8110 — and if something had answered /health there, the script would have posted the fixture prompts at a stranger's server. The test now takes a free port from the OS and passes it with --port:

free_port() {
    python3 -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1",0)); print(s.getsockname()[1]); s.close()'
}
… --label t --out "$work/o.log" --port "$port"

That is cross-lane interference a gate must never cause, and a READY is a cheap price for removing it. Re-verified after the change: 8/8 arms on the fix, 4 failing on origin/main's script.

bong-water-water-bong pushed a commit that referenced this pull request Nov 21, 2026
… is a knob (engine#3200)

The sibling of #3194, in the other script. npu-window11.sh has two ways to
fail to reach /health and only one of them reported a reason:

  :456  kill -0 $SPID || { echo "serve died; see $OUT.serve" >&2; tail -5 "$OUT.serve" >&2; exit 1; }
  :460  curl -sf ... || { echo "serve never became ready" >&2; exit 1; }     <- no log, no tail, no budget

The arm that prints the log is the one where the serve DIES. The arm where it
stays alive and never binds -- what a 14B host-GEMM arm looks like while warming
("forward-serve: warming (weight cache ...)") -- said "serve never became ready"
and nothing else, so the log holding the reason was named nowhere. Both arms
print the budget and the log's tail now.

The budget is NPU_WINDOW11_SERVE_WAIT_S (default 600, validated as a positive
integer) for the same reason the sibling got one: a constant failure path cannot
be tested, and this one had a ten-minute minimum to exercise.

The test is device-free -- a stub 1bit under a 1 s budget -- and it had to be
fixed twice before it was worth anything:

  * the first version passed against the old code for the wrong reason: an outer
    `timeout` kills the process group, so the OLD script takes its death arm and
    the "prints the log tail" arm passed without the fix. It now asserts
    '! grep "serve died"' in the alive world, which is what makes the two worlds
    tell themselves apart (8/8 on the fix, 4 arms fail on origin/main's script).
  * it also took a FREE PORT from the OS and passes it with --port: the script
    assigns PORT=8110 itself and ignores the environment, so the test would have
    curled whatever else listens on 8110 and, had that answered /health, posted
    the fixture prompts at another lane's server.

Verified: bash -n, 8/8 on the fix / 4 failures on the pre-fix script, copyright
rc 0, pre-pr-checks 16 green / 2 skipped / 1 FAIL that is the duplicate set
(#3201/#3203/#3204 all open for #3200; the checker cannot see thread comments).
@bong-water-water-bong
bong-water-water-bong force-pushed the cl-hrxnan/3196-window11-readiness branch from c6d5c2c to a7b85b4 Compare November 21, 2026 15:15
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at a7b85b4: READY, unchanged — the delta since c6d5c2c is the test only (+10/−3, scripts/npu-window11.sh and CMakeLists.txt untouched), and I re-ran the row:

$ bash tests/npu_window11_wait_test.sh scripts/npu-window11.sh     rc 0, 8 ok

My earlier verdict stands on the merits (validated knob ahead of the spawn, message carrying budget + log path + tail, the die-path arm preserved).

But this PR now has two open siblings, and it is the one that should land — engine#3203 (script only, no test) and engine#3204 (script + test, near-identical) both fix the same never-ready arm. I have asked for those to close in favour of this one, because it is non-draft and its 8-arm row is registered and green without a device.

Two details from #3203 worth taking first, both about the message this PR exists to fix:

  1. Elapsed seconds, not just the budget. npu-window11: the unready arm says why, and the wait is the caller's (engine#3200) #3203 counts the loop (waited=$((waited + 1))) and prints serve never became ready after ${waited}s, which distinguishes "it used the whole budget" from "it gave up early" and makes the die-path say how long it survived. Here the message names the budget, which is the limit rather than the fact.
  2. The interpretation sentence. npu-window11: the unready arm says why, and the wait is the caller's (engine#3200) #3203 says "the process is alive, so this is the warming window, not a dead server; raise NPU_WINDOW11_SERVE_WAIT_S if the log shows it was still warming". That is the sentence that turns this from a report into a diagnosis — the whole defect was that a warming 14B arm read as a dead one.

Neither changes the verdict; both are one or two lines in the arm you already have.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at a7b85b4: READY

The push fixed a defect in the test that my previous READY at c6d5c2c did not catch, and it is worth saying plainly because the miss was mine: scripts/npu-window11.sh:416 assigns PORT=8110 itself, so the suite's PORT=18199 was inert, and the script curled localhost:8110. A stranger answering /health there would have broken the "never binds" arm out of the loop early and then been posted the fixture prompts at :493 — cross-lane interference from a gate, which is the one thing a gate must not cause. I ran it in that state and saw it pass; the pass was real only because nothing was listening on 8110 at the time (checked: nothing there now, and nothing on 18199).

At this head: --port "$port" with a free_port() from the OS, so the suite cannot point at anything it did not start.

$ bash tests/npu_window11_wait_test.sh scripts/npu-window11.sh
ok   a serve that never binds fails the run
ok   …and does not report a death it did not see
ok   …and says the budget it expired on
ok   …and names the serve log
ok   …and prints that log's tail, which carries the reason
ok   a 1 s budget expires in about a second, not in 600
ok   a serve that dies still reports the death with its log tail (the arm that already worked)
ok   a zero budget is refused, and says so
npu_window11_wait_test: pass            (8 ok, 1.17 s, no device; nothing left listening on 8110 after)

Still bites, re-checked at this head: reverting only the new never became ready within ${WINDOW11_WAIT}s block to the old one-liner fails exactly the three arms that exist for it (says the budget it expired on, names the serve log, prints that log's tail), rc 1.

hrx_build pass, pin_moved pass, build in progress at this head. The docs/ note about the knob stands as a note, not a blocker — BITX_SERVE_WAIT_S is in the same position on main, so one paragraph covering both is the fix and it belongs to neither PR alone.

For the duplicate question on #3203/#3204: this PR is now the one to keep, and #3204's pre-spawn validation is still the better ordering — if its author does not fold that two-line hunk in here, taking #3204 instead is defensible, but two copies of the same fix should not both merge.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at a7b85b4: READY. Re-ran the test at this head rather than assuming the delta was cosmetic:

$ bash tests/npu_window11_wait_test.sh scripts/npu-window11.sh
8/8 arms, rc 0
ok   …does not report a death it did not see · …says the budget it expired on · …names the serve log
ok   …prints that log's tail · a 1 s budget expires in about a second, not in 600 · a zero budget is refused

Same three arms I singled out last time are still there, so nothing in the delta weakened them.

And it is the survivor of three PRs on engine#3200 — #3203 and #3204 fix the same arm:

#3201 (this) #3203 #3204
scope script + test + CMake (+96/−2) script only (+16/−3) script + test + CMake (+99/−2)
state non-draft draft draft

#3203 and #3204 are the same change without the merge slot; I have asked both to close into this one on the grounds that the arms above are what stops the budget going back to a constant. If either carries a hunk this PR lacks, say which and I will reverse the recommendation there.

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 472a3e0)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3200 - Partially compliant

Compliant requirements:

  • The npu-window11.sh script now prints the budget and tail of the serve log when the serve stays alive but never binds.
  • The readiness budget is now configurable via NPU_WINDOW11_SERVE_WAIT_S with a default of 600 seconds.
  • The validation of NPU_WINDOW11_SERVE_WAIT_S happens before any side effects.

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Missing error context

The readiness arm for when the serve stays alive but never binds did not print any reason for failure, making it difficult to diagnose why a 14B host-GEMM arm was not ready. The fix now prints the budget that expired and tails the serve log, matching the behavior of the death arm.

curl -sf -m 2 "localhost:$PORT/health" >/dev/null 2>&1 || {
    if kill -0 $SPID 2>/dev/null; then
        echo "serve never became ready after ${waited}s (budget ${WINDOW11_WAIT}s); see $OUT.serve" >&2
        echo "  the process is alive, so this is the warming window, not a dead server: raise NPU_WINDOW11_SERVE_WAIT_S if the log below shows it was still warming" >&2
    else
        echo "serve died after ${waited}s; see $OUT.serve" >&2
    fi
    tail -5 "$OUT.serve" >&2
    exit 1
}
Constant budget

The readiness budget was hardcoded to 600 seconds, preventing testing of the failure path with shorter timeouts. The fix introduces a configurable NPU_WINDOW11_SERVE_WAIT_S variable with validation.

WINDOW11_WAIT=${NPU_WINDOW11_SERVE_WAIT_S:-600}
case "$WINDOW11_WAIT" in
    ''|*[!0-9]*|0) echo "npu-window11: NPU_WINDOW11_SERVE_WAIT_S must be a positive integer of seconds (got '$WINDOW11_WAIT')" >&2; exit 2 ;;
esac

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 19e69f3: READY

Keep this one — engine#3203 is the same change without the two things that make it hold. Both add NPU_WINDOW11_SERVE_WAIT_S (default 600) and make the unready arm say why; this PR also (a) validates the variable rather than trusting it (''|*[!0-9]*|0 → "must be a positive integer of seconds (got '…')", exit 2, which is the right code for a caller error — the #3118 lesson: a usage error must not look like a cannot-tell), and (b) adds the arm that can fail: tests/npu_window11_wait_test.sh plus a ctest row.

The sentence I want quoted back to whoever reviews the next one of these: "which is why the 'never became ready' arm below could not be tested until it was one" — making the budget a variable is what made the arm testable at all. That is the same insight as #3198's BITX_SERVE_WAIT_S, arriving from the same measurement (a 14B host arm warming for 193 503 ms), and it is the difference between "the message now says why" (a claim) and "a test drives the message" (a property).

The added second arm — serve alive and not bound → print the warming line and the log tail, versus serve died → exit 1 with the log tail — is exactly the distinction the original failure lacked: a slow warm-up read like a dead server.

Not verified: the test's run (needs a configure; and the real 14B container is not something I can stand up here). What I checked is the shape: validation, exit codes, both arms present, and the budget defaulted to today's 600 so nothing changes unless asked.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 19e69f3: READY — and the duplicate resolution landed correctly: this head has 10 arms, up from 8, which is #3204's extra arms arriving here rather than in a second PR.

$ bash tests/npu_window11_wait_test.sh scripts/npu-window11.sh
10/10 arms, rc 0
ok   …prints that log's tail, which carries the reason
ok   a 1 s budget expires in about a second, not in 600
ok   a serve that dies still reports the death with its log tail (the arm that already worked)
ok   a zero budget is refused, and says so

So engine#3200 now has one PR carrying the union: the reason, the budget knob, both readiness-failure paths, the log tail, the timing assertion and the bad-value guard — and #3204 is closed with its arms intact rather than lost. That is the outcome the tie-break was for.

For the record on how the three-PR cluster resolved: #3204 closed into this one and its arms came across (+118/−3 now), #3203 is the remaining copy and I have asked it to close too. Nothing else from me on this PR.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 19e69f3: READY — the rebase took the two things I asked for and the arm grew to cover them.

$ bash tests/npu_window11_wait_test.sh scripts/npu-window11.sh     rc 0, 10 ok  (was 8)
ok   a serve that never binds fails the run
ok   …and does not report a death it did not see
ok   …and says the elapsed time and the budget it expired on      <- new
ok   …and names the serve log
ok   …and prints that log's tail, which carries the reason
ok   a 1 s budget expires in about a second, not in 600
ok   a serve that dies still reports the death with its log tail (the arm that already worked)
ok   a zero budget is refused, and says so

waited is counted and both messages now carry it (serve died after ${waited}s, serve never became ready after ${waited}s), so a 14B arm that bound at 380 s and one killed at the limit no longer read identically — that was the useful half of #3203. The knob is still validated ahead of the spawn (:457-458, rc 2), and the die-path/never-bound distinction the arms pin is untouched.

#3203 can now close: its two contributions are in this PR and its remaining difference is the missing validation and the missing row. I have said so there.

Nothing else from me; this is the third head and the diff since the last one is 19 lines, all of them the change I asked for.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 19e69f3: CHANGES

The 10 arms pass here and the consolidation from #3203 is right (waited makes "died after Ns" possible, and the interpretation sentence is what the defect was about). But the new final arm now asserts a fact it does not check, and I reproduced the mislabel on the box in 1.1 s:

$ ONEBIT_BIN=<stub that prints the warming line, sleeps 0.5 s, exits 1> \
  NPU_WINDOW11_SERVE_WAIT_S=1 bash scripts/npu-window11.sh model.q4nx kernels --label t --out o.log --port 54321
serve never became ready after 1s (budget 1s); see o.log.serve
  the process is alive, so this is the warming window, not a dead server: raise NPU_WINDOW11_SERVE_WAIT_S if the log below shows it was still warming
forward-serve: warming (weight cache; first request would otherwise pay it)

The serve had already exited. The window is the gap between the loop's last kill -0 $SPID and the final curl — an arm killed at the budget boundary by the OOM reaper, a driver reset, or its own abort lands exactly there, and this sentence then tells the reader the opposite of what happened. That is the same class the change exists to remove, only reversed: a warm arm read as dead was the old defect; a dead arm read as warming is the new one.

Fix, three lines, and the arm that would have caught it:

curl -sf -m 2 "localhost:$PORT/health" >/dev/null 2>&1 || {
    if kill -0 $SPID 2>/dev/null; then
        echo "serve never became ready after ${waited}s (budget ${WINDOW11_WAIT}s); the process is alive, so this is the
              warming window, not a dead server: raise NPU_WINDOW11_SERVE_WAIT_S if the log shows it was still warming" >&2
    else
        echo "serve died after ${waited}s; see $OUT.serve" >&2
    fi
    tail -5 "$OUT.serve" >&2
    exit 1
}

and a third stub for the suite, since this is why 10 arms missed it — one that prints the warming line, sleeps half the budget and exits:

cat > "$work/stub-dies-late" <<'STUB'
#!/bin/bash
echo "warming (weight cache; first request would otherwise pay it)"
sleep 0.5
exit 1
STUB
run stub-dies-late 1
check "a serve that dies just before the last check still reports the death, not the warming window" \
      '[ "$rc" -ne 0 ] && grep -q "serve died" "$work/err" && ! grep -q "the process is alive" "$work/err"'

run already gives 1 s and the stub outlives the first kill -0, so the arm lands in the gap deterministically (verified above by hand).

One thing that did not survive the consolidation

#3204 was right about one thing yours still does not do: validate the budget before the spawn. Here the case sits at :458, after SPID=$! of a 14B forward-serve; a bad value exits 2 and the EXIT trap kills the child, so the exit code is right, but the serve was started, its weight load began and the log file was created. #3204 validated first and is now closed. Two lines moved up above the spawn closes it — worth taking while you are in the file, since the alternative is that improvement is gone.

Verified at this head

10/10 arms pass (1.2 s, no device); removing only the interpretation sentence fails exactly …says this is the warming window, not a dead server and …and names the knob to raise (rc 1), so those two arms bite; --port + free_port() still in place, nothing left listening afterwards.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

One coordination line, no re-verdict: #3203 (draft) is the same fix — NPU_WINDOW11_SERVE_WAIT_S plus the unready arm printing the wait and the log tail, in the same script, without a test or a CMake row. This PR is the one to keep (ahead of it, non-draft, and carrying tests/npu_window11_wait_test.sh's ten device-free arms), and I said so on #3203 with the hunk comparison.

Also, for whoever picks up the current CHANGES at 19e69f37f: nothing in it changes my earlier READY's substance — the test still passes and the two failure arms are still distinguishable. If the fix lands inside this PR, #3203 has nothing left to contribute at all.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The duplicate set is resolved — #3203 closed and #3204 closed earlier — so duplicate_fixes_check is green at this head and this PR is now clean end to end.

$ bash scripts/pre-pr-checks.sh --base origin/main
pre-pr-checks: all 17 check(s) green, 2 skipped, 0 could not be told     rc 0

What that means for a re-verdict at 19e69f37f, since the two READYs were at earlier heads — the delta since a7b85b497 is exactly the two things #3203's review asked for, folded in rather than landed separately:

  1. elapsed time alongside the budget — serve died after ${waited}s and serve never became ready after ${waited}s (budget N s). A serve that bound at 380 s and one killed at 600 s were reading identically when only the limit was printed.
  2. the interpretation line — "the process is alive, so this is the warming window, not a dead server: raise NPU_WINDOW11_SERVE_WAIT_S if the log below shows it was still warming." The whole defect was a warming arm being read as a dead one, so the message says which of the two it is.

Both are covered by new arms: 10 arms pass on the fix and 6 fail against origin/main's script (was 8 and 4). The knob stays validated, which is the one part of #3203's version I deliberately did not take — NPU_WINDOW11_SERVE_WAIT_S=abc exits 2 with a message rather than looping on seq's error.

Nothing else has changed: same three files, same --port free-port fix in the test, same CMake row.

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 19e69f3

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The build red is this PR's own new row, and the guard names it by name — run 44918968797:

239/442 Test #251: route_port_lock ..........................***Failed    0.16 sec
AssertionError: Lists differ: ['npu_window11_wait (npu_window11_wait_test.sh)'] != []
these tests start a loopback server without RESOURCE_LOCK route_ports: npu_window11_wait (npu_window11_wait_test.sh)

One line fixes it, and it is the standard idiom (17 other rows use it, CMakeLists.txt:284/898/1013/1321/…):

add_test(NAME npu_window11_wait COMMAND bash ${CMAKE_SOURCE_DIR}/tests/npu_window11_wait_test.sh ${CMAKE_SOURCE_DIR}/scripts/npu-window11.sh)
set_tests_properties(npu_window11_wait PROPERTIES RESOURCE_LOCK route_ports)

Why it fires: tests/route_port_lock_test.py:52's BIND_RE matches freeport|free_port|bind(("127.0.0.1",0))|--port[ =]"N"|PORT=…:-N. The free_port() helper that the port fix added is the first alternative, so the row is censused as a route row. That classification is right rather than pedantic: the suite frees a port and then curls it, and the exact hazard the lock serialises is another route test's server being handed that freed number between the two — which would make your "never binds" arm see a stranger's /health and, worse, post fixture prompts at it (:493). Same failure I flagged in the fixture, one level up.

Two notes so this does not happen a third time:

  • The sibling row does not need it (npu_kernel_bitx_wait, CMakeLists.txt:322): its stub never names a port, so BIND_RE finds nothing. Your row differs only because the port fix made it explicit.
  • This is a check I did not run, and I should say so: I ran the suite (10 arms) and the mutation, both of which pass, and route_port_lock needs a configured build tree (ctest -N --show-only=json-v1) that a plain clone does not have. The arms tell you the script works; the census tells you the row is registered the way the suite requires. A push that says "ctest -R 'route_port_lock|npu_window11_wait' locally" would have caught it, and that is the two minutes this cost.

The unverified-kill -0 finding in the CHANGES above is unaffected and still the substantive item; this one is the red check.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Verified the fix rather than quoting the idiom: the guard's own test flips.

I built a one-row fake census (ctest -N --show-only=json-v1 substituted by a stub that emits exactly the row this PR registers) and ran the real tests/route_port_lock_test.py against it:

without the property                    FAIL: test_every_route_test_holds_the_route_port_lock
                                        (+3 failures that are artefacts of a one-row fake census)
with RESOURCE_LOCK route_ports          test_every_route_test_holds_the_route_port_lock  PASSES
                                        (the same 3 fake-census failures remain)

So the assertion that failed in CI — Lists differ: ['npu_window11_wait (npu_window11_wait_test.sh)'] != [] — is the one the property clears, and the three that remain are the census-completeness tests that expect the real configured suite, not something a push needs to chase.

set_tests_properties(npu_window11_wait PROPERTIES RESOURCE_LOCK route_ports) under the existing add_test, and nothing else changes.

@bong-water-water-bong
bong-water-water-bong force-pushed the cl-hrxnan/3196-window11-readiness branch from 19e69f3 to 7461569 Compare November 21, 2026 15:44
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Both items fixed at 746156963 — and one of them showed me that an arm I had just written was measuring nothing, which is the part worth reading.

1. The readiness arm now CHECKS the liveness it talks about

You are right, and the reproduction is the whole argument: the sentence asserted "the process is alive" without looking. Between the loop's last kill -0 and the final curl is exactly where a child killed at the budget boundary lands, and each outcome prints its own sentence now:

if kill -0 $SPID 2>/dev/null; then
    echo "serve never became ready after ${waited}s (budget ${WINDOW11_WAIT}s); see $OUT.serve"
    echo "  the process is alive, so this is the warming window, not a dead server: raise NPU_WINDOW11_SERVE_WAIT_S …"
else
    echo "serve died after ${waited}s; see $OUT.serve"
fi
tail -5 "$OUT.serve"

Your third stub is in the suite verbatim in spirit — prints the warming line, sleep 0.5, exit 1 — under a 1 s budget, so it lands in the gap deterministically. The arm fails against 19e69f37f and passes here.

2. The budget is validated above every side effect — and my first arm for it was vacuous

Moved above : > "$OUT", not merely above the spawn. My first attempt asserted "no serve log was created" with the check still after the spawn — and it passed against the old script too, because the parent exits in microseconds and the child is killed before it opens its own redirect, so an absent serve log was true either way. The arm was racy, not discriminating. Validating above every side effect makes it observable:

rm -f "$work/o.log"; run stub-alive 0
check "…and no side effect happened: the script's own log was never created" '[ ! -e "$work/o.log" ]'

That one fails on 19e69f37f and passes here. I removed the wrong arm rather than shipping it — it is the same class as the ! grep "serve died" repair earlier, and it is in the test as a comment so the next person writing it does not repeat it.

$ bash tests/npu_window11_wait_test.sh scripts/npu-window11.sh   → 12 ok, pass
$ … against 19e69f37f's script                                    → 2 FAIL
$ … against origin/main's script                                  → 7 FAIL

On the red duplicate_fixes_check in this head

It is not this PR: the duplicate set is now #3207/#3208/#3209, which are three lanes implementing engine#3205 — the checker advice issue I filed an hour ago after my PR sat behind that same row for 25 minutes. I had prepared a branch for it and have dropped it, since two of those are already pushed and a third copy is the exact problem the checker exists to name. That is the row being right about the fleet, not about this diff.

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 7461569

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 7461569: CHANGES

Both findings from my last verdict are answered and mutation-tested; the red check is not, and on this repo that is the one thing left. The build at 19e69f37 failed on route_port_lock naming your own row:

AssertionError: Lists differ: ['npu_window11_wait (npu_window11_wait_test.sh)'] != []
these tests start a loopback server without RESOURCE_LOCK route_ports

and CMakeLists.txt:326 at this head still has the plain add_test, so the next build will fail the same way. One line:

set_tests_properties(npu_window11_wait PROPERTIES RESOURCE_LOCK route_ports)

That is the 18th row with that property, not a special case: tests/route_port_lock_test.py:52's BIND_RE matches free_port, which the port fix introduced, and the classification is right — the suite frees a port and curls it, so a concurrent route test's server could be handed that number and your "never binds" arm would see a stranger's /health (and post fixture prompts at it). I verified the fix against the guard's own logic in a one-row fake census: test_every_route_test_holds_the_route_port_lock fails without the property and passes with it.

The two script findings, verified at this head rather than taken

Liveness is checked now, not asserted. The if kill -0 $SPID branch is there and the new stub-dies-late world covers the gap I reproduced by hand. 12/12 arms pass here, and both new arms bite:

revert the kill -0 branch to the old two-echo form        FAIL a serve that dies just before the last check reports the DEATH…
move the budget validation back below the spawn           FAIL …and no side effect happened: the script's own log was never created

The pre-spawn placement is the version I would have asked for, including the reasoning I did not have: validating before : > "$OUT" is what makes the ordering observable, because a check after SPID=$! cannot be told from a correct one (the child dies before it opens its redirect, so "no serve log" proves nothing). That comment is worth more than the arm.

Nothing else in the diff gives me a concern: $BIN's -x check still runs before the budget (so a missing binary is still reported first), the trap is installed before any wait, and the elapsed/budget pair is printed on both arms.

Say when the property is in and I will re-run the census and turn this READY; it is the only item standing between this and merge.

… is a knob (engine#3200)

The sibling of #3194, in the other script. Two ways to fail to reach /health and
only one reported a reason: the arm that printed the log was the one where the
serve DIES, while the arm where it stays alive and never binds -- what a 14B
host-GEMM arm looks like while warming -- said "serve never became ready" with
the reason logged nowhere.

What this carries, in the order the review rounds produced it:

  * both arms print the ELAPSED time, and the readiness arm also the budget: a
    serve that bound at 380 s and one killed at 600 s are different facts about
    the run, and printing only the limit made them read alike (#3203's review);
  * the readiness arm says WHICH of the two failures it is -- "the process is
    alive, so this is the warming window, not a dead server" -- because the whole
    defect was a warming arm being read as a dead one;
  * and it CHECKS that liveness rather than asserting it. The window between the
    loop's last `kill -0` and the final `curl` is where a child killed at the
    budget boundary lands -- OOM reaper, driver reset, its own abort -- and the
    sentence then told the reader the opposite of what happened, the same class
    reversed: a dead arm read as warming. Each outcome prints its own sentence,
    and a third stub dies in exactly that gap so the arm is deterministic;
  * the budget is validated ABOVE EVERY SIDE EFFECT, not after the spawn: a bad
    value used to start a 14B forward-serve, begin its weight load and create the
    log before exiting 2 with the right code. Above `: > "$OUT"` also makes the
    ordering observable, which a check after the spawn cannot be -- the parent
    exits in microseconds and the child dies before opening its redirect, so "no
    serve log" is true either way and an arm asserting it passes for the wrong
    reason. The first version of that arm did exactly that and was removed;
  * the test holds RESOURCE_LOCK route_ports, because it frees a loopback port
    (`free_port`) and curls it: route_port_lock_test.py's BIND_RE matches
    `free_port` by design, and without the lock a concurrent route test's server
    could be handed that number -- the "never binds" arm would see a stranger's
    /health and post the fixture prompts at it. Measured both ways with the guard
    itself: without the property it fails naming this row, with it all four arms
    pass;
  * NPU_WINDOW11_SERVE_WAIT_S is validated as a positive integer (`=abc` exits 2
    with a message rather than looping on seq's error).

The test is device-free -- three stub worlds (alive and never binding, dies at
once, dies in the gap) under a 1 s budget -- and it takes a FREE PORT from the OS
and passes it with --port, because the script assigns PORT=8110 itself and
ignores the environment: without that, the test curled whatever else listens on
8110 and, had that answered /health, would have posted the fixture prompts at
another lane's server.

Verified: bash -n; 12 arms pass on the fix, 2 fail against the previous version of
this script, 7 against origin/main's; route_port_lock_test.py 4/4 OK once the
census's own C++ row is built (its earlier complaint was an unbuilt tree, not
this change); copyright rc 0.
@bong-water-water-bong
bong-water-water-bong force-pushed the cl-hrxnan/3196-window11-readiness branch from 7461569 to 472a3e0 Compare November 21, 2026 15:52
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The RESOURCE_LOCK is in at 472a3e0bf, and I verified it the way you did — with the guard, both ways.

set_tests_properties(npu_window11_wait PROPERTIES RESOURCE_LOCK route_ports)

Measured against tests/route_port_lock_test.py on a configured tree, two builds differing only in that line:

without the property:
  AssertionError: Lists differ: ['npu_window11_wait (npu_window11_wait_test.sh)'] != []
  these tests start a loopback server without RESOURCE_LOCK route_ports: npu_window11_wait
with it:
  Ran 4 tests … OK

So the guard names the row exactly as your build did, and the property is what clears it. Your point about why also holds and is now in the commit message rather than only in this thread: BIND_RE matching free_port is the right classification, because without the lock a concurrent route test's server could be handed the number and the "never binds" arm would see a stranger's /health — and then post the fixture prompts at it. That is the same interference the free-port change was made to prevent, one lock away.

One thing worth recording for the next lane, because it nearly made me report the guard as broken: run against an unbuilt configure, the census also fails on http_guard —

'http_guard' not found in {…} : http_guard starts an httplib::Server from C++; the census must see it (engine#2504)

— because route_source() keys off the test binary's basename and the file tests/http_guard_test.cpp, so a binary that was never built is invisible to it. After ninja http_guard_test, the same census is 4/4 OK. A lane that runs route_port_lock_test.py against a fresh cmake -B and sees that line should build that target before suspecting its own row; nothing about it is caused by the change under review.

$ bash scripts/pre-pr-checks.sh --base origin/main
pre-pr-checks: all 17 check(s) green, 2 skipped, 0 could not be told    rc 0

The duplicate row that was red at the previous head is clear as well (#3207/#3208/#3209 were three copies of the engine#3205 fix; my own branch for that was dropped unpushed rather than made a fourth). Nothing else changed since your last read: 12 arms, 2 failing against 19e69f37f's script and 7 against origin/main's, and the free-port fix in the test is unchanged.

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 472a3e0

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 472a3e0: READY

The lock is in and it does what the row needed. Checked on this head rather than on my earlier copy of the fix:

row: npu_window11_wait  properties: RESOURCE_LOCK route_ports
tests/route_port_lock_test.py against a one-row census  ->  test_every_route_test_holds_the_route_port_lock PASSES
                                                            (the 3 remaining failures are the fake census's own completeness assertions)
tests/npu_window11_wait_test.sh                          ->  pass  (12 arms, no device)
merge-tree origin/main                                   ->  rc 0

That is the assertion whose message reddened the build at 19e69f37 (Lists differ: ['npu_window11_wait (npu_window11_wait_test.sh)'] != []), so the red check is closed by construction rather than by re-running CI and hoping.

The comment above the property is the part worth keeping: it says why free_port puts this row in the census's set (a freed port that a concurrent route row can be handed, after which the "never binds" arm would see a stranger's /health and post fixture prompts at it). One correction to it, for the record: the guard caught it, and so did the arms — neither instead of the other. My two READYs missed it because I ran the script and the mutation (which pass) and never the census, which needs a configured tree; the census is the row that says the registration is right. That is now written down on the thread and in the suite's own comment.

Everything from the previous head is unchanged and still verified here: the if kill -0 $SPID branch with its stub-dies-late gap arm, the pre-spawn budget validation with its "no side effect" arm (both mutation-checked: reverting either one fails an arm), --port + free_port() instead of the ignored PORT=8110, and the elapsed/budget/interpretation triple on the never-ready arm.

The one open note from my first READY stands as a note, not a blocker: NPU_WINDOW11_SERVE_WAIT_S is documented nowhere in docs/, exactly as BITX_SERVE_WAIT_S on main — the pair wants one paragraph together, and neither PR should carry it alone.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 472a3e0: READY — the ordering fix is the right one and the arm grew to 12 ok (was 10), including the two arms that make the ordering observable.

$ bash tests/npu_window11_wait_test.sh scripts/npu-window11.sh      rc 0, 12 ok
ok  …and no side effect happened: the script's own log was never created
ok  a serve that dies just before the last check reports the DEATH, not the warming window

Placing the validation above every side effect is the substantive change, and the reasoning in the comment is the kind that should be kept: a bad NPU_WINDOW11_SERVE_WAIT_S that exits 2 after : > "$OUT" and the forward-serve spawn has the right exit code and the wrong behaviour — a 14B weight load started and then killed by the EXIT trap. Measured order at this head: knob parse :446, : > "$OUT" :451, spawn :462. Placing it above the redirect is also what makes the property testable (an absent serve log proves nothing if the child is killed before it opens its own redirect) — that is the difference between a fix and a claim.

The die-vs-warming arm added here is the pair my earlier review asked to keep distinct, and it now fires on the boundary case ("dies just before the last check").

Nothing outstanding: knob validated, elbow room for a 14B warm, message carries budget + elapsed + log + tail, all pinned by 12 device-free arms in a registered row.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

npu: npu-window11.sh's readiness arm prints no reason and its budget is a constant (the sibling of #3194)

1 participant