Skip to content

[Bugfix] Drain Mooncake transfers before releasing KV pages - #31357

Closed
kflansburg wants to merge 2 commits into
sgl-project:mainfrom
kflansburg:kflansburg/fix-mooncake-abort-transfer-quiescence
Closed

kflansburg wants to merge 2 commits into
sgl-project:mainfrom
kflansburg:kflansburg/fix-mooncake-abort-transfer-quiescence

Conversation

@kflansburg

@kflansburg kflansburg commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Mooncake aborts and transfer timeouts currently make requests terminal before in-flight native transfers have quiesced. The scheduler can therefore return source or destination KV pages to the allocator while an existing RDMA, executor, or CUDA staging operation still reads or writes those addresses. If a page is reassigned, the old transfer can corrupt another request or read its KV state.

The existing ABORT_ACK only confirms that the abort notification was received. It does not prove that synchronous native transfer work has returned.

Modifications

  • Add a per-room transfer lifetime that closes admission on abort and tracks active Mooncake transfer workers.
  • Drain all submitted executor futures, including running siblings after an error or partial submission failure, before releasing the room lifetime.
  • Add tokenized, retryable abort notifications and defer ABORT_ACK until prefill transfer work is quiescent.
  • Advertise and require the QUIESCE_V1 capability on both peers so mixed versions fail before transferring KV rather than silently weakening the ownership barrier.
  • Propagate logical failure across TP and CP ranks first, then report terminal failure only after every participant confirms local transfer quiescence.
  • Retain decode staging allocations and chunked-prefill KV ownership until RDMA and CUDA staging work is complete, while rejecting late staging and auxiliary messages for aborted rooms.
  • Serialize messages sent through shared Mooncake ZMQ endpoints so status, auxiliary data, and abort acknowledgements preserve ordering.
  • Add deterministic unit coverage for blocked native transfers, sibling executor drain, capability negotiation, token retries, collective failure barriers, staging cleanup races, message ordering, and chunked-prefill retention.

This protocol requires coordinated rollout of prefill and decode peers. A peer that does not advertise QUIESCE_V1 is rejected before KV transfer begins.

Accuracy Tests

This change does not modify model forward computation or model outputs. It prevents stale transfers from reading or overwriting KV pages after request failure.

Focused and adjacent CPU unit tests passed:

26 focused tests passed
104 focused-plus-adjacent tests passed

Speed Tests and Profiling

No performance benchmarks were run. The normal data-transfer path is unchanged apart from lifecycle accounting and per-endpoint send serialization. The additional waiting occurs only when a transfer is aborted, fails, or must drain before ownership release.

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ❌ Run #29438714597
Latest PR Test (Extra): ❌ Run #29438714032

agent added 2 commits July 15, 2026 09:39
Motivation: aborted or failed requests could return KV pages while synchronous Mooncake, executor, or staging work still referenced them.

Modifications: track per-room transfer lifetimes, defer tokenized abort acknowledgements until drain, propagate quiescence across ranks, serialize endpoint sends, finalize staging ownership, and retain chunked-prefill requests until release is safe. Peers without the quiescence capability fail before transfer.

Accuracy: prevents stale transfers from reading or overwriting pages reassigned to another request. No model math changes.

Speed: adds locking only around transfer lifecycle and endpoint sends; normal transfer data paths are otherwise unchanged.

Tests: 26 focused and 104 focused-plus-adjacent CPU tests passed; pre-commit and py_compile passed.
Add deterministic coverage for blocked native transfers, executor sibling drain, tokenized abort retries, collective failure barriers, staging cleanup races, capability gating, message ordering, and chunked-prefill retention.

Tests: 26 focused and 104 focused-plus-adjacent CPU tests passed; pre-commit passed.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@KastanDay

Copy link
Copy Markdown

I this this patch is better addressed by #32564

@github-actions

Copy link
Copy Markdown
Contributor

Thanks @kflansburg. Closing this because it is still a draft and has not been updated in 40 days.

Reopen it if the work is still relevant.

Some directories moved recently, so an older branch may need retargeting:
sgl-kernel/ -> python/sglang/kernels/aot/, python/sglang/jit_kernel/
-> python/sglang/kernels/jit/, docs/ -> docs/docs/ (.mdx),
bench_serving.py -> benchmark/serving.py, test/srt/ -> test/registered/.

@github-actions github-actions Bot closed this Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hicache Hierarchical Caching for SGLang

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants