Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions docs/usage/environment_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ environment_variables: dict[str, Callable[[], Any]] = {
"FD_USE_DEEP_GEMM":
lambda: bool(int(os.getenv("FD_USE_DEEP_GEMM", "0"))),

# Whether to enable model cache feature
"FD_ENABLE_MODEL_LOAD_CACHE": lambda: bool(int(os.getenv("FD_ENABLE_MODEL_LOAD_CACHE", "0"))),

# Whether to use Machete for wint4 dense GEMM.
"FD_USE_MACHETE": lambda: os.getenv("FD_USE_MACHETE", "0"),

}
```
3 changes: 3 additions & 0 deletions docs/zh/usage/environment_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ environment_variables: dict[str, Callable[[], Any]] = {
"FD_USE_DEEP_GEMM":
lambda: bool(int(os.getenv("FD_USE_DEEP_GEMM", "0"))),

# 是否启用模型权重缓存功能
"FD_ENABLE_MODEL_LOAD_CACHE": lambda: bool(int(os.getenv("FD_ENABLE_MODEL_LOAD_CACHE", "0"))),

# 是否使用 Machete 后端的 wint4 GEMM.
"FD_USE_MACHETE": lambda: os.getenv("FD_USE_MACHETE", "0"),
}
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
# Whether to use new get_output and save_output method (0 or 1)
"FD_USE_GET_SAVE_OUTPUT_V1": lambda: bool(int(os.getenv("FD_USE_GET_SAVE_OUTPUT_V1", "0"))),
# Whether to enable model cache feature
"FD_ENABLE_MODEL_CACHE": lambda: bool(int(os.getenv("FD_ENABLE_MODEL_CACHE", "0"))),
"FD_ENABLE_MODEL_LOAD_CACHE": lambda: bool(int(os.getenv("FD_ENABLE_MODEL_LOAD_CACHE", "0"))),
}


Expand Down
8 changes: 6 additions & 2 deletions fastdeploy/model_executor/load_weight_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def is_weight_cache_enabled(fd_config, weight_cache_path=".cache"):
weight_cache_context = contextlib.nullcontext()
weight_cache_dir = None
enable_cache = False
if envs.FD_ENABLE_MODEL_CACHE:
if envs.FD_ENABLE_MODEL_LOAD_CACHE:
model_weight_cache_path = os.path.join(fd_config.model_config.model, weight_cache_path)
# model_type + quantization + tp_size + ep_size
weight_cache_key = "_".join(
Expand Down Expand Up @@ -132,7 +132,11 @@ def wrapper(*args, **kwargs):

with context:
result = func(*args, **kwargs)
if envs.FD_ENABLE_MODEL_CACHE and weight_cache_dir is not None and not os.path.exists(weight_cache_dir):
if (
envs.FD_ENABLE_MODEL_LOAD_CACHE
and weight_cache_dir is not None
and not os.path.exists(weight_cache_dir)
):
assert fd_config.quant_config is not None and getattr(
fd_config.quant_config, "is_checkpoint_bf16", False
), "Save cache only for dynamic quantization"
Expand Down
2 changes: 1 addition & 1 deletion tests/model_loader/test_model_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"quantizations": [
{
"quant_type": "wint4",
"env": {"FD_ENABLE_MODEL_CACHE": "1"},
"env": {"FD_ENABLE_MODEL_LOAD_CACHE": "1"},
}
],
}
Expand Down
Loading