[Core][Refactor] scheduler: refactor prefill chunk alignment logic#41728
Open
jzakrzew wants to merge 1 commit intovllm-project:mainfrom
Open
[Core][Refactor] scheduler: refactor prefill chunk alignment logic#41728jzakrzew wants to merge 1 commit intovllm-project:mainfrom
jzakrzew wants to merge 1 commit intovllm-project:mainfrom
Conversation
Introduce a PrefillChunkAlignmentPolicy interface to separate prefill chunk-shaping decisions from the scheduler control flow. Move the existing Mamba align-mode chunk splitting into a dedicated policy. Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Jakub Zakrzewski <jzakrzewski@nvidia.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the Mamba block-aligned splitting logic into a more flexible PrefillChunkAlignmentPolicy system. It introduces a protocol-based approach with a default no-op policy and a specific Mamba policy, allowing the scheduler to handle prefill chunk alignment more cleanly across different model types. A critical issue was identified in the Mamba alignment logic where a small token budget (less than the block size) could cause num_scheduled_tokens to snap to zero, potentially stalling the scheduler; this contradicts the code's internal documentation which suggests such small chunks should be allowed through without caching.
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.
Purpose
This is a behavior-preserving refactor that makes it possible to add prefill chunk alignment logic without introducing model-specific hacks directly into the scheduler. It introduces a
PrefillChunkAlignmentPolicyinterface, which separates prefill chunk-shaping decisions from the scheduler control flow. As part of this change, the existing Mamba align-mode chunk-splitting logic has been fully moved out of the scheduler and into the alignment policy layer.The immediate motivation for this PR is the lack of progress on #38561. This PR does not include any batch-invariance-related logic, but it may provide a cleaner foundation for that work.
Test Plan
Added new tests for scheduler alignment policy behavior in
tests/v1/core/test_scheduler.py.Added tests for the policies themselves in
tests/v1/core/test_prefill_chunk_alignment.py.