Skip to content

fix(offload): cap failed-save retries so a broken Store client can't pin requests forever - #3781

Open
ZhangLirong-amd wants to merge 2 commits into
mainfrom
lirzhang/offload-save-retry-cap
Open

ZhangLirong-amd wants to merge 2 commits into
mainfrom
lirzhang/offload-save-retry-cap

Conversation

@ZhangLirong-amd

@ZhangLirong-amd ZhangLirong-amd commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

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:

  • within about 10 minutes, all 128 per-request state slots were held by finished requests parked in deferred_free_blocks (requests_deferred_free 128; the paged pool was only about 4% used);
  • admission stopped at the state-slot gate (early load reported pool_full), and the rank stayed at Running 0, Waiting 70;
  • the D side starved, and the whole P/D pipeline hung (it showed up as a timeout, not as slowness);
  • the log showed retrying failed dense save for the same 128 requests about every 30 s. One request was retried 104 times over 51 minutes. No Abandoned … offload save and no save-lease reclaim was ever logged.

Root cause

Two behaviours combine:

  1. The retry has no bound. ChunkedOffloadSchedulerBase._retry_or_retire_failed_save retries 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, which protected_block_ids sets). That flag is not always set. For example, behind a MultiConnector whose P/D leg is still sending, protected_block_ids answers None (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. KVStoreOffloadScheduler paces the retries (1 s, doubling, capped at 30 s), which limits the rate but not the number.
  2. Every retry resets the reclaim clock. Each dispatch, retries included, calls _refresh_save_reclaim_clock, which resets seq._deferred_save_at and _save_lease_at. With a retry at least every 30 s, the 300 s window of _reconcile_stalled_deferred_saves never 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

Fix (ChunkedOffloadSchedulerBase)

  • Retry budget per request: at most OFFLOAD_MAX_FAILED_SAVE_RETRIES retries (new env, default 3; 0 drops on the first failure), counted since the request's last stored save. A stored save resets the count.
  • No-progress window: no new retry is set up once the save has made no progress for 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.
  • When either limit is hit: log a warning, drop the tracker entry through _retire_finished_save (which also returns any leased blocks), and report the request as a finished save. should_defer_free then 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.
  • The report goes out only where process_completions runs (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.
  • The retry bookkeeping is cleared on every exit: retire, drop, abandon_save, reclaim_stale_leases, late-save drop, request_finished, and source_blocks_released.
  • The reclaim clock is still refreshed on every dispatch, retries included. This is intentional: workers count a save's source read deadline from its own dispatch (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_free is 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 real Scheduler with 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 leaves deferred_free_blocks, and its state slot and blocks are freed.

All 8 new cases fail on main and pass here. They also pass with aiter imports blocked.

  • test_a_frontend_without_process_completions_queues_no_given_up_saves (tests/test_dense_offload_connector.py): the real DenseOffloadScheduler and the vLLM plugin's PluginDenseScheduler both drop 4 failing saves after their retry. The native one reports them once through process_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.py checks that an empty value reads as the default, and the hand-bound test doubles in test_offload_review_regressions.py and tests/plugin/test_vllm_offload_seq_view.py get the two new helpers (the second one failed with AttributeError on 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.

  • base: 3930 passed, 21 failed
  • this branch: 3939 passed (the 9 new cases), 21 failed

The 21 failures are the same on both (test_scheduler_metrics.py, environment-related), and there are no new ones. black and ruff are 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 need vllm/sglang/rtp_llm, which the CPU test container does not have).

Risk

  • A request whose save is dropped is not in the Store, so a later prefix hit on it recomputes instead of loading. Before this change, the same request would have pinned its blocks and state slot indefinitely.
  • A Store that fails only briefly will not usually trigger a drop on the Mooncake Store / KV-store path: a drop needs 4 consecutive failed attempts of the same request with no stored save in between, and those attempts are paced 1 s, 2 s, 4 s, and so on. The dense and LMCache MP schedulers do not pace retries, so there the 4 attempts can come within a few scheduler steps; raise OFFLOAD_MAX_FAILED_SAVE_RETRIES if 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

…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.
Copilot AI balanced review requested due to automatic review settings November 24, 2026 12:29
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every eligible PR before approval:

  • ✅ Pre Checkin: Black, Ruff, catalog schema validation, non-GPU unit tests

Heavy model tests:

  • ✅ Gate checks are published on every PR so required checks do not stay missing
  • ✅ Expensive jobs run only after the PR is approved, or when a matching ci:* label is present
  • ✅ Pre Checkin must pass before approved heavy jobs continue
  • ✅ Without a matching label, expensive jobs also require a relevant path
  • ✅ A matching ci:* label is an explicit request and can open the gate even when paths would otherwise skip it

Path scope:

  • Native ATOM, vLLM, and SGLang use ignore lists: docs/markdown and unrelated plugin or Mesh paths are skipped
  • ATOMesh uses an include list: Mesh code, the ATOMesh accuracy workflow and its 1P1D launcher, plus the shared models_accuracy.json and accuracy_to_dashboard.py. ATOMesh benchmarks run after merge or on dispatch, not on PRs
  • Relevant path alone does not start expensive jobs; approval still opens the automatic path-scoped gate
Label Tests
ci:full Run all heavy PR model tests: native ATOM, vLLM, SGLang, and ATOMesh
ci:atom Run native ATOM model accuracy tests
ci:vllm Run ATOM vLLM OOT model accuracy tests
ci:sglang Run ATOM SGLang model accuracy tests
ci:mesh Run the ATOMesh accuracy tests, standalone and 1P1D, for Mesh-related changes

Without a matching ci:* label, heavy jobs are skipped when the path is not relevant or the PR is not approved.
Add labels via the sidebar or gh pr edit 3781 --add-label <label>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@valar-cop valar-cop left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few small things..

ci green.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copilot AI balanced review requested due to automatic review settings November 24, 2026 13:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the bounded offload-save retry and resource-cleanup changes.

1 open issue

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants