Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/model_executor/weight_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import os

import huggingface_hub.constants
import pytest

from vllm.model_executor.weight_utils import enable_hf_transfer


def test_hf_transfer_auto_activation():
if "HF_HUB_ENABLE_HF_TRANSFER" in os.environ:
# in case it is already set, we can't test the auto activation
pytest.skip(
"HF_HUB_ENABLE_HF_TRANSFER is set, can't test auto activation")
enable_hf_transfer()
try:
# enable hf hub transfer if available
Expand Down
19 changes: 12 additions & 7 deletions vllm/model_executor/weight_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@


def enable_hf_transfer():
"""enforces activation of hf_transfer if installed."""
try:
# enable hf hub transfer if available
import hf_transfer # type: ignore # noqa
huggingface_hub.constants.HF_HUB_ENABLE_HF_TRANSFER = True
except ImportError:
pass
"""automatically activates hf_transfer
"""
if "HF_HUB_ENABLE_HF_TRANSFER" in os.environ:
# no additional logic, use default behaviour.
return
else:
try:
# enable hf hub transfer if available
import hf_transfer # type: ignore # noqa
huggingface_hub.constants.HF_HUB_ENABLE_HF_TRANSFER = True
except ImportError:
pass
Comment thread
michaelfeil marked this conversation as resolved.
Resolved


enable_hf_transfer()
Expand Down