Skip to content

Fix cache dir import #2409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 12 additions & 2 deletions torchao/prototype/galore/kernels/custom_autotune.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from typing import Dict

import numpy as np
from triton.runtime.cache import default_cache_dir
from triton.runtime.errors import OutOfResources
from triton.runtime.jit import KernelInterface
from triton.testing import do_bench
Expand Down Expand Up @@ -183,7 +182,18 @@ def run(self, *args, **kwargs):
)
_key_suffix = self._get_key_combination(args, sep="-")
autotune_file = f"autotune_{self.kernel_name}_{_key_suffix}.log"
autotune_log_path = os.path.join(default_cache_dir(), autotune_file)
# In newer Triton we always use knobs
# This try-catch is here only to support Triton upgrading
try:
from triton import knobs

# this API takes into consideration env var and redirecting user home dir for fbcode
triton_cache_dir = knobs.cache.dir
except ImportError:
from triton.runtime.cache import default_cache_dir

triton_cache_dir = default_cache_dir()
autotune_log_path = os.path.join(triton_cache_dir, autotune_file)

logger.info(f"\nFinished autotune, writing log to {autotune_log_path}")

Expand Down
Loading