vllm.transformers_utils.config
_CONFIG_ATTRS_MAPPING
module-attribute
¶
_CONFIG_REGISTRY
module-attribute
¶
_CONFIG_REGISTRY: dict[str, type[PretrainedConfig]] = {
"chatglm": ChatGLMConfig,
"cohere2": Cohere2Config,
"dbrx": DbrxConfig,
"deepseek_vl_v2": DeepseekVLV2Config,
"kimi_vl": KimiVLConfig,
"mpt": MPTConfig,
"RefinedWeb": RWConfig,
"RefinedWebModel": RWConfig,
"jais": JAISConfig,
"mlp_speculator": MLPSpeculatorConfig,
"medusa": MedusaConfig,
"eagle": EAGLEConfig,
"exaone": ExaoneConfig,
"minimax_text_01": MiniMaxText01Config,
"minimax_vl_01": MiniMaxVL01Config,
"nemotron": NemotronConfig,
"NVLM_D": NVLM_D_Config,
"ovis": OvisConfig,
"solar": SolarConfig,
"skywork_chat": SkyworkR1VChatConfig,
"telechat": Telechat2Config,
"ultravox": UltravoxConfig,
None: _CONFIG_REGISTRY_OVERRIDE_HF,
}
_CONFIG_REGISTRY_OVERRIDE_HF
module-attribute
¶
_CONFIG_REGISTRY_OVERRIDE_HF: dict[
str, type[PretrainedConfig]
] = {"mllama": MllamaConfig}
ConfigFormat
¶
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
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,
**kwargs,
) -> PretrainedConfig
Source code in vllm/transformers_utils/config.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 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 |
|
get_cross_encoder_activation_function
¶
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_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
¶
Returns the tokenization configuration dictionary for a given Sentence Transformer BERT model.
Parameters: - model (str): 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
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
load_params_config
¶
load_params_config(
model: Union[str, Path],
revision: Optional[str],
**kwargs,
) -> PretrainedConfig
Source code in vllm/transformers_utils/config.py
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 |
|
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
with_retry
¶
with_retry(
func: Callable[[], _R],
log_msg: str,
max_retries: int = 2,
retry_delay: int = 2,
) -> _R