Repository navigation
fix(prompt-cache): keep test schedulers off the host memory gate - #3186
Merged
Merged
Conversation
The nightly verify-test on the 16 GB-class Mac mini runner failed 18 scheduler prompt-cache tests with zero snapshot inserts. Every snapshot and state-checkpoint growth step goes through the macOS memory guardrail (#2883 step 4), a process-wide gate over host_statistics64 that refuses growth when available-now memory minus the reserve of max(7 GiB, 15% of RAM) cannot cover it. The unit-test schedulers read the real host through that gate, so a runner below the reserve stored nothing, and the skip recorded no reject, so the store just looked empty. The gate is now a scheduler field. Production schedulers share the process-wide host gate as before; cfg(test) schedulers get a gate whose availability is unknown, which approves every step, and with_snapshot_growth_gate lets a test install a simulated host. A refused snapshot or checkpoint is now counted under a new memory_reserve reject reason, exposed in the observability snapshot, last_reject, and mlxcel_prompt_cache_reject_total. Forcing the old behaviour with a simulated 16 GB host at 4 GiB available reproduces all 18 nightly failures at the same file:line panic sites. New tests pin the decline and its reason, and that the test scheduler stores snapshots regardless of host memory. Also fix a race in image_worker a_full_queue_sheds_load: with queue depth 1 the four requests could all arrive before the worker dequeued the first, rejecting three. The Gated model now signals when a generation starts and the test submits the rest after that. Closes #3146
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3146
Root cause
Every prompt-cache snapshot and state-checkpoint growth step goes through the macOS memory guardrail (#2883 step 4): a process-wide gate over
host_statistics64that refuses growth when available-now memory minus the reserve ofmax(7 GiB, 15% of RAM)cannot cover it. The scheduler unit tests read the real host through that gate. On the nightly runnerlablup-macmini11(a small-memory Mac mini) available-now sat below the reserve, so every snapshot was skipped, and the skip recorded no reject reason: the 18 tests saw an empty store and nothing said why. A 512 GB workstation never comes near the reserve, which is why the tests pass there.Evidence: forcing the old code path with a simulated 16 GB host at 4 GiB available reproduces all 18 nightly failures at exactly the same
file:linepanic sites as run 44584967904. The runner's memory size was not read directly (the runners API needs org admin), but the failure set match is exact.Fix
BatchSchedulerfield. Production schedulers share the process-wide host gate as before.cfg(test)schedulers get a gate whose availability is unknown, which approves every step, so unit tests store the same snapshots on any host;with_snapshot_growth_gateinstalls a simulated host.memory_reservereject reason, visible in the observability snapshot,last_rejectin/v1/cache/stats, andmlxcel_prompt_cache_reject_totalon/metrics. Documented indocs/macos-memory.md.image_worker::a_full_queue_sheds_loadcould reject three requests instead of two when all four arrived before the worker dequeued the first. TheGatedmodel now signals each started generation, and the test submits the other three only after the first is running.Validation
memory_reserve; a test scheduler stores snapshots with no gate and with a roomy simulated host.cargo clippy --lib --tests -D warningsandcargo fmt --checkpass.--test-threads=1, Metal, M3 Ultra): 12119 passed, 0 failed, 241 ignored.