[feature] Prompt Embeddings Support for v1 Engine#3026
[feature] Prompt Embeddings Support for v1 Engine#3026wangxiyuan merged 40 commits intovllm-project:mainfrom
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.
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.
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. |
…for multimodal models Signed-off-by: jesse <szxfml@gmail.com>
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: jesse <szxfml@gmail.com>
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: jesse <szxfml@gmail.com>
Signed-off-by: jesse <szxfml@gmail.com>
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
please fix the merge conflict |
Signed-off-by: jesse <szxfml@gmail.com>
Signed-off-by: jesse <szxfml@gmail.com>
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
maybe we should add the test to |
Signed-off-by: jesse <szxfml@gmail.com>
Signed-off-by: jesse <szxfml@gmail.com>
added |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: jesse <szxfml@gmail.com>
### What this PR does / why we need it? this PR based on [19746](vllm-project/vllm#19746), support Prompt Embeddings for v1 engine on NPU ### Does this PR introduce _any_ user-facing change? ### How was this patch tested? ```python python examples/prompt_embed_inference.py ``` - vLLM version: v0.11.0 - vLLM main: vllm-project/vllm@releases/v0.11.1 --------- Signed-off-by: jesse <szxfml@gmail.com> Signed-off-by: luolun <luolun1995@cmbchina.com>
### What this PR does / why we need it? this PR based on [19746](vllm-project/vllm#19746), support Prompt Embeddings for v1 engine on NPU ### Does this PR introduce _any_ user-facing change? ### How was this patch tested? ```python python examples/prompt_embed_inference.py ``` - vLLM version: v0.11.0 - vLLM main: vllm-project/vllm@releases/v0.11.1 --------- Signed-off-by: jesse <szxfml@gmail.com> Signed-off-by: hwhaokun <haokun0405@163.com>
### What this PR does / why we need it? this PR based on [19746](vllm-project/vllm#19746), support Prompt Embeddings for v1 engine on NPU ### Does this PR introduce _any_ user-facing change? ### How was this patch tested? ```python python examples/prompt_embed_inference.py ``` - vLLM version: v0.11.0 - vLLM main: vllm-project/vllm@releases/v0.11.1 --------- Signed-off-by: jesse <szxfml@gmail.com> Signed-off-by: nsdie <yeyifan@huawei.com>
### What this PR does / why we need it? this PR based on [19746](vllm-project/vllm#19746), support Prompt Embeddings for v1 engine on NPU ### Does this PR introduce _any_ user-facing change? ### How was this patch tested? ```python python examples/prompt_embed_inference.py ``` - vLLM version: v0.11.0 - vLLM main: vllm-project/vllm@releases/v0.11.1 --------- Signed-off-by: jesse <szxfml@gmail.com>
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?