-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
[Model] Support VLMs with transformers backend #20543
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
Open
zucchini-nlp
wants to merge
9
commits into
vllm-project:main
Choose a base branch
from
zucchini-nlp:vlm-transformers-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+579
−56
Open
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
aa2ebec
add vision LLMs
zucchini-nlp 75d8ca7
fix param dtype
Isotr0py 5da4358
v0 backward compatibility
Isotr0py f71449c
Merge branch 'main' into vlm-transformers-v2
Isotr0py f6458bc
fix out-of-date signature
Isotr0py cc1b223
revert auto mm preprocessor
Isotr0py 7efbdda
address test.txt
Isotr0py 2918b6b
fix typo and make pre-commiter happy
Isotr0py e7e6869
add transformers fallback test with image input
Isotr0py 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
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 |
---|---|---|
|
@@ -170,7 +170,7 @@ def device_loading_context(module: torch.nn.Module, | |
def resolve_transformers_arch(model_config: ModelConfig, | ||
architectures: list[str]): | ||
for i, arch in enumerate(architectures): | ||
if arch == "TransformersForCausalLM": | ||
if arch in ["TransformersForCausalLM", "TransformersForMultimodalLM"]: | ||
continue | ||
auto_map: dict[str, str] = getattr(model_config.hf_config, "auto_map", | ||
None) or dict() | ||
|
@@ -206,7 +206,13 @@ def resolve_transformers_arch(model_config: ModelConfig, | |
raise ValueError( | ||
f"The Transformers implementation of {arch} is not " | ||
"compatible with vLLM.") | ||
architectures[i] = "TransformersForCausalLM" | ||
# Check if text-config is `self`. If not most probably it is | ||
# a composite config, i.e. mutlimodal | ||
if model_config.hf_config.get_text_config( | ||
) != model_config.hf_config: | ||
architectures[i] = "TransformersForMultimodalLM" | ||
else: | ||
architectures[i] = "TransformersForCausalLM" | ||
if model_config.model_impl == ModelImpl.AUTO: | ||
if not model_module.is_backend_compatible(): | ||
raise ValueError( | ||
|
@@ -217,7 +223,13 @@ def resolve_transformers_arch(model_config: ModelConfig, | |
"%s has no vLLM implementation, falling back to Transformers " | ||
"implementation. Some features may not be supported and " | ||
"performance may not be optimal.", arch) | ||
architectures[i] = "TransformersForCausalLM" | ||
# Check if text-config is `self`. If not most probably it is | ||
# a composite config, i.e. mutlimodal | ||
if model_config.hf_config.get_text_config( | ||
) != model_config.hf_config: | ||
architectures[i] = "TransformersForMultimodalLM" | ||
else: | ||
architectures[i] = "TransformersForCausalLM" | ||
Comment on lines
+225
to
+231
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. This block of logic for determining the transformer architecture is duplicated from lines 209-215. To improve maintainability and prevent potential inconsistencies, I recommend extracting this logic into a local helper function within For example: def _get_transformers_arch():
# Check if text-config is `self`. If not, it is a composite config, i.e. multimodal
if model_config.hf_config.get_text_config() != model_config.hf_config:
return "TransformersForMultimodalLM"
else:
return "TransformersForCausalLM"
# ... then call _get_transformers_arch() in both places. |
||
return architectures | ||
|
||
|
||
|
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
Oops, something went wrong.
Oops, something went wrong.
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.