[None][fix] Fix VSWA gate in KVCacheManager window-size resolution#16233
Open
eopXD wants to merge 1 commit into
Open
[None][fix] Fix VSWA gate in KVCacheManager window-size resolution#16233eopXD wants to merge 1 commit into
eopXD wants to merge 1 commit into
Conversation
get_cache_indices, get_priority_by_block_id, and get_batch_cache_indices gated the "window_size required" check on len(max_attention_window_vec) > 1, which spuriously rejects a uniform per-layer window vector (e.g. [4096, 4096, ...]) that has a single effective window. commit_and_get_block_hashes already used the correct is_vswa signal (distinct positive windows); the others did not, so callers that omit window_size (e.g. the KV cache connector) broke on such models. Extract a shared _resolve_window_size helper keyed on is_vswa and route all four per-window accessors through it. Signed-off-by: Yueh-Ting Chen <yueh.ting.chen@gmail.com>
Collaborator
Author
|
/bot run |
Collaborator
|
PR_Github #58649 [ run ] triggered by Bot. Commit: |
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.
@coderabbitai summary
Description
KVCacheManager.get_cache_indices,get_priority_by_block_id, andget_batch_cache_indicesgated the "window_size required" check onlen(max_attention_window_vec) > 1. That spuriously rejects a uniformper-layer window vector such as
[4096, 4096, ...], which haslen > 1but asingle effective window (
is_vswais False).commit_and_get_block_hashesalready used the correct
is_vswasignal (distinct positive windows); theothers did not — so callers that legitimately omit
window_size(e.g. the KVcache connector) broke on any model with a uniform per-layer window vector.
This extracts a single
_resolve_window_sizehelper keyed onis_vswaandroutes all four per-window accessors through it, removing the copy-pasted guard
and its divergence. Behavior for genuine VSWA (raise when
window_sizeisomitted) and for an explicitly-provided
window_sizeis unchanged.Test Coverage
tests/unittest/_torch/executor/test_resource_manager.py::TestResolveWindowSizetest_uniform_multi_layer_vector_does_not_raise— the regression: a uniform[4096, 4096, 4096]vector resolves to4096instead of raising.test_genuine_vswa_requires_window_size— genuine VSWA still raises whenwindow_sizeis omitted, and an explicitwindow_sizepasses through.PR Checklist