-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
add vLLM-side LMCache EC connector entrypoint #38668
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,53 @@ | ||||||||||||||||||||||||||||||||||||||
| # SPDX-License-Identifier: Apache-2.0 | ||||||||||||||||||||||||||||||||||||||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| from typing import TYPE_CHECKING, Any | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| import torch | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| from vllm.config import VllmConfig | ||||||||||||||||||||||||||||||||||||||
| from vllm.distributed.ec_transfer.ec_connector.base import ( | ||||||||||||||||||||||||||||||||||||||
| ECConnectorBase, | ||||||||||||||||||||||||||||||||||||||
| ECConnectorMetadata, | ||||||||||||||||||||||||||||||||||||||
| ECConnectorRole, | ||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||
| from vllm.v1.core.sched.output import SchedulerOutput | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| from lmcache.integration.vllm.vllm_ec_adapter import LMCacheECConnectorImpl | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if TYPE_CHECKING: | ||||||||||||||||||||||||||||||||||||||
| from vllm.v1.request import Request | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| class LMCacheECConnector(ECConnectorBase): | ||||||||||||||||||||||||||||||||||||||
| def __init__(self, vllm_config: VllmConfig, role: ECConnectorRole): | ||||||||||||||||||||||||||||||||||||||
| super().__init__(vllm_config=vllm_config, role=role) | ||||||||||||||||||||||||||||||||||||||
| self._impl = LMCacheECConnectorImpl( | ||||||||||||||||||||||||||||||||||||||
| vllm_config=vllm_config, | ||||||||||||||||||||||||||||||||||||||
| role=role, | ||||||||||||||||||||||||||||||||||||||
| parent=self, | ||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+23
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since
Suggested change
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| def start_load_caches( | ||||||||||||||||||||||||||||||||||||||
| self, encoder_cache: dict[str, torch.Tensor], **kwargs: Any | ||||||||||||||||||||||||||||||||||||||
| ) -> None: | ||||||||||||||||||||||||||||||||||||||
| return self._impl.start_load_caches(encoder_cache, **kwargs) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| def save_caches( | ||||||||||||||||||||||||||||||||||||||
| self, | ||||||||||||||||||||||||||||||||||||||
| encoder_cache: dict[str, torch.Tensor], | ||||||||||||||||||||||||||||||||||||||
| mm_hash: str, | ||||||||||||||||||||||||||||||||||||||
| **kwargs: Any, | ||||||||||||||||||||||||||||||||||||||
| ) -> None: | ||||||||||||||||||||||||||||||||||||||
| return self._impl.save_caches(encoder_cache, mm_hash, **kwargs) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| def has_cache_item(self, identifier: str) -> bool: | ||||||||||||||||||||||||||||||||||||||
| return self._impl.has_cache_item(identifier) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| def update_state_after_alloc(self, request: "Request", index: int) -> None: | ||||||||||||||||||||||||||||||||||||||
| return self._impl.update_state_after_alloc(request, index) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| def build_connector_meta( | ||||||||||||||||||||||||||||||||||||||
| self, scheduler_output: SchedulerOutput | ||||||||||||||||||||||||||||||||||||||
| ) -> ECConnectorMetadata: | ||||||||||||||||||||||||||||||||||||||
| return self._impl.build_connector_meta(scheduler_output) | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+22
to
+53
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Specifically, |
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The top-level import of
lmcachecreates a hard dependency on an external package that is not a mandatory dependency of vLLM. Iflmcacheis not installed, this module will fail to import, which can break module discovery or static analysis tools. It is recommended to handle this optional dependency gracefully.