forked from vllm-project/vllm
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes RHOAIENG-8043 Co-authored-by: Chih-Chieh-Yang <[email protected]> Signed-off-by: Thomas Parnell <[email protected]>
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
|
||
from triton.runtime.cache import (FileCacheManager, default_cache_dir, | ||
default_dump_dir, default_override_dir) | ||
|
||
|
||
class CustomCacheManager(FileCacheManager): | ||
|
||
def __init__(self, key, override=False, dump=False): | ||
self.key = key | ||
self.lock_path = None | ||
if dump: | ||
self.cache_dir = default_dump_dir() | ||
self.cache_dir = os.path.join(self.cache_dir, self.key) | ||
self.lock_path = os.path.join(self.cache_dir, "lock") | ||
os.makedirs(self.cache_dir, exist_ok=True) | ||
elif override: | ||
self.cache_dir = default_override_dir() | ||
self.cache_dir = os.path.join(self.cache_dir, self.key) | ||
else: | ||
# create cache directory if it doesn't exist | ||
self.cache_dir = os.getenv("TRITON_CACHE_DIR", | ||
"").strip() or default_cache_dir() | ||
if self.cache_dir: | ||
self.cache_dir = f"{self.cache_dir}_{os.getpid()}" | ||
self.cache_dir = os.path.join(self.cache_dir, self.key) | ||
self.lock_path = os.path.join(self.cache_dir, "lock") | ||
os.makedirs(self.cache_dir, exist_ok=True) | ||
else: | ||
raise RuntimeError("Could not create or locate cache dir") | ||
|
||
print(f"Triton cache dir: {self.cache_dir=}") |