Repository navigation
Conversation
alphabetc1
requested review from
Ying1123,
hnyls2002,
merrymercy and
xiezhq-hermann
as code owners
October 15, 2026 03:08
Collaborator
Author
|
/rerun-test -c |
Contributor
|
🚀 |
hnyls2002
approved these changes
Oct 16, 2026
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.
Contributor
|
Thanks for fixing this. I reproduced the same race on CPU with a script that drives the real The role switch goes through the same check ( |
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.
Motivation
On PD decode, a failed or aborted transfer is held for deferred release (#35049, on by default). Its KV pages, request row, tree lock and metadata slot stay with it until every prefill rank acks that its writes drained, or until the timeout (30 s by default).
Scheduler.is_fully_idlenever looks at these holds. Its decode branch checks the prealloc, retracted and transfer queues, but a held request has already left the transfer queue. Soflush_cacheruns while a hold is outstanding:_do_release→release_kv_cachefrees the same pages again.req.lockpoints at a node of the old tree.RL rollouts hit this without any unusual timing. The flow is abort,
pause_generation, thenupdate_weights(flush_cache=True). While paused, the decode loop skipsprocess_decode_queue, so nothing resolves the holds before the flush.The idle leak check already knew about these holds and skipped itself while they were pending. Only the flush gate was missing.
Modifications
is_fully_idle, the decode branch now requireshas_pending_deferred_releases()to be False.The same gate also covers attach / detach of a storage backend and
release_memory_occupation. The last of these currently drops held entries and pauses KV memory while a prefill write may still be landing.Tests
SimpleNamespace, which now also needshas_pending_deferred_releases.test_decode_queue_cleanup.pypasses (14 tests).is_fully_idle, the realDecodeTransferQueuedefer / resolve and a real allocator. On main, a flush followed by the deferred release raised available pages above the pool total (272 of 256), and one alloc returned 16 pages twice. With this change the flush is refused, and the pool returns to 256 with no duplicates.Related: #36869 rewrites
is_fully_idleasnot_idle_reasons(). When it rebases, this condition becomes one morerequire_emptyentry.CI States
Latest PR Test (Base): ❌ Run #38836202980
Latest PR Test (Extra): ❌ Run #38836203143
Latest PR Test (AMD ROCm 10): ❌ Run #38836203142