vllm.transformers_utils.config
_AUTO_CONFIG_KWARGS_OVERRIDES module-attribute
¶
_AUTO_CONFIG_KWARGS_OVERRIDES: dict[str, dict[str, Any]] = {
"internvl_chat": {"has_no_defaults_at_init": True},
"mllama": {"is_encoder_decoder": True},
"NVLM_D": {"has_no_defaults_at_init": True},
}
_CONFIG_ATTRS_MAPPING module-attribute
¶
_CONFIG_REGISTRY module-attribute
¶
_CONFIG_REGISTRY: dict[str, type[PretrainedConfig]] = (
LazyConfigDict(
chatglm="ChatGLMConfig",
deepseek_vl_v2="DeepseekVLV2Config",
kimi_vl="KimiVLConfig",
Llama_Nemotron_Nano_VL="Nemotron_Nano_VL_Config",
RefinedWeb="RWConfig",
RefinedWebModel="RWConfig",
jais="JAISConfig",
mlp_speculator="MLPSpeculatorConfig",
medusa="MedusaConfig",
eagle="EAGLEConfig",
speculators="SpeculatorsConfig",
nemotron="NemotronConfig",
ovis="OvisConfig",
ultravox="UltravoxConfig",
step3_vl="Step3VLConfig",
step3_text="Step3TextConfig",
)
)
ConfigFormat ¶
Source code in vllm/transformers_utils/config.py
_download_mistral_config_file ¶
_download_mistral_config_file(model, revision) -> dict
Source code in vllm/transformers_utils/config.py
_get_hf_token ¶
Get the HuggingFace token from environment variable.
Returns None if the token is not set, is an empty string, or contains only whitespace. This follows the same pattern as huggingface_hub library which treats empty string tokens as None to avoid authentication errors.
Source code in vllm/transformers_utils/config.py
_maybe_remap_hf_config_attrs ¶
Remap config attributes to match the expected names.
Source code in vllm/transformers_utils/config.py
_maybe_retrieve_max_pos_from_hf ¶
_maybe_retrieve_max_pos_from_hf(
model, revision, **kwargs
) -> int
Source code in vllm/transformers_utils/config.py
_maybe_update_auto_config_kwargs ¶
Update kwargs for AutoConfig initialization based on model_type
Source code in vllm/transformers_utils/config.py
file_exists ¶
file_exists(
repo_id: str,
file_name: str,
*,
repo_type: Optional[str] = None,
revision: Optional[str] = None,
token: Union[str, bool, None] = None,
) -> bool
Source code in vllm/transformers_utils/config.py
file_or_path_exists ¶
Source code in vllm/transformers_utils/config.py
get_config ¶
get_config(
model: Union[str, Path],
trust_remote_code: bool,
revision: Optional[str] = None,
code_revision: Optional[str] = None,
config_format: ConfigFormat = AUTO,
hf_overrides_kw: Optional[dict[str, Any]] = None,
hf_overrides_fn: Optional[
Callable[[PretrainedConfig], PretrainedConfig]
] = None,
**kwargs,
) -> PretrainedConfig
Source code in vllm/transformers_utils/config.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 |
|
get_hf_file_bytes ¶
get_hf_file_bytes(
file_name: str,
model: Union[str, Path],
revision: Optional[str] = "main",
) -> Optional[bytes]
Get file contents from HuggingFace repository as bytes.
Source code in vllm/transformers_utils/config.py
get_hf_file_to_dict ¶
Downloads a file from the Hugging Face Hub and returns its contents as a dictionary.
Parameters: - file_name (str): The name of the file to download. - model (str): The name of the model on the Hugging Face Hub. - revision (str): The specific version of the model.
Returns: - config_dict (dict): A dictionary containing the contents of the downloaded file.
Source code in vllm/transformers_utils/config.py
get_hf_image_processor_config ¶
get_hf_image_processor_config(
model: Union[str, Path],
hf_token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
**kwargs,
) -> dict[str, Any]
Source code in vllm/transformers_utils/config.py
get_hf_text_config ¶
Get the "sub" config relevant to llm for multi modal models. No op for pure text models.
Source code in vllm/transformers_utils/config.py
get_model_path ¶
Source code in vllm/transformers_utils/config.py
get_pooling_config cached
¶
This function gets the pooling and normalize config from the model - only applies to sentence-transformers models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model | str | The name of the Hugging Face model. | required |
revision | str | The specific version | 'main' |
Returns:
Name | Type | Description |
---|---|---|
dict | A dictionary containing the pooling | |
type and whether normalization is used. |
Source code in vllm/transformers_utils/config.py
get_pooling_config_name ¶
Source code in vllm/transformers_utils/config.py
get_sentence_transformer_tokenizer_config cached
¶
get_sentence_transformer_tokenizer_config(
model: Union[str, Path],
revision: Optional[str] = "main",
)
Returns the tokenization configuration dictionary for a given Sentence Transformer BERT model.
Parameters: - model (str|Path): The name of the Sentence Transformer BERT model. - revision (str, optional): The revision of the m odel to use. Defaults to 'main'.
Returns: - dict: A dictionary containing the configuration parameters for the Sentence Transformer BERT model.
Source code in vllm/transformers_utils/config.py
is_encoder_decoder ¶
is_encoder_decoder(config: PretrainedConfig) -> bool
Detect if the model with this config is used as an encoder/decoder.
Source code in vllm/transformers_utils/config.py
is_interleaved ¶
is_interleaved(config: PretrainedConfig) -> bool
Detect if the model with this config is used with interleaved attention.
Source code in vllm/transformers_utils/config.py
list_repo_files cached
¶
list_repo_files(
repo_id: str,
*,
revision: Optional[str] = None,
repo_type: Optional[str] = None,
token: Union[str, bool, None] = None,
) -> list[str]
Source code in vllm/transformers_utils/config.py
maybe_override_with_speculators_target_model ¶
maybe_override_with_speculators_target_model(
model: str,
tokenizer: str,
trust_remote_code: bool,
revision: Optional[str] = None,
**kwargs,
) -> tuple[str, str]
If running a speculators config, override running model with target model
Source code in vllm/transformers_utils/config.py
maybe_register_config_serialize_by_value ¶
Try to register HF model configuration class to serialize by value
If trust_remote_code is set, and the model's config file specifies an AutoConfig
class, then the config class is typically an instance of a custom class imported from the HF modules cache.
Examples:
from transformers import AutoConfig klass = AutoConfig.from_pretrained('meta-llama/Meta-Llama-3-8B', trust_remote_code=True) klass.class # transformers.models.llama.configuration_llama.LlamaConfig import transformers_modules # error, not initialized klass = AutoConfig.from_pretrained('deepseek-ai/DeepSeek-V2.5', trust_remote_code=True) import transformers_modules # success, initialized klass.class # transformers_modules.deepseek-ai.DeepSeek-V2.5.98b11844770b2c3ffc18b175c758a803640f4e77.configuration_deepseek.DeepseekV2Config
In the DeepSeek example, the config class is an instance of a custom class that is not serializable by default. This class will not be importable in spawned workers, and won't exist at all on other nodes, which breaks serialization of the config.
In this function we tell the cloudpickle serialization library to pass instances of these generated classes by value instead of by reference, i.e. the class definition is serialized along with its data so that the class module does not need to be importable on the receiving end.
See: https://github.com/cloudpipe/cloudpickle?tab=readme-ov-file#overriding-pickles-serialization-mechanism-for-importable-constructs
Source code in vllm/transformers_utils/config.py
patch_rope_scaling ¶
Provide backwards compatibility for RoPE.
Source code in vllm/transformers_utils/config.py
patch_rope_scaling_dict ¶
Source code in vllm/transformers_utils/config.py
thinker_uses_mrope ¶
thinker_uses_mrope(config: PretrainedConfig) -> bool
Detect if the model contains a thinker config and it uses M-ROPE.
Source code in vllm/transformers_utils/config.py
try_get_generation_config ¶
try_get_generation_config(
model: str,
trust_remote_code: bool,
revision: Optional[str] = None,
) -> Optional[GenerationConfig]
Source code in vllm/transformers_utils/config.py
try_get_local_file ¶
try_get_local_file(
model: Union[str, Path],
file_name: str,
revision: Optional[str] = "main",
) -> Optional[Path]
Source code in vllm/transformers_utils/config.py
try_get_safetensors_metadata ¶
Source code in vllm/transformers_utils/config.py
try_get_tokenizer_config ¶
try_get_tokenizer_config(
pretrained_model_name_or_path: Union[str, PathLike],
trust_remote_code: bool,
revision: Optional[str] = None,
) -> Optional[dict[str, Any]]
Source code in vllm/transformers_utils/config.py
uses_mrope ¶
uses_mrope(config: PretrainedConfig) -> bool
Detect if the model with this config uses M-ROPE.
with_retry ¶
with_retry(
func: Callable[[], _R],
log_msg: str,
max_retries: int = 2,
retry_delay: int = 2,
) -> _R