Repository navigation
Conversation
…s stop it The hard-pressure requeue writes every live request's KV to the paged SSD cache on the inference thread at the cache drive's write speed. On a slow drive this froze all decoding for minutes and aborts were not processed until the whole store ended. store_cache now takes an optional should_stop callback checked between blocks; the requeue stops on a pending abort or after OMLX_MEMORY_REQUEUE_STORE_BUDGET_S (default 30 s, 0 = no limit). Stored blocks stay a valid prefix; the rest is recomputed.
zviratko
added a commit
to zviratko/omlx-uplift
that referenced
this pull request
Nov 22, 2026
A memory-pressure requeue stored every running request's KV on the inference thread at the cache drive's write speed; on an SD-card cache that froze decoding for minutes and ignored aborts. The PR stops the store between blocks on a pending abort or after OMLX_MEMORY_REQUEUE_STORE_BUDGET_S (30 s). Linked as github_pr per the catalog rule; notes file with the analysis, verification and the uplift autopatch pitfall found while testing.
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.
Problem
At hard memory pressure,
ProcessMemoryEnforcerasks the scheduler to store and requeue the live requests instead of aborting them (#4509)._process_pending_memory_requeuewrites each request's KV to the paged SSD cache on the inference thread, underbounded_pending_writes, so the store runs at the write speed of the SSD cache drive. While it runs:_pending_abort_idsis checked only between requests, not between blocks.On a slow drive this looks like a deadlock. Measured with the SSD cache on an SD card (about 21 MB/s write): two 150k-token requests on Qwen3.8-Flash-Next (8192-token blocks of 216 MB) froze the engine for about 3 minutes and were still storing; client aborts had no effect and the server had to be killed. The enforcer repeated "Hard memory pressure: storing and requeueing 2 request(s)" every second for the whole time. On a fast internal SSD the same store takes seconds, so the problem shows only with slow or throttling cache drives.
Approach
BlockAwarePrefixCache.store_cachegets an optionalshould_stopcallback. It is checked before each new block is allocated; when it returns True the store ends through the same exit as a failed block allocation, so the blocks stored so far stay a valid prefix. Callers that do not pass it are unchanged.should_stop = pending abort or time budget spent. The budget is_MEMORY_REQUEUE_STORE_BUDGET_S = 30.0, override withOMLX_MEMORY_REQUEUE_STORE_BUDGET_S(0 = no limit, the old behavior). Requests not reached within the budget are requeued without a stored prefix and recompute; requests stopped mid-store resume from the blocks they kept.40960/73728), not the tokens it tried to store.The freeze can exceed the budget by at most one block write, because the check runs between blocks.
Validation
tests/test_memory_requeue_store_budget.py(6 tests) on the existing_chunked_scheduler_rig(tiny hybrid GDN and rotating models, real paged SSD cache):With the
should_stopcheck instore_cacheremoved, the two partial-prefix tests and the abort test fail; with the deadline removed, the two spent-budget tests fail.test_scheduler_boundary_completion,test_process_memory_enforcer,test_prefill_oom_graceful,test_scheduler_prompt_boundary_store): 360 passed.python -m pytest): 19,804 passed, 6 failed; the same 6 fail onmainwithout this change (test_glm5_next_mtpsplit-K x2,test_hy_v4NAX paths,test_install_detectionx2,test_mcp_clientSSE headers).Prefix cache restore ... cached=40960), and both completed with all 64 output tokens. Without the change the same situation stored block after block for minutes.Not tested: the hard-pressure trigger itself with the fix on real hardware. I could not reproduce it reliably by load (the chunk sizer usually throttles first), so the live run triggered
request_memory_requeue()directly through a temporary test hook (not part of this PR). The real-model runs (the hang and the fix) used a local build of an earliermainwith other local patches; none of them touch the requeue or store path, and this diff applies unchanged on currentmain. The default budget of 30 s is a judgment call; it is long enough that a normal SSD never reaches it.