Skip to content

tests: mem_admit_route and laya_gguf_route take the port serve reports; census moves again (refs #1485) - #1555

Merged
bong-water-water-bong merged 1 commit into
mainfrom
1bit/i669-port0-batch4
Nov 8, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
1bit/i669-port0-batch4

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Refs #1485, batch 4. Lock list and census floor in the same commit — the #1537 lesson, applied for the second time.

What

  • tests/mem_admit_route.sh: the refusal case (a 4 TiB model that serve rejects before binding anything) uses --port 0 and reads nothing back — the port was decoration. The two --no-mem-check runs and the small-model run take serve_port_wait inside the loop, since each iteration starts its own process. newport() is deleted with its last caller.
  • tests/laya_gguf_route.sh: the two refusal cases (--laya-model without ggmlc's laya, ONEBIT_LAYA_DEVICE=npu without the NPU add-on) are --port 0 with no parse; the daemon case reads the port back and only then builds $api — previously $api was computed from a guessed port before any serve had started.
  • _onebit_route_tests drops laya_gguf_route and mem_admit_route; the census floor goes 12 → 10, with the comment updated to say it counted 15 before this migration moved nine scripts to serve --port 0.

Verified

  • bash -n clean on both scripts.
  • shellcheck warning counts unchanged against main (mem_admit_route 1, laya_gguf_route 5) — counted against main, not against zero.
  • Census rehearsed against a stand-in ctest built from the new lists: 3/3 cases pass.
  • Not run end to end here (no engine build tree); the CI build job runs the census and mem_admit_route.

Deliberately not in this batch

  • laya_models_e2e, laya_route_e2e: they assert on serve's output text for refusals; they need the parse only where they actually serve, so they want their own read-through rather than a sweep.
  • npu_repack_path: needs an NPU device, and runs serve inside timeout (the pid to watch is the wrapper's).
  • kvshare_fd_handoff.py: python, spawns serve itself.
  • hrx_cpu_weight_parity: out of scope permanently — it runs llama-server, not 1bit serve; its port is not ours to choose. That is now written in the lock-list comment so the next person does not re-litigate it.

…s; census moves again

Batch 4 of #1485, with the lock list and the census floor in the same commit (the #1537 lesson).

- `mem_admit_route.sh`: the refusal case (a 4 TiB model) uses `--port 0` with no readiness parse - that serve is
  refused before it binds, so the port was decoration. The two `--no-mem-check` runs and the small-model run read the
  port back with `serve_port_wait`, inside the loop where the process is started. `newport()` is gone with its last
  caller.
- `laya_gguf_route.sh`: both refusal cases (`--laya-model` without ggmlc's laya, `ONEBIT_LAYA_DEVICE=npu` without the
  NPU add-on) drop to `--port 0` with no parse; the daemon case reads the port back and only then builds `$api`.
- `_onebit_route_tests` loses `laya_gguf_route` and `mem_admit_route` (neither pre-picks now), and the census floor
  goes 12 -> 10 with the comment updated: it counted 15 before this migration moved nine scripts to `serve --port 0`.

Census rehearsed against a stand-in `ctest` built from the new lists: 3/3 cases pass. `bash -n` clean on both scripts;
shellcheck warning counts unchanged against main (mem_admit 1, laya_gguf_route 5).

Deliberately not in this batch, with the reason: `laya_models_e2e`/`laya_route_e2e` assert on serve's *output text* for
refusals (they would need the parse only where they actually serve), `npu_repack_path` needs an NPU device and runs serve
inside a `timeout`, and `kvshare_fd_handoff.py` is python spawning serve itself.

@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: READY at 9e761c9d.

newport() is gone with nothing left pointing at it — the check a deleted helper deserves, and the strongest form of it: git grep newport over the whole
tree at this head returns zero references, so neither the definition nor a caller survives anywhere (not just in the two scripts).

The census moved in the same commit again, and the arithmetic says it was counted rather than guessed: the lock list goes 13 → 11 names
(mem_admit_route and laya_gguf_route leave), the floor 12 → 10, and the comment's "seven scripts moved to serve --port 0" becomes "nine" — which
is 7 + these 2. A floor that moves in step with the thing it counts, with the reason written beside it, is what #1537 taught.

Static check of the property the census enforces (it cannot run here without a configured build, which is why your rehearsal used a stand-in): I listed
every tests/*.sh matching the census's own BIND_RE and diffed against the lock list. Nothing is missing — the unlocked binders are exactly the ones that
should be: hrx_cpu_weight_parity (runs llama-server, whose port is not ours) and hybrid_e2e/laya_models_e2e/laya_route_e2e/pm_laya_route (the
model/config-only APPEND list).

Mechanical: bash -n clean on both; shellcheck per file identical to main (mem_admit_route 1 SC2034, laya_gguf_route 5 SC2034 — unchanged); zero
s.bind(("127.0.0.1", 0)) left in either. mem_admit_route's --port 0 on an arm that is refused before it binds is right, with the reason in the comment.

One pattern worth deciding once, because this is the third time: both scripts call serve_port_wait "$log" "$pid" without a budget, so the helper's
default 30 s applies.

laya_gguf_route   port budget 30 s   health window 300 x 0.1 = 30 s   exact
mem_admit_route   port budget 30 s   health window 100 x 0.1 = 10 s   3x the window

For laya_gguf_route that is a match by coincidence; for mem_admit_route it is a 3x margin (batch 3's serve_e2e was 2x). Not blocking — the margin errs
toward waiting rather than failing a good build, and kill -0 catches a dead serve immediately — but the convention "pass the health window as the budget,
or say why the margin is larger" would make the next batch mechanical instead of another judgement call.

@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: READY at 9e761c9d27e81974499e4a63a87b829930f853bd

Two more scripts off the pick-a-port-and-release-it pattern, and both now read what serve reports:

leftover bind(0)/socket picking in tests/laya_gguf_route.sh: 0        (was 1)
leftover bind(0)/socket picking in tests/mem_admit_route.sh: 0        (was 1)
serve_port_from_log/wait call sites:  1 and 3

and the shared helper still parses the suffixed ready line (…:8095 (laya-models: x) → 8095), so the lazily-routed serve path these tests use is covered by the same extractor #1531 fixed.

The comment is the right one to leave behind: "--port 0 for every serve below: the kernel picks and serve reports the port it bound, so nothing is picked and released before serve binds (engine #1444/#1485). The two refusal cases need no port at all; the daemon case reads the port back from serve's ready line." That last clause is the useful part — the refusal arms genuinely do not need a port, and saying so stops a future reader from adding a --port 0 there "for consistency" and then wondering why it hangs.

Both scripts parse, and both now source tests/serve_port.sh rather than carrying their own extractor, which is the property that keeps the four ready-line shapes fixed in one place.

Not run: the two suites end to end (they need 1bit and a --laya-model pack); the port handling is what changed and it is the helper I verified on six log shapes earlier.

@bong-water-water-bong
bong-water-water-bong merged commit b8c30ef into main Nov 8, 2026
9 of 10 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/i669-port0-batch4 branch November 8, 2026 22:33
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

1485 - Partially compliant

Compliant requirements:

  • The scripts mem_admit_route.sh and laya_gguf_route.sh now use --port 0 and read the port from the ready line
  • The census test in route_port_lock_test.py has been updated to reflect the new count of route tests
  • The CMakeLists.txt file has been updated to remove the scripts that now use --port 0 from the list of tests that pick ports upfront

Non-compliant requirements:

  • The PR does not include a reference script showing the parse mechanism for the ready line, as mentioned in the ticket description

Requires further human verification:

  • The end-to-end functionality of the migrated scripts needs to be verified with a full engine build
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Port Binding Race Condition

The script now uses --port 0 and reads the port from the ready line, which eliminates the race condition. However, the script still uses serve_port_wait to parse the port, which might introduce a small delay or potential parsing error if the ready line format changes.

port=$(serve_port_wait "$scratch/serve.log" "$pid") || { echo "FAIL serve never reported a port"; cat "$scratch/serve.log"; exit 1; }
api="http://127.0.0.1:$port"
Port Binding Race Condition

The script now uses --port 0 and reads the port from the ready line, which eliminates the race condition. However, the script still uses serve_port_wait to parse the port, which might introduce a small delay or potential parsing error if the ready line format changes.

port=$(serve_port_wait "$scratch/skip-$how.log" "$pid") || { echo "FAIL serve never reported a port ($how)"; cat "$scratch/skip-$how.log"; exit 1; }
code=000
Census Floor Update

The census floor has been updated from 12 to 10, which is correct given that 9 scripts have been migrated to use --port 0. However, the comment in the test should be updated to reflect the new number of scripts that still pick ports upfront.

self.assertGreaterEqual(len(found), 10,
                        "fewer route tests found than the suite has: " + ", ".join(sorted(found)))

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.

1 participant