-
Notifications
You must be signed in to change notification settings - Fork 452
[feature] Prompt Embeddings Support for v1 Engine #3026
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: jesse <szxfml@gmail.com>
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. |
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 prompt embeddings in the v1 engine. The changes span across the model runner and input batch management to handle requests with embeddings instead of token IDs. A new boolean tensor is_token_ids
is introduced to differentiate between the two types of inputs. The logic for preparing inputs, managing cached states, and handling special cases like dummy runs and prompt logprobs has been updated accordingly.
The review identifies a critical issue where inputs_embeds
buffer is not initialized when prompt embeddings are enabled for non-multimodal models, which would lead to a runtime error. A fix is suggested.
if self.is_multimodal_model: | ||
self.inputs_embeds = torch.zeros( | ||
(self.max_num_tokens, self.model_config.get_hidden_size()), | ||
dtype=self.dtype, | ||
device=self.device) | ||
self.inputs_embeds = self._make_buffer(self.max_num_tokens, | ||
self.model_config.get_hidden_size(), | ||
dtype=self.dtype, | ||
numpy=False) |
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.
The inputs_embeds
buffer is only initialized for multimodal models. However, it is also required when enable_prompt_embeds
is true for non-multimodal models. Without this initialization, an AttributeError
will be raised when self.inputs_embeds
is accessed later in methods like _dummy_run
or _prepare_input_ids
. The condition should be updated to include self.enable_prompt_embeds
.
if self.is_multimodal_model: | |
self.inputs_embeds = torch.zeros( | |
(self.max_num_tokens, self.model_config.get_hidden_size()), | |
dtype=self.dtype, | |
device=self.device) | |
self.inputs_embeds = self._make_buffer(self.max_num_tokens, | |
self.model_config.get_hidden_size(), | |
dtype=self.dtype, | |
numpy=False) | |
if self.is_multimodal_model or self.enable_prompt_embeds: | |
self.inputs_embeds = self._make_buffer(self.max_num_tokens, | |
self.model_config.get_hidden_size(), | |
dtype=self.dtype, | |
numpy=False) |
wow, you are so quick! Let's make vllm-ascend work with vLLM main branch first. #2907 Then you can rebase main and add e2e test for this feature. And please note that vLLM Ascend should work on both vLLM main and vLLM latest version( it's v0.10.2 now). So you need consider backward capability perhaps. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
What this PR does / why we need it?
this PR based on 19746, support Prompt Embeddings for v1 engine on NPU
Does this PR introduce any user-facing change?
How was this patch tested?