-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[diffusion] refactor: make timestep scheduler request-local #23716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
dbf0898
Use request-local scheduler runtime
mickqian d1b4c15
Move model-specific schedulers to request-local state
mickqian f1b40ce
lint
mickqian 086174e
upd
mickqian 8f3c1dc
Address stateless scheduler review feedback
mickqian 65e77e4
upd
mickqian 2086e75
Centralize scheduler runtime cloning
mickqian c68937f
Rename diffusion scheduler helper
mickqian 3695d47
Move diffusion scheduler helper to pipeline core
mickqian 3438c27
lint
mickqian 76341ea
Merge branch 'main' into diffusion-stateless-scheduler
mickqian 0157720
Clear consumed sigmas in Qwen layered stage
mickqian 2edc1a0
Skip timestep preparation when scheduler is precomputed
mickqian c1f84da
Fix disagg request-local scheduler transfer
mickqian 3332d5d
Fix disagg scheduler timesteps device
mickqian fcbd4f7
Avoid cloning DMD scheduler per request
mickqian e2f2293
Avoid unnecessary scheduler cloning
mickqian ff4abde
Clarify request scheduler ownership
mickqian bb4a575
lint
mickqian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
python/sglang/multimodal_gen/runtime/pipelines_core/diffusion_scheduler_utils.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from copy import deepcopy | ||
| from typing import Any | ||
|
|
||
| from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import Req | ||
|
|
||
|
|
||
| def clone_scheduler_runtime(scheduler: Any) -> Any: | ||
| """Create an isolated scheduler runtime from a scheduler template or runtime.""" | ||
| return deepcopy(scheduler) | ||
|
|
||
|
|
||
| def get_or_create_request_scheduler( | ||
| batch: Req, scheduler_template: Any, *, isolate: bool = False | ||
| ) -> Any: | ||
| """Return the scheduler runtime for this request. | ||
|
|
||
| Diffusion serving currently executes one request at a time on the normal | ||
| worker path, so reusing the stage-local scheduler preserves warmup caches | ||
| and avoids unnecessary deepcopy overhead. Set ``isolate=True`` only when a | ||
| request can run concurrently or outlive the stage-local scheduler state. | ||
| """ | ||
| if batch.scheduler is None: | ||
| batch.scheduler = ( | ||
| clone_scheduler_runtime(scheduler_template) | ||
| if isolate | ||
| else scheduler_template | ||
| ) | ||
| return batch.scheduler |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.