-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
[Platform] Add platform pluggable framework #11222
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 was deleted.
Oops, something went wrong.
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
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,12 @@ | ||
import pytest | ||
|
||
from vllm import LLM | ||
|
||
# The test in this file should be run with env VLLM_PLUGINS='', for example: | ||
# VLLM_PLUGINS='' pytest -v -s test_model_plugin_disabled.py | ||
|
||
|
||
def test_plugin_disabled(dummy_opt_path): | ||
with pytest.raises(Exception) as excinfo: | ||
LLM(model=dummy_opt_path, load_format="dummy") | ||
assert "are not supported for now" in str(excinfo.value) |
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,10 @@ | ||
from vllm.platforms import PlatformRegistry, current_platform | ||
|
||
|
||
def test_current_platform_register(): | ||
# make sure the platform is registered | ||
assert PlatformRegistry.current_platform == "my_platform" | ||
# make sure the platform is loaded | ||
assert current_platform.device_name == "dummy" | ||
assert current_platform.is_async_output_supported(enforce_eager=True) \ | ||
is False |
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,9 @@ | ||
from setuptools import setup | ||
|
||
setup(name='vllm_add_dummy_platform', | ||
version='0.1', | ||
packages=['vllm_add_dummy_platform'], | ||
entry_points={ | ||
'vllm.general_plugins': | ||
["register_dummy_model = vllm_add_dummy_platform:register"] | ||
}) | ||
wangxiyuan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
9 changes: 9 additions & 0 deletions
9
tests/plugins/vllm_add_dummy_platform/vllm_add_dummy_platform/__init__.py
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,9 @@ | ||
from vllm import PlatformRegistry | ||
|
||
|
||
def register(): | ||
# Register the dummy platform | ||
PlatformRegistry.register_platform( | ||
"my_platform", "vllm_add_dummy_platform.my_platform.DummyPlatform") | ||
# Set the current platform to the dummy platform | ||
PlatformRegistry.set_current_platform("my_platform") |
13 changes: 13 additions & 0 deletions
13
tests/plugins/vllm_add_dummy_platform/vllm_add_dummy_platform/my_attention.py
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,13 @@ | ||
class DummyAttentionImpl: | ||
|
||
def forward(self): | ||
pass | ||
|
||
|
||
class DummyAttentionBackend: | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def get_impl_cls(self): | ||
return DummyAttentionImpl |
7 changes: 7 additions & 0 deletions
7
tests/plugins/vllm_add_dummy_platform/vllm_add_dummy_platform/my_model_runner.py
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,7 @@ | ||
from my_attention import DummyAttentionBackend | ||
|
||
|
||
class DummyModelRunner: | ||
|
||
def __init__(self): | ||
self.attn_backend = DummyAttentionBackend() |
26 changes: 26 additions & 0 deletions
26
tests/plugins/vllm_add_dummy_platform/vllm_add_dummy_platform/my_platform.py
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,26 @@ | ||
from typing import Optional | ||
|
||
from vllm.config import VllmConfig | ||
from vllm.platforms import Platform, PlatformEnum | ||
|
||
|
||
class DummyPlatform(Platform): | ||
_enum = PlatformEnum.UNSPECIFIED | ||
device_name = "dummy" | ||
|
||
def __init__(self): | ||
super().__init__() | ||
|
||
@classmethod | ||
def get_device_name(cls) -> str: | ||
return "dummy" | ||
|
||
@classmethod | ||
def check_and_update_config(cls, vllm_config: VllmConfig) -> None: | ||
parallel_config = vllm_config.parallel_config | ||
parallel_config.worker_cls = \ | ||
"vllm_add_dummy_platform.my_worker.DummyWorker" | ||
|
||
@classmethod | ||
def is_async_output_supported(cls, enforce_eager: Optional[bool]) -> bool: | ||
return False |
14 changes: 14 additions & 0 deletions
14
tests/plugins/vllm_add_dummy_platform/vllm_add_dummy_platform/my_worker.py
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,14 @@ | ||
from typing import List | ||
|
||
from my_model_runner import DummyModelRunner | ||
|
||
|
||
class DummyCacheEngine: | ||
pass | ||
|
||
|
||
class DummyWorker: | ||
|
||
def __init__(self): | ||
self.cache_engine = List[DummyCacheEngine] | ||
self.model_runner = DummyModelRunner() |
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.
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.