vllm.config.utils ¶
Utility functions for vLLM config dataclasses.
Range ¶
A range of numbers. Inclusive of start, inclusive of end.
Source code in vllm/config/utils.py
SupportsHash ¶
SupportsMetricsInfo ¶
config ¶
config(
cls: type[ConfigT] | None = None,
*,
config: ConfigDict | None = None,
**kwargs: Any,
) -> (
type[ConfigT] | Callable[[type[ConfigT]], type[ConfigT]]
)
Decorator to create a pydantic dataclass with default config. The default config for the dataclass forbids extra fields.
All config classes in vLLM should use this decorator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls | type[ConfigT] | None | The class to decorate | None |
config | ConfigDict | None | The pydantic ConfigDict to use. If provided, it will be merged with the default config. | None |
**kwargs | Any | Additional arguments to pass to pydantic.dataclass. | {} |
Source code in vllm/config/utils.py
get_attr_docs ¶
Get any docstrings placed after attribute assignments in a class body.
https://davidism.com/mit-license/
Source code in vllm/config/utils.py
get_field ¶
get_field(cls: ConfigType, name: str) -> Field
Get the default factory field of a dataclass by name. Used for getting default factory fields in EngineArgs.
Source code in vllm/config/utils.py
get_hash_factors ¶
Gets the factors used for hashing a config class. - Includes all dataclass fields not in ignored_factors. - Errors on non-normalizable values.
Source code in vllm/config/utils.py
getattr_iter ¶
getattr_iter(
object: object,
names: Sequence[str],
default: Any | None = None,
default_factory: Callable[[], Any] | None = None,
warn: bool = False,
) -> Any
A helper function that retrieves an attribute from an object which may have multiple possible names. This is useful when fetching attributes from arbitrary transformers.PretrainedConfig instances.
In the case where the first name in names is the preferred name, and any other names are deprecated aliases, setting warn=True will log a warning when a deprecated name is used.
Source code in vllm/config/utils.py
handle_deprecated ¶
handle_deprecated(
config: ConfigT,
old_name: str,
new_name_or_names: str | list[str],
removal_version: str,
) -> None
Source code in vllm/config/utils.py
hash_factors ¶
Return a SHA-256 hex digest of the canonical items structure.
is_init_field ¶
is_init_field(cls: ConfigType, name: str) -> bool
normalize_value ¶
Return a stable, JSON-serializable canonical form for hashing. Order: primitives, special types (Enum, callable, torch.dtype, Path), then generic containers (Mapping/Set/Sequence) with recursion.
Source code in vllm/config/utils.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
replace ¶
Like dataclasses.replace, but compatible with Pydantic dataclasses which use pydantic.fields.Field instead of dataclasses.field