Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
tilelang
Commits
422fb129
Unverified
Commit
422fb129
authored
Dec 02, 2025
by
Chaofan Lin
Committed by
GitHub
Dec 02, 2025
Browse files
[Enhancement] Add DISABLE_CACHE environment variables (#1368)
parent
6501bd07
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
+20
-10
tilelang/autotuner/tuner.py
tilelang/autotuner/tuner.py
+2
-2
tilelang/env.py
tilelang/env.py
+18
-8
No files found.
tilelang/autotuner/tuner.py
View file @
422fb129
...
@@ -325,7 +325,7 @@ class AutoTuner:
...
@@ -325,7 +325,7 @@ class AutoTuner:
key
=
self
.
generate_cache_key
(
parameters
,
extra_parameters
)
key
=
self
.
generate_cache_key
(
parameters
,
extra_parameters
)
with
self
.
_lock
:
with
self
.
_lock
:
if
env
.
is_cache_enabled
():
if
env
.
is_cache_enabled
()
and
not
env
.
is_autotune_cache_disabled
()
:
# First check in-memory cache
# First check in-memory cache
if
key
in
self
.
_memory_cache
:
if
key
in
self
.
_memory_cache
:
logger
.
warning
(
"Found kernel in memory cache. For better performance,"
\
logger
.
warning
(
"Found kernel in memory cache. For better performance,"
\
...
@@ -601,7 +601,7 @@ class AutoTuner:
...
@@ -601,7 +601,7 @@ class AutoTuner:
logger
.
warning
(
"DLPack backend does not support cache saving to disk."
)
logger
.
warning
(
"DLPack backend does not support cache saving to disk."
)
else
:
else
:
with
self
.
_lock
:
with
self
.
_lock
:
if
env
.
is_cache_enabled
():
if
env
.
is_cache_enabled
()
and
not
env
.
is_autotune_cache_disabled
()
:
self
.
_save_result_to_disk
(
key
,
autotuner_result
)
self
.
_save_result_to_disk
(
key
,
autotuner_result
)
self
.
_memory_cache
[
key
]
=
autotuner_result
self
.
_memory_cache
[
key
]
=
autotuner_result
...
...
tilelang/env.py
View file @
422fb129
...
@@ -196,12 +196,6 @@ class EnvVar:
...
@@ -196,12 +196,6 @@ class EnvVar:
# os.environ[self.key] = value
# os.environ[self.key] = value
# Cache control API (wrap CacheState)
enable_cache
=
CacheState
.
enable
disable_cache
=
CacheState
.
disable
is_cache_enabled
=
CacheState
.
is_enabled
# Utility function for environment variables with defaults
# Utility function for environment variables with defaults
# Assuming EnvVar and CacheState are defined elsewhere
# Assuming EnvVar and CacheState are defined elsewhere
class
Environment
:
class
Environment
:
...
@@ -234,13 +228,18 @@ class Environment:
...
@@ -234,13 +228,18 @@ class Environment:
# Kernel Build options
# Kernel Build options
TILELANG_PRINT_ON_COMPILATION
=
EnvVar
(
"TILELANG_PRINT_ON_COMPILATION"
,
TILELANG_PRINT_ON_COMPILATION
=
EnvVar
(
"TILELANG_PRINT_ON_COMPILATION"
,
"1"
)
# print kernel name on compile
"1"
)
# print kernel name on compile
TILELANG_CLEAR_CACHE
=
EnvVar
(
"TILELANG_CLEAR_CACHE"
,
"0"
)
# clear cache automatically if set
TILELANG_DISABLE_CACHE
=
EnvVar
(
"TILELANG_DISABLE_CACHE"
,
"0"
)
# disable kernel cache, usually for unit testing / debugging, high priority
TILELANG_CLEAR_CACHE
=
EnvVar
(
"TILELANG_CLEAR_CACHE"
,
"0"
)
# DEPRECATED! clear cache automatically if set
# Kernel selection options
# Kernel selection options
# Default to GEMM v2; set to "1"/"true"/"yes"/"on" to force v1
# Default to GEMM v2; set to "1"/"true"/"yes"/"on" to force v1
TILELANG_USE_GEMM_V1
=
EnvVar
(
"TILELANG_USE_GEMM_V1"
,
"0"
)
TILELANG_USE_GEMM_V1
=
EnvVar
(
"TILELANG_USE_GEMM_V1"
,
"0"
)
# Auto-tuning settings
# Auto-tuning settings
TILELANG_AUTO_TUNING_DISABLE_CACHE
=
EnvVar
(
"TILELANG_AUTO_TUNING_DISABLE_CACHE"
,
"0"
)
TILELANG_AUTO_TUNING_CPU_UTILITIES
=
EnvVar
(
"TILELANG_AUTO_TUNING_CPU_UTILITIES"
,
TILELANG_AUTO_TUNING_CPU_UTILITIES
=
EnvVar
(
"TILELANG_AUTO_TUNING_CPU_UTILITIES"
,
"0.9"
)
# percent of CPUs used
"0.9"
)
# percent of CPUs used
TILELANG_AUTO_TUNING_CPU_COUNTS
=
EnvVar
(
"TILELANG_AUTO_TUNING_CPU_COUNTS"
,
TILELANG_AUTO_TUNING_CPU_COUNTS
=
EnvVar
(
"TILELANG_AUTO_TUNING_CPU_COUNTS"
,
...
@@ -267,7 +266,7 @@ class Environment:
...
@@ -267,7 +266,7 @@ class Environment:
# Cache control API (wrap CacheState)
# Cache control API (wrap CacheState)
def
is_cache_enabled
(
self
)
->
bool
:
def
is_cache_enabled
(
self
)
->
bool
:
return
CacheState
.
is_enabled
()
return
not
self
.
is_cache_globally_disabled
()
and
CacheState
.
is_enabled
()
def
enable_cache
(
self
)
->
None
:
def
enable_cache
(
self
)
->
None
:
CacheState
.
enable
()
CacheState
.
enable
()
...
@@ -275,6 +274,12 @@ class Environment:
...
@@ -275,6 +274,12 @@ class Environment:
def
disable_cache
(
self
)
->
None
:
def
disable_cache
(
self
)
->
None
:
CacheState
.
disable
()
CacheState
.
disable
()
def
is_cache_globally_disabled
(
self
)
->
bool
:
return
self
.
TILELANG_DISABLE_CACHE
.
lower
()
in
(
"1"
,
"true"
,
"yes"
,
"on"
)
def
is_autotune_cache_disabled
(
self
)
->
bool
:
return
self
.
TILELANG_AUTO_TUNING_DISABLE_CACHE
.
lower
()
in
(
"1"
,
"true"
,
"yes"
,
"on"
)
def
is_print_on_compilation_enabled
(
self
)
->
bool
:
def
is_print_on_compilation_enabled
(
self
)
->
bool
:
return
self
.
TILELANG_PRINT_ON_COMPILATION
.
lower
()
in
(
"1"
,
"true"
,
"yes"
,
"on"
)
return
self
.
TILELANG_PRINT_ON_COMPILATION
.
lower
()
in
(
"1"
,
"true"
,
"yes"
,
"on"
)
...
@@ -290,6 +295,11 @@ class Environment:
...
@@ -290,6 +295,11 @@ class Environment:
# Instantiate as a global configuration object
# Instantiate as a global configuration object
env
=
Environment
()
env
=
Environment
()
# Cache control API (wrap env, which is managed by CacheState and Environment Variables jointly)
enable_cache
=
env
.
enable_cache
# CacheState.enable
disable_cache
=
env
.
disable_cache
# CacheState.disable
is_cache_enabled
=
env
.
is_cache_enabled
# CacheState.is_enabled
# Export CUDA_HOME and ROCM_HOME, both are static variables
# Export CUDA_HOME and ROCM_HOME, both are static variables
# after initialization.
# after initialization.
CUDA_HOME
=
env
.
CUDA_HOME
CUDA_HOME
=
env
.
CUDA_HOME
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment