forked from vllm-project/vllm
-
Notifications
You must be signed in to change notification settings - Fork 0
NWOR masking via cumprod; add SCV modes (graph/adaptive) #2
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
Draft
yuz207
wants to merge
9
commits into
main
Choose a base branch
from
scv-graph
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Replaced explicit conditional logic and nonzero indexing with a cumulative product approach to compute mask_work. This change streamlines the code for better readability and maintainability without altering functionality.
…omputation Introduced SCV (Speculative Computation Vectorization) mode to GPUModelRunner to optimize mask computation during decoding. Added SCVGraphExecutor and _SCVGraphEntry classes leveraging CUDA Graphs for efficient repeated mask calculations. The SCV mode supports 'graph' and 'adaptive' operation and falls back gracefully if CUDA graph execution fails. This enhancement improves decoding performance by reusing captured CUDA graphs for mask operations in speculative decoding workflows. Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
…peculation tokens Introduce an adaptive mode in the GPUModelRunner to dynamically compute and adjust the speculation token mask based on recent acceptance ratios during decoding. This update adds the `_scv_update_controller` method to modify the number of speculative tokens used, aiming to maintain a target acceptance ratio, improving decoding efficiency and performance. Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
…V adaptive mode Add a new unit test `test_scv_vectorized_mask_matches_reference` to validate the behavior of the `_build_nwor_acceptance_mask` method in the GPUModelRunner class configured with SCV adaptive mode. This test ensures the mask output matches the expected reference. Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
…lization code The _scv_enabled method was relocated within the GPUModelRunner class to follow the initialization code block, improving code readability and organization without changing functionality. Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
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.
Summary
Changes
NWOR masking
comparison = (row == draft_slice)
prefix = torch.cumprod(comparison.to(torch.int32), dim=0)
mask_work[start:end] = prefix.to(torch.bool)
SCV mode support
VLLM_SCV_MODE
environment variable with options "off", "graph", or "adaptive" (default "off").self._scv_mode
initialized fromenvs.VLLM_SCV_MODE.lower()
and added_scv_enabled()
to validate and enable SCV modes._scv_vectorized_mask(...)
handles SCV mask computation across modes._SCVGraphEntry
andSCVGraphExecutor
enable CUDA graph-based SCV execution when in graph mode.Rationale
Tests
test_scv_vectorized_mask_matches_reference
validates the SCV-based mask equals the expected reference for a given metadata and sampled inputs.Backwards Compatibility
How to Review
vllm/v1/worker/gpu_model_runner.py
.📎 Task: https://www.terragonlabs.com/task/cfda0cbe-9bb8-4b82-9858-540824550cf2