-
Notifications
You must be signed in to change notification settings - Fork 624
[Bugfix] Resolve the interface compatibility issue of get_input_embeddings in MM #4638
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import copy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import gc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import inspect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import itertools | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import math | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import re | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1394,11 +1395,19 @@ def _prepare_inputs( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # embeddings), we always use embeddings (rather than token ids) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # as input to the multimodal model, even when the input is text. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input_ids = self.input_ids[:total_num_scheduled_tokens] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inputs_embeds = self.model.get_input_embeddings( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input_ids, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| multimodal_embeddings=mm_embeds, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_multimodal=is_mm_embed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| has_is_multimodal = 'is_multimodal' in inspect.signature(self.model.get_input_embeddings).parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if has_is_multimodal: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inputs_embeds = self.model.get_input_embeddings( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input_ids, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| multimodal_embeddings=mm_embeds, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_multimodal=is_mm_embed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if mm_embeds: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inputs_embeds = self.model.get_input_embeddings( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input_ids, mm_embeds) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inputs_embeds = self.model.get_input_embeddings(input_ids) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| has_is_multimodal = 'is_multimodal' in inspect.signature(self.model.get_input_embeddings).parameters | |
| if has_is_multimodal: | |
| inputs_embeds = self.model.get_input_embeddings( | |
| input_ids, | |
| multimodal_embeddings=mm_embeds, | |
| is_multimodal=is_mm_embed, | |
| ) | |
| else: | |
| if mm_embeds: | |
| inputs_embeds = self.model.get_input_embeddings( | |
| input_ids, mm_embeds) | |
| else: | |
| inputs_embeds = self.model.get_input_embeddings(input_ids) | |
| if not hasattr(self, "_has_is_multimodal_in_get_input_embeddings"): | |
| self._has_is_multimodal_in_get_input_embeddings = ( | |
| 'is_multimodal' in inspect.signature( | |
| self.model.get_input_embeddings).parameters) | |
| if self._has_is_multimodal_in_get_input_embeddings: | |
| inputs_embeds = self.model.get_input_embeddings( | |
| input_ids, | |
| multimodal_embeddings=mm_embeds, | |
| is_multimodal=is_mm_embed, | |
| ) | |
| else: | |
| if mm_embeds: | |
| inputs_embeds = self.model.get_input_embeddings( | |
| input_ids, mm_embeds) | |
| else: | |
| inputs_embeds = self.model.get_input_embeddings(input_ids) |
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.
I have checked that
is_multimodalis not included in vLLM v0.11.0, thus only the custom Qwen2_5_vl in vllm-ascend have this arg. Maybe we can just check themodel_typeThere 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.
ok