Skip to content

[Refactor] scheduler: Release every PD disaggregation exit through RequestRetirer - #48491

Merged
hnyls2002 merged 9 commits into
mainfrom
lsyin/sched-pr22
Nov 5, 2026
Merged

hnyls2002 merged 9 commits into
mainfrom
lsyin/sched-pr22

Conversation

@hnyls2002

@hnyls2002 hnyls2002 commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

PD disaggregation exits (prefill transfer success and failure, aborted prefill results, bootstrap failures, and the decode transfer, deferred-release, prealloc-failure and checksum-mismatch paths) each released their request by hand, with different subsets of the cleanup steps. They now go through RequestRetirer, whose API is cut to two verbs, split by who reports the request:

  • abort(req) (was abort_queued): ends a request no launched step carries, tells the tokenizer once, and ends in release.
  • release(req, *, checkpoint): gives back what an ended request holds; the caller finishes and streams it. An aborted request is first detached: its multimodal inputs, its streaming-session in-flight flag and its uOCR reuse state are dropped, its cache attempt is abandoned unless the KV is checkpointed (the cache's store then settles it, as on a normal finish), and its beam group leaves the live set. Then its KV backup, HiSparse rows, KV and mamba state go. It replaces release_finished, release_aborted and the separate free step.

The detach (was release_aborted_request) is now the retirer's private _detach, run only inside release: an aborted request cannot be released without being detached, and no caller detaches on its own. A logical abort only marks the request; the exit that releases it detaches it.

  • Add release_prefill_sender(req, *, abort_sender) on the prefill mixin (replacing release_aborted_prefill_waiting_req): clears the pending chunk send, optionally aborts the sender (best effort, logged on failure), frees the metadata buffer and clears pending_bootstrap. The waiting-queue abort, the aborted-result path and the pending chunked abort pass abort_sender=True; the bootstrap failure passes abort_sender=False, since failure_exception() already concluded that sender.
  • The PD prefill waiting-queue abort stops the sender first, then runs the full abort, which loses its release_memory flag.
  • Decode _release_request is removed; its callers and _handle_kv_checksum_mismatch call release(checkpoint=False). Host-staged requests hold no device KV row, so the retirer's holds_kv gating replaces the old host-staged early return.
  • The bootstrap-queue abort, retire_unadmitted_request and the pending chunked abort stop detaching and retiring the beam group by hand; they mark the request, and release does both. retire_group is a no-op on an already retired group, so the step paths that retire an aborted group first are unchanged.
  • Prefill transfer success drops tree_cache.finish(SUCCESS), which is a no-op in every cache.
  • The Scheduler delegate of the detach is removed; the prefix caches' hook behind finish(handle, outcome) becomes _abandon_attempt(handle). The dLLM manager's hook is renamed to abort.
  • The allowlist of direct release_kv_cache / _detach callers in test_request_retirer.py drops 8 entries.

Behavior changes:

  • Decode exits (transfer failure, deferred release, host-staged abort, corruption abort, prealloc failure, checksum mismatch) and prefill aborted results and bootstrap failures now also release multimodal inputs, clear the streaming-session in-flight flag and run the uOCR drop, like the other aborts; before, a failed decode request could leave its session marked in flight. Covered by a new test_request_retirer.py test.
  • An aborted request that a step finishes (an abort that lands while it runs) is detached too; before, only its memory was released. Its multimodal token counts are read before the inputs go, so its output still reports them; for the same reason, a PD bootstrap failure or a door reject that still holds media now reports its real counts instead of 0. When its KV is checkpointed into the cache, its cache attempt is not abandoned, since the cache's store settles it.
  • A beam leader whose prefill output is discarded (an external cache load failure) now leaves the beam live set at its release; before, nothing retired its group.
  • A failed prefill transfer releases its KV uncached instead of inserting it into the tree, like every other abort, and is no longer finished as LENGTH before the abort.
  • The cache-side abort always runs before the memory release (the bootstrap failure ran it last), and an exception from sender.abort() on the waiting-abort and chunked-abort paths is logged instead of raised.
  • A PD decode waiting-queue abort, which checkpoints the received KV, no longer abandons the cache attempt before the store; it ends like a finished decode request. This only differs for caches with an attempt to settle (LMCache, FlexKV).

Test plan

  • The unit tests of the changed sites, the other unit tests that import the changed modules, and the session, multimodal, dLLM and uOCR unit tests pass locally, one file per process; their failures are the same as on main (environment-only). The CUDA-only test_kv_checksum cases were updated but not run locally.

CI States

Latest PR Test (Base): ❌ Run #41990375583
Latest PR Test (Extra): ❌ Run #41990375552
Latest PR Test (AMD ROCm 10): ⏳ Run #41990375561

Tip

Base CI only covers the core cases, and its workload may not exercise your change. Use /rerun-test to run the tests your change touches, or copy this prompt for an agent:

Find the registered tests this PR affects and run them with /rerun-test, following https://github.com/sgl-project/sglang/blob/main/.agents/skills/rerun-test/SKILL.md

…e_aborted; share release_prefill_sender; drop abort_queued release_memory

@claude claude Bot 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.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@github-actions

This comment has been minimized.

…abandon_attempt in the prefix caches; drop the scheduler delegate
@github-actions

This comment has been minimized.

…d free into release; count mm tokens before the detach and abandon only uncached attempts
@hnyls2002 hnyls2002 added the run-ci CI: run the baseline test suite on this PR label Nov 5, 2026
@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/rerun-test registered/disaggregation/test_disaggregation_optimistic_prefill.py registered/unit/disaggregation/test_kv_checksum.py registered/unit/mem_cache/unified_radix_cache/test_unified_radix_cache_storage.py registered/disaggregation/test_disaggregation_chunked_prefill_abort.py registered/disaggregation/test_disaggregation_kv_checksum.py registered/disaggregation/test_disaggregation_basic.py registered/disaggregation/test_disaggregation_decode_offload.py registered/sessions/test_streaming_session.py registered/sessions/test_session_control.py registered/vlm/test_unlimited_ocr_server.py

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🚀 2-gpu-h100 (4 tests): ✅ View workflow run

cd test/ && python3 registered/disaggregation/test_disaggregation_optimistic_prefill.py
cd test/ && python3 registered/disaggregation/test_disaggregation_chunked_prefill_abort.py
cd test/ && python3 registered/disaggregation/test_disaggregation_basic.py
cd test/ && python3 registered/disaggregation/test_disaggregation_decode_offload.py

🚀 1-gpu-h100 (4 tests): ✅ View workflow run

cd test/ && python3 registered/unit/disaggregation/test_kv_checksum.py
cd test/ && python3 registered/sessions/test_streaming_session.py
cd test/ && python3 registered/sessions/test_session_control.py
cd test/ && python3 registered/vlm/test_unlimited_ocr_server.py

🚀 1-gpu-5090 (1 test): ✅ View workflow run

cd test/ && python3 registered/unit/mem_cache/unified_radix_cache/test_unified_radix_cache_storage.py

🚀 4-gpu-h100 (1 test): ✅ View workflow run

cd test/ && python3 registered/disaggregation/test_disaggregation_kv_checksum.py

…tempt to the store; fold _release into release
… abandon from _detach into release; fix retirer docstrings; rename the dllm abort callback; drop the sender abort hasattr
@hnyls2002 hnyls2002 added the highest-priority CI: all three control labels, plus never batch-cancelled or stale-closed label Nov 5, 2026
@hnyls2002
hnyls2002 merged commit 8898429 into main Nov 5, 2026
155 of 166 checks passed
@hnyls2002
hnyls2002 deleted the lsyin/sched-pr22 branch November 5, 2026 21:35
detain added a commit to detain/sglang that referenced this pull request Nov 11, 2026
…r/URC markers -- 3/18 census consumed, 3 gates in one

CASCADE (start_writing(wait_for_forward) TypeError class, 68 distinct nodes):
upstream sgl-project#48012's NEW fixture hicache_write_back_fixtures.InstantWriteBackController
mirrored the pre-sgl-project#44800 no-kwarg surface while the fork's writing_check drain
(entries 199/218: the batched-backup flush=False + ONE fenced start_writing)
calls the real API. Def-site fixes, no fence weakened:
- fixture start_writing gains the keyword (instant copies -> accepted-ignored,
  documented);
- test_write_back_eviction_batching: record_submission wrapper FORWARDS the
  flag (it measures the very wait, so swallowing it would understate the
  fence); _FencedController gains load_fence_stream = forward (the fork's
  unconditional entry-168 fence reads it first; prod: both streams are the
  same forward stream) -- also silences the 16-test Rust TreeCore panic class
  whose "victims not demoted" assert was the aborted submission downstream.

MARKERS (3): managers/cache_controller.py:1202 ADOPTED -- the dropped
set_hicache_transfer_done_event write line is superseded by upstream
c24285b(sgl-project#48008 per-band page ledger)+2cbb66f563(sgl-project#48012): record_host_transfer
publishes the same signal per-page BOTH directions (load twin writes=True).
unified_radix_cache.py:627 ADOPTED -- the buffer-mode threshold floor
(resolve_prefetch_threshold) was DELIBERATELY deleted upstream by
dfaca56(sgl-project#46934, restores sub-window SWA L3 hits); window sizing now lives
per-allocation in BufferModePipeline; the per-call-site file_storage_path fold
is consistent with the entry-253 funnel (cache_controller.py:948, intact).
unified_radix_cache.py:3917 RE-PLANTED -- entry-293's cadence gate (park, do
not re-enter allocate_storage_hit/evict_host inside the retry window) + the
expired no-retry arm were dropped; wait_full folded into upstream's
comp_xfers allow_partial rule (min_tokens form already equivalent).

URC context guard: _deferred_ready_sync_group read get_memory() unguarded --
upstream's NEW _arm_tick CPU/spawn fixtures (their restructured timeout tests,
sgl-project#44614) reach it without a published server config. Now published-check
(schedule_policy.py:615 idiom): default-off CPU path, production unchanged.

Deadline-anchor retargets (fork B3-9 family vs upstream's sgl-project#44614 vote-before-
poll restructure; every assertion preserved): _vote_prefetch_deadlines drives
the verdict before the expiry polls; failed-arm polled inside-budget so the
storage failure stays the SOLE cut reason; fixture cc gains the sgl-project#44342
liveness attrs + pp_prefetch_command_thread; _arm_tick stub returns the fork's
5-tuple (health bit True); release_aborted_request -> finish(ABORT) per
8898429(sgl-project#48491).

Battery actuals (CPU, CVD=9, prod venv, PYTHONPATH=wt/python):
- the 5 cascade files 68F/39P -> 3F/70P (survivors = the sgl-project#48491/pp-thread/
  budget-anchor fixes committed here; after them): test_storage_prefetch_
  lifecycle ** 31P/31sub ** (entry-311 pin 28P/31sub, 295's >=23P/28sub
  EXCEEDED); decode_retraction_backup 6F + chunked_publish 2F = No-CUDA
  device class (env, reported).
- combined gate run: trailing_endpoint + batching + parity + async_ready_sync
  + staged_write_back = 89P/1S/28sub 0F.
Gates: ruff repo ruleset+format clean on touched files; registration trio rc=0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apple-silicon hicache Hierarchical Caching for SGLang highest-priority CI: all three control labels, plus never batch-cancelled or stale-closed run-ci CI: run the baseline test suite on this PR unified-radix-cache

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant