-
-
Notifications
You must be signed in to change notification settings - Fork 20.6k
[Model] Support Unlimited OCR #46564
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
24 commits
Select commit
Hold shift + click to select a range
33a666c
Support Unlimited OCR
gty111 1bd417a
fix tokenizer with transformers v5
Isotr0py f3bcc62
Address review feedback
gty111 27d93d7
Fix compat issue with prefix caching
gty111 f9c6e84
Fix flexattention
gty111 6f5cca3
Add fa4 support and fixed kv
gty111 1c728d5
Fix RSWASpec
gty111 8be995c
Fix attn config
gty111 ef41a32
Fix default preprocess
gty111 2e6845f
Fix multi-images preprocess
gty111 e1bd4c9
Fix fa4 prefix caching
gty111 b50faf8
Lint
gty111 e99d991
Lint
gty111 f8b79e7
Resolve comments
gty111 41721ba
Lint
gty111 4c953ad
avoid unnecessary tracking
Isotr0py bd41f0a
Merge branch 'main' into unlimited_ocr
gty111 6ce8a97
Fix cached processor
gty111 e979716
Resolve comments
gty111 b620a8f
Merge branch 'main' into unlimited_ocr
ywang96 92b371f
Resolve issues
gty111 7aaf016
Lint
gty111 c5d3172
Merge branch 'main' into unlimited_ocr
ywang96 842498d
Support model runner v2
gty111 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
|
|
||
| from vllm.config.vllm import VllmConfig | ||
| from vllm.model_executor.layers.attention import Attention | ||
| from vllm.v1.kv_cache_interface import KVCacheSpec, RSWASpec, get_kv_quant_mode | ||
|
|
||
|
|
||
| class RSWAAttention(Attention): | ||
| """Attention layer that reports ``RSWASpec`` as its KV cache spec. | ||
|
|
||
| Drop-in replacement for the standard ``Attention`` layer when the model is | ||
| configured with Reference Sliding Window Attention (R-SWA, | ||
| ``rswa_window > 0``). The actual masking logic lives in the attention | ||
| backend (FlexAttention or FA4 mask_mod); this layer only overrides | ||
| ``get_kv_cache_spec`` so the KV cache manager instantiates ``RSWAManager`` | ||
| (instead of ``FullAttentionManager``) and can therefore evict "gap" blocks | ||
| to keep per-request KV memory bounded at O(prefix + window). | ||
| """ | ||
|
|
||
| def __init__(self, *args, rswa_window: int, **kwargs) -> None: | ||
| super().__init__(*args, **kwargs) | ||
| self._rswa_window = rswa_window | ||
|
|
||
| def get_kv_cache_spec(self, vllm_config: VllmConfig) -> KVCacheSpec | None: | ||
| spec = super().get_kv_cache_spec(vllm_config) | ||
| if spec is None: | ||
| return None | ||
| return RSWASpec( | ||
| block_size=vllm_config.cache_config.block_size, | ||
| num_kv_heads=self.num_kv_heads, | ||
| head_size=self.head_size, | ||
| head_size_v=self.head_size_v, | ||
| dtype=self.kv_cache_torch_dtype, | ||
| kv_quant_mode=get_kv_quant_mode(self.kv_cache_dtype), | ||
| rswa_window=self._rswa_window, | ||
| ) |
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
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.