vllm.transformers_utils.gguf_utils ¶
GGUF utility functions.
_GGUF_QUANT_SUFFIXES module-attribute ¶
check_gguf_file cached ¶
Check if the file is a GGUF model.
Source code in vllm/transformers_utils/gguf_utils.py
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
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 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 | |
get_gguf_file_path_from_hf ¶
get_gguf_file_path_from_hf(
repo_id: str | Path,
quant_type: str,
revision: str | None = None,
) -> str
Get the GGUF file path from HuggingFace Hub based on repo_id and quant_type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_id | str | Path | The HuggingFace repository ID (e.g., "Qwen/Qwen3-0.6B") | required |
quant_type | str | The quantization type (e.g., "Q4_K_M", "F16") | required |
revision | str | None | Optional revision/branch name | None |
Returns:
| Type | Description |
|---|---|
str | The path to the GGUF file on HuggingFace Hub (e.g., "filename.gguf"), |
Source code in vllm/transformers_utils/gguf_utils.py
is_gguf ¶
Check if the model is a GGUF model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model | str | Path | Model name, path, or Path object to check. | required |
Returns:
| Type | Description |
|---|---|
bool | True if the model is a GGUF model, False otherwise. |
Source code in vllm/transformers_utils/gguf_utils.py
is_remote_gguf cached ¶
Check if the model is a remote GGUF model.
Source code in vllm/transformers_utils/gguf_utils.py
is_valid_gguf_quant_type ¶
Check if the quant type is a valid GGUF quant type.
Supports both exact GGML quant types (e.g., Q4_K, IQ1_S) and extended naming conventions (e.g., Q4_K_M, Q3_K_S, Q5_K_L).
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 |
Source code in vllm/transformers_utils/gguf_utils.py
split_remote_gguf ¶
Split the model into repo_id and quant type.