Repository navigation
Fix: abort handling for dispatched requests after client disconnect - #35255
Conversation
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
1 similar comment
|
/rerun-failed-ci |
|
/rerun-failed-ci |
7 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
We hit the same failure on CUDA / H200 with DeepSeek-V4-Flash (TP=2, DSPARK speculative decoding) and posted the numbers in #35936: v0.5.17 aborts a disconnected streaming request after 2 log lines, while v0.5.18 produces bursts of 278–756 lines per minute for the same client behaviour (9129 lines vs 63 across an A/B/A/B benchmark, with zero client-visible errors on either version). Cross-linking here since both PRs target the same path — we can re-run that benchmark against either fix on this hardware if it helps you compare them. |
|
/rerun-failed-ci |
|
I need this, it produce too many logs: |
|
/rerun-failed-ci |
|
/tag-and-rerun-ci |
|
@hnyls2002 Hi, liangsheng. Could you pls review this PR again? Any other problems? Or just waiting for passing CI? |
Conflict resolutions, all mechanical adaptations to main's refactors: - scheduler.py process_pending_chunked_abort: main replaced `req.req_pool_idx is None` with `not req.kv.holds_kv`. Took main's condition, kept this branch's deferred-abort retry below it. - tokenizer_manager.py: main made `_send_one_request` / `_send_batch_request` async. Kept `async def` and the `await` call sites alongside this branch's `_mark_state_dispatched` and `request_rids` additions. - test_tokenizer_manager_rid_cleanup.py: both sides appended a test class at end of file; kept both. - test_tokenizer_manager_rid_cleanup.py: the disconnect test stubbed `cuda_vmm_feature_transport` with a plain Mock, which no longer works now that `_send_one_request` awaits `prepare_for_dispatch_async`. Stubbed it with AsyncMock. - test_scheduler_chunked_abort_race.py: `_FakeReq` exposed flat `req_pool_idx` / `mamba_pool_idx`, which main moved onto `req.kv`. Replaced with a `kv` namespace carrying `holds_kv` / `holds_mamba`.
|
/rerun-test test/registered/unit/managers/test_tokenizer_manager_rid_cleanup.py test/registered/unit/managers/test_scheduler_chunked_abort_race.py test/registered/unit/multimodal/test_gpu_feature_transport.py test/registered/unit/test_chain_read_ratchet.py I will merge this. Fixed two issues while resolving the conflicts
|
|
Results for 🚀 |
…gl-project#35255) Signed-off-by: Shijin Zhang <[email protected]> Co-authored-by: Xinyuan Tong <[email protected]> Co-authored-by: cctry <[email protected]>
|
This did not make v0.5.19. The tag was cut before the merge: the compare API reports We hit the bug on the release build. On v0.5.19, five streamed requests aborted at 3s produced 5082 Two hunks needed manual adjustment, since Is a patch release planned, or should we stay on the backport until 0.5.20? |
…bie-request fix (sglang #35255) Why: the pinned dev-qwen38-27b-dflash2 image (sglang 5f55db35e, 2026-08-22) predates sgl-project/sglang#35255 (merged 2026-09-04). On that build a streaming client disconnect mid-generation leaves a zombie request: the TokenizerManager pops the state on CancelledError, then abort_request() early-returns (rid no longer in rid_to_state), so AbortReq never reaches the scheduler — which keeps decoding to max_tokens, burning a --max-running-requests slot and flooding "Received output for rid=… but the state was deleted in TokenizerManager". Upstream: sgl-project/sglang#36333 (open) and #36876 (open; scheduler-side window with overlap + speculative decoding). v0.5.19 (tag cut 2026-09-03) does NOT contain the fix; the first arm64 artifacts that do are the post-2026-09-04 nightlies / dev tags. Observed on the box (old image, 2026-09-09): Sep 09 00:45:57 minirouter: auto -> 127.0.0.1:8888 client hung up # request had a ~51.6k-token prompt; client gave up after 17.3 min [22:45:57] Received output for rid='056526c6…' but the state was deleted in TokenizerManager. # x6,466 flood lines until 23:02:37 — 16.75 min of dead GPU decode [23:02:32] Decode batch, #running-req: 1, #full token: 98116, gen throughput (token/s): 40.35 # still decoding with nobody listening since 09:30 UTC: zombie floods rid=f238470e… x10,483 | rid=0170a914… x7,148 | rid=bb89f329… x1,746 (+7 more rids) journalctl --user -u minirouter (today): 18x "client hung up" Decode batch … #queue-req: 10, gen throughput (token/s): 1.05 # instantaneous throughput collapse under zombie + live load Verified after the swap (new image, 2026-09-09 13:07–13:12 UTC): sglang 0.0.0.dev1+g708f51e44.d20260909 tokenizer_manager.py: _release_req_states_on_failure x3, abort_sent x4, _discard_pending_req_states x0 # the #35255 fix is in the image repro: stream request, kill client mid-generation (24,655 bytes already streamed) -> t+15s state-deleted(last60s)=0 running=0.0 t+30s state-deleted(last60s)=0 running=0.0 t+45s state-deleted(last60s)=0 running=0.0 # old build under the same disconnect: 6,466 flood lines + 16.75 min zombie decode smoke: direct :8888 -> "SWAP-OK" finish=stop router.hedwig.sh (cloudflared -> minirouter -> :8888) -> "ROUTER-OK" finish=stop, model=orcarouter/Qwen3.8-27B-Uncensored-NVFP4 RAM 113/121 GiB resident — unchanged profile Rollback: the previous digest image stays local (lmsysorg/sglang@sha256:616a3e97f45191af975896cfa644279096cb31bd408a071c2e99ca7209c3cafe). A stable tag carrying the fix is expected as v0.5.20 — re-pin then.
The rc10 Scheduler.abort_request path reads mm_receiver before checking the running batch. Set the field explicitly in the deferred chunked-abort fixture so the PR sgl-project#35255 regression exercises the intended queue transition instead of failing during fixture setup.
PR sgl-project#35255 makes request dispatch record scheduler delivery in rid_to_state. Initialize the map in the three TokenizerManager test doubles so the transport tests continue to exercise dispatch ownership and cancellation behavior.
… abort dispatched requests on handler failure Upstream f478b2b (sgl-project#35255, tokenizer hunks) and 70088aa (sgl-project#36638), both v0.5.20. sgl-project#35255: generate_request's failure cleanup only dropped the rid states. For a request that had already reached the scheduler the scheduler request ran on with its KV to the end, and a later abort for the rid was swallowed as an unknown rid. On this line the handler caught only Exception, so a client disconnect (CancelledError) skipped the cleanup altogether. Now: - ReqState.dispatched, set by _mark_state_dispatched after the single and the batch dispatch; - except BaseException (as upstream since sgl-project#32588) -> _release_req_states_on_ failure(request_rids): undelivered states are dropped, dispatched requests are aborted and their state kept until the scheduler's answer removes it; - _handle_batch_request adds the rids it mints for n>1 to request_rids. Adapted / not carried: - upstream's ReqState.abort_sent dedupe: it ships with the scheduler-side retry of a deferred chunked abort that moved queues (process_pending_ chunked_abort). That retry is not taken here -- this line's deferred abort runs the weg2 PP countdown (xsn324) and a rank-local re-abort is a rank consistency question; on P the moved case ends with the request finishing its prefill, on D prompts are not chunk-prefilled. Without the retry a second AbortReq (e.g. the front's /abort_request) can be the one that lands, and a repeated AbortReq is a no-op, so no dedupe. - the disconnect task's `if rid in rid_to_state` filter: it would re-open weg2xsn276 (an abort for a rid this manager no longer knows must still reach every weg2 scheduler rank); abort_request keeps that path verbatim. sgl-project#36638: _wait_one_response captures the ReqState when the waiter is built (plain function returning _stream_one_response) instead of when the async generator is first advanced -- batch dispatch builds every waiter before advancing any, and a sub-request finishing in between had its state deleted (KeyError). Tests (CPU, incg cgroup): test/registered/unit/managers/test_tokenizer_manager_rid_cleanup.py, upstream tests ported (release helper incl. dispatched/undelivered split and a failing abort, n>1 minted-rid cleanup, cancel-after-dispatch sends AbortReq and keeps the state, waiter built before finish still delivers): 21 passed; on the base file the 9 new tests fail.
…r part, sgl-project#36638) into the B1 staging line Agent B: dispatched requests are aborted on handler failure/disconnect (except BaseException as upstream), the waiter holds the ReqState from construction (no KeyError for batch requests). Not taken with reason: abort_sent dedup, rid filter in the disconnect task (would reopen weg2xsn276). sgl-project#30986 already covered by the fork, sgl-project#35957 unreachable, sgl-project#37143 not applicable (timeouts -1). Tests: test_tokenizer_manager_rid_cleanup 21 passed (hermetic, cgroup 3G).
…cks, chronologisch) Grundlage: Präsenz-Scan aller 230 27B-Commits seit 76f8deb gegen diesen Baum (Stichprobe der hinzugefügten Zeilen je Commit); die 94 fehlenden minus die bewusst anders gewählten Formen (76e87ac/4ae11ababd -> S3 form.calibration_identity; 479f6ec/d7f588e017/d0fba8955f/34892e3017 -> S2 NF-Formen; 7f81f09/3c14481318 -> S4/S7a; 3dbb790 line_gate_27b (Werkzeug, Schritt 9); 8604d13 W100-by-name (Nutzer: bleibt aus); 6545e2c flashinfer-Pin in pyproject (Image-Frage, nicht Baum)). Liste: 92bbccb eb5d044 829ebd0 431fcbc ef4d11f 6816062 a233e50 2cc593c f0c8451 87cc4fb c529777 31f2dbe c50085a 3301a96 036b368 e1d1fe9 03c68af 6dddc2e 06932b5 87389c4 58a7490 f85ac55 fc64aa5 5aa24dd 97c0e9a 159333c d9f1532 f3c685b 8550655 e50fb59 db2c2ef f09dc0d c255e10 51b810e 28a55a2 34965fc ff3d9cc 340a018 bee5e10 67b6352 fdade85 ed6630d f1c9a43 b434831 517f26d 0b6b60b a40837f 644de86 aff2b7c 197b701 856024b 238512a 9738626 b857a22 1f8c24d d294b3e 810239d b429dfd e714c95 9efd974 3d63e0a d3cfcf3 fee6134 7985b56 49a14e9 fc45706 19c720e 5306bee 6f1235a c98eaa3 93bc802 328349e f9fb3a2 572af73 94fa8b4 d342caa 2fd7d7e 3ebbb96 871d55f 78c2f16 3babf51 196f6a8 e70af54 22eccfc Inhalt: Upstream-Ports (sgl-project#33758 sgl-project#37818 sgl-project#36738 sgl-project#33459/sgl-project#30096 sgl-project#34446 sgl-project#36267 sgl-project#33778 sgl-project#34859 sgl-project#36415 sgl-project#35255/sgl-project#36638 sgl-project#39858/sgl-project#40259 sgl-project#31417 sgl-project#34892 sgl-project#32225 sgl-project#30832/sgl-project#36626 sgl-project#39574 sgl-project#29579 sgl-project#31468 sgl-project#32575 sgl-project#31648); xsn409/410-Wake-Verdikte; Vision-Linie V1-V3b + xsn438 (SGLANG_WEG2_VISION_FLIP_URGENT); D-Planer L6 (159333c); DFLASH-Window-Pool sync-frei, PLAN_SYNC_FREE, D-Kollektive (vocab-argmax, a2a-Merge, deferred rebuild), #DGAP/D_DEFER_SEQ_LENS_CPU; Mamba-Anker Raster 4096 + Per-Path-Cap + Inner-Release; P-TRIM (--p-trim-end-anchor); FP8 uniform Marlin; ModelOpt/NVFP4 RadixArk; GGUF G1-G6 + F1/F2; native-mixed sgl-project#38 (sm_8x W4A8, sm_12x CUTLASS/W4A16); RC1-Capture-Set; sgl-project#49 Agent-Turns; dynchunk (--p-chunk-policy, --p-chunk-dynamic-min-tokens). Auflösungen (Gabel -> Form, Grund): - L6 d_operating_point_rows: 27B (d) "Token-Vektor auf jeder Position aus der Kapazität" nur bei TP-symmetrischem D (Profil d_layout paged_dcp); sonst NF-sgl-project#1293-Pin + NF-Anker- Klausel. mamba_ssm_dtype aus EARLY_READ_FACTS nur bei Profil early_read_flags. Overhead-Kalibrierung liest mit form.CalibrationIdentity statt LineIdentity. - RC1 Capture-Set: neuer RecordKey-Term d_capture_set (qwen27b), Leser CalibrationIdentity.d_max_running_requests; nextflash unverändert. - URC Carrier-Hold: 27B _weg2_carrier_hold entfällt (S2 NF-Rotation), Inner-Release und Per-Path-Cap bleiben (Env, Default aus; 27b.env setzt sie). - scheduler_pp_mixin/overlap_utils/batch_result_processor: NF H49/H58 und 27B #PGAP/#DGAP komponiert (beide Instrumente getrennt schaltbar). - schedule_policy: P-TRIM-Kurzschluss vor NF H63-Fold/QSA-Korn; sgl-project#36415 Hoist + NF computed_input_len. - gdn_backend sgl-project#33778: 27B-strided-Verify; NF-Ring flacht beide Layouts ab. - flashinfer_backend: RC9-Datei + NF-Form-A-Waiver (27B-intern mehrfach gegabelt). - checkpoint_census: GGUF-Leser + NF exclude_segments (PLE) in einer Aggregation. - xchg_manifest: FLAT_SEGMENTS in beiden (dst/src) NF-Breitenbedingungen ausgenommen. - vram_peak_window: NF-Kumulativ-Peak liest über den 27B-Fast-Read. - FP8: 8c86eb8-Rest nachgezogen (private Workspace-Registry entfernt, wie RC9). - argv_d: vision= an allen drei Aufrufstellen (inkl. NF --d-only). - census_checkpoint_decision (W161) jetzt für beide Profile aktiv. Gates: py_compile aller geänderten Dateien; ruff F821/F811 ohne neue Funde gegenüber dem Vorgänger (PendingSeqLensCpu ist String-Annotation wie in RC9); dup_defs_gate 0 neu. Tests: 73 portierte Testdateien, Lauf nach dem Ruhefenster (Boot aktiv).
The scripted runtime could not bring up an engine on --device xpu, so none of test/manual/chunked_prefill/ ran there. Every change here is test-side. - kv-canary now has an XPU path: its write / verify / plan kernels are CUDA-JIT only, so they route to a torch reference. install_canary refuses to capture a decode over that reference, so the harness turns the decode graph off where the canary falls back, instead of turning the canary off. The decision is made after engine_kwargs merge and only when the canary is actually enabled, so a class that opts out of the canary keeps its decode graph. That reference folds on the host, so the script timeout is scaled where it is in play; a 100-chunk prefill needs about 220s of the 120s the CUDA path was budgeted. - TestSpecialCaseHiCache needs the MHA host-pool movers, which pool_host/mha.py builds only for CUDA and ROCm, so it is skipped off those two platforms rather than off XPU alone. - TestSpecialCaseDeterministicFlashInfer needs flashinfer, which ships NVIDIA-only kernels. Test-side fixes the above exposed: - Reusing a rid needs the TokenizerManager to have released it, which is not observable from the scheduler, so the settle helper is named for the wait it performs rather than for a condition it never checks. - _drain_until_released had drifted into four copies; it is now one helper, and it waits on lock_refs, which drops an iteration after the KV pages. - The abort-release regression guards read through find_req_by_rid, which stops seeing a req whether it released or leaked, so they passed on a leaked row. They now compare the pool free counts. - Dropped the double-abort test: since sgl-project#35255 the TokenizerManager returns early on a repeat abort, so the scheduler never sees the second AbortReq and the test could not exercise the idempotency it was named for. New CPU-CI unit tests cover that the canary stays enabled on every device and that an opted-out canary leaves the decode graph alone.
…connect engine-patches/apply.sh applies engine-patches/<engine>/*.diff to the installed engine, reports with --check, takes them out with --revert, and leaves alone a build that no longer fits (one that has the fix upstream). First patch: a backport of sgl-project/sglang#35255 (f478b2bb2d). Without it a client that disconnects mid-answer leaves the request decoding to max_tokens. Tested against upstream's unit tests on 0.0.0.dev1+gd91c3682b. README documents both this and the decode watchdog. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
This PR fixes an issue where a request could continue decoding after the client disconnected, wasting GPU resources and repeatedly logging:
Root Cause
When a request handler was cancelled after dispatch, TokenizerManager removed its
rid_to_stateentry immediately. The disconnect abort path checks this state before sending an AbortReq, so the abort was skipped while the request continued running in the scheduler.A related race also existed for chunked-prefill requests: if a request moved out of the chunked-prefill slot before its deferred abort was processed, the abort could be lost.
Changes
Original commits
f9ad78ba2471abbc9a55ff4b4b1f3fa88a798a9eCI States
Latest PR Test (Base): ⏳ Run #33838041956
Latest PR Test (Extra): ❌ Run #33838041647
Latest PR Test (AMD ROCm 7.2): ⏳ Run #33838041965