Repository navigation
[Fix] scheduler: Count a request's held req_to_token row once at admission - #44401
Merged
Merged
Conversation
hnyls2002
requested review from
ClawSeven,
Ying1123,
merrymercy,
rwang5203 and
xiezhq-hermann
as code owners
October 15, 2026 04:28
Collaborator
Author
|
/rerun-test test_streaming_session.py test_streaming_session_swa.py test_dllm_batching_fdfo.py test_disaggregation_chunked_prefill_abort.py test_scripted_core_1gpu.py test_mixed_chunked_prefill.py test_retract_decode.py test_priority_scheduling.py test_load_snapshot_server.py test_dllm_fdfo_joint_threshold.py |
Collaborator
Author
|
/tag-and-rerun-ci |
Contributor
|
🚀 🚀 🚀 |
This was referenced Oct 15, 2026
Closed
This was referenced Oct 15, 2026
jhsmith409
added a commit
to jhsmith409/sglang-rtxpro6000
that referenced
this pull request
Oct 18, 2026
…sion get_num_allocatable_reqs caps admission at req_to_token_pool.available_size(). A chunked request keeps its req_to_token row across chunks, but it is also in adder.can_run_list, so admission counted its row twice: once as taken and once as needed. With --max-running-requests 4 there are exactly four rows, so when a long prompt's final chunk ran, the free row was treated as spoken for, and a waiting request joined one step later than it could have. Pass the number of can_run_list requests that already hold a row (req_pool_idx is not None, Penny's equivalent of upstream's kv.holds_kv) and add those rows back to the available count. The PD-prefill check gets the same correction. Applied from upstream sgl-project/sglang#44401 (Liangsheng Yin), with its test adapted to Penny's scheduler: Penny builds PrefillAdder directly (patched in the test) and keeps req_pool_idx on Req. Co-Authored-By: Claude Opus 5.5 <[email protected]>
detain
pushed a commit
to detain/sglang
that referenced
this pull request
Oct 19, 2026
…ssion (sgl-project#44401) (cherry picked from commit f9bdb74) (cherry picked from commit b8324cd40e383b1cfdd9e977c989829e56f17a3c)
kenji21
pushed a commit
to kenji21/sglang-rtxpro6000
that referenced
this pull request
Oct 22, 2026
Minimal port of sgl-project/sglang#44401 for runtime evaluation on Penny3.0.2. Upstream: head 99e79ef77e7e6b8b345af5206f05104cd34115b0, merged f9bdb74 Author: Liangsheng Yin <[email protected]> Adapted to this checkout: the row-held predicate is Req.req_pool_idx is not None (this fork has no ReqKvInfo.holds_kv), PrefillAdder is constructed directly so the regression patches the class instead of a factory seam, and upstream's comment-only tweak of the is_empty() batch_is_full reset is dropped (this fork has no such block). Held rows restore only the req_to_token pool term; the pp_max_micro_batch_size / max-running term is unchanged.
detain
added a commit
to detain/sglang
that referenced
this pull request
Oct 30, 2026
…entries 122,198,200,211,215,220,267,268,305 Re-plants the scheduler.py fork-hunks (replant/...managers__scheduler.py.fork-hunks.patch) onto the post-sgl-project#46977 admission structure. tp_worker marker consumed (15/23 B4 markers still on the tree; per-file counts, damage-state from entry 310's map). PER-HUNK DECISIONS (all VERIFIED against the merged tree, not taken on faith): - entry 122 (sgl-project#40458): grammar-sync overlap disable RE-PLANTED for mixed mode (is_decode() OR is_mixed()) + the fork's trimmed comments; upstream's host-draft-only arm was the pre-sgl-project#40458 form (origin/main verified: absent). - entry 220 (sgl-project#39765, OPEN port): _has_pending_mamba_cache_update + the early pop_and_process/short-circuited disable-overlap RE-PLANTED into event_loop_overlap; the require_mlp_sync/disable/extra-buffer gate verbatim. - entry 198 (sgl-project#37612): THE CATCHER — B3-5 landed the raiser; the try/except MambaCowAllocError around init_next_round_input (res=NO_TOKEN, request stays queued; the revert block + unconditional alloc_group_end were already in the merged tree = the no-leak halves VERIFIED PRESENT) RE-PLANTED with the import. COW component test re-anchored to the #46970x kv_storage seam the B3-5 replant moved _state() behind (stub was the pre-split mamba_allocator shape). - entry 268 (sgl-project#46643, OPEN port -- VERIFIED NEVER MERGED: git log 12dc623..2a6c204 --grep 46643 = ZERO; only sgl-project#45491/sgl-project#45435/sgl-project#45472/sgl-project#45670 of the briefed merged-list arrived in-range): the UNCONDITIONAL batch_is_full clear RE-PLANTED on the scheduler side, subsuming the entry-198 hybrid-SSM arm and the priority-preemption/is_empty arms (policy side lands in B4-3). - entry 267 (sgl-project#46496): retract_decode new_token_ratio FLOOR clamp RE-PLANTED. - entry 211: triton_load_watch.prewarm_device_loads(self.model_worker) line RE-PLANTED between install() and mark_serving_started (the utils-side function survived the merge; only the call site was dropped). - entry 200 (sgl-project#43527) CAPACITY PAIR RE-PLANTED: model_runner .logical_max_total_num_tokens passes allocator= again (the configurator's PageInterleavePoolAllocator -> allocator.size branch SURVIVED the merge byte-identical, so the merged tree had the fork predicate with upstream's consumer-side multiplications = DOUBLE-COUNT); the three scheduler * kv_shard_widening multipliers back to the fork form (pool-stats shape, load_inquirer, and the init_req one-page-per-shard subtraction); tp_worker drops page_interleave_shard_size x + import. Upstream's invariant-checker hunk: OBSOLETE (the constructor no longer takes max_total_num_tokens -- absorbed by refactor). - entry 215 (sgl-project#44351/sgl-project#44401/sgl-project#44420): VERIFIED ALREADY PRESENT at the merge (filter_batch-every-step + reset ride, num_held_rows, budget_state FIRST statement, PD-gate deletion all byte-compare to the fork form) -- DEDUPED, no edit. Entry 107's local early-revision of sgl-project#40940 stays superseded (entry 215 rule), and its re-plant here would double-count. - entry 220's/305's pause-window busy accounting + write_fence_stream + is_empty arm: VERIFIED PRESENT (entry 305 landed patch-identical via sgl-project#46127; the fence assignment is the B3-2 controller half) -- DEDUPED. TEST FIXTURE RE-ANCHORS (not B2's: no markers, pure new-upstream-contract drift, per the entry-198 fixture-adaptation precedent): the two hybrid-ssm admission stubs gain disagg_prefill_bootstrap_queue=None (upstream's routing-key bootstrap_queue arg in calc_priority arrived in-range). PRUNE vs BREAKAGE (managers −523sub audit): the three managers test files vanished in-range (test_schedule_policy_dfs_weight, test_scheduler_batch_is _full_latch, test_uno_token_accounting) were ALL deleted by upstream's OWN sgl-project#45672 prune (3438ed6). Two are byte-identical upstream copies = zero fork delta. The third carried a 3-line fork comment/stub delta whose SEMANTICS the re-planted unconditional clear pins: its case was the is_empty-arm mirror of test_scheduler_hybrid_ssm_admission_latch (present, green, hybrid_swa/non-hybrid arms included) -- NOT re-homed, recorded. ACTUALS (damage -> after, CVD=9, prod venv, PYTHONPATH=python, per-file): test_scheduler_hybrid_ssm_admission_retry 4F -> ** 4P ** test_scheduler_hybrid_ssm_admission_latch 3F -> ** 4P ** test_mamba_prefill_cache_boundary 2F/12subF -> ** 5P/12sub EXACT (220 pin) ** test_scheduler_retract_ratio 1F -> ** 2P EXACT (267 pin) ** test_scheduler_init_req_max_new_tokens 1F -> ** 10P/6sub ** test_scheduler_grammar_mixed_tail_sync 1F -> ** 4P ** adjacent scheduler-stub files (held_row, running_batch_finished, pause_generation, disagg_idle, dp_converted, hicache_events) 56P/64sub UNMOVED -- no regression from the clear/catcher/capacity edits. Lint: ruff format + F821/E9 clean on all five files; imports OK (no GPU execution, no push). Co-Authored-By: OpenCode <[email protected]>
detain
added a commit
to detain/sglang
that referenced
this pull request
Oct 30, 2026
…s 94,95,119,122,169,215,262,263,265 (re-plant + verified-absorbed) 3 markers consumed (batch B4 total now 23-1-3=19; briefing's '20' was the session-1 census -- true tree count is 23, per the B3 census lesson). RE-PLANTED (batch_result_processor.py, from its fork-hunks patch): - _logprob_rows_to_host tensor-or-placeholder converter + 3 call sites (the mixed-batch per-row mixed-type class; damage: 3F). - Entry 265 (sgl-project#46272, OPEN port -- VERIFIED NOT MERGED in-range): the decoding_req_ids lazy {id(r)} set replacing the three O(B) 'req in batch.decoding_reqs' scans in the prefill-result loop. The entry-265 interlock holds: the re-planted set feeds the SAME branch that mamba_untracked_decode_batch_idx gates, and that gate landed byte- present upstream via sgl-project#45435 (schedule_batch x3 + brp x1 references audited) -- the byte-count invariant of the merge point is preserved. VERIFIED-ABSORBED (markers consumed, NO edits -- the merged tree already carries the semantics, hunk-a-hunk against the 309-tip): - schedule_batch.py (no fork-hunks patch existed; tsv DRIVER class was TRIAGE-UNION all-mechanical, so the audit was semantic): sgl-project#45435's mamba_lazy_undo_prealloc_at_boundary x2, _mamba_track_for_mixed DELETED (0 refs) with upstream's -1 tail padding + freed_rows->-1 guard carried VERBATIM (entry 263(a)), sgl-project#45472's _gather_mamba_track_indices x3 + pinned async_h2d track tensors + mamba_ping_pong_empty host mirror x4 + the collapsed single set_mamba_track_indices_from_reqs, holds_kv x4 (sgl-project#44401), untracked_decode_batch_idx x3. Entry 119's supersession by the sgl-project#45435 upstream form CONFIRMED (32c2678 in-range per git log 12dc623..2a6c204 -- this is the merge's own absorption of our entry-262 pick). - mm_utils.py: entry 263(b)'s UNION was superseded IN-RANGE by upstream landing the plural padding_values() (pad_values or (pad_value,) -- exactly the fork's scalar source degenerate case) with the sorted invariant; _get_multimodal_mask (mm_schedule.py:655) is the sgl-project#45472 searchsorted no-sync form fed by that sortedness contract. - brp's _mamba_can_cache_finished_req gate + mamba_ping_pong_empty mirror consumption x2 + the two rich FINISH_ABORT sites + the untracked_decode_batch_idx advance gate: PRESENT upstream. TEST RE-ANCHORS (mixed_mamba_track, contract-driven, per entry 198's fixture-adaptation precedent; NOT production): - CacheInitParams tree_components kwarg -> tree_slots_of((FULL, MAMBA)) (#46970x: slots drive components), - allocator.state = req_to_token_pool.state -- production's equivalent is the configurator's runner_state() bind (kv_cache_configurator:553); a manual classic build must bind too or ensure_mamba_capacity (#46970x seam) reads state=None (diagnosed: NOT a fork-delta loss, NOT upstream-own -- upstream binds in prod; fixture bypass), - backend._state_ids identity IdSpace stub (runner_ids seam; classic pools index slots directly -- matches production for this config). ACTUALS (damage -> after, CVD=9, prod venv, per-file): test_schedule_batch_mixed_mamba_track 7F -> ** 7P EXACT (262 pin) ** test_batch_result_processor_mixed_token_ids_logprob 3F -> ** 3P ** brp family (mamba_boundary, spec_grammar) + mix_with_running: 33P/17sub GREEN incl. the entry-265 quartet proof. DIR: unit/managers 1025P/83F/9S/427sub -> ** 1048P/48F/9S/439sub ** (remaining 48F = prefill_adder 39F + dcp_logical 7F [both B4-3's pricing reconciliation] + the two known order-dependent test_mm_process_config F's [env class, reproduce at base]). Lint: ruff format + F821/E9 clean; 3 EOF-marker artifacts the merge left (schedule_batch/mm_utils/brp trailing comments) resolved by the marker removals. No GPU; no push. Co-Authored-By: OpenCode <[email protected]>
Nozom1ff
added a commit
to Nozom1ff/sglang
that referenced
this pull request
Nov 6, 2026
…vation v0.5.23 (sgl-project#44401) made get_num_allocatable_reqs give back the rows that counted requests already hold, and the admission loop now passes the continuation's row. The replayed HRRN chunk-limit reservation (sgl-project#99) still asked for the cap without it and then subtracted the continuation again, so with free rows binding it reserved budget for one short request fewer than the pass admits (none at one free row). Co-Authored-By: Claude <[email protected]>
Nozom1ff
added a commit
to Infrawaves/sglang
that referenced
this pull request
Nov 7, 2026
…vation v0.5.23 (sgl-project#44401) made get_num_allocatable_reqs give back the rows that counted requests already hold, and the admission loop now passes the continuation's row. The replayed HRRN chunk-limit reservation (#99) still asked for the cap without it and then subtracted the continuation again, so with free rows binding it reserved budget for one short request fewer than the pass admits (none at one free row). Co-Authored-By: Claude <[email protected]>
frgossen
pushed a commit
to sgl-project/sglang-torchtpu
that referenced
this pull request
Nov 18, 2026
Cherry-pick of sgl-project/sglang@f9bdb74a5ae9 (sgl-project/sglang#44401): count a request that already holds a req_to_token row once at admission. A continuing chunked prefill, a session borrow or a dLLM staging request is in can_run_list and its row is already excluded from req_to_token_pool.available_size(), so the gate counted it twice and set batch_is_full with a row still free; nothing cleared the flag until a request finished, so the waiting queue starved meanwhile. Conflict resolution: the hunk rewording the comment on the empty-batch batch_is_full reset is dropped, since this core has no such reset. The test is adapted to this core's scheduler (PrefillAdder patched directly, the _tpu_pp_chunk_cost and _dynamic_first_chunk_cap attributes, the chunk_tokens_cap keyword).
frgossen
added a commit
to sgl-project/sglang-torchtpu
that referenced
this pull request
Nov 18, 2026
…01) (#2256) * [Sync] Cherry-pick upstream held req_to_token row admission fix (#44401) Cherry-pick of sgl-project/sglang@f9bdb74a5ae9 (sgl-project/sglang#44401): count a request that already holds a req_to_token row once at admission. A continuing chunked prefill, a session borrow or a dLLM staging request is in can_run_list and its row is already excluded from req_to_token_pool.available_size(), so the gate counted it twice and set batch_is_full with a row still free; nothing cleared the flag until a request finished, so the waiting queue starved meanwhile. Conflict resolution: the hunk rewording the comment on the empty-batch batch_is_full reset is dropped, since this core has no such reset. The test is adapted to this core's scheduler (PrefillAdder patched directly, the _tpu_pp_chunk_cost and _dynamic_first_chunk_cap attributes, the chunk_tokens_cap keyword). * Drop an unneeded test stub --------- Co-authored-by: Liangsheng Yin <[email protected]>
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.
req_to_tokenrow once at admission. Such a request (a continuing chunked prefill, a streaming-session borrow, a dLLM staging request) is incan_run_list, and its row is already excluded fromreq_to_token_pool.available_size(), so the gatelen(can_run_list) >= get_num_allocatable_reqs(...)counted it twice and declared the batch full with a row still free.get_num_allocatable_reqstakesnum_held_rowsand adds those rows back to the pool term only; thepp_max_micro_batch_sizeterm still counts every request. The main gate, the PD-prefill gate, and the dLLM gate passsum(r.kv.holds_kv for r in adder.can_run_list).max_running_requests - 1, and when the final chunk's pass setbatch_is_full, nothing cleared it until a request finished, so the waiting queue starved meanwhile.update_running_batchis no longer the only other place that clearsbatch_is_full._get_new_batch_prefill_rawwith a final chunk, two running requests, and one free row, in normal and PD-prefill mode; it fails on main.Behavior change: a prefill pass whose batch already contains a row-holding request now admits one more request per held row; with no such request, admission is unchanged.
Fixes #38118, fixes #35537; supersedes #30295, which found the chunked-prefill case.
CI States
Latest PR Test (Base): ❌ Run #38684565822
Latest PR Test (Extra): ❌ Run #38684565775
Latest PR Test (AMD ROCm 10): ⏳ Run #38684565779