Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Commit f9f3bc7

Browse files
tdoublepcyang49
authored andcommitted
add triton CustomCacheManger
fixes RHOAIENG-8043 Co-authored-by: Chih-Chieh-Yang <[email protected]> Signed-off-by: Thomas Parnell <[email protected]>
1 parent cc5d64a commit f9f3bc7

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

Dockerfile.ubi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ ENV PATH=$VIRTUAL_ENV/bin/:$PATH
180180
RUN microdnf install -y gcc \
181181
&& microdnf clean all
182182

183+
# Custom cache manager (fix for https://issues.redhat.com/browse/RHOAIENG-8043)
184+
COPY extras/custom_cache_manager.py /opt/vllm/lib/python3.11/site-packages/custom_cache_manager.py
185+
183186
# install vllm wheel first, so that torch etc will be installed
184187
RUN --mount=type=bind,from=build,src=/workspace/dist,target=/workspace/dist \
185188
--mount=type=cache,target=/root/.cache/pip \
@@ -189,7 +192,8 @@ ENV HF_HUB_OFFLINE=1 \
189192
PORT=8000 \
190193
HOME=/home/vllm \
191194
VLLM_USAGE_SOURCE=production-docker-image \
192-
VLLM_WORKER_MULTIPROC_METHOD=fork
195+
VLLM_WORKER_MULTIPROC_METHOD=fork \
196+
TRITON_CACHE_MANAGER="custom_cache_manager:CustomCacheManager"
193197

194198
# setup non-root user for OpenShift
195199
RUN umask 002 \

extras/custom_cache_manager.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import os
2+
3+
from triton.runtime.cache import (FileCacheManager, default_cache_dir,
4+
default_dump_dir, default_override_dir)
5+
6+
7+
class CustomCacheManager(FileCacheManager):
8+
9+
def __init__(self, key, override=False, dump=False):
10+
self.key = key
11+
self.lock_path = None
12+
if dump:
13+
self.cache_dir = default_dump_dir()
14+
self.cache_dir = os.path.join(self.cache_dir, self.key)
15+
self.lock_path = os.path.join(self.cache_dir, "lock")
16+
os.makedirs(self.cache_dir, exist_ok=True)
17+
elif override:
18+
self.cache_dir = default_override_dir()
19+
self.cache_dir = os.path.join(self.cache_dir, self.key)
20+
else:
21+
# create cache directory if it doesn't exist
22+
self.cache_dir = os.getenv("TRITON_CACHE_DIR",
23+
"").strip() or default_cache_dir()
24+
if self.cache_dir:
25+
self.cache_dir = f"{self.cache_dir}_{os.getpid()}"
26+
self.cache_dir = os.path.join(self.cache_dir, self.key)
27+
self.lock_path = os.path.join(self.cache_dir, "lock")
28+
os.makedirs(self.cache_dir, exist_ok=True)
29+
else:
30+
raise RuntimeError("Could not create or locate cache dir")
31+
32+
print(f"Triton cache dir: {self.cache_dir=}")

0 commit comments

Comments
 (0)