tilelang.envΒΆ
AttributesΒΆ
, which may lead to compilation bugs when utilize tilelang backend. |
|
, which may lead to compilation bugs when utilize tilelang backend. |
|
, which may lead to compilation bugs when utilize tilelang backend. |
|
ClassesΒΆ
Class to manage global kernel caching state. |
|
Descriptor for managing access to a single environment variable. |
|
Environment configuration for TileLang. |
Module ContentsΒΆ
- tilelang.env.loggerΒΆ
- tilelang.env.CUTLASS_NOT_FOUND_MESSAGE = 'CUTLASS is not installed or found in the expected path'ΒΆ
, which may lead to compilation bugs when utilize tilelang backend.
- tilelang.env.COMPOSABLE_KERNEL_NOT_FOUND_MESSAGE = 'Composable Kernel is not installed or found in the expected path'ΒΆ
, which may lead to compilation bugs when utilize tilelang backend.
- tilelang.env.TL_TEMPLATE_NOT_FOUND_MESSAGE = 'TileLang is not installed or found in the expected path'ΒΆ
, which may lead to compilation bugs when utilize tilelang backend.
- tilelang.env.TVM_LIBRARY_NOT_FOUND_MESSAGE = 'TVM is not installed or found in the expected path'ΒΆ
- class tilelang.env.CacheStateΒΆ
Class to manage global kernel caching state.
- classmethod enable()ΒΆ
Enable kernel caching globally.
- classmethod disable()ΒΆ
Disable kernel caching globally.
- classmethod is_enabled()ΒΆ
Return current cache state.
- Return type:
bool
- class tilelang.env.EnvVarΒΆ
Descriptor for managing access to a single environment variable.
PurposeΒΆ
- In many projects, access to environment variables is scattered across the codebase:
os.environ.get(β¦) calls are repeated everywhere
Default values are hard-coded in multiple places
Overriding env vars for tests/debugging is messy
Thereβs no central place to see all environment variables a package uses
- This descriptor solves those issues by:
Centralizing the definition of the variableβs key and default value
Allowing dynamic reads from os.environ so changes take effect immediately
Supporting forced overrides at runtime (for unit tests or debugging)
Logging a warning when a forced value is used (helps detect unexpected overrides)
Optionally syncing forced values back to os.environ if global consistency is desired
How it worksΒΆ
This is a dataclass implementing the descriptor protocol (__get__, __set__)
- When used as a class attribute, instance.attr triggers __get__()
β returns either the forced override or the live value from os.environ
- Assigning to the attribute (instance.attr = value) triggers __set__()
β stores _forced_value for future reads
You may uncomment the os.environ[β¦] = value line in __set__ if you want the override to persist globally in the process
Example
TILELANG_PRINT_ON_COMPILATION = EnvVar(βTILELANG_PRINT_ON_COMPILATIONβ, β0β)
env = Environment() print(cfg.TILELANG_PRINT_ON_COMPILATION) # Reads from os.environ (with default fallback) cfg.TILELANG_PRINT_ON_COMPILATION = β1β # Forces value to β1β until changed/reset ```
BenefitsΒΆ
Centralizes all env-var keys and defaults in one place
Live, up-to-date reads (no stale values after import)
Testing convenience (override without touching the real env)
Improves IDE discoverability and type hints
Avoids hardcoding os.environ.get(β¦) in multiple places
- key: strΒΆ
- default: strΒΆ
- get()ΒΆ
- __get__(instance, owner)ΒΆ
Called when the attribute is accessed. 1. If a forced value is set, return it and log a warning 2. Otherwise, look up the value in os.environ; return the default if missing
- __set__(instance, value)ΒΆ
Called when the attribute is assigned to. Stores the value as a runtime override (forced value). Optionally, you can also sync this into os.environ for global effect.
- tilelang.env.enable_cacheΒΆ
- tilelang.env.disable_cacheΒΆ
- tilelang.env.is_cache_enabledΒΆ
- class tilelang.env.EnvironmentΒΆ
Environment configuration for TileLang. Handles CUDA/ROCm detection, integration paths, template/cache locations, auto-tuning configs, and build options.
- CUDA_HOMEΒΆ
- ROCM_HOMEΒΆ
- TILELANG_PACKAGE_PATHΒΆ
- CUTLASS_INCLUDE_DIRΒΆ
- COMPOSABLE_KERNEL_INCLUDE_DIRΒΆ
- TVM_PYTHON_PATHΒΆ
- TVM_LIBRARY_PATHΒΆ
- TILELANG_TEMPLATE_PATHΒΆ
- TILELANG_CACHE_DIRΒΆ
- TILELANG_TMP_DIRΒΆ
- TILELANG_PRINT_ON_COMPILATIONΒΆ
- TILELANG_CLEAR_CACHEΒΆ
- TILELANG_AUTO_TUNING_CPU_UTILITIESΒΆ
- TILELANG_AUTO_TUNING_CPU_COUNTSΒΆ
- TILELANG_AUTO_TUNING_MAX_CPU_COUNTΒΆ
- SKIP_LOADING_TILELANG_SOΒΆ
- TVM_IMPORT_PYTHON_PATHΒΆ
- is_cache_enabled()ΒΆ
- Return type:
bool
- enable_cache()ΒΆ
- Return type:
None
- disable_cache()ΒΆ
- Return type:
None
- is_print_on_compilation_enabled()ΒΆ
- Return type:
bool
- tilelang.env.envΒΆ
- tilelang.env.CUDA_HOMEΒΆ
- tilelang.env.ROCM_HOMEΒΆ
- tilelang.env.install_tvm_pathΒΆ
- tilelang.env.install_cutlass_pathΒΆ
- tilelang.env.install_ck_pathΒΆ
- tilelang.env.install_tl_template_pathΒΆ
- tilelang.env.CUTLASS_INCLUDE_DIRΒΆ
- tilelang.env.COMPOSABLE_KERNEL_INCLUDE_DIRΒΆ
- tilelang.env.TILELANG_TEMPLATE_PATHΒΆ