-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[sglang-miles] Cherry-pick #24851: Add routed_experts_start_len for absolute routing slice control #24904
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
[sglang-miles] Cherry-pick #24851: Add routed_experts_start_len for absolute routing slice control #24904
Changes from all commits
Commits
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,13 +97,48 @@ def process_batch_result_prebuilt(self: Scheduler, batch: ScheduleBatch): | |
| self.stream_output(batch.reqs, batch.return_logprob) | ||
|
|
||
| def maybe_collect_routed_experts(self: Scheduler, req: Req): | ||
| """Collect routed experts for a finished request.""" | ||
| req.routed_experts = get_global_experts_capturer().get_routed_experts( | ||
| """Collect routed experts for a finished request. | ||
|
|
||
| Returns immediately if `return_routed_experts` was not set on the | ||
| request, so non-opted-in reqs don't pay the host-gather cost. | ||
|
|
||
| Honors the caller's absolute start so the response covers | ||
| `[start_len, seqlen - 1)`. The default start_len is 0, which returns | ||
| the full sequence. | ||
|
|
||
| Logs a soft warning if the resulting tensor's row count differs from | ||
| the expected `seqlen - 1 - start_len`, to catch silent regressions. | ||
| """ | ||
| if not req.return_routed_experts: | ||
| return | ||
| capturer = get_global_experts_capturer() | ||
| if capturer is None: | ||
| return | ||
| start_len = req.routed_experts_start_len | ||
| req.routed_experts = capturer.get_routed_experts( | ||
| req_pool_idx=req.req_pool_idx, | ||
| seqlen=req.seqlen, | ||
| req_to_token_pool=self.req_to_token_pool, | ||
| start_len=start_len, | ||
| ) | ||
|
|
||
| expected_rows = max(0, req.seqlen - 1 - start_len) | ||
| if ( | ||
| req.routed_experts is not None | ||
| and req.routed_experts.shape[0] != expected_rows | ||
| ): | ||
| logger.warning( | ||
| "routed_experts row-count mismatch for req %s: got %d, " | ||
| "expected %d (seqlen=%d, cached_tokens=%d, start_len=%s). " | ||
| "This indicates a silent bug.", | ||
| req.rid, | ||
| req.routed_experts.shape[0], | ||
| expected_rows, | ||
| req.seqlen, | ||
| req.cached_tokens, | ||
| req.routed_experts_start_len, | ||
| ) | ||
|
Comment on lines
+130
to
+140
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is wrong. it is above |
||
|
|
||
| def maybe_collect_customized_info( | ||
| self: Scheduler, i: int, req: Req, logits_output: LogitsProcessorOutput | ||
| ): | ||
|
|
||
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.