Skip to content

Commit aab2bb0

Browse files
committed
address comments
Signed-off-by: Chenheli Hua <huachenheli@outlook.com>
1 parent 923a964 commit aab2bb0

File tree

4 files changed

+23
-20
lines changed

4 files changed

+23
-20
lines changed

vllm/multimodal/registry.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
33
from collections.abc import Mapping
44
from dataclasses import dataclass
5-
from typing import TYPE_CHECKING, Any, Generic, Protocol, TypeVar
5+
from typing import TYPE_CHECKING, Generic, Protocol, TypeVar
66

77
import torch.nn as nn
88

@@ -358,20 +358,3 @@ def get_encdec_max_encoder_len(self, model_config: "ModelConfig") -> int:
358358

359359
first_modality = next(iter(max_tokens))
360360
return max_tokens[first_modality]
361-
362-
363-
class ExtensionManager:
364-
def __init__(self) -> None:
365-
self.name2class: dict[str, type] = {}
366-
367-
def register(self, name: str):
368-
def wrap(cls_to_register):
369-
self.name2class[name] = cls_to_register
370-
return cls_to_register
371-
372-
return wrap
373-
374-
def load(self, cls_name: str, *args, **kwargs) -> Any:
375-
cls = self.name2class.get(cls_name)
376-
assert cls is not None, f"Extension class {cls_name} not found"
377-
return cls(*args, **kwargs)

vllm/multimodal/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import vllm.envs as envs
2020
from vllm.connections import HTTPConnection, global_http_connection
2121
from vllm.logger import init_logger
22-
from vllm.multimodal.registry import ExtensionManager
2322
from vllm.utils.jsontree import json_map_leaves
23+
from vllm.utils.registry import ExtensionManager
2424

2525
from .audio import AudioMediaIO
2626
from .base import MediaIO

vllm/multimodal/video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from vllm import envs
1616
from vllm.logger import init_logger
17-
from vllm.multimodal.registry import ExtensionManager
17+
from vllm.utils.registry import ExtensionManager
1818

1919
from .base import MediaIO
2020
from .image import ImageMediaIO

vllm/utils/registry.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3+
from typing import Any
4+
5+
6+
class ExtensionManager:
7+
def __init__(self) -> None:
8+
self.name2class: dict[str, type] = {}
9+
10+
def register(self, name: str):
11+
def wrap(cls_to_register):
12+
self.name2class[name] = cls_to_register
13+
return cls_to_register
14+
15+
return wrap
16+
17+
def load(self, cls_name: str, *args, **kwargs) -> Any:
18+
cls = self.name2class.get(cls_name)
19+
assert cls is not None, f"Extension class {cls_name} not found"
20+
return cls(*args, **kwargs)

0 commit comments

Comments
 (0)