multimodal: precompute hash for MultimodalDataItem (#14354)
Signed-off-by: Feng Su <sufeng@linux.alibaba.com> Signed-off-by: Junjie Mao <junjie.mao@linux.alibaba.com>
This commit is contained in:
@@ -330,6 +330,7 @@ class Envs:
|
||||
SGLANG_IMAGE_MAX_PIXELS = EnvInt(16384 * 28 * 28)
|
||||
SGLANG_RESIZE_RESAMPLE = EnvStr("")
|
||||
SGLANG_MM_BUFFER_SIZE_MB = EnvInt(0)
|
||||
SGLANG_MM_PRECOMPUTE_HASH = EnvBool(False)
|
||||
|
||||
# VLM Item CUDA IPC Transport
|
||||
SGLANG_USE_CUDA_IPC_TRANSPORT=EnvBool(False)
|
||||
|
||||
@@ -243,6 +243,9 @@ class MultimodalDataItem:
|
||||
"""
|
||||
Set the pad value after first hashing the data
|
||||
"""
|
||||
if self.pad_value is not None:
|
||||
return
|
||||
|
||||
from sglang.srt.managers.mm_utils import hash_feature
|
||||
|
||||
if self.hash is None:
|
||||
|
||||
@@ -73,7 +73,7 @@ from sglang.srt.managers.io_struct import (
|
||||
from sglang.srt.managers.mm_utils import TensorTransportMode
|
||||
from sglang.srt.managers.multimodal_processor import get_mm_processor, import_processors
|
||||
from sglang.srt.managers.request_metrics_exporter import RequestMetricsExporterManager
|
||||
from sglang.srt.managers.schedule_batch import RequestStage
|
||||
from sglang.srt.managers.schedule_batch import MultimodalDataItem, RequestStage
|
||||
from sglang.srt.managers.scheduler import is_health_check_generate_req
|
||||
from sglang.srt.managers.scheduler_input_blocker import input_blocker_guard_region
|
||||
from sglang.srt.managers.tokenizer_communicator_mixin import TokenizerCommunicatorMixin
|
||||
@@ -653,6 +653,14 @@ class TokenizerManager(TokenizerCommunicatorMixin, TokenizerManagerMultiItemMixi
|
||||
|
||||
if mm_inputs and "input_ids" in mm_inputs:
|
||||
input_ids = mm_inputs["input_ids"]
|
||||
if (
|
||||
envs.SGLANG_MM_PRECOMPUTE_HASH.get()
|
||||
and mm_inputs
|
||||
and "mm_items" in mm_inputs
|
||||
):
|
||||
for item in mm_inputs["mm_items"]:
|
||||
if isinstance(item, MultimodalDataItem):
|
||||
item.set_pad_value()
|
||||
else:
|
||||
mm_inputs = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user