Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions vllm/config/ec_manager_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project

from abc import ABC
from dataclasses import field
from typing import Any

from vllm.config.utils import config
from vllm.utils.import_utils import resolve_obj_by_qualname
Expand All @@ -10,8 +12,16 @@
@config
class EncoderCacheManagerConfig:
encoder_cache_manager_cls: str | None = None
"""The qualified class name of the custom encoder cache manager.
"""
"""Fully qualified class name of the custom encoder cache manager."""

manager_config: dict[str, Any] = field(default_factory=dict)
"""Opaque configuration interpreted by the custom cache manager."""

def __post_init__(self) -> None:
if self.encoder_cache_manager_cls is None and self.manager_config:
raise ValueError(
"manager_config requires encoder_cache_manager_cls to be set."
)

def get_encoder_cache_manager_obj(self):
cls_path = self.encoder_cache_manager_cls
Expand Down
10 changes: 10 additions & 0 deletions vllm/engine/arg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
DeviceConfig,
DiffusionConfig,
ECTransferConfig,
EncoderCacheManagerConfig,
EPLBConfig,
FaultToleranceConfig,
KernelConfig,
Expand Down Expand Up @@ -683,6 +684,9 @@ class EngineArgs:
kv_events_config: KVEventsConfig | None = None

ec_transfer_config: ECTransferConfig | None = None
ec_manager_config: EncoderCacheManagerConfig = get_field(
VllmConfig, "ec_manager_config"
)
reasoning_config: ReasoningConfig = get_field(VllmConfig, "reasoning_config")

generation_config: str = ModelConfig.generation_config
Expand Down Expand Up @@ -763,6 +767,8 @@ def __post_init__(self):
self.mamba_config = MambaConfig(**self.mamba_config)
if isinstance(self.kernel_config, dict):
self.kernel_config = KernelConfig(**self.kernel_config)
if isinstance(self.ec_manager_config, dict):
self.ec_manager_config = EncoderCacheManagerConfig(**self.ec_manager_config)
if isinstance(self.eplb_config, dict):
self.eplb_config = EPLBConfig(**self.eplb_config)
if isinstance(self.weight_transfer_config, dict):
Expand Down Expand Up @@ -1590,6 +1596,9 @@ def add_cli_args(parser: FlexibleArgumentParser) -> FlexibleArgumentParser:
vllm_group.add_argument(
"--ec-transfer-config", **vllm_kwargs["ec_transfer_config"]
)
vllm_group.add_argument(
"--ec-manager-config", **vllm_kwargs["ec_manager_config"]
)
vllm_group.add_argument(
"--compilation-config", "-cc", **vllm_kwargs["compilation_config"]
)
Expand Down Expand Up @@ -2476,6 +2485,7 @@ def create_engine_config(
kv_transfer_config=self.kv_transfer_config,
kv_events_config=self.kv_events_config,
ec_transfer_config=self.ec_transfer_config,
ec_manager_config=self.ec_manager_config,
reasoning_config=self.reasoning_config,
profiler_config=self.profiler_config,
additional_config=self.additional_config,
Expand Down
7 changes: 7 additions & 0 deletions vllm/v1/core/encoder_cache_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from collections.abc import Mapping
from typing import TYPE_CHECKING

from vllm.config import VllmConfig
from vllm.config.ec_manager_config import EncoderCacheManagerMetadata
from vllm.logger import init_logger
from vllm.v1.request import Request
Expand Down Expand Up @@ -65,6 +66,12 @@ class EncoderCacheManager:
last call to get_freed_mm_hashes(). This list is cleared on return.
"""

@classmethod
def create_manager(
cls, *, cache_size: int, vllm_config: "VllmConfig"
) -> "EncoderCacheManager":
return cls(cache_size=cache_size)

def __init__(self, cache_size: int):
self.cache_size = cache_size
self.num_free_slots = cache_size
Expand Down
13 changes: 7 additions & 6 deletions vllm/v1/core/sched/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,15 @@ def __init__(
)
encoder_cache_size = mm_budget.encoder_cache_size if mm_budget else 0
manager_cls_obj = vllm_config.ec_manager_config.get_encoder_cache_manager_obj()
if manager_cls_obj is not None:
self.encoder_cache_manager = manager_cls_obj(cache_size=encoder_cache_size)
else:
self.encoder_cache_manager = (
EncoderDecoderCacheManager(cache_size=encoder_cache_size)
if manager_cls_obj is None:
manager_cls_obj = (
EncoderDecoderCacheManager
if self.is_encoder_decoder
else EncoderCacheManager(cache_size=encoder_cache_size)
else EncoderCacheManager
)
self.encoder_cache_manager = manager_cls_obj.create_manager(
cache_size=encoder_cache_size, vllm_config=vllm_config
)
speculative_config = vllm_config.speculative_config
self.use_eagle = False
self.num_spec_tokens = vllm_config.num_speculative_tokens
Expand Down
Loading