Merge remote-tracking branch 'upstream/main' into patches
Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
@@ -100,6 +100,7 @@ class EngramConfig:
|
||||
if self.dp_shared_memory is None:
|
||||
self.dp_shared_memory = (
|
||||
self.cpu_offload
|
||||
and not self.use_thp
|
||||
and parallel_config.data_parallel_size > 1
|
||||
and not parallel_config.enable_elastic_ep
|
||||
)
|
||||
|
||||
@@ -84,6 +84,9 @@ class LoRAConfig:
|
||||
experts (stored once with expert-dim 1) instead of per-expert. The shared
|
||||
factors are broadcast to the expert count at kernel time. Only meaningful for
|
||||
MoE models whose adapters use this layout; ignored otherwise."""
|
||||
max_lora_cls_labels: int | None = Field(default=None, ge=1)
|
||||
"""Maximum output size for LoRA classification heads. Defaults to the
|
||||
base classification head size."""
|
||||
|
||||
def compute_hash(self) -> str:
|
||||
"""WARNING: Whenever a new field is added to this config,
|
||||
@@ -104,6 +107,7 @@ class LoRAConfig:
|
||||
factors.append(self.enable_tower_connector_lora)
|
||||
factors.append(self.enable_mixed_moe_lora_format)
|
||||
factors.append(self.enable_moe_shared_loras)
|
||||
factors.append(self.max_lora_cls_labels)
|
||||
# target_modules affects which modules get LoRA applied
|
||||
factors.append(
|
||||
tuple(sorted(self.target_modules)) if self.target_modules else None
|
||||
|
||||
+187
-1
@@ -27,6 +27,186 @@ logger = init_logger(__name__)
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
# HuggingFace processors accept a shared flat namespace in addition to the
|
||||
# nested processor kwarg scopes ``text_kwargs`` / ``images_kwargs`` /
|
||||
# ``videos_kwargs`` / ``audio_kwargs``. vLLM recognizes these scopes when
|
||||
# resolving ``mm_processor_kwargs``.
|
||||
_HF_PROCESSOR_KWARG_SCOPES = (
|
||||
"text_kwargs",
|
||||
"images_kwargs",
|
||||
"videos_kwargs",
|
||||
"audio_kwargs",
|
||||
)
|
||||
|
||||
|
||||
def _recursively_merge_mm_processor_kwargs(
|
||||
defaults: Mapping[str, object],
|
||||
overrides: Mapping[str, object],
|
||||
) -> dict[str, object]:
|
||||
"""Merge two mappings recursively, with ``overrides`` taking precedence.
|
||||
|
||||
Nested values are merged only when both values are mappings; otherwise the
|
||||
override replaces the existing value.
|
||||
"""
|
||||
merged = dict(defaults)
|
||||
|
||||
for key, value in overrides.items():
|
||||
default_value = merged.get(key)
|
||||
if isinstance(default_value, Mapping) and isinstance(value, Mapping):
|
||||
merged[key] = _recursively_merge_mm_processor_kwargs(default_value, value)
|
||||
else:
|
||||
merged[key] = value
|
||||
|
||||
return merged
|
||||
|
||||
|
||||
def _merge_mm_processor_scope(
|
||||
config_flat: Mapping[str, object],
|
||||
config_scoped: Mapping[str, object],
|
||||
inference_flat: Mapping[str, object],
|
||||
inference_scoped: Mapping[str, object],
|
||||
) -> dict[str, object]:
|
||||
"""Merge kwargs for one existing HuggingFace processor kwarg scope.
|
||||
|
||||
Flat kwargs contribute only to keys present in either the configured or
|
||||
inference-time scope. For those keys, precedence is:
|
||||
configured flat < configured scoped < inference flat < inference scoped.
|
||||
|
||||
Nested mappings are merged recursively; otherwise the higher-priority value
|
||||
replaces the lower-priority value.
|
||||
"""
|
||||
# Flat kwargs contribute only to keys present in this scope in either input.
|
||||
scoped_keys = config_scoped.keys() | inference_scoped.keys()
|
||||
config_flat_for_scope = {
|
||||
key: value for key, value in config_flat.items() if key in scoped_keys
|
||||
}
|
||||
inference_flat_for_scope = {
|
||||
key: value for key, value in inference_flat.items() if key in scoped_keys
|
||||
}
|
||||
|
||||
# Merge from lowest to highest priority:
|
||||
# configured flat -> configured scoped -> inference flat -> inference scoped.
|
||||
merged = _recursively_merge_mm_processor_kwargs(
|
||||
config_flat_for_scope, config_scoped
|
||||
)
|
||||
merged = _recursively_merge_mm_processor_kwargs(merged, inference_flat_for_scope)
|
||||
merged = _recursively_merge_mm_processor_kwargs(merged, inference_scoped)
|
||||
return merged
|
||||
|
||||
|
||||
def _merge_mm_processor_kwargs(
|
||||
config_kwargs: Mapping[str, object],
|
||||
inference_kwargs: Mapping[str, object],
|
||||
) -> dict[str, object]:
|
||||
"""Merge configured and inference-time multi-modal processor kwargs.
|
||||
|
||||
The merge is performed in two parts:
|
||||
|
||||
1. The shared flat kwargs are merged recursively, with inference-time values
|
||||
taking precedence.
|
||||
2. Each existing HuggingFace processor kwarg scope is merged separately.
|
||||
For keys present in either the configured or inference-time scope,
|
||||
precedence is:
|
||||
configured flat < configured scoped < inference flat < inference scoped.
|
||||
|
||||
For example:
|
||||
|
||||
configured = {
|
||||
"size": {"shortest_edge": 256},
|
||||
"videos_kwargs": {
|
||||
"size": {"longest_edge": 1024},
|
||||
"num_frames": 16,
|
||||
},
|
||||
}
|
||||
inference = {
|
||||
"size": {"shortest_edge": 512},
|
||||
"videos_kwargs": {"fps": 4},
|
||||
}
|
||||
|
||||
produces:
|
||||
|
||||
{
|
||||
"size": {"shortest_edge": 512},
|
||||
"videos_kwargs": {
|
||||
"size": {
|
||||
"shortest_edge": 512,
|
||||
"longest_edge": 1024,
|
||||
},
|
||||
"num_frames": 16,
|
||||
"fps": 4,
|
||||
},
|
||||
}
|
||||
|
||||
Scoped values do not modify the shared flat kwargs or sibling scopes.
|
||||
Missing scopes, None-valued scopes, and empty scope mappings are treated as
|
||||
absent and do not create a scope.
|
||||
"""
|
||||
# Merge the shared flat kwargs first; nested scopes are handled separately
|
||||
# below.
|
||||
config_flat = {
|
||||
key: value
|
||||
for key, value in config_kwargs.items()
|
||||
if key not in _HF_PROCESSOR_KWARG_SCOPES
|
||||
}
|
||||
inference_flat = {
|
||||
key: value
|
||||
for key, value in inference_kwargs.items()
|
||||
if key not in _HF_PROCESSOR_KWARG_SCOPES
|
||||
}
|
||||
merged = _recursively_merge_mm_processor_kwargs(config_flat, inference_flat)
|
||||
|
||||
# Merge each nested processor kwarg scope present in either input.
|
||||
for scoped_key in _HF_PROCESSOR_KWARG_SCOPES:
|
||||
config_scope_value = config_kwargs.get(scoped_key)
|
||||
inference_scope_value = inference_kwargs.get(scoped_key)
|
||||
|
||||
# Treat missing scopes, None-valued scopes, and empty scope mappings as
|
||||
# absent.
|
||||
if isinstance(config_scope_value, Mapping) and not config_scope_value:
|
||||
config_scope_value = None
|
||||
if isinstance(inference_scope_value, Mapping) and not inference_scope_value:
|
||||
inference_scope_value = None
|
||||
|
||||
# Skip adding the scope to the merged result when it is absent from both
|
||||
# sources.
|
||||
if config_scope_value is None and inference_scope_value is None:
|
||||
continue
|
||||
|
||||
# Handle the inference scope first because it has higher precedence; only
|
||||
# mapping-valued scopes participate in the recursive scoped merge.
|
||||
inference_scope_kwargs: Mapping[str, object]
|
||||
if inference_scope_value is None:
|
||||
inference_scope_kwargs = {}
|
||||
elif not isinstance(inference_scope_value, Mapping):
|
||||
# Non-mapping scopes cannot participate in the recursive scoped merge;
|
||||
# the higher-priority inference value replaces the configured scope.
|
||||
merged[scoped_key] = inference_scope_value
|
||||
continue
|
||||
else:
|
||||
inference_scope_kwargs = inference_scope_value
|
||||
|
||||
# Handle the configured scope next because it has lower precedence; only
|
||||
# mapping-valued scopes participate in the recursive scoped merge.
|
||||
if isinstance(config_scope_value, Mapping):
|
||||
config_scope_kwargs = config_scope_value
|
||||
elif inference_scope_value is None:
|
||||
# Non-mapping scopes cannot participate in the recursive scoped merge;
|
||||
# preserve the configured value when inference contributes nothing.
|
||||
merged[scoped_key] = config_scope_value
|
||||
continue
|
||||
else:
|
||||
config_scope_kwargs = {}
|
||||
|
||||
# Merge this scope together with the matching flat kwargs.
|
||||
merged[scoped_key] = _merge_mm_processor_scope(
|
||||
config_flat,
|
||||
config_scope_kwargs,
|
||||
inference_flat,
|
||||
inference_scope_kwargs,
|
||||
)
|
||||
|
||||
return merged
|
||||
|
||||
|
||||
@dataclass
|
||||
class BaseDummyOptions:
|
||||
@@ -533,8 +713,14 @@ class MultiModalConfig:
|
||||
) -> dict[str, object]:
|
||||
"""Get the keyword arguments to pass to the multi-modal processor
|
||||
according to the extra arguments passed during inference.
|
||||
|
||||
Nested mappings are merged recursively, with inference-time values taking
|
||||
precedence over configured values.
|
||||
"""
|
||||
merged = dict(self.mm_processor_kwargs or {}) | dict(inference_kwargs)
|
||||
merged = _merge_mm_processor_kwargs(
|
||||
self.mm_processor_kwargs or {},
|
||||
inference_kwargs,
|
||||
)
|
||||
if self.mm_device_do_normalize:
|
||||
# The model expects raw pixels and normalises on device;
|
||||
# overriding these per request would silently double-normalise.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import os
|
||||
import socket
|
||||
from collections.abc import Callable
|
||||
from datetime import timedelta
|
||||
from typing import TYPE_CHECKING, Any, Literal, overload
|
||||
|
||||
import regex as re
|
||||
@@ -613,6 +614,11 @@ class ParallelConfig:
|
||||
"""
|
||||
return self.data_parallel_external_lb or self.data_parallel_hybrid_lb
|
||||
|
||||
@property
|
||||
def cpu_distributed_timeout(self) -> timedelta | None:
|
||||
seconds = self.cpu_distributed_timeout_seconds
|
||||
return timedelta(seconds=seconds) if seconds is not None else None
|
||||
|
||||
def get_next_dp_init_port(self) -> int:
|
||||
"""We might need to initialize process groups in multiple
|
||||
processes that is related to data parallelism,
|
||||
@@ -694,6 +700,7 @@ class ParallelConfig:
|
||||
backend="gloo",
|
||||
return_store=return_store,
|
||||
listen_socket=listen_socket,
|
||||
timeout=self.cpu_distributed_timeout,
|
||||
)
|
||||
except DistNetworkError as e:
|
||||
# We only want to retry when the root cause is EADDRINUSE.
|
||||
|
||||
+23
-8
@@ -2041,6 +2041,7 @@ class VllmConfig:
|
||||
self._validate_mm_processor_device()
|
||||
|
||||
if self.use_v2_model_runner:
|
||||
self._disable_cudagraphs_for_v2_stock_torch_compile()
|
||||
self._validate_v2_model_runner()
|
||||
else:
|
||||
self._validate_v1_model_runner()
|
||||
@@ -3045,9 +3046,6 @@ class VllmConfig:
|
||||
unsupported: list[str] = []
|
||||
speculative_config = self.speculative_config
|
||||
|
||||
if self.compilation_config.mode == CompilationMode.STOCK_TORCH_COMPILE:
|
||||
unsupported.append("stock torch.compile")
|
||||
|
||||
if (
|
||||
self.compilation_config.pass_config.enable_sp
|
||||
and self.parallel_config.tensor_parallel_size > 1
|
||||
@@ -3067,8 +3065,6 @@ class VllmConfig:
|
||||
# https://github.com/vllm-project/vllm/pull/40704
|
||||
"ngram",
|
||||
"ngram_gpu",
|
||||
# https://github.com/vllm-project/vllm/pull/43091
|
||||
"draft_model",
|
||||
"suffix",
|
||||
"medusa",
|
||||
"mlp_speculator",
|
||||
@@ -3088,9 +3084,6 @@ class VllmConfig:
|
||||
if self.parallel_config.use_ubatching:
|
||||
unsupported.extend(self._get_dbo_unsupported_features())
|
||||
|
||||
if self.parallel_config.enable_elastic_ep:
|
||||
unsupported.append("elastic expert parallelism")
|
||||
|
||||
if self.cache_config.mamba_cache_mode == "all":
|
||||
unsupported.append("mamba cache mode 'all'")
|
||||
|
||||
@@ -3306,6 +3299,28 @@ class VllmConfig:
|
||||
"Enable attribution or use --enforce-eager."
|
||||
)
|
||||
|
||||
def _disable_cudagraphs_for_v2_stock_torch_compile(self) -> None:
|
||||
"""Run stock torch.compile without CUDA graphs in Model Runner V2.
|
||||
|
||||
V1 never wraps a stock-compiled model in CUDAGraphWrapper, so it runs
|
||||
without CUDA graphs. V2's CUDA graph manager would otherwise capture
|
||||
FULL graphs around the stock-compiled model, so disable them to match.
|
||||
"""
|
||||
compilation_config = self.compilation_config
|
||||
if (
|
||||
compilation_config.mode != CompilationMode.STOCK_TORCH_COMPILE
|
||||
or compilation_config.cudagraph_mode == CUDAGraphMode.NONE
|
||||
):
|
||||
return
|
||||
logger.info_once(
|
||||
"CUDA graphs are not supported with stock torch.compile in Model "
|
||||
"Runner V2. Overriding cudagraph_mode %s to NONE.",
|
||||
compilation_config.cudagraph_mode.name,
|
||||
)
|
||||
compilation_config.cudagraph_mode = CUDAGraphMode.NONE
|
||||
compilation_config.max_cudagraph_capture_size = 0
|
||||
compilation_config.cudagraph_capture_sizes = []
|
||||
|
||||
def _validate_v2_model_runner(self) -> None:
|
||||
"""Check for features not yet supported by the V2 model runner."""
|
||||
if not HAS_TRITON:
|
||||
|
||||
Reference in New Issue
Block a user