-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
[Core] Support model loader plugins #21067
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5f0ac47
model loader plugin
22quinn 7d05267
Merge branch 'main' into loader-plugin
22quinn 7a74a1a
isolate unit tests
22quinn 1379e3e
test invalid model loader
22quinn 7660c9d
hmellor comment
22quinn ea1cd1c
fix example
22quinn 35f7354
fix mypi, try fix mkdocs
22quinn 97bd40d
fix mkdocs
22quinn 479d912
fix mkdocs
22quinn a81d13d
rebase
22quinn 37cd547
remove get_supported_load_formats, add docstring reminder
22quinn 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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
|
||
import pytest | ||
from torch import nn | ||
|
||
from vllm.config import LoadConfig, ModelConfig | ||
from vllm.model_executor.model_loader import (get_model_loader, | ||
register_model_loader) | ||
from vllm.model_executor.model_loader.base_loader import BaseModelLoader | ||
|
||
|
||
@register_model_loader("custom_load_format") | ||
class CustomModelLoader(BaseModelLoader): | ||
|
||
def __init__(self, load_config: LoadConfig) -> None: | ||
super().__init__(load_config) | ||
|
||
def download_model(self, model_config: ModelConfig) -> None: | ||
pass | ||
|
||
def load_weights(self, model: nn.Module, | ||
model_config: ModelConfig) -> None: | ||
pass | ||
|
||
|
||
def test_register_model_loader(): | ||
load_config = LoadConfig(load_format="custom_load_format") | ||
assert isinstance(get_model_loader(load_config), CustomModelLoader) | ||
|
||
|
||
def test_invalid_model_loader(): | ||
with pytest.raises(ValueError): | ||
|
||
@register_model_loader("invalid_load_format") | ||
class InValidModelLoader: | ||
pass |
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
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.
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.
this could've remained an enums and would've supported a
to_model_loader
method.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.
Personally, I do prefer using a
Literal
as it makes for nicer type hinting.The way that @22quinn has organised the typing and the registry is exactly the same as for quantization methods. If we change one we should probably change both? Maybe as a follow up task to improve the way we handle built-in plugins in general?
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.
Thanks for the review! I don't have a strong opinion for this, but agree we'd better be consistent everywhere. I'm leaving it as
Literal
for nowThere 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.
Yeah let's keep them consistent for now