Repository navigation
[PD] Wait for prefill completion before Mooncake early KV transfer - #41395
Merged
ShangmingCai merged 5 commits intoOct 6, 2026
Merged
Conversation
salexspb
marked this pull request as ready for review
September 27, 2026 06:53
salexspb
requested review from
ByronHsu,
Duyi-Wang,
HaiShaw,
ShangmingCai,
hnyls2002 and
sogalin
as code owners
September 27, 2026 06:53
2 of 3 tasks
This was referenced Sep 28, 2026
salexspb
force-pushed
the
codex/mooncake-early-send
branch
2 times, most recently
from
October 1, 2026 17:38
21369fb to
dad7422
Compare
salexspb
force-pushed
the
codex/mooncake-early-send
branch
from
October 2, 2026 23:16
dad7422 to
69d3a60
Compare
Collaborator
|
/tag-and-rerun-ci |
TestMooncakeEarlySend drives the unbound MooncakeKVManager.transfer_worker against a hand-rolled SimpleNamespace. That fake was complete when written, but two changes have since landed on main that made transfer_worker read attributes it does not carry: - sgl-project#42051 added self.state_layout_rejections, read under session_lock for every non-dummy req. - sgl-project#37077 added self.poison_deferred_ack_room(), called from the worker's except path. Merging main into the branch picked up the new conn.py without touching the fake, and the merge was clean because the two sides touch different files. test_worker_waits_before_reading_kv and test_worker_preserves_no_event_path then died with AttributeError on state_layout_rejections, which the except handler turned into a second AttributeError on poison_deferred_ack_room. Only the fixture was stale: the real manager initializes state_layout_rejections on the prefill path in __init__ and inherits poison_deferred_ack_room from CommonKVManager, so no shipping path was affected. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
4 tasks done
Collaborator
4 of 5 tasks
3 tasks done
ZitingLiu
added a commit
to pagoda-inference/sglang
that referenced
this pull request
Oct 10, 2026
Align DP speculative prefill coordination and Mooncake early-transfer cleanup. The Mooncake cleanup semantics follow upstream sgl-project#41395. Validated five full 100k benchmark rounds for both GLM models through batch 128.
LinyuanLi0046
added a commit
to LinyuanLi0046/sglang
that referenced
this pull request
Oct 19, 2026
Port existing community lifecycle code onto b85c644. Fixed upstream source: 0dc6de2. Keep generation-tagged ABORT/ACK state across sender cleanup, count dequeued and in-flight transfers, drain running transfer futures, poison uncertain native failures, and retain decode KV plus metadata until ACK or the community device-destination timeout. Resolve held releases before decode scheduling gates and account for them in scheduler idle checks. Complete the existing cached-prefix event handoff through the worker. Use shared terminal-status helpers and socket locks for failure fanout and to prevent Success after cancellation. Migrated upstream implementations and provenance: - 97dedd1 (sgl-project#35049): device deferred release, ACK tracking, future draining and worker drain integration. - adca19c (sgl-project#35360): common ACK helpers, unique prefill rank and dequeue-before-status accounting. - 8ef6d31 (sgl-project#40645): preserve pending drain ACK targets across sender cleanup. - cd11037 (sgl-project#41023): default-on setting and explicit backend capability gate. - 14ab74e (sgl-project#41402): ACK endpoint fanout. - 2a1c477 (sgl-project#41404): defer all eligible failure paths and force-arm partial metadata publication. - 8293f9a (sgl-project#37077): shared ABORT/ACK types, generation filtering and common target/poison state. - 4195980 (sgl-project#43719): suppress drained ACK after uncertain native KV/state/aux failure. - f9df334 (sgl-project#44386): pending decode releases keep the scheduler non-idle. - c683190 (sgl-project#41395): cached-prefix ready-event forwarding and worker-side synchronization. - 2a46cf2 (sgl-project#36612): terminal/cleared room handling, first failure cause and shared failure/status fanout. - abddb1c (sgl-project#32541): state-send return propagation and per-cached-socket send locking. - 05c7ebf (sgl-project#30545): staging_counted and outstanding accounting across worker requeue/completion. - 8ad7641 (sgl-project#36160): common wait_event job field used by the early-send handoff. - 5b5d721 (sgl-project#40703): worker cleanup precedes outstanding-entry removal. - 348689d (sgl-project#38959): sender poll wrapper holds Success while counted transfers remain. - 1a0250c (sgl-project#41607): check Failed after state transfer before continuing to aux. - 8bf780d (sgl-project#41128): retain deferred release start_time/deadline tuple shape without its new metrics API. - 4dc9cda (sgl-project#37454): decode-side backend capability check before deferring a failed request. Baseline compatibility adaptations: - Insert selected snippets into existing server_args/configuration and worker/listener layout; retain local request timing and transfer batching. - Omit absent deferred-allocation/bootstrap ownership, role-switch teardown, host-receive and PP-consensus branches; import no placeholder subsystems. - Keep baseline 30-second socket timeout, optional sender-table guards and three-frame Mooncake status wire format; serialize existing manager sends with the imported endpoint locks. - Use release_kv_cache(req, tree_cache, is_insert=False), the old failed request release API, and the existing scheduler invariant-check entrypoint. - Omit unavailable new deferred-release metrics without importing the full metrics refactor; retain existing local metrics and diagnostics. No WELM/NPU layerwise additions are included. Device timeout behavior and backend capability defaults match the pinned community source. Validation: 48 external CPU protocol/worker/decode cases; source AST comparison for unadapted helpers; Python syntax, isort and configured Ruff checks; git diff --check. CPU fixtures remain outside this repository. No NPU/RDMA hardware execution was available for this commit.
5 tasks done
This was referenced Oct 27, 2026
luke396
pushed a commit
to Infrawaves/sglang
that referenced
this pull request
Oct 31, 2026
…gl-project#41395) Co-authored-by: Shangming Cai <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit c683190)
luke396
added a commit
to Infrawaves/sglang
that referenced
this pull request
Oct 31, 2026
The sgl-project#41395 worker tests built their manager stub around the upstream _staging_outstanding counter. spec-bp tracks queued chunks with TransferLifetimeTracker leases instead, so the stub now opens and acquires one lease per chunk and asserts the room drains.
LinyuanLi0046
added a commit
to LinyuanLi0046/sglang
that referenced
this pull request
Nov 12, 2026
Backport the early-send wait from sgl-project#41395 (c683190). Pass the forward-stream event with its cached-prefix chunk and wait for it before reading source KV. Recheck the room after the wait to skip transfers aborted in the meantime. The scheduler can launch the suffix forward as soon as it enqueues the prefix. Adapt the worker device binding from sgl-project#45678 (7fe5b12). Bind each transfer worker to its rank's device on its first event wait, preserving the Ascend worker's CPU affinity. Ascend uses the existing transfer_to_npu mapping for torch.cuda.Event().
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.
PD stack
Motivation
Under overlap scheduling with chunked prefill, the Mooncake sender can hand a chunk's KV to the transfer worker before that chunk's forward has finished writing it. This is a race in the sender and applies to any GPU or NIC.
maybe_send_cached_prefix_chunk(disaggregation/prefill.py) runs while the next chunk is being launched, and it records_early_send_wait_eventon the forward stream for exactly this case. However,MooncakeKVSender.sendnever forwards that event, and the transfer worker never waits on it. The NIC can therefore read KV that is still unwritten, or stale from an earlier request. The decode then receives zero or stale KV for most of a long prompt, and every transfer still reports success. The Mori path already waits on this event.Modifications
MooncakeKVSender.sendpasses the event through the existingTransferKVChunkfield.transfer_workersynchronizes on the event before reading source KV, clears it, and re-checks the request status, so an abort during the wait still cancels the transfer.Tests
test/registered/unit/disaggregation/test_mooncake_transfer_batching.py::TestMooncakeEarlySend(CPU, 6 tests) covers:Without the fix, the event and wait tests fail and the no-event test passes.
Validation
Measured on MI355X with GLM-5.2 MXFP4 with FP8 KV, PD prefill TP4 → decode TP4 over Mooncake RDMA, using 491K-token cold prompts in 16K chunks:
Steady-state throughput on a multi-turn workload is unchanged (111.7 vs 111.8 output tok/s).
CI States
Latest PR Test (Base): ⏳ Run #37384567537⚠️ Not enabled -- add
Latest PR Test (Extra):
run-ci-extralabel to opt in.Latest PR Test (AMD ROCm 10): ❌ Run #37384567697