Skip to content

Commit ff91749

Browse files
authored
[REFACTOR] Terminology download=>download_cache (#2425)
This PR renames download to download_cache for better clarity.
1 parent 8b38a4b commit ff91749

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

python/mlc_llm/chat_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def _get_model_path(model: str) -> Tuple[str, str]:
355355
FileNotFoundError: if we cannot find a valid `model_path`.
356356
"""
357357
if model.startswith("HF://"):
358-
from mlc_llm.support.download import ( # pylint: disable=import-outside-toplevel
358+
from mlc_llm.support.download_cache import ( # pylint: disable=import-outside-toplevel
359359
download_and_cache_mlc_weights,
360360
)
361361

python/mlc_llm/cli/delivery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from mlc_llm.support import logging
1818
from mlc_llm.support.argparse import ArgumentParser
1919
from mlc_llm.support.constants import MLC_TEMP_DIR
20-
from mlc_llm.support.download import git_clone
20+
from mlc_llm.support.download_cache import git_clone
2121
from mlc_llm.support.style import bold, green, red
2222

2323
logging.enable_logging()

python/mlc_llm/interface/package.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from typing import Any, Dict, List, Literal
1111

1212
from mlc_llm.interface import jit
13-
from mlc_llm.support import download, logging, style
13+
from mlc_llm.support import download_cache, logging, style
1414

1515
logging.enable_logging()
1616
logger = logging.getLogger(__name__)
@@ -70,7 +70,7 @@ def build_model_library( # pylint: disable=too-many-branches,too-many-locals,to
7070
raise ValueError('The value of "model_lib" in "model_list" is expected to be string.')
7171

7272
# - Load model config. Download happens when needed.
73-
model_path = download.get_or_download_model(model)
73+
model_path = download_cache.get_or_download_model(model)
7474

7575
# - Jit compile if the model lib path is not specified.
7676
model_lib_path = (

python/mlc_llm/serve/engine_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from mlc_llm.serve.config import EngineConfig, GenerationConfig
2424
from mlc_llm.serve.event_trace_recorder import EventTraceRecorder
2525
from mlc_llm.streamer import TextStreamer
26-
from mlc_llm.support import download, logging
26+
from mlc_llm.support import download_cache, logging
2727
from mlc_llm.support.auto_device import detect_device
2828
from mlc_llm.support.style import green
2929
from mlc_llm.tokenizer import Tokenizer
@@ -120,7 +120,7 @@ def _process_model_args(
120120
def _convert_model_info(model: ModelInfo) -> Tuple[str, str]:
121121
nonlocal conversation
122122

123-
model_path = download.get_or_download_model(model.model)
123+
model_path = download_cache.get_or_download_model(model.model)
124124
mlc_config_path = model_path / "mlc-chat-config.json"
125125
config_file_paths.append(str(mlc_config_path))
126126

python/mlc_llm/support/auto_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def detect_mlc_chat_config(mlc_chat_config: str) -> Path:
3535
# pylint: disable=import-outside-toplevel
3636
from mlc_llm.model import MODEL_PRESETS
3737

38-
from .download import download_and_cache_mlc_weights
38+
from .download_cache import download_and_cache_mlc_weights
3939

4040
# pylint: enable=import-outside-toplevel
4141

python/mlc_llm/support/constants.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ def _check():
1515
f"but got {MLC_JIT_POLICY}."
1616
)
1717

18-
if MLC_DOWNLOAD_POLICY not in ["ON", "OFF", "REDO", "READONLY"]:
18+
if MLC_DOWNLOAD_CACHE_POLICY not in ["ON", "OFF", "REDO", "READONLY"]:
1919
raise ValueError(
2020
"Invalid MLC_AUTO_DOWNLOAD_POLICY. "
2121
'It has to be one of "ON", "OFF", "REDO", "READONLY"'
22-
f"but got {MLC_DOWNLOAD_POLICY}."
22+
f"but got {MLC_DOWNLOAD_CACHE_POLICY}."
2323
)
2424

2525

@@ -80,7 +80,7 @@ def _get_read_only_weight_caches() -> List[Path]:
8080
MLC_DSO_SUFFIX = _get_dso_suffix()
8181
MLC_TEST_MODEL_PATH: List[Path] = _get_test_model_path()
8282

83-
MLC_DOWNLOAD_POLICY = os.environ.get("MLC_DOWNLOAD_POLICY", "ON")
83+
MLC_DOWNLOAD_CACHE_POLICY = os.environ.get("MLC_DOWNLOAD_CACHE_POLICY", "ON")
8484
MLC_LLM_HOME: Path = _get_cache_dir()
8585
MLC_LLM_READONLY_WEIGHT_CACHE = _get_read_only_weight_caches()
8686

python/mlc_llm/support/download.py renamed to python/mlc_llm/support/download_cache.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from . import logging, tqdm
1616
from .constants import (
17-
MLC_DOWNLOAD_POLICY,
17+
MLC_DOWNLOAD_CACHE_POLICY,
1818
MLC_LLM_HOME,
1919
MLC_LLM_READONLY_WEIGHT_CACHE,
2020
MLC_TEMP_DIR,
@@ -24,12 +24,12 @@
2424
logger = logging.getLogger(__name__)
2525

2626

27-
def log_download_policy():
27+
def log_download_cache_policy():
2828
"""log current download policy"""
2929
logger.info(
3030
"%s = %s. Can be one of: ON, OFF, REDO, READONLY",
31-
bold("MLC_DOWNLOAD_POLICY"),
32-
MLC_DOWNLOAD_POLICY,
31+
bold("MLC_DOWNLOAD_CACHE_POLICY"),
32+
MLC_DOWNLOAD_CACHE_POLICY,
3333
)
3434

3535

@@ -130,9 +130,9 @@ def download_and_cache_mlc_weights( # pylint: disable=too-many-locals
130130
force_redo: Optional[bool] = None,
131131
) -> Path:
132132
"""Download weights for a model from the HuggingFace Git LFS repo."""
133-
log_download_policy()
134-
if MLC_DOWNLOAD_POLICY == "OFF":
135-
raise RuntimeError(f"Cannot download {model_url} as MLC_DOWNLOAD_POLICY=OFF")
133+
log_download_cache_policy()
134+
if MLC_DOWNLOAD_CACHE_POLICY == "OFF":
135+
raise RuntimeError(f"Cannot download {model_url} as MLC_DOWNLOAD_CACHE_POLICY=OFF")
136136

137137
prefixes, mlc_prefix = ["HF://", "https://huggingface.co/"], ""
138138
mlc_prefix = next(p for p in prefixes if model_url.startswith(p))
@@ -155,7 +155,7 @@ def download_and_cache_mlc_weights( # pylint: disable=too-many-locals
155155
return cache_dir
156156

157157
if force_redo is None:
158-
force_redo = MLC_DOWNLOAD_POLICY == "REDO"
158+
force_redo = MLC_DOWNLOAD_CACHE_POLICY == "REDO"
159159

160160
git_dir = MLC_LLM_HOME / "model_weights" / domain / user / repo
161161
readonly_cache_dirs.append(str(git_dir))
@@ -166,10 +166,10 @@ def download_and_cache_mlc_weights( # pylint: disable=too-many-locals
166166
logger.info("Weights already downloaded: %s", bold(str(git_dir)))
167167
return git_dir
168168

169-
if MLC_DOWNLOAD_POLICY == "READONLY":
169+
if MLC_DOWNLOAD_CACHE_POLICY == "READONLY":
170170
raise RuntimeError(
171171
f"Cannot find cache for {model_url}, "
172-
"cannot proceed to download as MLC_DOWNLOAD_POLICY=READONLY, "
172+
"cannot proceed to download as MLC_DOWNLOAD_CACHE_POLICY=READONLY, "
173173
"please check settings MLC_LLM_READONLY_WEIGHT_CACHE, "
174174
f"local path candidates: {readonly_cache_dirs}"
175175
)

0 commit comments

Comments
 (0)