-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Encoder model support for the Transformers backend #25174
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
Encoder model support for the Transformers backend #25174
Conversation
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
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.
Code Review
This pull request adds support for encoder models to the Transformers backend. The main changes include detecting encoder models by checking for is_causal=False
and using EncoderOnlyAttention
accordingly. It also adds logic to skip loading position_ids
from checkpoints for encoder models, as vLLM handles this. The changes look good, but I have a critical suggestion to improve the type hint for create_attention_instances
to reflect that it can return EncoderOnlyAttention
instances, which will improve code clarity and maintainability.
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
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.
Just a nit. Otherwise LGTM!
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: charlifu <charlifu@amd.com>
Adds support for encoder models to the Transformers backend.
Depends on
I have conditioned this feature on the Transformers version, so as soon as the following dependency is merged we can merge this PR and users installing vLLM and Transformers from main can use this feature:
Attention
] Bert-based Models Attention Refactor huggingface/transformers#38301 - so that encoder models use theALL_ATTENTION_FUNCTIONS
interface necessary for the Transformers backendChanges
EncoderOnlyAttention
if an encoder model is detectedposition_ids
buffers if they're found in the checkpoint because vLLM always passesposition_ids
anywayTesting