Repository navigation
fix(offload): cap failed-save retries so a broken Store client can't pin requests forever - #3781
ZhangLirong-amd wants to merge 2 commits into
Conversation
…pin requests forever A chunked (dense / KV-store) offload save that fails was retried with no bound for as long as its request stayed tracked, and every dispatch -- retries included -- restarts the reclaim clock (`_refresh_save_reclaim_clock`). With the KV-store pacing capping the retry interval at 30 s, the 300 s stalled-save reclaim never fired. When one rank's Mooncake Store client started failing every put, each finished request it had saved stayed in `deferred_free_blocks` with its blocks and per-request state slot until the slots ran out and admission on that rank stopped. Bound the retries in `ChunkedOffloadSchedulerBase`: - at most OFFLOAD_MAX_FAILED_SAVE_RETRIES (default 3) retries per request since its last stored save; a stored save restarts the budget; - no retry once the save has made no progress (a new range dispatched, or a save stored) for `save_abandon_timeout_s` -- the no-progress window the DSV4 scheduler already keeps (`_save_retries_expired`). Past either, the save is dropped with a warning and the request is reported as a finished save so the engine re-checks its deferred free. The reclaim clock is still restarted on every dispatch: the workers count a save's source read deadline from its own dispatch, so a reclaim that started earlier could free blocks a retry is still reading.
🏷️ CI GuideRuns automatically on every eligible PR before approval:
Heavy model tests:
Path scope:
|
There was a problem hiding this comment.
🟡 Changes recommended
The vLLM plugin path never drains _save_given_up notifications, so retired or dropped failed saves accumulate request IDs and cause unbounded host-memory growth during persistent tier failures.
1 open issue
What changed in this PR
This PR bounds failed-save retries in ATOM’s shared chunked offload scheduler so persistent Store failures cannot indefinitely pin finished requests’ KV blocks and state slots.
Changes:
- Adds a configurable retry budget and a separate no-progress timeout while preserving per-dispatch source-read protection.
- Cleans up retry bookkeeping and reports abandoned saves for deferred resource release.
- Documents the new setting and adds regression coverage for retry limits, budget resets, timeout behavior, and state-slot release.
| File | Description |
|---|---|
tests/test_offload_review_regressions.py |
Updates the scheduler test double with retry helpers. |
tests/test_mooncake_store_offload.py |
Adds failure-retry and resource-release regression tests. |
tests/test_envs.py |
Checks the new setting’s empty-value default. |
docs/environment_variables.md |
Documents retry limits and timeout behavior. |
atom/utils/envs.py |
Registers OFFLOAD_MAX_FAILED_SAVE_RETRIES, defaulting to 3. |
atom/kv_transfer/offload/README.md |
Explains bounded retries and their operational effects. |
atom/kv_transfer/offload/chunked_scheduler.py |
Implements retry bounds, progress tracking, cleanup, and abandonment notifications. |
Review effort: Balanced
| # completion that is not itself a store terminal: reported as | ||
| # finished saves by the next `process_completions`, so the engine | ||
| # re-checks their deferred free. | ||
| self._save_given_up: set = set() |
There was a problem hiding this comment.
Confirmed and fixed in 28cf0fa. The vLLM adapter only calls connector_completion, so nothing drained _save_given_up there. Probe on 12806cc with the real PluginDenseScheduler, 200 requests whose saves all fail: every save was given up after its retries, and all 200 request IDs stayed in _save_given_up.
The report is only needed where ATOM's engine re-checks a deferred free on finished_saving. The plugin's adapter already re-checks every deferred free each step (_collect_releases), so PluginSchedulerMixin now sets _reports_given_up_saves = False and nothing is queued on that path. ATOM's engine still gets the report.
New test test_a_frontend_without_process_completions_queues_no_given_up_saves drives the real DenseOffloadScheduler and PluginDenseScheduler through failing saves: the native one reports the dropped saves once through process_completions, the plugin one queues nothing. It fails with the opt-out reverted.
While checking this I also found that tests/plugin/test_vllm_offload_seq_view.py::test_view_accepts_the_frozen_placement_the_chunked_scheduler_writes failed on 12806cc (its hand-built scheduler lacked the two new helpers); fixed in the same commit. Base vs this head, with tests/plugin added to the regression selection: identical failure lists (environment-only), and 10 more passes.
| output = super().process_completions(output) | ||
| self._ensure_save_retry_state() | ||
| if self._save_given_up: | ||
| output.finished_saving = set(output.finished_saving) | self._save_given_up |
There was a problem hiding this comment.
vllm plugin never calls process_completions, so _save_given_up grows unbounded there. drain it in the per-step hook? applies to plugin_schedulers.py and connector.py too
There was a problem hiding this comment.
Same issue as Copilot's thread above; fixed in 28cf0fa. Rather than drain it in the per-step hook, the plugin schedulers no longer queue it (PluginSchedulerMixin._reports_given_up_saves = False): the report only exists to make ATOM's engine re-check a deferred free on finished_saving, and the plugin adapter already re-checks every deferred free each step in _collect_releases, so a drained report would have no consumer there. test_a_frontend_without_process_completions_queues_no_given_up_saves covers both sides (native reports once through process_completions, plugin queues nothing) and fails with the opt-out reverted.
…ins them The vLLM plugin calls no `process_completions` (its adapter re-checks every deferred free each step), so a save given up on there left its request ID in `_save_given_up` for the life of the server. `PluginSchedulerMixin` now opts out of the report; ATOM's engine still gets it. Also binds the two new retry helpers on the hand-built scheduler in tests/plugin/test_vllm_offload_seq_view.py, which calls the real `request_finished` and failed with AttributeError since the retry cap.

