Skip to content

fix(prompt-cache): keep test schedulers off the host memory gate - #3186

Merged
inureyes merged 1 commit into
mainfrom
fix/issue-3146-nightly-snapshot-donation
Nov 20, 2026
Merged

inureyes merged 1 commit into
mainfrom
fix/issue-3146-nightly-snapshot-donation

Conversation

@inureyes

Copy link
Copy Markdown
Member

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_statistics64 that refuses growth when available-now memory minus the reserve of max(7 GiB, 15% of RAM) cannot cover it. The scheduler unit tests read the real host through that gate. On the nightly runner lablup-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:line panic 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

  • The gate is now a BatchScheduler 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, so unit tests store the same snapshots on any host; with_snapshot_growth_gate installs a simulated host.
  • A refused snapshot or checkpoint is counted under a new memory_reserve reject reason, visible in the observability snapshot, last_reject in /v1/cache/stats, and mlxcel_prompt_cache_reject_total on /metrics. Documented in docs/macos-memory.md.
  • Separate flake: image_worker::a_full_queue_sheds_load could reject three requests instead of two when all four arrived before the worker dequeued the first. The Gated model now signals each started generation, and the test submits the other three only after the first is running.

Validation

  • New tests: a host below the reserve declines the snapshot and names memory_reserve; a test scheduler stores snapshots with no gate and with a roomy simulated host.
  • The six affected scheduler test modules, image worker, metrics, and route tests pass (107 tests, Metal, serial). cargo clippy --lib --tests -D warnings and cargo fmt --check pass.
  • Full serial lib run (--test-threads=1, Metal, M3 Ultra): 12119 passed, 0 failed, 241 ignored.

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
@inureyes inureyes added status:review Under review type:bug Bug fixes, error corrections, or issue resolutions priority:high High priority labels Nov 20, 2026
@inureyes
inureyes merged commit 431621b into main Nov 20, 2026
32 checks passed
@inureyes
inureyes deleted the fix/issue-3146-nightly-snapshot-donation branch November 20, 2026 14:04
@inureyes inureyes added status:done Completed and removed status:review Under review labels Nov 20, 2026
inureyes added a commit that referenced this pull request Nov 20, 2026
Since #3168 the absorbed DeepSeek V2 cache stores its latent as affine int8, so `--kv-bits 8` resolves to Int8 in the serve preflight. The test still expected the pre-#3168 fp16 answer and failed in the 2026-11-19 nightly, the one failure #3186 did not cover.

Refs #3146
@inureyes inureyes added this to the 0.9 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:high High priority status:done Completed type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[nightly-verify] main is red

1 participant