-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Platform] Move get_punica_wrapper() function to Platform (#11516)
Signed-off-by: Shanshan Shen <[email protected]>
- Loading branch information
1 parent
458e63a
commit a7d5968
Showing
6 changed files
with
32 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,26 +1,18 @@ | ||
from vllm.logger import init_logger | ||
from vllm.platforms import current_platform | ||
from vllm.utils import resolve_obj_by_qualname | ||
|
||
from .punica_base import PunicaWrapperBase | ||
|
||
logger = init_logger(__name__) | ||
|
||
|
||
def get_punica_wrapper(*args, **kwargs) -> PunicaWrapperBase: | ||
if current_platform.is_cuda_alike(): | ||
# Lazy import to avoid ImportError | ||
from vllm.lora.punica_wrapper.punica_gpu import PunicaWrapperGPU | ||
logger.info_once("Using PunicaWrapperGPU.") | ||
return PunicaWrapperGPU(*args, **kwargs) | ||
elif current_platform.is_cpu(): | ||
# Lazy import to avoid ImportError | ||
from vllm.lora.punica_wrapper.punica_cpu import PunicaWrapperCPU | ||
logger.info_once("Using PunicaWrapperCPU.") | ||
return PunicaWrapperCPU(*args, **kwargs) | ||
elif current_platform.is_hpu(): | ||
# Lazy import to avoid ImportError | ||
from vllm.lora.punica_wrapper.punica_hpu import PunicaWrapperHPU | ||
logger.info_once("Using PunicaWrapperHPU.") | ||
return PunicaWrapperHPU(*args, **kwargs) | ||
else: | ||
raise NotImplementedError | ||
punica_wrapper_qualname = current_platform.get_punica_wrapper() | ||
punica_wrapper_cls = resolve_obj_by_qualname(punica_wrapper_qualname) | ||
punica_wrapper = punica_wrapper_cls(*args, **kwargs) | ||
assert punica_wrapper is not None, \ | ||
"the punica_wrapper_qualname(" + punica_wrapper_qualname + ") is wrong." | ||
logger.info_once("Using " + punica_wrapper_qualname.rsplit(".", 1)[1] + | ||
".") | ||
return punica_wrapper |
This file contains 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 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 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 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 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