Symptom
P/D deployment, DeepSeek-V4.1-Flash, Mooncake Store offload on the prefill side. After about an hour of sustained load, one prefill rank's Store client started failing every put and get with
TRANSFER_FAIL(-800). The other ranks, which used the same Store owner, kept working. Failed loads fell back to prefill as designed (180 of them). On the affected rank, though:deferred_free_blocks(requests_deferred_free 128; the paged pool was only about 4% used);pool_full), and the rank stayed atRunning 0, Waiting 70;retrying failed dense savefor the same 128 requests about every 30 s. One request was retried 104 times over 51 minutes. NoAbandoned … offload saveand no save-lease reclaim was ever logged.Root cause
Two behaviours combine:
ChunkedOffloadSchedulerBase._retry_or_retire_failed_saveretries a failed save as long as the request is tracked. It retires the save only when the store side knows the request finished (_offload_finished, whichprotected_block_idssets). That flag is not always set. For example, behind aMultiConnectorwhose P/D leg is still sending,protected_block_idsanswersNone(the P/D leg cannot narrow its protection), so the request is deferred whole and the store leg never learns it finished. Its failed save is then retried forever.KVStoreOffloadSchedulerpaces the retries (1 s, doubling, capped at 30 s), which limits the rate but not the number._refresh_save_reclaim_clock, which resetsseq._deferred_save_atand_save_lease_at. With a retry at least every 30 s, the 300 s window of_reconcile_stalled_deferred_savesnever elapses.So the request keeps its blocks and its state slot forever. Once enough requests are stuck this way, admission on that rank stops for good.
Introduced by
_refresh_save_reclaim_clock. The same PR gave the DSV4 scheduler_save_retries_expired, a no-progress window that the per-dispatch clock cannot reset. The chunked scheduler had no failed-save retry at that time and never got the equivalent.kv_storelayer by refactor(offload): shared kv_store layer for store-backed offload, with save dedup #3374) added the KV-store retry pacing. Its 30 s cap is the interval seen in the incident.Fix (
ChunkedOffloadSchedulerBase)OFFLOAD_MAX_FAILED_SAVE_RETRIESretries (new env, default 3;0drops on the first failure), counted since the request's last stored save. A stored save resets the count.save_abandon_timeout_s. Progress means a new range was dispatched or a save was stored; a retry of the same range does not count. This is the bound the DSV4 scheduler already has. It makes the abandon timeout a real backstop, whatever the budget is set to._retire_finished_save(which also returns any leased blocks), and report the request as a finished save.should_defer_freethen turns False, and the engine re-checks the deferred free on the same step, even when the give-up happens on a source-safe or quiescent report instead of a store terminal.process_completionsruns (ATOM's engine). The vLLM plugin never calls it and re-checks every deferred free each step anyway, so its schedulers (PluginSchedulerMixin) do not queue it; otherwise each given-up save's request ID would stay queued for the life of the server.abandon_save,reclaim_stale_leases, late-save drop,request_finished, andsource_blocks_released.dispatched_at+save_abandon_timeout_s− margin). If a retry did not refresh the clock, the reclaim could free blocks that the retry is still reading. The bound is therefore on setting up retries, not on the clock.Nothing changes when saves succeed. The counters are only touched on a failure, and the progress record is bookkeeping only.
Docs: offload README (pacing section and env table) and
docs/environment_variables.md. The setting applies to the chunked schedulers (dense, Mooncake Store / KV-store, LMCache MP, and the vLLM plugin's dense and MP schedulers). DeepSeek-V4's hybrid offload scheduler has its own retry handling (its_save_retries_expired) and is unchanged.Tests
New tests in
tests/test_mooncake_store_offload.py, using the fake Store and the real worker, each run in serial and pipelined mode:test_a_save_the_store_keeps_failing_is_dropped_after_its_retries: every put fails. Exactly 1 attempt plus 3 retries are sent, then nothing. The tracker entry and bookkeeping are gone,should_defer_freeis False, and a later save still goes out.test_a_stored_save_gives_the_request_its_retries_back: two failures, then a success (no drop). Then three failures on the next range: still not dropped, because the budget restarted.test_retries_of_one_range_cannot_outlive_the_abandon_timeout: budget set to 1000, with a retry every 30 s. Each retry still restarts_deferred_save_at, but the save is given up at 300 s with no progress.test_a_request_whose_save_keeps_failing_gives_back_its_state_slot: uses the realSchedulerwith a one-slot state pool and the store behind a composite that cannot narrow, as with a P/D send. The finished request is deferred whole. After 1 attempt and 3 retries it leavesdeferred_free_blocks, and its state slot and blocks are freed.All 8 new cases fail on
mainand pass here. They also pass withaiterimports blocked.test_a_frontend_without_process_completions_queues_no_given_up_saves(tests/test_dense_offload_connector.py): the realDenseOffloadSchedulerand the vLLM plugin'sPluginDenseSchedulerboth drop 4 failing saves after their retry. The native one reports them once throughprocess_completions; the plugin one queues nothing. It fails without the plugin opt-out (on the first revision of this PR the plugin path held all 200 request IDs in a 200-request probe).Also changed:
test_envs.pychecks that an empty value reads as the default, and the hand-bound test doubles intest_offload_review_regressions.pyandtests/plugin/test_vllm_offload_seq_view.pyget the two new helpers (the second one failed withAttributeErroron the first revision of this PR).CPU regression run on base and on this branch (first revision): scheduler, engine, dp, envs, load, early, offload, mooncake_store, prefill, kv, lmcache, dense_offload, multi_connector and pd tests.
The 21 failures are the same on both (
test_scheduler_metrics.py, environment-related), and there are no new ones.blackandruffare clean.Re-run on the current head (28cf0fa), same selection plus
tests/plugin: base 4,406 passed, this branch 4,416 passed (the 10 new cases); 119 failed and 19 collection errors on both, identical lists (test_scheduler_metrics.py, and plugin tests that needvllm/sglang/rtp_llm, which the CPU test container does not have).Risk
OFFLOAD_MAX_FAILED_SAVE_RETRIESif such a backend sees short failure bursts.Context (not fixed here)
The trigger was a single Store client whose transfer path stopped working permanently. Its NICs stayed ACTIVE, and Mooncake logged no QP or work-completion errors, only
Batch completed with task failures. Other clients to the same owner kept working. The cause of that is not known; a single queue pair per endpoint stuck in an error state is one guess, and it is unverified. A worker-side circuit breaker that pauses a rank's saves after repeated put failures would be a separate change. This PR only makes sure such a failure can no longer stop admission.Related
ATOM_OFFLOAD_PRESTART_LOAD_WAIT_MS); independent of this fix.