Repository navigation
[Refactor] scheduler: Move Req into managers/req.py - #54065
Merged
Merged
Conversation
There was a problem hiding this comment.
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.
hnyls2002
requested review from
ByronHsu,
ClawSeven,
Fridge003,
HaiShaw,
Jialin,
Qiaolin-Yu,
ShangmingCai,
ZhengWG,
alphabetc1,
fzyzcjy,
hanming-lu,
huangtingwei9988,
iforgetmyname,
ispobock,
jybsuper,
lifuhuang,
merrymercy,
ping1jing2,
rwang5203,
sufeng-buaa,
whybeyoung,
xiezhq-hermann,
yeahdongcn,
yizhang2077 and
yushengsu-thu
as code owners
November 30, 2026 08:52
Collaborator
Author
|
/rerun-test test_finish_length_speculative.py test_req_finish_state.py test_admission_abort_not_enqueued.py test_gpu_feature_transport.py test_srt_endpoint.py |
Contributor
|
🚀 🚀 |
Collaborator
Author
|
/tag-and-rerun-ci |
1 task done
This was referenced Nov 30, 2026
This was referenced Dec 1, 2026
3 of 5 tasks
Open
3 of 5 tasks
Open
5 tasks done
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.
Why
schedule_batch.pyholds two core objects: the per-requestReq(withReqKvInfoandReqLogprob) and the batchScheduleBatch.Reqis shared well beyond the scheduler (speculative, mem_cache, sampling, model_executor, disaggregation), so it gets its own module next toreq_types.py. This PR is a pure move: whole classes, bytes unchanged, plus imports.ScheduleBatch, the batch helpers, the lifecycle helpers (release_req,retract_all,free_beam_member_rows,unresumable_abort_message),NextBatchPlanand the field helpers stay inschedule_batch.py.Block map
Moved as one contiguous block, in the same order (
python/sglang/srt/managers/schedule_batch.pyat6d630df467->python/sglang/srt/managers/req.py):ReqLogprobmanagers/req.pyReqKvInfomanagers/req.pyReqmanagers/req.pyschedule_batch.pygoes from 3744 to 2128 lines.Reqonly usesloggerfrom the module level, andschedule_batch.pystill uses it.req.pygets only the imports the block needs, and its ownlogger = logging.getLogger(__name__). Log lines fromReqnow carry the logger namesglang.srt.managers.reqinstead ofsglang.srt.managers.schedule_batch.req.pyimports nothing fromschedule_batch.py;schedule_batch.pyimportsReqfromreq.py. TheTYPE_CHECKINGand function-local imports in the moved code are unchanged.schedule_batch.pyimportsReqfor its own use only.Importers
Two commits: the move, then the importer updates (the first commit alone does not import cleanly).
python/sglang, 111 undertest/, 1 inbenchmark/, 1 intools/sglang-simulator.from sglang.srt.managers.schedule_batch import Req(andReqKvInfo) now readsfrom sglang.srt.managers.req import ...; the other names of the same import stay.mock.patch("...schedule_batch.get_parallel")in 3 tests that exerciseReq.set_finish_with_abort, andpatch.object(schedule_batch, "get_parallel")intest_gpu_feature_transport.py, now patchsglang.srt.managers.reqbecauseReqreadsget_parallelfrom its own module.sglang.srt.managers.schedule_batch.Reqare nowsglang.srt.managers.req.Req.benchmark/io/bench_mm_token_padding.pyimportedMultimodalInputsthroughschedule_batch; it imports it fromreq_typesnow.The script
Rerunnable on another version of the file (it locates the classes by AST and fails if anything else sits inside the block):
move_req.py
update_importers.py
Checks
ast_check.py): each moved class's source segment inreq.pyequals the original byte for byte,req.pyends with the original block, andschedule_batch.pyminus the moved classes equals the original minus them, imports excluded.python/sglangtouched by the importer commit imports in its own process (103 modules): same 8 failures asorigin/main(optional deps missing on the host).unit/managers,sampling,spec,speculative,mem_cache,model_executor,disaggregation) onorigin/mainand on this head: identical failure ids (1445 on both, all pre-existing on a CPU-only host).CI States
Latest PR Test (Base): ⏳ Run #46395702463
Latest PR Test (Extra): ⊘ Skipped -- add the
run-ci-nv-extralabel to opt in.Latest PR Test (AMD ROCm 10): ❌ Run #46395709061
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: