vllm.utils.func_utils ¶
Contains helpers that are applied to functions.
This is similar in concept to the functools module.
Functions:
-
get_allowed_kwarg_only_overrides–Given a callable which has one or more keyword only params and a dict
-
identity–Returns the first provided value.
-
supports_kw–Check if a keyword is a valid kwarg for a callable; if requires_kw_only
_supports_kw(callable, kw_name, *, requires_kw_only=False, allow_var_kwargs=True) cached ¶
Internal cached implementation of supports_kw.
Source code in vllm/utils/func_utils.py
get_allowed_kwarg_only_overrides(callable, overrides, *, requires_kw_only=True, allow_var_kwargs=False) ¶
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:
-
(callable¶Callable[..., object]) –Callable which takes 0 or more keyword only arguments. If None is provided, all overrides names are allowed.
-
(overrides¶Mapping[str, object] | None) –Potential overrides to be used when invoking the callable.
-
(allow_var_kwargs¶bool, default:False) –Allows overrides that are expandable for var kwargs.
Returns:
-
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(value, **kwargs) ¶
supports_kw(callable, kw_name, *, requires_kw_only=False, allow_var_kwargs=True) ¶
Check if a keyword is a valid kwarg for a callable; if requires_kw_only disallows kwargs names that can also be positional arguments.