Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
22 changes: 20 additions & 2 deletions tests/test_common/llm_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,29 @@ def with_mocked_hf_download(func):

When applied, any calls to snapshot_download will be redirected to use
local model paths from LLM_MODELS_ROOT instead of downloading from HuggingFace.

NOTE: We must patch snapshot_download at the location where it's actually imported
with 'from huggingface_hub import snapshot_download', since that creates a
local binding that won't be affected by patching huggingface_hub.snapshot_download.

Additionally sets HF_HUB_OFFLINE=1 to ensure no network requests are made to
HuggingFace.
"""

@wraps(func)
def wrapper(*args, **kwargs):
with patch("huggingface_hub.snapshot_download", side_effect=mock_snapshot_download):
return func(*args, **kwargs)
original_offline = os.environ.get("HF_HUB_OFFLINE")
os.environ["HF_HUB_OFFLINE"] = "1"
Comment thread
anish-shanbhag marked this conversation as resolved.
Outdated

try:
with patch(
"tensorrt_llm.llmapi.utils.snapshot_download", side_effect=mock_snapshot_download
):
return func(*args, **kwargs)
finally:
if original_offline is None:
os.environ.pop("HF_HUB_OFFLINE", None)
else:
os.environ["HF_HUB_OFFLINE"] = original_offline

return wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@pytest.mark.skip(
reason="OOM on A30 GPUs on CI - speculative model loading does not support model_kwargs reduction"
)
@pytest.mark.parametrize("use_hf_speculative_model", [False])
@pytest.mark.parametrize("use_hf_speculative_model", [False, True])
@with_mocked_hf_download
def test_ad_speculative_decoding_smoke(use_hf_speculative_model: bool):
"""Test speculative decoding with AutoDeploy using the build_and_run_ad main()."""
Expand Down
Loading