vllm.config.utils ¶
Utility functions for vLLM config dataclasses.
SupportsHash ¶
SupportsMetricsInfo ¶
assert_hashable ¶
Source code in vllm/config/utils.py
config ¶
A decorator that ensures all fields in a dataclass have default values and that each field has a docstring.
If a ConfigT is used as a CLI argument itself, the type keyword argument provided by get_kwargs will be pydantic.TypeAdapter(ConfigT).validate_json(cli_arg) which treats the cli_arg as a JSON string which gets validated by pydantic.
Config validation is performed by the tools/pre_commit/validate_config.py script, which is invoked during the pre-commit checks.
Source code in vllm/config/utils.py
contains_object_print ¶
Check if the text looks like a printed Python object, e.g. contains any substring matching the pattern: "at 0xFFFFFFF>" We match against 0x followed by 2-16 hex chars (there's a max of 16 on a 64-bit system).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text | str | The text to check | required |
Returns:
| Name | Type | Description |
|---|---|---|
result | bool |
|
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 ¶
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.
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
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 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 | |