Implementation:Vllm project Vllm Snapshot Download LoRA
| Knowledge Sources | |
|---|---|
| Domains | LLM Serving, Model Adaptation, Weight Management |
| Last Updated | 2026-02-08 13:00 GMT |
Overview
Concrete tool for downloading LoRA adapter weights from HuggingFace Hub to local filesystem provided by the huggingface_hub library.
Description
The snapshot_download function from huggingface_hub downloads all files from a specified HuggingFace repository to a local cache directory. In the multi-LoRA serving workflow, it is used to fetch LoRA adapter weight files (such as adapter_config.json and adapter_model.safetensors) so they can be referenced by LoRARequest objects when submitting inference requests. The function returns the local filesystem path to the downloaded snapshot, which is passed directly as the lora_path argument when constructing LoRA requests.
Usage
Use this function to download LoRA adapter repositories from HuggingFace Hub before starting inference. This is typically called once during setup, before constructing LoRARequest objects. The allow_patterns parameter can be used to filter which files are downloaded, reducing bandwidth and storage when only specific files are needed.
Code Reference
Source Location
- Repository: vllm
- File: examples/offline_inference/multilora_inference.py (usage), huggingface_hub library (source)
Signature
def snapshot_download(
repo_id: str,
repo_type: str | None = None,
revision: str | None = None,
cache_dir: str | Path | None = None,
local_dir: str | Path | None = None,
allow_patterns: list[str] | str | None = None,
ignore_patterns: list[str] | str | None = None,
token: str | bool | None = None,
) -> str
Import
from huggingface_hub import snapshot_download
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| repo_id | str | Yes | The HuggingFace repository ID containing LoRA adapter weights (e.g., "jeeejeee/llama32-3b-text2sql-spider") |
| repo_type | str or None | No | Type of repository ("model", "dataset", "space"). Defaults to "model". |
| revision | str or None | No | Git revision (branch, tag, or commit hash) to download. Defaults to main branch. |
| cache_dir | str, Path, or None | No | Path to the cache directory. Defaults to HuggingFace default cache. |
| local_dir | str, Path, or None | No | If set, files are downloaded to this directory instead of the cache. |
| allow_patterns | list[str], str, or None | No | Glob patterns to filter which files to download (e.g., ["*.safetensors", "*.json"]). |
| ignore_patterns | list[str], str, or None | No | Glob patterns to exclude files from downloading. |
| token | str, bool, or None | No | Authentication token for private repositories. True uses the stored token. |
Outputs
| Name | Type | Description |
|---|---|---|
| snapshot_path | str | Local filesystem path to the downloaded snapshot directory containing all adapter files |
Usage Examples
Download LoRA Adapter for Multi-LoRA Serving
from huggingface_hub import snapshot_download
# Download the LoRA adapter weights to local cache
lora_path = snapshot_download(repo_id="jeeejeee/llama32-3b-text2sql-spider")
# lora_path is now a local directory path like:
# "/home/user/.cache/huggingface/hub/models--jeeejeee--llama32-3b-text2sql-spider/snapshots/abc123"
# This path is passed to LoRARequest when creating inference requests
Download with Filtered Patterns
from huggingface_hub import snapshot_download
# Download only the essential adapter files
lora_path = snapshot_download(
repo_id="jeeejeee/llama32-3b-text2sql-spider",
allow_patterns=["*.safetensors", "*.json"],
)