vllm.utils.func_utils ¶
Contains helpers that are applied to functions.
This is similar in concept to the functools
module.
deprecate_args ¶
deprecate_args(
start_index: int,
is_deprecated: bool | Callable[[], bool] = True,
additional_message: str | None = None,
) -> Callable[[F], F]
Source code in vllm/utils/func_utils.py
deprecate_kwargs ¶
deprecate_kwargs(
*kws: str,
is_deprecated: bool | Callable[[], bool] = True,
additional_message: str | None = None,
) -> Callable[[F], F]
Source code in vllm/utils/func_utils.py
get_allowed_kwarg_only_overrides ¶
get_allowed_kwarg_only_overrides(
callable: Callable[..., object],
overrides: Mapping[str, object] | None,
*,
requires_kw_only: bool = True,
allow_var_kwargs: bool = False,
) -> dict[str, Any]
Given a callable which has one or more keyword only params and a dict mapping param names to values, drop values that can be not be kwarg expanded to overwrite one or more keyword-only args. This is used in a few places to handle custom processor overrides for multimodal models, e.g., for profiling when processor options provided by the user may affect the number of mm tokens per instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callable | Callable[..., object] | Callable which takes 0 or more keyword only arguments. If None is provided, all overrides names are allowed. | required |
overrides | Mapping[str, object] | None | Potential overrides to be used when invoking the callable. | required |
allow_var_kwargs | bool | Allows overrides that are expandable for var kwargs. | False |
Returns:
Type | Description |
---|---|
dict[str, Any] | Dictionary containing the kwargs to be leveraged which may be used |
dict[str, Any] | to overwrite one or more keyword only arguments when invoking the |
dict[str, Any] | callable. |
Source code in vllm/utils/func_utils.py
identity ¶
run_once ¶
Source code in vllm/utils/func_utils.py
supports_kw cached
¶
supports_kw(
callable: Callable[..., object],
kw_name: str,
*,
requires_kw_only: bool = False,
allow_var_kwargs: bool = True,
) -> bool
Check if a keyword is a valid kwarg for a callable; if requires_kw_only disallows kwargs names that can also be positional arguments.