Skip to content

Commit f1d637e

Browse files
authored
[None][fix] AutoDeploy: Use tmp folder for the load_moe_align (#9101)
Signed-off-by: Chenghao Zhang <211069071+nvchenghaoz@users.noreply.github.com>
1 parent 9241cca commit f1d637e

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

tensorrt_llm/_torch/auto_deploy/custom_ops/fused_moe/load_moe_align.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import os
7+
import tempfile
78

89
import torch
910
from torch.utils.cpp_extension import load
@@ -12,21 +13,10 @@
1213
os.environ.setdefault("TORCH_CUDA_ARCH_LIST", "8.0;8.6;8.9;9.0")
1314

1415
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
15-
CACHE_ROOT = os.environ.get("AD_CACHE_DIR") or os.path.join(
16-
os.environ.get("XDG_CACHE_HOME", os.path.join(os.path.expanduser("~"), ".cache")),
17-
"ad_cache",
18-
)
19-
BUILD_DIR = os.path.join(CACHE_ROOT, "auto_deploy", "fused_moe", "moe_align")
20-
try:
21-
os.makedirs(BUILD_DIR, exist_ok=True)
22-
except PermissionError:
23-
import tempfile
2416

25-
# Fallback to the system temp dir while maintaining a stable subfolder layout
26-
BUILD_DIR = os.path.join(
27-
tempfile.gettempdir(), "ad_cache", "auto_deploy", "fused_moe", "moe_align"
28-
)
29-
os.makedirs(BUILD_DIR, exist_ok=True)
17+
# Use system temp directory to avoid environment variable dependency
18+
BUILD_DIR = os.path.join(tempfile.gettempdir(), "ad_cache", "auto_deploy", "fused_moe", "moe_align")
19+
os.makedirs(BUILD_DIR, exist_ok=True)
3020

3121
moe_align_ext = load(
3222
name="moe_align_ext",

0 commit comments

Comments
 (0)