main
py 38 lines 1.19 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4 from abc import ABC
5 from dataclasses import field
6 from typing import Any
7
8 from vllm.config.utils import config
9 from vllm.utils.import_utils import resolve_obj_by_qualname
10
11
12 @config
13 class EncoderCacheManagerConfig:
14 encoder_cache_manager_cls: str | None = None
15 """Fully qualified class name of the custom encoder cache manager."""
16
17 manager_config: dict[str, Any] = field(default_factory=dict)
18 """Opaque configuration interpreted by the custom cache manager."""
19
20 def __post_init__(self) -> None:
21 if self.encoder_cache_manager_cls is None and self.manager_config:
22 raise ValueError(
23 "manager_config requires encoder_cache_manager_cls to be set."
24 )
25
26 def get_encoder_cache_manager_obj(self):
27 cls_path = self.encoder_cache_manager_cls
28 if cls_path is None:
29 return None
30 return resolve_obj_by_qualname(cls_path)
31
32
33 class EncoderCacheManagerMetadata(ABC): # noqa: B024
34 """Abstract Metadata used to communicate between the
35 Scheduler EncoderCacheManager and Worker EncoderCacheManager.
36 """
37
38 pass