[Security] Authenticate shared-memory multimodal cache handles (#59357)
Signed-off-by: Clinton Thomas <1033162+KernelClint@users.noreply.github.com> Co-authored-by: Lucas Bourtoule <35483370+dhalf@users.noreply.github.com> Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
This commit is contained in:
co-authored by
Lucas Bourtoule
Cyrus Leung
parent
72e7874fa6
commit
3d5625cc3c
@@ -39,6 +39,7 @@ from vllm.inputs import EngineInput, TokensPrompt, mm_input
|
||||
from vllm.logger import init_logger
|
||||
from vllm.logprobs import Logprob
|
||||
from vllm.multimodal.inputs import (
|
||||
MultiModalKwargsItem,
|
||||
MultiModalKwargsItems,
|
||||
PlaceholderRange,
|
||||
)
|
||||
@@ -106,6 +107,23 @@ class ServingTokens(GenerateBaseServing):
|
||||
else getattr(mc, "override_generation_config", {}).get("max_new_tokens")
|
||||
)
|
||||
|
||||
def _validate_mm_cache_handles(
|
||||
self,
|
||||
mm_kwargs: dict[str, list[MultiModalKwargsItem | None]],
|
||||
mm_hashes: dict[str, list[str]],
|
||||
) -> ErrorResponse | None:
|
||||
cache = self.online_renderer.renderer.mm_processor_cache
|
||||
if cache is None:
|
||||
return None
|
||||
try:
|
||||
for modality, items in mm_kwargs.items():
|
||||
for mm_hash, item in zip(mm_hashes[modality], items, strict=True):
|
||||
if item is not None:
|
||||
cache.validate_input_item(item, mm_hash)
|
||||
except ValueError as error:
|
||||
return self.create_error_response(error)
|
||||
return None
|
||||
|
||||
async def serve_tokens(
|
||||
self,
|
||||
request: GenerateRequest,
|
||||
@@ -201,6 +219,8 @@ class ServingTokens(GenerateBaseServing):
|
||||
# Deserialize full tensor data and optional metadata-only data.
|
||||
# Metadata-only items are valid when ec_transfer_params is set.
|
||||
mm_kwargs = mm_kwargs_from_features(features)
|
||||
if error := self._validate_mm_cache_handles(mm_kwargs, features.mm_hashes):
|
||||
return error
|
||||
|
||||
engine_input = mm_input(
|
||||
prompt_token_ids=request.token_ids,
|
||||
|
||||
Reference in New Issue
Block a user