Repository navigation
[PD] Centralize drain-aware abort acknowledgements - #37077
ShangmingCai merged 16 commits into
Conversation
fed2b63 to
1b5910b
Compare
There was a problem hiding this comment.
Thanks @livingshade! LGTM, verified on MI355*2 node and left minor comments.
| self.bootstrap_room, failure_reason, is_from_another_rank=is_propagated | ||
| ) | ||
|
|
||
| def _send_abort_notification(self): |
There was a problem hiding this comment.
I validated it on MI355X E2E: 45 focused tests passed, the registered Mori E2E passed for TP1→1 and TP2→4, and a cross-node 1P1D abort test remained healthy with a successful follow-up request.
There was a problem hiding this comment.
we can userun-mori-pd label if the AMD CI still has some issue. see
#37077
jambow0320
left a comment
There was a problem hiding this comment.
Two thoughts, both about scope rather than correctness.
1. Can we move the pre-arm into CommonKVReceiver._send_abort_notification
_send_abort_notification has a second caller: _check_waiting_timeout (common/conn.py:1617, reached from poll() in all three backends). It sends the ABORT and sets abort_notified = True without going through Scheduler._abort_request, so register_deferred_abort_room is never called for it.
This PR already fixes this for Mori. The same logic in the base method would fix mooncake and nixl too:
# CommonKVReceiver
def _send_abort_notification(self):
if self.kv_mgr.enable_deferred_decode_kv_release and self.init_time is not None:
self.kv_mgr.register_deferred_abort_room(self.bootstrap_room)
for bootstrap_info in self.bootstrap_infos:
...self.init_time already encodes what metadata_published encodes — it stays None until the end of send_metadata in all three receivers (mooncake:2600, mori:2055, nixl:2968) and _check_waiting_timeout already uses it as that marker — so the new field metadata_published may not be needed. (However, adding a field for readability is also reasonable.)
With putting 'register_deferred_abort_room' into '_send_abort_notification', scheduler.py:4918-4930 (the re-arm right after receiver.abort()) can be deleted. That in turn makes reset_deferred_abort_room and the setdefault override unnecessary.
2. Consider nixl's "no ack" fallback instead of the drain queue
nixl handles the same situation — writes possibly still in flight when completion can no longer be confirmed — by not acking at all:
# nixl/conn.py:1390-1393
self.record_failure(room, str(e))
self.update_status(room, KVPoll.Failed)
# No ack here on purpose: the DONE barrier bails on the first
# ERR, so siblings may still be writing; fall back to the timeout.It needs no extra threads or queue.
The current drain path can stop prefill-side transfers: _enqueue_transfer_drain calls put without block=False, so a transfer worker blocks once the queue is full, while status.Wait() has no timeout parameter and _drain_worker retries indefinitely. _num_shards (default 8) sizes the transfer workers, the drain workers and the queue, so roughly 16 transfers that never reach a terminal status are enough to block every transfer worker — and shards are keyed by room % _num_shards, so healthy rooms stop too.
1353231 to
b0e466f
Compare
52bded8 to
11dc85d
Compare
|
/tag-and-rerun-ci |
sgl-project#41023 kept Mori out of the default-on deferred release because its bootstrap thread marked an aborted room Failed without ever sending an ABORT_ACK. Mori now holds the ack until the transfer worker or drainer quiesces the room, so it can opt in like Mooncake and NIXL. With SGLANG_DISAGGREGATION_DEFERRED_DECODE_KV_RELEASE at its default, this turns deferred release on for Mori; set it to 0 to keep the immediate release. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With deferred release on, a chunk whose room was aborted between submit and the post-submit check waited inline in _wait_transfer_completion, which has no cutoff at the default SGLANG_MORI_TRANSFER_TIMEOUT_MS=0. Hand it to the drain queue instead and return not-quiescent: the drainer still waits for the statuses before decrementing and ACKing, so safety is unchanged, and the shard worker moves on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A failure whose statuses were still in progress was concluded only after the drainer's status.Wait() returned, so a stuck transfer left the room un-Failed: decode learned of it only from its own waiting timeout, and later chunks for the room kept being submitted. Conclude at the drain handoff instead and keep only the ACK deferred. The drain queue now carries (chunk, statuses). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
/rerun-failed-ci |
|
/rerun-failed-ci |
…ncake manager sgl-project#37077 added `_deferred_ack_poisoned_rooms` to CommonKVManager and clears it in update_status() on a new room lifecycle, so a manager built via __new__ must carry it. Co-Authored-By: Claude Fable 5.1 <[email protected]>
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]>
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.
Post-rebase review fixes, squashed. Each corrects how one of our commits merged with an upstream v0.5.22 change. PD abort / deferred release (with upstream sgl-project#37077 generation protocol): - A receiver's clear() drops its own generation's ACK-tracker entry again. The merge dropped the token-scoped clear, so a receiver aborted before KV pre-allocation left a permanent tracker entry. - Keep a held room exclusive to its receiver under transfer drain (Mooncake), as the per-receiver token did locally: - a new receiver of a room its earlier receiver has not released fails fast before publishing any destination, leaving the room's status and failure record to the owner. Only the owner may resend the ABORT that drains the room, so a takeover would strand both receivers' buffers; - arm_deferred_abort_room() keeps the receiver's own generation and refuses to replace another undrained receiver's; - is_abort_release_safe()/clear_deferred_abort_state() take an optional generation; the decode release path passes the receiver's own. Upstream rejects a duplicate room only under prefill_complete; it can leave early mode alone because it force-releases on timeout, which fail-closed Mooncake does not. Non-drain backends keep upstream's semantics, and the wire format is unchanged. - Document that SGLANG_DISAGGREGATION_DECODE_BOOTSTRAP_TIMEOUT does not cover the prefill_complete wait. Drop lazy creation added during the rebase only so that tests built with __new__ would not raise AttributeError. Production always runs __init__, and the fallbacks would hide a missing initialization behind a fresh lock or table: CommonKVManager.connection_lock and the parallel-info tables are plain attributes set by __init__ / _init_decode_handshake_state() again, as upstream has them. _transfer_lifetime gets a declared class default instead of getattr lookups. trtllm_mla: pass forward_batch.kv_loc_plan, the first argument upstream (it raised TypeError on the first breakable prefill graph capture on SM100), and use paged_row_view for the KV buffer like upstream's call sites. cutedsl_mla fixed split-KV: allow FlashInfer 0.7.1, which upstream now pins. The adapter's private dependencies (cute_dsl_mla_decode, the _get_split_kv_and_workspace_size planner and the workspace layout) are unchanged from 0.6.18; 0.7.1 only adds lse_scale, whose default keeps the natural-log LSE. Without this, setting SGLANG_CUTEDSL_MLA_NUM_KV_SPLITS failed at startup. Docs: add --dcp-kv-layout, --max-parallel-samples and --max-batch-outputs to server_arguments.mdx, which upstream sgl-project#38520 now checks. Co-Authored-By: Claude <[email protected]>
… decode KV allocation Brings in upstream sgl-project#40703 (Mooncake PD: defer decode KV allocation until prefill completes, opt-in via --disaggregation-decode-allocation-policy prefill_complete) on top of its hard dependency sgl-project#37077 (generation-based centralized drain-aware abort acks), adapted to this fork's mooncake hardening and mm-length reconciliation.

Motivation
When decode aborts or fails a request, prefill may still be RDMA-writing into the decode's KV pages; releasing them early lets a late write corrupt the request that reuses them. Deferred decode KV release (default-on since #41023) holds the pages until every prefill rank ACKs that its writes drained.
This PR adds the drain-aware ACK to Mori and moves the ACK protocol into the common layer shared by Mooncake, NIXL and Mori.
Built on #40645, #41402 and #41404 and resolved potental conflicts.
Related to #33861 and #34510.
Modifications
Mori
supports_deferred_decode_kv_release = True).Common
The common layer is extracted from what Mori established:
AbortNotification/AbortAckwire format. ABORT carries a per-room generation armed before sending, and decode only counts ACKs of the current generation.transfer_infossnapshot, which has no generation.Tests
Commonand backend-specific test.Speed Tests and Profiling
No change on the normal transfer path beyond per-chunk counter bookkeeping.
Accuracy Tests
No change to model forward or sampling. 1P1D H100 (Mooncake),
TestDisaggregationAccuracy: gsm8k 0.83.Unit tests (CPU): test_deferred_decode_kv_release.py (common protocol, tracker, fan-out, decode release), plus backend-specific test_mooncake_deferred_kv_release.py, test_nixl_deferred_kv_release.py and test_mori_deferred_kv_release.py.
1P1D e2e on H100 (TP1 / TP1 over IB), Mooncake and NIXL.
test_disaggregation_chunked_prefill_abort,TestDisaggregationMooncakeFailureMori: AMD CI stage-b-test-large-8-gpu-mi35x-disaggregation-amd (includes test_mori_transfer_engine_e2e.py).
Checklist
CI States
Latest PR Test (Base): ✅ Run #37089529256⚠️ Not enabled -- add
Latest PR Test (Extra):
run-ci-extralabel to opt in.Latest PR Test (AMD ROCm 10): ❌ Run #37089529181