Skip to content

vllm_omni.model_executor.model_loader.weight_utils

logger module-attribute

logger = init_logger(__name__)

download_weights_from_hf_specific

download_weights_from_hf_specific(
    model_name_or_path: str,
    cache_dir: str | None,
    allow_patterns: list[str],
    revision: str | None = None,
    ignore_patterns: str | list[str] | None = None,
    require_all: bool = False,
) -> str

Download model weights from Hugging Face Hub. Users can specify the allow_patterns to download only the necessary weights.

Parameters:

Name Type Description Default
model_name_or_path str

The model name or path.

required
cache_dir Optional[str]

The cache directory to store the model weights. If None, will use HF defaults.

required
allow_patterns list[str]

The allowed patterns for the weight files. Files matched by any of the patterns will be downloaded.

required
revision Optional[str]

The revision of the model.

None
ignore_patterns Optional[Union[str, list[str]]]

The patterns to filter out the weight files. Files matched by any of the patterns will be ignored.

None
require_all bool

If True, will iterate through and download files matching all patterns in allow_patterns. If False, will stop after the first pattern that matches any files.

False

Returns:

Name Type Description
str str

The path to the downloaded model weights.

resolve_model_to_local_path

resolve_model_to_local_path(
    model: str,
    *,
    allow_download: bool = False,
    allow_patterns: list[str] | None = None,
    cache_dir: str | None = None,
) -> str

Resolve a model reference to a local directory. Failure is always raised: whether a failure is fatal is the caller's decision.

Parameters:

Name Type Description Default
model str

A local directory or an HF Hub repo ID.

required
allow_download bool

Fetch missing files instead of requiring a warm cache. Downloads go through :func:download_weights_from_hf_specific

False
allow_patterns list[str] | None

Restrict the fetch to these glob patterns. Defaults to the whole repository. Ignored when model is already a directory.

None
cache_dir str | None

Download cache location; None uses the HF default.

None

Returns:

Type Description
str

Path to a local directory containing the model files.