[Refactor] Simplify dummy data generation (#35025)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
This commit is contained in:
@@ -293,21 +293,22 @@ Assuming that the memory usage increases with the number of tokens, the dummy in
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
target_width, target_height = \
|
target_width, target_height = \
|
||||||
self.info.get_image_size_with_most_features()
|
self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image":
|
"image": self._get_dummy_images(
|
||||||
self._get_dummy_images(width=target_width,
|
width=target_width,
|
||||||
height=target_height,
|
height=target_height,
|
||||||
num_images=num_images,
|
num_images=num_images,
|
||||||
overrides=image_overrides)
|
overrides=image_overrides,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -479,17 +480,16 @@ Assuming that the memory usage increases with the number of tokens, the dummy in
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Optional[Mapping[str, BaseDummyOptions]] = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
target_width, target_height = \
|
target_width, target_height = \
|
||||||
self.info.get_image_size_with_most_features()
|
self.info.get_image_size_with_most_features()
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image":
|
"image": self._get_dummy_images(
|
||||||
self._get_dummy_images(
|
|
||||||
width=target_width,
|
width=target_width,
|
||||||
height=target_height,
|
height=target_height,
|
||||||
num_images=num_images,
|
num_images=num_images,
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ def test_dummy_data_generation(mock_ctx):
|
|||||||
builder = AudioFlamingo3DummyInputsBuilder(info)
|
builder = AudioFlamingo3DummyInputsBuilder(info)
|
||||||
|
|
||||||
mm_counts = {"audio": 2}
|
mm_counts = {"audio": 2}
|
||||||
dummy_data = builder.get_dummy_mm_data(100, mm_counts, None)
|
dummy_data = builder.get_dummy_mm_data(100, mm_counts, {})
|
||||||
|
|
||||||
assert "audio" in dummy_data
|
assert "audio" in dummy_data
|
||||||
assert len(dummy_data["audio"]) == 2
|
assert len(dummy_data["audio"]) == 2
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ def get_text_token_prompts(
|
|||||||
inputs = dummy_inputs.get_dummy_processor_inputs(
|
inputs = dummy_inputs.get_dummy_processor_inputs(
|
||||||
model_config.max_model_len,
|
model_config.max_model_len,
|
||||||
mm_counts,
|
mm_counts,
|
||||||
|
mm_options={},
|
||||||
)
|
)
|
||||||
text_prompt = None
|
text_prompt = None
|
||||||
token_prompt = (
|
token_prompt = (
|
||||||
@@ -224,6 +225,7 @@ def get_text_token_prompts(
|
|||||||
inputs = dummy_inputs.get_dummy_processor_inputs(
|
inputs = dummy_inputs.get_dummy_processor_inputs(
|
||||||
model_config.max_model_len,
|
model_config.max_model_len,
|
||||||
mm_counts,
|
mm_counts,
|
||||||
|
mm_options={},
|
||||||
)
|
)
|
||||||
assert isinstance(inputs.prompt, str)
|
assert isinstance(inputs.prompt, str)
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ def create_batched_mm_kwargs(
|
|||||||
processor_inputs = dummy_inputs.get_dummy_processor_inputs(
|
processor_inputs = dummy_inputs.get_dummy_processor_inputs(
|
||||||
seq_len=model_config.max_model_len,
|
seq_len=model_config.max_model_len,
|
||||||
mm_counts=mm_counts,
|
mm_counts=mm_counts,
|
||||||
|
mm_options={},
|
||||||
)
|
)
|
||||||
mm_items = processor_inputs.mm_items
|
mm_items = processor_inputs.mm_items
|
||||||
resized_mm_data = {
|
resized_mm_data = {
|
||||||
|
|||||||
+36
-20
@@ -2,7 +2,7 @@
|
|||||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from typing import Any, Literal, TypeAlias
|
from typing import Any, Literal, TypeAlias, TypedDict, final
|
||||||
|
|
||||||
from pydantic import ConfigDict, Field, field_validator, model_validator
|
from pydantic import ConfigDict, Field, field_validator, model_validator
|
||||||
from pydantic.dataclasses import dataclass
|
from pydantic.dataclasses import dataclass
|
||||||
@@ -43,11 +43,29 @@ class AudioDummyOptions(BaseDummyOptions):
|
|||||||
length: int | None = Field(None, gt=0)
|
length: int | None = Field(None, gt=0)
|
||||||
|
|
||||||
|
|
||||||
|
@final
|
||||||
|
class MultiModalDummyOptionsBuiltins(TypedDict, total=False):
|
||||||
|
"""Type annotations for modality types predefined by vLLM."""
|
||||||
|
|
||||||
|
image: ImageDummyOptions
|
||||||
|
"""Options for dummy images."""
|
||||||
|
|
||||||
|
video: VideoDummyOptions
|
||||||
|
"""Options for dummy videos."""
|
||||||
|
|
||||||
|
audio: AudioDummyOptions
|
||||||
|
"""Options for dummy audios."""
|
||||||
|
|
||||||
|
|
||||||
MMEncoderTPMode = Literal["weights", "data"]
|
MMEncoderTPMode = Literal["weights", "data"]
|
||||||
MMCacheType = Literal["shm", "lru"]
|
MMCacheType = Literal["shm", "lru"]
|
||||||
DummyOptions: TypeAlias = (
|
MMDummyOptions: TypeAlias = dict[str, BaseDummyOptions]
|
||||||
BaseDummyOptions | VideoDummyOptions | ImageDummyOptions | AudioDummyOptions
|
"""
|
||||||
)
|
A dictionary containing an entry for each modality type of dummy data.
|
||||||
|
|
||||||
|
The built-in modalities are defined by
|
||||||
|
[`MultiModalDummyOptionsBuiltins`][vllm.config.multimodal.MultiModalDummyOptionsBuiltins].
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
@config
|
@config
|
||||||
@@ -57,7 +75,7 @@ class MultiModalConfig:
|
|||||||
language_model_only: bool = False
|
language_model_only: bool = False
|
||||||
"""If True, disables all multimodal inputs by setting all modality limits to 0.
|
"""If True, disables all multimodal inputs by setting all modality limits to 0.
|
||||||
Equivalent to setting `--limit-mm-per-prompt` to 0 for every modality."""
|
Equivalent to setting `--limit-mm-per-prompt` to 0 for every modality."""
|
||||||
limit_per_prompt: dict[str, DummyOptions] = Field(default_factory=dict)
|
limit_per_prompt: MMDummyOptions = Field(default_factory=dict)
|
||||||
"""The maximum number of input items and options allowed per
|
"""The maximum number of input items and options allowed per
|
||||||
prompt for each modality.
|
prompt for each modality.
|
||||||
|
|
||||||
@@ -158,22 +176,27 @@ class MultiModalConfig:
|
|||||||
@field_validator("limit_per_prompt", mode="before")
|
@field_validator("limit_per_prompt", mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
def _validate_limit_per_prompt(
|
def _validate_limit_per_prompt(
|
||||||
cls, value: dict[str, int | dict[str, int]]
|
cls,
|
||||||
) -> dict[str, DummyOptions]:
|
value: dict[str, int | dict[str, int]],
|
||||||
|
) -> MMDummyOptions:
|
||||||
|
out: MMDummyOptions = {}
|
||||||
|
|
||||||
for k, v in value.items():
|
for k, v in value.items():
|
||||||
# Handle legacy format where only count is specified
|
# Handle legacy format where only count is specified
|
||||||
if isinstance(v, int):
|
if isinstance(v, int):
|
||||||
v = {"count": v}
|
v = {"count": v}
|
||||||
|
|
||||||
# Convert to the appropriate DummyOptions subclass
|
# Convert to the appropriate DummyOptions subclass
|
||||||
if k == "video":
|
if k == "video":
|
||||||
value[k] = VideoDummyOptions(**v)
|
out[k] = VideoDummyOptions(**v)
|
||||||
elif k == "image":
|
elif k == "image":
|
||||||
value[k] = ImageDummyOptions(**v)
|
out[k] = ImageDummyOptions(**v)
|
||||||
elif k == "audio":
|
elif k == "audio":
|
||||||
value[k] = AudioDummyOptions(**v)
|
out[k] = AudioDummyOptions(**v)
|
||||||
else:
|
else:
|
||||||
value[k] = BaseDummyOptions(**v)
|
out[k] = BaseDummyOptions(**v)
|
||||||
return value
|
|
||||||
|
return out
|
||||||
|
|
||||||
@field_validator("mm_encoder_attn_backend", mode="before")
|
@field_validator("mm_encoder_attn_backend", mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -240,15 +263,8 @@ class MultiModalConfig:
|
|||||||
if limit_data is None:
|
if limit_data is None:
|
||||||
# Unspecified modality is set to 999 by default
|
# Unspecified modality is set to 999 by default
|
||||||
return 999
|
return 999
|
||||||
return limit_data.count
|
|
||||||
|
|
||||||
def get_dummy_options(self, modality: str) -> BaseDummyOptions | None:
|
return limit_data.count
|
||||||
"""
|
|
||||||
Get the configurable dummy data options for a modality.
|
|
||||||
Returns None if no options are configured for this modality.
|
|
||||||
"""
|
|
||||||
# All values are now DummyOptions after normalization
|
|
||||||
return self.limit_per_prompt.get(modality)
|
|
||||||
|
|
||||||
def merge_mm_processor_kwargs(
|
def merge_mm_processor_kwargs(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -444,15 +444,14 @@ class AriaDummyInputsBuilder(BaseDummyInputsBuilder[AriaProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
vision_config = self.info.get_vision_config()
|
vision_config = self.info.get_vision_config()
|
||||||
|
|
||||||
max_image_size = vision_config.image_size
|
max_image_size = vision_config.image_size
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -252,16 +252,13 @@ class AudioFlamingo3DummyInputsBuilder(
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
feature_extractor = self.info.get_feature_extractor(
|
feature_extractor = self.info.get_feature_extractor()
|
||||||
**(mm_processor_kwargs or {})
|
|
||||||
)
|
|
||||||
sampling_rate = feature_extractor.sampling_rate
|
sampling_rate = feature_extractor.sampling_rate
|
||||||
audio_len = MAX_AUDIO_LEN * sampling_rate
|
audio_len = MAX_AUDIO_LEN * sampling_rate
|
||||||
num_audios = mm_counts.get("audio", 0)
|
num_audios = mm_counts.get("audio", 0)
|
||||||
audio_overrides = mm_options.get("audio") if mm_options else None
|
audio_overrides = mm_options.get("audio")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"audio": self._get_dummy_audios(
|
"audio": self._get_dummy_audios(
|
||||||
|
|||||||
@@ -191,13 +191,12 @@ class AyaVisionDummyInputsBuilder(BaseDummyInputsBuilder[AyaVisionProcessingInfo
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
image_size = self.info.get_image_size_with_most_features()
|
image_size = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -249,8 +249,7 @@ class BagelDummyInputsBuilder(BaseDummyInputsBuilder[BagelProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
hf_config = self.info.get_hf_config()
|
hf_config = self.info.get_hf_config()
|
||||||
@@ -258,7 +257,7 @@ class BagelDummyInputsBuilder(BaseDummyInputsBuilder[BagelProcessingInfo]):
|
|||||||
|
|
||||||
# Use the configured image size
|
# Use the configured image size
|
||||||
image_size = vit_config.image_size
|
image_size = vit_config.image_size
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -90,14 +90,13 @@ class BeeDummyInputsBuilder(LlavaDummyInputsBuilder[BeeProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -445,8 +445,7 @@ class Blip2DummyInputsBuilder(BaseDummyInputsBuilder[Blip2ProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
hf_config = self.info.get_hf_config()
|
hf_config = self.info.get_hf_config()
|
||||||
vision_config = hf_config.vision_config
|
vision_config = hf_config.vision_config
|
||||||
@@ -454,7 +453,7 @@ class Blip2DummyInputsBuilder(BaseDummyInputsBuilder[Blip2ProcessingInfo]):
|
|||||||
max_image_size = vision_config.image_size
|
max_image_size = vision_config.image_size
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -116,15 +116,14 @@ class ChameleonDummyInputsBuilder(BaseDummyInputsBuilder[ChameleonProcessingInfo
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
config = self.info.get_hf_config()
|
config = self.info.get_hf_config()
|
||||||
|
|
||||||
width = height = config.vq_config.resolution
|
width = height = config.vq_config.resolution
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -174,14 +174,13 @@ class CLIPDummyInputsBuilder(BaseDummyInputsBuilder[CLIPProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -197,13 +197,12 @@ class Cohere2VisionDummyInputsBuilder(
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
image_size = self.info.get_image_size_with_most_features()
|
image_size = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -132,12 +132,12 @@ class ColModernVBertDummyInputsBuilder(
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
width=target_width,
|
width=target_width,
|
||||||
|
|||||||
@@ -255,8 +255,7 @@ class DeepseekOCRDummyInputsBuilder(BaseDummyInputsBuilder[DeepseekOCRProcessing
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
|
|||||||
@@ -137,8 +137,7 @@ class DeepseekOCR2DummyInputsBuilder(
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
|
|||||||
@@ -214,14 +214,13 @@ class DeepseekVL2DummyInputsBuilder(BaseDummyInputsBuilder[DeepseekVL2Processing
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
max_image_size = self.info.get_image_size_with_most_features()
|
max_image_size = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -106,17 +106,13 @@ class DotsOCRDummyInputsBuilder(Qwen2VLDummyInputsBuilder):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
mm_processor_kwargs = mm_processor_kwargs or {}
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features( # noqa: E501
|
|
||||||
mm_processor_kwargs.get("max_pixels", None)
|
|
||||||
)
|
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -1168,8 +1168,7 @@ class Ernie4_5_VLDummyInputsBuilder(BaseDummyInputsBuilder[Ernie4_5_VLProcessing
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
num_videos = mm_counts.get("video", 0)
|
num_videos = mm_counts.get("video", 0)
|
||||||
@@ -1179,8 +1178,8 @@ class Ernie4_5_VLDummyInputsBuilder(BaseDummyInputsBuilder[Ernie4_5_VLProcessing
|
|||||||
seq_len, mm_counts
|
seq_len, mm_counts
|
||||||
)
|
)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
video_overrides = mm_options.get("video") if mm_options else None
|
video_overrides = mm_options.get("video")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -746,23 +746,22 @@ class FunASRDummyInputsBuilder(BaseDummyInputsBuilder[FunASRProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
feature_extractor = self.info.get_feature_extractor(
|
feature_extractor = self.info.get_feature_extractor()
|
||||||
**(mm_processor_kwargs or {})
|
|
||||||
)
|
|
||||||
|
|
||||||
sampling_rate = feature_extractor.sampling_rate
|
sampling_rate = feature_extractor.sampling_rate
|
||||||
audio_len = feature_extractor.chunk_length * sampling_rate
|
audio_len = feature_extractor.chunk_length * sampling_rate
|
||||||
num_audios = mm_counts.get("audio", 0)
|
num_audios = mm_counts.get("audio", 0)
|
||||||
|
|
||||||
audio_overrides = mm_options.get("audio") if mm_options else None
|
audio_overrides = mm_options.get("audio")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"audio": self._get_dummy_audios(
|
"audio": self._get_dummy_audios(
|
||||||
length=audio_len, num_audios=num_audios, overrides=audio_overrides
|
length=audio_len,
|
||||||
)
|
num_audios=num_audios,
|
||||||
|
overrides=audio_overrides,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -610,12 +610,9 @@ class FunAudioChatDummyInputsBuilder(
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
feature_extractor = self.info.get_feature_extractor(
|
feature_extractor = self.info.get_feature_extractor()
|
||||||
**(mm_processor_kwargs or {})
|
|
||||||
)
|
|
||||||
sampling_rate = int(feature_extractor.sampling_rate)
|
sampling_rate = int(feature_extractor.sampling_rate)
|
||||||
|
|
||||||
# Dummy inputs are used for profiling; construct the worst-case audio
|
# Dummy inputs are used for profiling; construct the worst-case audio
|
||||||
@@ -632,7 +629,7 @@ class FunAudioChatDummyInputsBuilder(
|
|||||||
)
|
)
|
||||||
num_audios = int(mm_counts.get("audio", 0))
|
num_audios = int(mm_counts.get("audio", 0))
|
||||||
|
|
||||||
audio_overrides = mm_options.get("audio") if mm_options else None
|
audio_overrides = mm_options.get("audio")
|
||||||
return {
|
return {
|
||||||
"audio": self._get_dummy_audios(
|
"audio": self._get_dummy_audios(
|
||||||
length=audio_len,
|
length=audio_len,
|
||||||
|
|||||||
@@ -142,13 +142,12 @@ class FuyuDummyInputsBuilder(BaseDummyInputsBuilder[FuyuProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -241,14 +241,13 @@ class Gemma3DummyInputsBuilder(BaseDummyInputsBuilder[Gemma3ProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -175,8 +175,7 @@ class Gemma3nDummyInputsBuilder(BaseDummyInputsBuilder[Gemma3nProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
num_audios = mm_counts.get("audio", 0)
|
num_audios = mm_counts.get("audio", 0)
|
||||||
@@ -189,8 +188,8 @@ class Gemma3nDummyInputsBuilder(BaseDummyInputsBuilder[Gemma3nProcessingInfo]):
|
|||||||
img_width = image_processor.size.get("width", 224)
|
img_width = image_processor.size.get("width", 224)
|
||||||
img_height = image_processor.size.get("height", 224)
|
img_height = image_processor.size.get("height", 224)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
audio_overrides = mm_options.get("audio") if mm_options else None
|
audio_overrides = mm_options.get("audio")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
@@ -200,7 +199,9 @@ class Gemma3nDummyInputsBuilder(BaseDummyInputsBuilder[Gemma3nProcessingInfo]):
|
|||||||
overrides=image_overrides,
|
overrides=image_overrides,
|
||||||
),
|
),
|
||||||
"audio": self._get_dummy_audios(
|
"audio": self._get_dummy_audios(
|
||||||
length=audio_len, num_audios=num_audios, overrides=audio_overrides
|
length=audio_len,
|
||||||
|
num_audios=num_audios,
|
||||||
|
overrides=audio_overrides,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1163,8 +1163,7 @@ class Glm4vDummyInputsBuilder(BaseDummyInputsBuilder[Glm4vProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
num_videos = mm_counts.get("video", 0)
|
num_videos = mm_counts.get("video", 0)
|
||||||
@@ -1174,8 +1173,8 @@ class Glm4vDummyInputsBuilder(BaseDummyInputsBuilder[Glm4vProcessingInfo]):
|
|||||||
seq_len, mm_counts
|
seq_len, mm_counts
|
||||||
)
|
)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
video_overrides = mm_options.get("video") if mm_options else None
|
video_overrides = mm_options.get("video")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -492,8 +492,7 @@ class GLM4VDummyInputsBuilder(BaseDummyInputsBuilder[GLM4VProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
hf_config = self.info.get_hf_config()
|
hf_config = self.info.get_hf_config()
|
||||||
vision_config = hf_config.vision_config
|
vision_config = hf_config.vision_config
|
||||||
@@ -501,7 +500,7 @@ class GLM4VDummyInputsBuilder(BaseDummyInputsBuilder[GLM4VProcessingInfo]):
|
|||||||
target_width = target_height = vision_config["image_size"]
|
target_width = target_height = vision_config["image_size"]
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -726,15 +726,12 @@ class GlmAsrDummyInputsBuilder(BaseDummyInputsBuilder[GlmAsrProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
feature_extractor = self.info.get_feature_extractor(
|
feature_extractor = self.info.get_feature_extractor()
|
||||||
**(mm_processor_kwargs or {})
|
|
||||||
)
|
|
||||||
sampling_rate = feature_extractor.sampling_rate
|
sampling_rate = feature_extractor.sampling_rate
|
||||||
num_audios = mm_counts.get("audio", 0)
|
num_audios = mm_counts.get("audio", 0)
|
||||||
audio_overrides = mm_options.get("audio") if mm_options else None
|
audio_overrides = mm_options.get("audio")
|
||||||
|
|
||||||
max_audio_len = getattr(
|
max_audio_len = getattr(
|
||||||
self.info.get_hf_processor(), "max_audio_len", DEFAULT_MAX_AUDIO_LEN_S
|
self.info.get_hf_processor(), "max_audio_len", DEFAULT_MAX_AUDIO_LEN_S
|
||||||
@@ -743,7 +740,9 @@ class GlmAsrDummyInputsBuilder(BaseDummyInputsBuilder[GlmAsrProcessingInfo]):
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
"audio": self._get_dummy_audios(
|
"audio": self._get_dummy_audios(
|
||||||
length=audio_len, num_audios=num_audios, overrides=audio_overrides
|
length=audio_len,
|
||||||
|
num_audios=num_audios,
|
||||||
|
overrides=audio_overrides,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -216,11 +216,10 @@ class GraniteSpeechDummyInputsBuilder(
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_audios = mm_counts.get("audio", 0)
|
num_audios = mm_counts.get("audio", 0)
|
||||||
audio_overrides = mm_options.get("audio") if mm_options else None
|
audio_overrides = mm_options.get("audio")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"audio": self._get_dummy_audios(
|
"audio": self._get_dummy_audios(
|
||||||
|
|||||||
@@ -713,8 +713,7 @@ class HunYuanVLDummyInputsBuilder(BaseDummyInputsBuilder[HunYuanVLProcessingInfo
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 1)
|
num_images = mm_counts.get("image", 1)
|
||||||
|
|
||||||
|
|||||||
@@ -165,8 +165,7 @@ class HCXVisionDummyInputsBuilder(BaseDummyInputsBuilder[HCXVisionProcessingInfo
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
num_videos = mm_counts.get("video", 0)
|
num_videos = mm_counts.get("video", 0)
|
||||||
@@ -174,8 +173,8 @@ class HCXVisionDummyInputsBuilder(BaseDummyInputsBuilder[HCXVisionProcessingInfo
|
|||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
target_num_frames = 32
|
target_num_frames = 32
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
video_overrides = mm_options.get("video") if mm_options else None
|
video_overrides = mm_options.get("video")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -277,15 +277,14 @@ class Idefics3DummyInputsBuilder(BaseDummyInputsBuilder[Idefics3ProcessingInfo])
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
hf_processor = self.info.get_hf_processor(**(mm_processor_kwargs or {}))
|
hf_processor = self.info.get_hf_processor()
|
||||||
image_processor: Idefics3ImageProcessor = hf_processor.image_processor
|
image_processor: Idefics3ImageProcessor = hf_processor.image_processor
|
||||||
longest_edge = image_processor.max_image_size["longest_edge"]
|
longest_edge = image_processor.max_image_size["longest_edge"]
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -297,8 +297,7 @@ class InternS1DummyInputsBuilder(BaseDummyInputsBuilder[InternS1ProcessingInfo])
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
target_num_frames = self.info.get_num_frames_with_most_features(
|
target_num_frames = self.info.get_num_frames_with_most_features(
|
||||||
@@ -310,8 +309,8 @@ class InternS1DummyInputsBuilder(BaseDummyInputsBuilder[InternS1ProcessingInfo])
|
|||||||
config = self.info.get_hf_config()
|
config = self.info.get_hf_config()
|
||||||
image_size_h, image_size_w = config.vision_config.image_size
|
image_size_h, image_size_w = config.vision_config.image_size
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
video_overrides = mm_options.get("video") if mm_options else None
|
video_overrides = mm_options.get("video")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -762,13 +762,12 @@ class BaseInternVLDummyInputsBuilder(BaseDummyInputsBuilder[_I]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
@@ -935,12 +934,9 @@ class InternVLDummyInputsBuilder(
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
dummy_image = super().get_dummy_mm_data(
|
dummy_image = super().get_dummy_mm_data(seq_len, mm_counts, mm_options)
|
||||||
seq_len=seq_len, mm_counts=mm_counts, mm_options=mm_options
|
|
||||||
)
|
|
||||||
if self.info.supports_video:
|
if self.info.supports_video:
|
||||||
config = self.info.get_hf_config()
|
config = self.info.get_hf_config()
|
||||||
image_size: int = config.vision_config.image_size
|
image_size: int = config.vision_config.image_size
|
||||||
@@ -948,7 +944,7 @@ class InternVLDummyInputsBuilder(
|
|||||||
seq_len, mm_counts
|
seq_len, mm_counts
|
||||||
)
|
)
|
||||||
num_videos = mm_counts.get("video", 0)
|
num_videos = mm_counts.get("video", 0)
|
||||||
video_overrides = mm_options.get("video") if mm_options else None
|
video_overrides = mm_options.get("video")
|
||||||
dummy_video = {
|
dummy_video = {
|
||||||
"video": self._get_dummy_videos(
|
"video": self._get_dummy_videos(
|
||||||
width=image_size,
|
width=image_size,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ from typing_extensions import TypedDict, Unpack
|
|||||||
|
|
||||||
from vllm.config import VllmConfig
|
from vllm.config import VllmConfig
|
||||||
from vllm.config.model import ModelConfig
|
from vllm.config.model import ModelConfig
|
||||||
|
from vllm.config.multimodal import BaseDummyOptions
|
||||||
from vllm.distributed import parallel_state
|
from vllm.distributed import parallel_state
|
||||||
from vllm.distributed import utils as dist_utils
|
from vllm.distributed import utils as dist_utils
|
||||||
from vllm.model_executor.layers.attention import MMEncoderAttention
|
from vllm.model_executor.layers.attention import MMEncoderAttention
|
||||||
@@ -849,13 +850,12 @@ class IsaacDummyInputsBuilder(BaseDummyInputsBuilder[IsaacProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -444,8 +444,7 @@ class KananaVDummyInputsBuilder(BaseDummyInputsBuilder[KananaVProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1170,8 +1170,7 @@ class KeyeBaseDummyInputsBuilder(BaseDummyInputsBuilder[_I]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
num_videos = mm_counts.get("video", 0)
|
num_videos = mm_counts.get("video", 0)
|
||||||
@@ -1179,8 +1178,8 @@ class KeyeBaseDummyInputsBuilder(BaseDummyInputsBuilder[_I]):
|
|||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
target_num_frames = self.info.get_num_frames_with_most_features(seq_len)
|
target_num_frames = self.info.get_num_frames_with_most_features(seq_len)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
video_overrides = mm_options.get("video") if mm_options else None
|
video_overrides = mm_options.get("video")
|
||||||
|
|
||||||
mm_data = {
|
mm_data = {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -240,8 +240,7 @@ class KimiK25DummyInputsBuilder(BaseDummyInputsBuilder[KimiK25ProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
# TODO: Support mm_options for vision_chunk to allow user configuration
|
# TODO: Support mm_options for vision_chunk to allow user configuration
|
||||||
dummy_items = self.get_dummy_mm_items()
|
dummy_items = self.get_dummy_mm_items()
|
||||||
|
|||||||
@@ -215,12 +215,11 @@ class KimiVLDummyInputsBuilder(BaseDummyInputsBuilder[KimiVLProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -343,14 +343,13 @@ class Lfm2VLDummyInputsBuilder(BaseDummyInputsBuilder[Lfm2VLProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -232,14 +232,13 @@ class LlavaDummyInputsBuilder(BaseDummyInputsBuilder[_I]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -165,8 +165,7 @@ class LlavaNextVideoDummyInputsBuilder(
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_videos = mm_counts.get("video", 0)
|
num_videos = mm_counts.get("video", 0)
|
||||||
|
|
||||||
@@ -175,7 +174,7 @@ class LlavaNextVideoDummyInputsBuilder(
|
|||||||
seq_len, mm_counts
|
seq_len, mm_counts
|
||||||
)
|
)
|
||||||
|
|
||||||
video_overrides = mm_options.get("video") if mm_options else None
|
video_overrides = mm_options.get("video")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"video": self._get_dummy_videos(
|
"video": self._get_dummy_videos(
|
||||||
|
|||||||
@@ -276,8 +276,7 @@ class LlavaOnevisionDummyInputsBuilder(
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
num_videos = mm_counts.get("video", 0)
|
num_videos = mm_counts.get("video", 0)
|
||||||
@@ -287,8 +286,8 @@ class LlavaOnevisionDummyInputsBuilder(
|
|||||||
seq_len, mm_counts
|
seq_len, mm_counts
|
||||||
)
|
)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
video_overrides = mm_options.get("video") if mm_options else None
|
video_overrides = mm_options.get("video")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -565,12 +565,11 @@ class MiDashengLMDummyInputsBuilder(BaseDummyInputsBuilder[MiDashengLMProcessing
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_audios = mm_counts.get("audio", 0)
|
num_audios = mm_counts.get("audio", 0)
|
||||||
|
|
||||||
audio_overrides = mm_options.get("audio") if mm_options else None
|
audio_overrides = mm_options.get("audio")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"audio": self._get_dummy_audios(
|
"audio": self._get_dummy_audios(
|
||||||
|
|||||||
@@ -301,8 +301,7 @@ class MiniCPMODummyInputsBuilder(MiniCPMVDummyInputsBuilder[MiniCPMOProcessingIn
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_audios = mm_counts.get("audio", 0)
|
num_audios = mm_counts.get("audio", 0)
|
||||||
audio_len = (
|
audio_len = (
|
||||||
@@ -310,11 +309,13 @@ class MiniCPMODummyInputsBuilder(MiniCPMVDummyInputsBuilder[MiniCPMOProcessingIn
|
|||||||
* self.info.get_default_audio_sampling_rate()
|
* self.info.get_default_audio_sampling_rate()
|
||||||
)
|
)
|
||||||
|
|
||||||
audio_overrides = mm_options.get("audio") if mm_options else None
|
audio_overrides = mm_options.get("audio")
|
||||||
|
|
||||||
audio_mm_data = {
|
audio_mm_data = {
|
||||||
"audio": self._get_dummy_audios(
|
"audio": self._get_dummy_audios(
|
||||||
length=audio_len, num_audios=num_audios, overrides=audio_overrides
|
length=audio_len,
|
||||||
|
num_audios=num_audios,
|
||||||
|
overrides=audio_overrides,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -707,8 +707,7 @@ class MiniCPMVDummyInputsBuilder(BaseDummyInputsBuilder[_I]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
num_videos = mm_counts.get("video", 0)
|
num_videos = mm_counts.get("video", 0)
|
||||||
@@ -719,8 +718,8 @@ class MiniCPMVDummyInputsBuilder(BaseDummyInputsBuilder[_I]):
|
|||||||
seq_len, mm_counts
|
seq_len, mm_counts
|
||||||
)
|
)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
video_overrides = mm_options.get("video") if mm_options else None
|
video_overrides = mm_options.get("video")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -236,14 +236,13 @@ class Mistral3DummyInputsBuilder(BaseDummyInputsBuilder[_I]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -707,14 +707,13 @@ class Mllama4DummyInputsBuilder(BaseDummyInputsBuilder[Mllama4ProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
(target_width, target_height) = self.info.get_image_size_with_most_features()
|
(target_width, target_height) = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -1274,13 +1274,12 @@ class MolmoDummyInputsBuilder(BaseDummyInputsBuilder[MolmoProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -2082,8 +2082,7 @@ class Molmo2DummyInputsBuilder(BaseDummyInputsBuilder[Molmo2ProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
num_videos = mm_counts.get("video", 0)
|
num_videos = mm_counts.get("video", 0)
|
||||||
@@ -2094,7 +2093,7 @@ class Molmo2DummyInputsBuilder(BaseDummyInputsBuilder[Molmo2ProcessingInfo]):
|
|||||||
if num_images > 0:
|
if num_images > 0:
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
dummy_images = self._get_dummy_images(
|
dummy_images = self._get_dummy_images(
|
||||||
width=target_width,
|
width=target_width,
|
||||||
@@ -2110,7 +2109,7 @@ class Molmo2DummyInputsBuilder(BaseDummyInputsBuilder[Molmo2ProcessingInfo]):
|
|||||||
seq_len, mm_counts
|
seq_len, mm_counts
|
||||||
)
|
)
|
||||||
|
|
||||||
video_overrides = mm_options.get("video") if mm_options else None
|
video_overrides = mm_options.get("video")
|
||||||
|
|
||||||
if video_overrides:
|
if video_overrides:
|
||||||
assert isinstance(video_overrides, VideoDummyOptions)
|
assert isinstance(video_overrides, VideoDummyOptions)
|
||||||
|
|||||||
@@ -1388,8 +1388,7 @@ class NanoNemotronVLDummyInputsBuilder(BaseDummyInputsBuilder[_I]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
processor = self.info.get_hf_processor()
|
processor = self.info.get_hf_processor()
|
||||||
@@ -1404,7 +1403,7 @@ class NanoNemotronVLDummyInputsBuilder(BaseDummyInputsBuilder[_I]):
|
|||||||
max_num_tiles
|
max_num_tiles
|
||||||
)
|
)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
@@ -1461,12 +1460,9 @@ class NanoNemotronVLDummyInputsBuilder(
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
dummy_image = super().get_dummy_mm_data(
|
dummy_image = super().get_dummy_mm_data(seq_len, mm_counts, mm_options)
|
||||||
seq_len=seq_len, mm_counts=mm_counts, mm_options=mm_options
|
|
||||||
)
|
|
||||||
if self.info.supports_video:
|
if self.info.supports_video:
|
||||||
config = self.info.get_hf_config()
|
config = self.info.get_hf_config()
|
||||||
image_size: int = config.force_image_size
|
image_size: int = config.force_image_size
|
||||||
@@ -1474,7 +1470,7 @@ class NanoNemotronVLDummyInputsBuilder(
|
|||||||
seq_len, mm_counts
|
seq_len, mm_counts
|
||||||
)
|
)
|
||||||
num_videos = mm_counts.get("video", 0)
|
num_videos = mm_counts.get("video", 0)
|
||||||
video_overrides = mm_options.get("video") if mm_options else None
|
video_overrides = mm_options.get("video")
|
||||||
dummy_video = {
|
dummy_video = {
|
||||||
"video": self._get_dummy_videos(
|
"video": self._get_dummy_videos(
|
||||||
width=image_size,
|
width=image_size,
|
||||||
|
|||||||
@@ -645,8 +645,7 @@ class NemotronParseDummyInputsBuilder(
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
|
|||||||
@@ -92,13 +92,12 @@ class NVLMDummyInputsBuilder(BaseInternVLDummyInputsBuilder[NVLMProcessingInfo])
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -306,14 +306,13 @@ class OvisDummyInputsBuilder(BaseDummyInputsBuilder[OvisProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
mm_data = {
|
mm_data = {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -287,8 +287,7 @@ class Ovis2_5DummyInputsBuilder(BaseDummyInputsBuilder[Ovis2_5ProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
num_videos = mm_counts.get("video", 0)
|
num_videos = mm_counts.get("video", 0)
|
||||||
@@ -298,8 +297,8 @@ class Ovis2_5DummyInputsBuilder(BaseDummyInputsBuilder[Ovis2_5ProcessingInfo]):
|
|||||||
seq_len, mm_counts
|
seq_len, mm_counts
|
||||||
)
|
)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
video_overrides = mm_options.get("video") if mm_options else None
|
video_overrides = mm_options.get("video")
|
||||||
|
|
||||||
mm_data = {
|
mm_data = {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -206,13 +206,12 @@ class PaddleOCRVLDummyInputsBuilder(BaseDummyInputsBuilder[PaddleOCRVLProcessing
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
max_image_size = self.info.get_image_size_with_most_features()
|
max_image_size = self.info.get_image_size_with_most_features()
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -131,8 +131,7 @@ class PaliGemmaDummyInputsBuilder(BaseDummyInputsBuilder[PaliGemmaProcessingInfo
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
hf_config = self.info.get_hf_config()
|
hf_config = self.info.get_hf_config()
|
||||||
vision_config = hf_config.vision_config
|
vision_config = hf_config.vision_config
|
||||||
@@ -140,7 +139,7 @@ class PaliGemmaDummyInputsBuilder(BaseDummyInputsBuilder[PaliGemmaProcessingInfo
|
|||||||
|
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -376,14 +376,13 @@ class Phi3VDummyInputsBuilder(BaseDummyInputsBuilder[Phi3VProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -822,16 +822,15 @@ class Phi4MMDummyInputsBuilder(BaseDummyInputsBuilder[Phi4MMProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_audios = mm_counts.get("audio", 0)
|
num_audios = mm_counts.get("audio", 0)
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
audio_overrides = mm_options.get("audio") if mm_options else None
|
audio_overrides = mm_options.get("audio")
|
||||||
|
|
||||||
mm_data = {
|
mm_data = {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -249,14 +249,13 @@ class PixtralDummyInputsBuilder(BaseDummyInputsBuilder[PixtralProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
@@ -271,8 +270,7 @@ class PixtralDummyInputsBuilder(BaseDummyInputsBuilder[PixtralProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> ProcessorInputs:
|
) -> ProcessorInputs:
|
||||||
tokenizer = self.info.get_tokenizer()
|
tokenizer = self.info.get_tokenizer()
|
||||||
|
|
||||||
|
|||||||
@@ -357,15 +357,13 @@ class Qwen2_5OmniThinkerDummyInputsBuilder(
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_audios = mm_counts.get("audio", 0)
|
num_audios = mm_counts.get("audio", 0)
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
num_videos = mm_counts.get("video", 0)
|
num_videos = mm_counts.get("video", 0)
|
||||||
|
|
||||||
mm_processor_kwargs = mm_processor_kwargs or {}
|
feature_extractor = self.info.get_feature_extractor()
|
||||||
feature_extractor = self.info.get_feature_extractor(**mm_processor_kwargs)
|
|
||||||
|
|
||||||
target_audio_length = (
|
target_audio_length = (
|
||||||
min(
|
min(
|
||||||
@@ -375,16 +373,14 @@ class Qwen2_5OmniThinkerDummyInputsBuilder(
|
|||||||
* feature_extractor.sampling_rate
|
* feature_extractor.sampling_rate
|
||||||
)
|
)
|
||||||
|
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features(
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
max_pixels=mm_processor_kwargs.get("max_pixels", None),
|
|
||||||
)
|
|
||||||
target_num_frames = self.info.get_num_frames_with_most_features(
|
target_num_frames = self.info.get_num_frames_with_most_features(
|
||||||
seq_len, mm_counts
|
seq_len, mm_counts
|
||||||
)
|
)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
video_overrides = mm_options.get("video") if mm_options else None
|
video_overrides = mm_options.get("video")
|
||||||
audio_overrides = mm_options.get("audio") if mm_options else None
|
audio_overrides = mm_options.get("audio")
|
||||||
|
|
||||||
mm_data = {
|
mm_data = {
|
||||||
"audio": self._get_dummy_audios(
|
"audio": self._get_dummy_audios(
|
||||||
|
|||||||
@@ -195,22 +195,21 @@ class Qwen2AudioDummyInputsBuilder(BaseDummyInputsBuilder[Qwen2AudioProcessingIn
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
feature_extractor = self.info.get_feature_extractor(
|
feature_extractor = self.info.get_feature_extractor()
|
||||||
**(mm_processor_kwargs or {})
|
|
||||||
)
|
|
||||||
|
|
||||||
sampling_rate = feature_extractor.sampling_rate
|
sampling_rate = feature_extractor.sampling_rate
|
||||||
audio_len = feature_extractor.chunk_length * sampling_rate
|
audio_len = feature_extractor.chunk_length * sampling_rate
|
||||||
num_audios = mm_counts.get("audio", 0)
|
num_audios = mm_counts.get("audio", 0)
|
||||||
|
|
||||||
audio_overrides = mm_options.get("audio") if mm_options else None
|
audio_overrides = mm_options.get("audio")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"audio": self._get_dummy_audios(
|
"audio": self._get_dummy_audios(
|
||||||
length=audio_len, num_audios=num_audios, overrides=audio_overrides
|
length=audio_len,
|
||||||
|
num_audios=num_audios,
|
||||||
|
overrides=audio_overrides,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -925,9 +925,14 @@ class Qwen2VLProcessingInfo(BaseProcessingInfo):
|
|||||||
vision_config = hf_config.vision_config
|
vision_config = hf_config.vision_config
|
||||||
patch_size = vision_config.patch_size
|
patch_size = vision_config.patch_size
|
||||||
merge_size = vision_config.spatial_merge_size
|
merge_size = vision_config.spatial_merge_size
|
||||||
|
|
||||||
if max_pixels is None:
|
if max_pixels is None:
|
||||||
image_processor = self.get_image_processor()
|
image_processor = self.get_image_processor()
|
||||||
max_pixels = image_processor.size["longest_edge"]
|
|
||||||
|
mm_kwargs = self.ctx.get_merged_mm_kwargs({})
|
||||||
|
size = mm_kwargs.get("size", image_processor.size)
|
||||||
|
max_pixels = size["longest_edge"]
|
||||||
|
|
||||||
unit = patch_size * merge_size
|
unit = patch_size * merge_size
|
||||||
max_seq_len = max_pixels // (unit * unit)
|
max_seq_len = max_pixels // (unit * unit)
|
||||||
|
|
||||||
@@ -1027,22 +1032,18 @@ class Qwen2VLDummyInputsBuilder(BaseDummyInputsBuilder[Qwen2VLProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
num_videos = mm_counts.get("video", 0)
|
num_videos = mm_counts.get("video", 0)
|
||||||
|
|
||||||
mm_processor_kwargs = mm_processor_kwargs or {}
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features(
|
|
||||||
max_pixels=mm_processor_kwargs.get("max_pixels", None)
|
|
||||||
)
|
|
||||||
target_num_frames = self.info.get_num_frames_with_most_features(
|
target_num_frames = self.info.get_num_frames_with_most_features(
|
||||||
seq_len, mm_counts
|
seq_len, mm_counts
|
||||||
)
|
)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
video_overrides = mm_options.get("video") if mm_options else None
|
video_overrides = mm_options.get("video")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -146,14 +146,11 @@ class Qwen3ASRDummyInputsBuilder(BaseDummyInputsBuilder[Qwen3ASRProcessingInfo])
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_audios = mm_counts.get("audio", 0)
|
num_audios = mm_counts.get("audio", 0)
|
||||||
|
|
||||||
feature_extractor = self.info.get_feature_extractor(
|
feature_extractor = self.info.get_feature_extractor()
|
||||||
**(mm_processor_kwargs or {})
|
|
||||||
)
|
|
||||||
|
|
||||||
target_audio_length = (
|
target_audio_length = (
|
||||||
min(
|
min(
|
||||||
@@ -163,7 +160,7 @@ class Qwen3ASRDummyInputsBuilder(BaseDummyInputsBuilder[Qwen3ASRProcessingInfo])
|
|||||||
* feature_extractor.sampling_rate
|
* feature_extractor.sampling_rate
|
||||||
)
|
)
|
||||||
|
|
||||||
audio_overrides = mm_options.get("audio") if mm_options else None
|
audio_overrides = mm_options.get("audio")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"audio": self._get_dummy_audios(
|
"audio": self._get_dummy_audios(
|
||||||
|
|||||||
@@ -703,11 +703,18 @@ class Qwen3VLProcessingInfo(Qwen2VLProcessingInfo):
|
|||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
) -> int:
|
) -> int:
|
||||||
video_processor = self.get_video_processor()
|
video_processor = self.get_video_processor()
|
||||||
video_max_pixels = video_processor.size["longest_edge"]
|
|
||||||
|
mm_kwargs = self.ctx.get_merged_mm_kwargs({})
|
||||||
|
video_size = mm_kwargs.get("size", video_processor.size)
|
||||||
|
temporal_patch_size = mm_kwargs.get(
|
||||||
|
"temporal_patch_size", video_processor.temporal_patch_size
|
||||||
|
)
|
||||||
|
|
||||||
# video_max_pixels contains the temporal compression factor,
|
# video_max_pixels contains the temporal compression factor,
|
||||||
# so we divide by 2 to get the maximum number of image pixels.
|
# so we divide by 2 to get the maximum number of image pixels.
|
||||||
|
video_max_pixels = video_size["longest_edge"]
|
||||||
target_width, target_height = self.get_image_size_with_most_features(
|
target_width, target_height = self.get_image_size_with_most_features(
|
||||||
max_pixels=video_max_pixels // video_processor.temporal_patch_size
|
max_pixels=video_max_pixels // temporal_patch_size
|
||||||
)
|
)
|
||||||
num_video_soft_tokens = self.get_num_video_tokens(
|
num_video_soft_tokens = self.get_num_video_tokens(
|
||||||
image_width=target_width,
|
image_width=target_width,
|
||||||
@@ -789,19 +796,15 @@ class Qwen3VLDummyInputsBuilder(BaseDummyInputsBuilder[Qwen3VLProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
num_videos = mm_counts.get("video", 0)
|
num_videos = mm_counts.get("video", 0)
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
video_overrides = mm_options.get("video") if mm_options else None
|
video_overrides = mm_options.get("video")
|
||||||
|
|
||||||
mm_processor_kwargs = mm_processor_kwargs or {}
|
|
||||||
target_image_width, target_image_height = (
|
target_image_width, target_image_height = (
|
||||||
self.info.get_image_size_with_most_features(
|
self.info.get_image_size_with_most_features()
|
||||||
max_pixels=mm_processor_kwargs.get("max_pixels", None),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# treat videos as special images
|
# treat videos as special images
|
||||||
@@ -826,13 +829,20 @@ class Qwen3VLDummyInputsBuilder(BaseDummyInputsBuilder[Qwen3VLProcessingInfo]):
|
|||||||
target_num_frames = min(target_num_frames, num_frames_override)
|
target_num_frames = min(target_num_frames, num_frames_override)
|
||||||
target_num_frames = max(target_num_frames, 2)
|
target_num_frames = max(target_num_frames, 2)
|
||||||
|
|
||||||
video_processor = self.info.get_video_processor(**(mm_processor_kwargs or {}))
|
video_processor = self.info.get_video_processor()
|
||||||
video_max_pixels = video_processor.size["longest_edge"]
|
|
||||||
|
mm_kwargs = self.info.ctx.get_merged_mm_kwargs({})
|
||||||
|
video_size = mm_kwargs.get("size", video_processor.size)
|
||||||
|
temporal_patch_size = mm_kwargs.get(
|
||||||
|
"temporal_patch_size", video_processor.temporal_patch_size
|
||||||
|
)
|
||||||
|
|
||||||
# video_max_pixels contains the temporal compression factor,
|
# video_max_pixels contains the temporal compression factor,
|
||||||
# so we divide by 2 to get the maximum number of image pixels.
|
# so we divide by 2 to get the maximum number of image pixels.
|
||||||
|
video_max_pixels = video_size["longest_edge"]
|
||||||
target_video_width, target_video_height = (
|
target_video_width, target_video_height = (
|
||||||
self.info.get_image_size_with_most_features(
|
self.info.get_image_size_with_most_features(
|
||||||
max_pixels=video_max_pixels // video_processor.temporal_patch_size
|
max_pixels=video_max_pixels // temporal_patch_size
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
target_video_size, _ = self.info._get_vision_info(
|
target_video_size, _ = self.info._get_vision_info(
|
||||||
|
|||||||
@@ -617,8 +617,7 @@ class QwenVLDummyInputsBuilder(BaseDummyInputsBuilder[QwenVLProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
hf_config = self.info.get_hf_config()
|
hf_config = self.info.get_hf_config()
|
||||||
vision_config = hf_config.visual
|
vision_config = hf_config.visual
|
||||||
@@ -626,7 +625,7 @@ class QwenVLDummyInputsBuilder(BaseDummyInputsBuilder[QwenVLProcessingInfo]):
|
|||||||
target_width = target_height = vision_config["image_size"]
|
target_width = target_height = vision_config["image_size"]
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -40,14 +40,13 @@ class RVLDummyInputsBuilder(LlavaDummyInputsBuilder[RVLProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -158,14 +158,13 @@ class SiglipDummyInputsBuilder(BaseDummyInputsBuilder[SiglipProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -529,13 +529,12 @@ class SkyworkR1VDummyInputsBuilder(BaseDummyInputsBuilder[SkyworkR1VProcessingIn
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -564,13 +564,12 @@ class Step3VLDummyInputsBuilder(BaseDummyInputsBuilder[Step3VLProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
target_width, target_height = self.info.get_image_size_with_most_features()
|
target_width, target_height = self.info.get_image_size_with_most_features()
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -154,8 +154,7 @@ class TerratorchInputBuilder(BaseDummyInputsBuilder[TerratorchProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
# Dummy data is generated based on the 'input' section
|
# Dummy data is generated based on the 'input' section
|
||||||
# defined in the HF configuration file
|
# defined in the HF configuration file
|
||||||
|
|||||||
@@ -101,14 +101,13 @@ class MultiModalDummyInputsBuilder(BaseDummyInputsBuilder[MultiModalProcessingIn
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, "BaseDummyOptions"] | None = None,
|
mm_options: Mapping[str, "BaseDummyOptions"],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_images = mm_counts.get("image", 0)
|
num_images = mm_counts.get("image", 0)
|
||||||
|
|
||||||
target_width, target_height = self.info.get_max_image_size()
|
target_width, target_height = self.info.get_max_image_size()
|
||||||
|
|
||||||
image_overrides = mm_options.get("image") if mm_options else None
|
image_overrides = mm_options.get("image")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"image": self._get_dummy_images(
|
"image": self._get_dummy_images(
|
||||||
|
|||||||
@@ -164,12 +164,9 @@ class UltravoxDummyInputsBuilder(BaseDummyInputsBuilder[UltravoxProcessingInfo])
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
feature_extractor = self.info.get_feature_extractor(
|
feature_extractor = self.info.get_feature_extractor()
|
||||||
**(mm_processor_kwargs or {})
|
|
||||||
)
|
|
||||||
|
|
||||||
sampling_rate = feature_extractor.sampling_rate
|
sampling_rate = feature_extractor.sampling_rate
|
||||||
audio_len = (
|
audio_len = (
|
||||||
@@ -177,11 +174,13 @@ class UltravoxDummyInputsBuilder(BaseDummyInputsBuilder[UltravoxProcessingInfo])
|
|||||||
)
|
)
|
||||||
num_audios = mm_counts.get("audio", 0)
|
num_audios = mm_counts.get("audio", 0)
|
||||||
|
|
||||||
audio_overrides = mm_options.get("audio") if mm_options else None
|
audio_overrides = mm_options.get("audio")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"audio": self._get_dummy_audios(
|
"audio": self._get_dummy_audios(
|
||||||
length=audio_len, num_audios=num_audios, overrides=audio_overrides
|
length=audio_len,
|
||||||
|
num_audios=num_audios,
|
||||||
|
overrides=audio_overrides,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -218,18 +218,19 @@ class VoxtralDummyInputsBuilder(BaseDummyInputsBuilder[VoxtralProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
num_audios = mm_counts.get("audio", 0)
|
num_audios = mm_counts.get("audio", 0)
|
||||||
|
|
||||||
target_length = self.info.get_max_audio_array_len()
|
target_length = self.info.get_max_audio_array_len()
|
||||||
|
|
||||||
audio_overrides = mm_options.get("audio") if mm_options else None
|
audio_overrides = mm_options.get("audio")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"audio": self._get_dummy_audios(
|
"audio": self._get_dummy_audios(
|
||||||
length=target_length, num_audios=num_audios, overrides=audio_overrides
|
length=target_length,
|
||||||
|
num_audios=num_audios,
|
||||||
|
overrides=audio_overrides,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,8 +238,7 @@ class VoxtralDummyInputsBuilder(BaseDummyInputsBuilder[VoxtralProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> ProcessorInputs:
|
) -> ProcessorInputs:
|
||||||
tokenizer = self.info.get_tokenizer()
|
tokenizer = self.info.get_tokenizer()
|
||||||
|
|
||||||
|
|||||||
@@ -695,22 +695,21 @@ class WhisperDummyInputsBuilder(BaseDummyInputsBuilder[WhisperProcessingInfo]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
feature_extractor = self.info.get_feature_extractor(
|
feature_extractor = self.info.get_feature_extractor()
|
||||||
**(mm_processor_kwargs or {})
|
|
||||||
)
|
|
||||||
|
|
||||||
sampling_rate = feature_extractor.sampling_rate
|
sampling_rate = feature_extractor.sampling_rate
|
||||||
audio_len = feature_extractor.chunk_length * sampling_rate
|
audio_len = feature_extractor.chunk_length * sampling_rate
|
||||||
num_audios = mm_counts.get("audio", 0)
|
num_audios = mm_counts.get("audio", 0)
|
||||||
|
|
||||||
audio_overrides = mm_options.get("audio") if mm_options else None
|
audio_overrides = mm_options.get("audio")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"audio": self._get_dummy_audios(
|
"audio": self._get_dummy_audios(
|
||||||
length=audio_len, num_audios=num_audios, overrides=audio_overrides
|
length=audio_len,
|
||||||
|
num_audios=num_audios,
|
||||||
|
overrides=audio_overrides,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -266,11 +266,14 @@ class InputProcessingContext:
|
|||||||
if isinstance(tokenizer, MistralTokenizer):
|
if isinstance(tokenizer, MistralTokenizer):
|
||||||
tokenizer = tokenizer.transformers_tokenizer
|
tokenizer = tokenizer.transformers_tokenizer
|
||||||
|
|
||||||
|
merged_kwargs = self.get_merged_mm_kwargs(kwargs)
|
||||||
|
merged_kwargs.pop("tokenizer", None)
|
||||||
|
|
||||||
return cached_processor_from_config(
|
return cached_processor_from_config(
|
||||||
self.model_config,
|
self.model_config,
|
||||||
processor_cls=typ,
|
processor_cls=typ,
|
||||||
tokenizer=tokenizer,
|
tokenizer=tokenizer,
|
||||||
**kwargs,
|
**merged_kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
def init_processor(
|
def init_processor(
|
||||||
@@ -283,12 +286,7 @@ class InputProcessingContext:
|
|||||||
Initialize a HuggingFace-like processor class, merging the
|
Initialize a HuggingFace-like processor class, merging the
|
||||||
keyword arguments with those in the model's configuration.
|
keyword arguments with those in the model's configuration.
|
||||||
"""
|
"""
|
||||||
mm_config = self.model_config.get_multimodal_config()
|
merged_kwargs = self.get_merged_mm_kwargs(kwargs)
|
||||||
base_kwargs = mm_config.mm_processor_kwargs
|
|
||||||
if base_kwargs is None:
|
|
||||||
base_kwargs = {}
|
|
||||||
|
|
||||||
merged_kwargs = {**base_kwargs, **kwargs}
|
|
||||||
|
|
||||||
return typ(**merged_kwargs)
|
return typ(**merged_kwargs)
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,7 @@ class BaseDummyInputsBuilder(ABC, Generic[_I]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> MultiModalDataDict:
|
) -> MultiModalDataDict:
|
||||||
"""
|
"""
|
||||||
Build the multimodal input which, after processing, results in
|
Build the multimodal input which, after processing, results in
|
||||||
@@ -83,8 +82,7 @@ class BaseDummyInputsBuilder(ABC, Generic[_I]):
|
|||||||
self,
|
self,
|
||||||
seq_len: int,
|
seq_len: int,
|
||||||
mm_counts: Mapping[str, int],
|
mm_counts: Mapping[str, int],
|
||||||
mm_options: Mapping[str, BaseDummyOptions] | None = None,
|
mm_options: Mapping[str, BaseDummyOptions],
|
||||||
mm_processor_kwargs: Mapping[str, object] | None = None,
|
|
||||||
) -> ProcessorInputs:
|
) -> ProcessorInputs:
|
||||||
"""
|
"""
|
||||||
Build the input which, after processing, results in
|
Build the input which, after processing, results in
|
||||||
@@ -94,16 +92,9 @@ class BaseDummyInputsBuilder(ABC, Generic[_I]):
|
|||||||
seq_len: Sequence length
|
seq_len: Sequence length
|
||||||
mm_counts: Count of items per modality
|
mm_counts: Count of items per modality
|
||||||
mm_options: Configurable options per modality (optional)
|
mm_options: Configurable options per modality (optional)
|
||||||
mm_processor_kwargs: Additional keyword arguments
|
|
||||||
for hf_processor (optional)
|
|
||||||
"""
|
"""
|
||||||
dummy_text = self.get_dummy_text(mm_counts)
|
dummy_text = self.get_dummy_text(mm_counts)
|
||||||
dummy_mm_data = self.get_dummy_mm_data(
|
dummy_mm_data = self.get_dummy_mm_data(seq_len, mm_counts, mm_options)
|
||||||
seq_len,
|
|
||||||
mm_counts,
|
|
||||||
mm_options,
|
|
||||||
mm_processor_kwargs=mm_processor_kwargs,
|
|
||||||
)
|
|
||||||
dummy_mm_items = self.info.parse_mm_data(dummy_mm_data, validate=False)
|
dummy_mm_items = self.info.parse_mm_data(dummy_mm_data, validate=False)
|
||||||
|
|
||||||
tokenization_kwargs = {"truncation": False}
|
tokenization_kwargs = {"truncation": False}
|
||||||
@@ -111,7 +102,6 @@ class BaseDummyInputsBuilder(ABC, Generic[_I]):
|
|||||||
return ProcessorInputs(
|
return ProcessorInputs(
|
||||||
prompt=dummy_text,
|
prompt=dummy_text,
|
||||||
mm_items=dummy_mm_items,
|
mm_items=dummy_mm_items,
|
||||||
hf_processor_mm_kwargs=mm_processor_kwargs or {},
|
|
||||||
tokenization_kwargs=tokenization_kwargs,
|
tokenization_kwargs=tokenization_kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ from dataclasses import dataclass
|
|||||||
from multiprocessing.synchronize import Lock as LockType
|
from multiprocessing.synchronize import Lock as LockType
|
||||||
from typing import TYPE_CHECKING, Generic, Literal, Protocol, TypeVar, cast
|
from typing import TYPE_CHECKING, Generic, Literal, Protocol, TypeVar, cast
|
||||||
|
|
||||||
from vllm.config.multimodal import BaseDummyOptions
|
|
||||||
from vllm.config.observability import ObservabilityConfig
|
from vllm.config.observability import ObservabilityConfig
|
||||||
from vllm.logger import init_logger
|
from vllm.logger import init_logger
|
||||||
from vllm.tokenizers import TokenizerLike, cached_tokenizer_from_config
|
from vllm.tokenizers import TokenizerLike, cached_tokenizer_from_config
|
||||||
@@ -99,27 +98,6 @@ class MultiModalRegistry:
|
|||||||
A registry that dispatches data processing according to the model.
|
A registry that dispatches data processing according to the model.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _extract_mm_options(
|
|
||||||
self,
|
|
||||||
model_config: "ModelConfig",
|
|
||||||
) -> Mapping[str, BaseDummyOptions] | None:
|
|
||||||
"""
|
|
||||||
Extract multimodal dummy options from model config.
|
|
||||||
|
|
||||||
Returns None if no configurable options are found, otherwise returns
|
|
||||||
a mapping of modality names to their dummy options.
|
|
||||||
"""
|
|
||||||
if not model_config.multimodal_config:
|
|
||||||
return None
|
|
||||||
|
|
||||||
mm_options = {
|
|
||||||
m: opt
|
|
||||||
for m in model_config.multimodal_config.limit_per_prompt
|
|
||||||
if (opt := model_config.multimodal_config.get_dummy_options(m)) is not None
|
|
||||||
}
|
|
||||||
|
|
||||||
return mm_options if len(mm_options) > 0 else None
|
|
||||||
|
|
||||||
def supports_multimodal_inputs(self, model_config: "ModelConfig") -> bool:
|
def supports_multimodal_inputs(self, model_config: "ModelConfig") -> bool:
|
||||||
"""
|
"""
|
||||||
Checks if the model supports multimodal inputs.
|
Checks if the model supports multimodal inputs.
|
||||||
@@ -261,8 +239,7 @@ class MultiModalRegistry:
|
|||||||
processor_inputs = processor.dummy_inputs.get_dummy_processor_inputs(
|
processor_inputs = processor.dummy_inputs.get_dummy_processor_inputs(
|
||||||
seq_len=seq_len,
|
seq_len=seq_len,
|
||||||
mm_counts=mm_counts,
|
mm_counts=mm_counts,
|
||||||
mm_options=self._extract_mm_options(model_config),
|
mm_options=mm_config.limit_per_prompt,
|
||||||
mm_processor_kwargs=mm_config.mm_processor_kwargs,
|
|
||||||
)
|
)
|
||||||
mm_inputs = processor.apply(
|
mm_inputs = processor.apply(
|
||||||
prompt=processor_inputs.prompt,
|
prompt=processor_inputs.prompt,
|
||||||
|
|||||||
Reference in New Issue
Block a user