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:
@@ -36,6 +36,7 @@ SGLang supports various environment variables that can be used to configure its
|
|||||||
| `SGLANG_SCHEDULER_RECV_SKIPPER_WEIGHT_DECODE` | Weight increment for decode forward mode in scheduler recv skipper. Works with `--scheduler-recv-interval` to control polling frequency during decode phase. | `1` |
|
| `SGLANG_SCHEDULER_RECV_SKIPPER_WEIGHT_DECODE` | Weight increment for decode forward mode in scheduler recv skipper. Works with `--scheduler-recv-interval` to control polling frequency during decode phase. | `1` |
|
||||||
| `SGLANG_SCHEDULER_RECV_SKIPPER_WEIGHT_VERIFY` | Weight increment for target verify forward mode in scheduler recv skipper. Works with `--scheduler-recv-interval` to control polling frequency during verification phase. | `1` |
|
| `SGLANG_SCHEDULER_RECV_SKIPPER_WEIGHT_VERIFY` | Weight increment for target verify forward mode in scheduler recv skipper. Works with `--scheduler-recv-interval` to control polling frequency during verification phase. | `1` |
|
||||||
| `SGLANG_SCHEDULER_RECV_SKIPPER_WEIGHT_NONE` | Weight increment when forward mode is None in scheduler recv skipper. Works with `--scheduler-recv-interval` to control polling frequency when no specific forward mode is active. | `1` |
|
| `SGLANG_SCHEDULER_RECV_SKIPPER_WEIGHT_NONE` | Weight increment when forward mode is None in scheduler recv skipper. Works with `--scheduler-recv-interval` to control polling frequency when no specific forward mode is active. | `1` |
|
||||||
|
| `SGLANG_MM_PRECOMPUTE_HASH` | Enable precomputing of hash values for MultimodalDataItem | `false` |
|
||||||
|
|
||||||
|
|
||||||
## DeepGEMM Configuration (Advanced Optimization)
|
## DeepGEMM Configuration (Advanced Optimization)
|
||||||
|
|||||||
@@ -330,6 +330,7 @@ class Envs:
|
|||||||
SGLANG_IMAGE_MAX_PIXELS = EnvInt(16384 * 28 * 28)
|
SGLANG_IMAGE_MAX_PIXELS = EnvInt(16384 * 28 * 28)
|
||||||
SGLANG_RESIZE_RESAMPLE = EnvStr("")
|
SGLANG_RESIZE_RESAMPLE = EnvStr("")
|
||||||
SGLANG_MM_BUFFER_SIZE_MB = EnvInt(0)
|
SGLANG_MM_BUFFER_SIZE_MB = EnvInt(0)
|
||||||
|
SGLANG_MM_PRECOMPUTE_HASH = EnvBool(False)
|
||||||
|
|
||||||
# VLM Item CUDA IPC Transport
|
# VLM Item CUDA IPC Transport
|
||||||
SGLANG_USE_CUDA_IPC_TRANSPORT=EnvBool(False)
|
SGLANG_USE_CUDA_IPC_TRANSPORT=EnvBool(False)
|
||||||
|
|||||||
@@ -243,6 +243,9 @@ class MultimodalDataItem:
|
|||||||
"""
|
"""
|
||||||
Set the pad value after first hashing the data
|
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
|
from sglang.srt.managers.mm_utils import hash_feature
|
||||||
|
|
||||||
if self.hash is None:
|
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.mm_utils import TensorTransportMode
|
||||||
from sglang.srt.managers.multimodal_processor import get_mm_processor, import_processors
|
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.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 import is_health_check_generate_req
|
||||||
from sglang.srt.managers.scheduler_input_blocker import input_blocker_guard_region
|
from sglang.srt.managers.scheduler_input_blocker import input_blocker_guard_region
|
||||||
from sglang.srt.managers.tokenizer_communicator_mixin import TokenizerCommunicatorMixin
|
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:
|
if mm_inputs and "input_ids" in mm_inputs:
|
||||||
input_ids = mm_inputs["input_ids"]
|
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:
|
else:
|
||||||
mm_inputs = None
|
mm_inputs = None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user