-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
[Bugfix] Fix encoder-only model support for transformers backend #28021
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
+16
−10
Merged
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
| from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS | ||
|
|
||
| from vllm.attention import Attention, AttentionType | ||
| from vllm.attention.layers.encoder_only_attention import EncoderOnlyAttention | ||
| from vllm.config.utils import getattr_iter | ||
| from vllm.distributed import get_pp_group, get_tp_group | ||
| from vllm.distributed.utils import get_pp_indices | ||
|
|
@@ -317,7 +318,7 @@ def create_attention_instances(self) -> dict[int, Attention]: | |
| # vLLM does not support encoder-decoder models, so if any encoder layer is | ||
| # found in a text only model, we assume the whole model is an encoder model | ||
| if has_encoder(self.model) and not is_multimodal(self.config): | ||
| self.check_version("4.57.0.dev0", "encoder models support") | ||
| self.check_version("5.0.0.dev0", "encoder models support") | ||
| attn_type = AttentionType.ENCODER_ONLY | ||
| else: | ||
| attn_type = AttentionType.DECODER | ||
|
|
@@ -336,7 +337,12 @@ def create_attention_instances(self) -> dict[int, Attention]: | |
| ): | ||
| per_layer_sliding_window = self.config.sliding_window | ||
|
|
||
| attention_instances[i] = Attention( | ||
| attn_cls = ( | ||
| EncoderOnlyAttention | ||
| if attn_type == AttentionType.ENCODER_ONLY | ||
| else Attention | ||
| ) | ||
| attention_instances[i] = attn_cls( | ||
|
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. Why does passing 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. |
||
| num_heads=num_heads, | ||
| head_size=head_size, | ||
| # NOTE: We use Llama scale as default, if it's set by | ||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heheda12345 do you want to handle it inside the
Attentionclass init to signal deprecation with a warning?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to handle it like this now. For the deprecation warning, just add one line of warning in Attention class? (not necessary in this PR)