Repository navigation
Give the page-fault stall test a window the scheduler cannot close - #11284
Conversation
test_mmap_page_ins_with_flat_resident_memory_count has failed on consecutive main runs in Backend CI (Python 3.13, l-r), always as 'assert ok is True'. It is the only test in the file where page faults are the sole progress signal, because it disables the other two on purpose. That matters, because _made_startup_progress measures CPU as MIN_CPU_FRACTION * elapsed while it compares page faults against a flat MIN_PAGE_FAULTS. A CPU-driven child that loses the scheduler needs proportionally less CPU to still count as progressing; a fault-driven one does not get the same relief, so starvation lowers the count without lowering the bar. Its siblings are starvation-proof by construction and this test is not. At the 0.6s stall window the others share, one sample window where the child is not scheduled ends the wait. Reproduced on a 2-CPU cpuset against 8 competing busy loops: 2 failures in 12 runs at this assertion, the shape CI sees where 18,747 tests share four workers. With the window at 1.5s, 10 runs out of 10 pass under identical contention. Production is not affected and is not changed: _wait_for_health defaults to a 120s timeout, and it is the test that compresses the window to 0.6s. The claim is unchanged rather than widened. Without page-fault progress the wait still expires at 1.5s, well before the 2.5s health flip, so the test still fails if the signal breaks. Verified by raising MIN_PAGE_FAULTS to 1 << 40: the test fails as before, and 87 passed with it restored.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
…othai#11288) test_companion_root_scan_does_not_block_the_event_loop failed on main in Backend CI (Python 3.13, l-r) at 'assert loop_was_responsive', on a shard that took 565s against a 371s baseline. The assertion was time.monotonic() - started < 0.5, a proxy for the loop staying responsive. It is only a proxy, and it measures the wrong thing: the elapsed window includes dispatching asyncio.to_thread(entered.wait, ...) through the default executor, so a runner that is merely busy blows the 0.5s budget while the loop is behaving perfectly. Against a 1.0s block it had a 2x margin to spend on scheduling. routes.inference awaits the scan through await asyncio.to_thread(local_gguf_companion_roots, ...) so running on another thread IS the mechanism the wall clock was standing in for. The test records the thread the scan executed on and compares it with the loop's own thread, which is the same claim with no timing in it and cannot be defeated by a slow machine. The waits that remain are generous upper bounds for a hung test rather than thresholds anything is measured against. Proved by making routes.inference call the scan synchronously instead of through to_thread: the test fails with both idents equal. Restored, 694 passed. Not reproduced locally first, unlike the sibling fix in unslothai#11284: CPU contention on a pinned cpuset and a saturated default executor both left it passing 10 and 8 times. The CI traceback names the assertion, and the assertion is a wall-clock threshold, so the diagnosis does not depend on reproducing the timing.
…nslothai#11284) test_mmap_page_ins_with_flat_resident_memory_count has failed on consecutive main runs in Backend CI (Python 3.13, l-r), always as 'assert ok is True'. It is the only test in the file where page faults are the sole progress signal, because it disables the other two on purpose. That matters, because _made_startup_progress measures CPU as MIN_CPU_FRACTION * elapsed while it compares page faults against a flat MIN_PAGE_FAULTS. A CPU-driven child that loses the scheduler needs proportionally less CPU to still count as progressing; a fault-driven one does not get the same relief, so starvation lowers the count without lowering the bar. Its siblings are starvation-proof by construction and this test is not. At the 0.6s stall window the others share, one sample window where the child is not scheduled ends the wait. Reproduced on a 2-CPU cpuset against 8 competing busy loops: 2 failures in 12 runs at this assertion, the shape CI sees where 18,747 tests share four workers. With the window at 1.5s, 10 runs out of 10 pass under identical contention. Production is not affected and is not changed: _wait_for_health defaults to a 120s timeout, and it is the test that compresses the window to 0.6s. The claim is unchanged rather than widened. Without page-fault progress the wait still expires at 1.5s, well before the 2.5s health flip, so the test still fails if the signal breaks. Verified by raising MIN_PAGE_FAULTS to 1 << 40: the test fails as before, and 87 passed with it restored.
…othai#11288) test_companion_root_scan_does_not_block_the_event_loop failed on main in Backend CI (Python 3.13, l-r) at 'assert loop_was_responsive', on a shard that took 565s against a 371s baseline. The assertion was time.monotonic() - started < 0.5, a proxy for the loop staying responsive. It is only a proxy, and it measures the wrong thing: the elapsed window includes dispatching asyncio.to_thread(entered.wait, ...) through the default executor, so a runner that is merely busy blows the 0.5s budget while the loop is behaving perfectly. Against a 1.0s block it had a 2x margin to spend on scheduling. routes.inference awaits the scan through await asyncio.to_thread(local_gguf_companion_roots, ...) so running on another thread IS the mechanism the wall clock was standing in for. The test records the thread the scan executed on and compares it with the loop's own thread, which is the same claim with no timing in it and cannot be defeated by a slow machine. The waits that remain are generous upper bounds for a hung test rather than thresholds anything is measured against. Proved by making routes.inference call the scan synchronously instead of through to_thread: the test fails with both idents equal. Restored, 694 passed. Not reproduced locally first, unlike the sibling fix in unslothai#11284: CPU contention on a pinned cpuset and a saturated default executor both left it passing 10 and 8 times. The CI traceback names the assertion, and the assertion is a wall-clock threshold, so the diagnosis does not depend on reproducing the timing.
…nslothai#16476) The mmap startup-progress test depends on a child process generating enough real page faults inside a 1.5-second stall window before health becomes ready at 2.5 seconds. It failed in the Python 3.13 CPU job even though the same test passed locally on both base and the auth branch. The exact remote scheduling or page-cache cause is unproven; a wall-clock resource dependency makes this an unreliable test of the progress policy. The reviewed unslothai#16471 spacing dependency is already merged. The remaining changes are confined to tests. Drive the production startup sampler and health wait with a controlled clock and process counters. CPU time, resident memory and read-byte counters stay flat. Advancing faults keep the wait alive beyond its original deadline; fixed faults reach the original stall timeout. A separate parser check covers the platform counter fields and Linux stat parsing, including a process name containing a closing parenthesis. The health-test fix changes no production startup code, stall budget or polling interval. The test does not sleep, skip the failing case or relax its negative assertion. Fake process IDs are outside the valid host PID range and all process access is controlled. The final validation pass also corrects the installer progress fixture to model successful uv bootstrap. Forcing bootstrap failure could instead hit the valid torch-freeze guard before reaching the progress assertion on newer torch installations. All 16 progress checks now pass without changing installer behavior or weakening assertions. Current-main integration with this health change passes 896 checks, with two existing platform skips. That integration also verifies the upstream CI fixture fixes from unslothai#16530 through unslothai#16533. The rewrite also removes the now-unused `os` import. The existing import-safety check correctly rejected the preceding head; the same command passes after this one-line cleanup. All 101 local health/font checks pass. Refreshed Linux, macOS and Windows staging explicitly includes that required import-safety gate. The raw logs confirm that the gate runs and passes on all three platforms. The health-wait behavior and original test came from unslothai#11055, with later timing adjustments in unslothai#11284 and unslothai#12065. The complete health-wait test file passes 89 tests. This hardens the test contract without claiming a production mmap failure was reproduced or that every earlier CI timeout has the same cause. Disabling production fault accounting makes the new positive case fail while the stalled case still passes. Three panel reviews and three independent focused reviews found no actionable defect. Platform counter formats are simulated on Linux; removing the worker means this case no longer covers actual native mmap page-ins. Other real-process startup tests remain. The paired Studio switchboard completes auth, Settings and route crawling with functional `NO_REGRESSION`: 38 matching steps and one Hub visual difference. All 39 functional captures succeed on both arms. The Hub benchmark-popover comparison retains a visual/mask difference on confirmation, so exact visual parity for that capture is not claimed. The health-test change itself has no production UI effect. The included unslothai#16471 dependency changes Settings spacing and uses its existing before/after evidence below. Current-head staging passes 117 Python checks (89 health, 12 font-contract and 16 installer progress checks), 42 Node spacing/control checks and the required import-safety gate on each of [Linux](https://github.com/Imagineer99/unsloth/actions/runs/41645022400), [Apple Silicon macOS](https://github.com/Imagineer99/unsloth/actions/runs/41645022445) and [Windows](https://github.com/Imagineer99/unsloth/actions/runs/41645022404), with zero failures or skips. Raw logs and exact source-head ancestry were checked. The current-head switchboard reports functional `NO_REGRESSION` across auth, all 19 Settings steps, model picker and route crawling. The retained Hub/data-recipes comparisons include DOM/mask differences with zero changed pixels; exact visual parity is not claimed for those captures. The current head also carries unslothai#16471's rich-paste badge correction for the font-contract CI regression introduced by unslothai#16298. Both Settings components are byte-identical to the parent. Local validation passes 101 Python checks and 42 Node checks. Refreshed platform checks include the font contract as well as the unchanged health-policy checks. The shared spacing dependency below is the exact unslothai#16471 change; this comparison validates that dependency.  The inherited rich-paste badge correction is also byte-identical to unslothai#16471. At the enlarged font setting it scales from the previous fixed 10 px to 15 px, with the feature and switch retained: 
Summary
test_mmap_page_ins_with_flat_resident_memory_counthas failed on consecutivemainruns inBackend CI (Python 3.13, l-r), always at the same line:Reproduced and fixed. Part of #11241, which collected two unrelated failures under one title; this is the one that is not about leaked state, and the 500s in
test_openai_auto_switch.pyare still open there.Why this one test and not its siblings
Three tests in this class race a real child against the stall detector. Only this one is fragile, and the asymmetry is in
_made_startup_progress:CPU is a fraction of elapsed time, so a CPU-driven child that loses the scheduler needs proportionally less CPU to still count as progressing. Those tests are starvation-proof by construction. Page faults are compared against a flat count, so starvation lowers the number of faults in a window without lowering the bar.
This is the only test where that matters, because it disables the other two signals on purpose so faults are the sole remaining one:
and its worker calls
posix_fadvise(DONTNEED)every iteration, so every read is real I/O rather than a page-cache hit.At the 0.6s stall window the siblings share, a single sample window where that child is not scheduled expires the deadline.
Reproduction
On a 192-core host, ordinary load proves nothing: 6 of 6 passed against 12 busy loops. Pinning the test and the load to the same 2 CPUs is what reproduces the CI shape, where 18,747 tests share four workers:
What changed, and what did not
Only the stall window for this one test, 0.6s to 1.5s.
Production is untouched and not at issue:
_wait_for_healthdefaults totimeout = 120.0, and it is the test that compresses the window to 0.6s to keep itself fast. The thresholds themselves are unchanged.The claim the test makes is unchanged rather than widened. Without page-fault progress the wait still expires at 1.5s, well before the 2.5s health flip, so the test still fails if the signal stops working. Verified by disabling that signal: