vllm.transformers_utils.gguf_utils ¶
GGUF utility functions.
detect_gguf_multimodal ¶
Check if GGUF model has multimodal projector file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model | str | Model path string | required |
Returns:
| Type | Description |
|---|---|
Path | None | Path to mmproj file if found, None otherwise |
Source code in vllm/transformers_utils/gguf_utils.py
extract_vision_config_from_gguf ¶
extract_vision_config_from_gguf(
mmproj_path: str,
) -> SiglipVisionConfig | None
Extract vision config parameters from mmproj.gguf metadata.
Reads vision encoder configuration from GGUF metadata fields using standardized GGUF constants. Automatically detects the projector type (e.g., gemma3, llama4) and applies model-specific parameters accordingly.
The function extracts standard CLIP vision parameters from GGUF metadata and applies projector-type-specific customizations. For unknown projector types, it uses safe defaults from SiglipVisionConfig.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mmproj_path | str | Path to mmproj.gguf file (str or Path) | required |
Returns:
| Type | Description |
|---|---|
SiglipVisionConfig | None | SiglipVisionConfig if extraction succeeds, None if any required |
SiglipVisionConfig | None | field is missing from the GGUF metadata |
Raises:
| Type | Description |
|---|---|
Exception | Exceptions from GGUF reading (file not found, corrupted file, etc.) propagate directly from gguf.GGUFReader |
Source code in vllm/transformers_utils/gguf_utils.py
maybe_patch_hf_config_from_gguf ¶
maybe_patch_hf_config_from_gguf(
model: str, hf_config: PretrainedConfig
) -> PretrainedConfig
Patch HF config for GGUF models.
Applies GGUF-specific patches to HuggingFace config: 1. For multimodal models: patches architecture and vision config 2. For all GGUF models: overrides vocab_size from embedding tensor
This ensures compatibility with GGUF models that have extended vocabularies (e.g., Unsloth) where the GGUF file contains more tokens than the HuggingFace tokenizer config specifies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model | str | Model path string | required |
hf_config | PretrainedConfig | HuggingFace config to patch in-place | required |
Returns:
| Type | Description |
|---|---|
PretrainedConfig | Updated HuggingFace config |