tilelang.envΒΆ

AttributesΒΆ

ClassesΒΆ

CacheState

Class to manage global kernel caching state.

EnvVar

Descriptor for managing access to a single environment variable.

Environment

Environment configuration for TileLang.

FunctionsΒΆ

prepend_dll_search_path(paths)

Prepend paths to %PATH% on Windows, skipping entries already present.

get_cuda_dll_search_dirs()

Return CUDA_HOME-derived DLL search directories (Windows only).

get_windows_runtime_dll_dirs()

Return Windows-only DLL directories shipped with sibling Python packages.

prepend_pythonpath(path)

Module ContentsΒΆ

tilelang.env.loggerΒΆ
tilelang.env.EnvVarDefaultΒΆ
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'ΒΆ
tilelang.env.TL_ROOTΒΆ
tilelang.env.TL_LIBSΒΆ
tilelang.env.TL_LIBSΒΆ
tilelang.env.DEV = FalseΒΆ
tilelang.env.THIRD_PARTY_ROOTΒΆ
tilelang.env.DEV = TrueΒΆ
tilelang.env.prepend_dll_search_path(paths)ΒΆ

Prepend paths to %PATH% on Windows, skipping entries already present.

Used by Windows DLL discovery: PATH is consulted by LoadLibrary and by os.add_dll_directory-registered directories alike. POSIX is a no-op.

Parameters:

paths (list[str])

Return type:

None

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:
  1. Centralizing the definition of the variable’s key and default value

  2. Allowing dynamic reads from os.environ so changes take effect immediately

  3. Supporting forced overrides at runtime (for unit tests or debugging)

  4. Logging a warning when a forced value is used (helps detect unexpected overrides)

  5. 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

```python class Environment:

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: EnvVarDefaultΒΆ
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.

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_DISABLE_CACHEΒΆ
TILELANG_CLEANUP_TEMP_FILESΒΆ
TILELANG_HIP_SAVE_TEMP_FILESΒΆ
TILELANG_JIT_DIAGNOSTICSΒΆ
TILELANG_COMPILE_TIMEOUT_SECONDSΒΆ
TILELANG_PASS_DIFFΒΆ
TILELANG_PASS_DIFF_OUTPUTΒΆ
TILELANG_AUTO_TUNING_DISABLE_CACHEΒΆ
TILELANG_AUTO_TUNING_CPU_UTILITIESΒΆ
TILELANG_AUTO_TUNING_CPU_COUNTSΒΆ
TILELANG_AUTO_TUNING_MAX_CPU_COUNTΒΆ
TILELANG_DEFAULT_TARGETΒΆ
TILELANG_DEFAULT_EXECUTION_BACKENDΒΆ
TILELANG_DEFAULT_VERBOSEΒΆ
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_cache_globally_disabled()ΒΆ
Return type:

bool

is_autotune_cache_disabled()ΒΆ
Return type:

bool

is_print_on_compilation_enabled()ΒΆ
Return type:

bool

should_cleanup_temp_files()ΒΆ
Return type:

bool

is_jit_diagnostics_enabled()ΒΆ
Return type:

bool

get_compile_timeout_seconds()ΒΆ
Return type:

float | None

get_pass_diff_mode()ΒΆ

Return the pass diff mode: None (off), β€˜terminal’, β€˜html’, or β€˜both’.

Return type:

str | None

get_default_target()ΒΆ

Get default compilation target from environment.

Return type:

str

get_default_execution_backend()ΒΆ

Get default execution backend from environment.

Return type:

str

get_default_verbose()ΒΆ

Get default verbose flag from environment.

Return type:

bool

is_running_autodd()ΒΆ

Return True if we are running under python -m tilelang.autodd.

Return type:

bool

is_light_import()ΒΆ

Return True if we are running in light import mode.

Return type:

bool

tilelang.env.envΒΆ
tilelang.env.enable_cacheΒΆ
tilelang.env.disable_cacheΒΆ
tilelang.env.is_cache_enabledΒΆ
tilelang.env.CUDA_HOMEΒΆ
tilelang.env.ROCM_HOMEΒΆ
tilelang.env.get_cuda_dll_search_dirs()ΒΆ

Return CUDA_HOME-derived DLL search directories (Windows only).

The CUDA_HOME value itself is auto-detected by _find_cuda_home (env vars, nvcc on PATH, pip nvidia-cuda-nvcc package, or default install paths). This helper expands it into the subdirectories that actually contain nvcuda.dll / cudart64_*.dll / nvrtc64_*.dll / nvvm*.dll.

Return type:

list[str]

tilelang.env.get_windows_runtime_dll_dirs()ΒΆ

Return Windows-only DLL directories shipped with sibling Python packages.

Currently locates tvm_ffi and z3 install dirs so their DLLs resolve when TileLang is imported. Each lookup is best-effort; failures are ignored.

Return type:

list[str]

tilelang.env.prepend_pythonpath(path)ΒΆ
tilelang.env.tvm_pathΒΆ
tilelang.env.cutlass_inc_pathΒΆ
tilelang.env.ck_inc_pathΒΆ
tilelang.env.tl_template_pathΒΆ
tilelang.env.CUTLASS_INCLUDE_DIRΒΆ
tilelang.env.COMPOSABLE_KERNEL_INCLUDE_DIRΒΆ
tilelang.env.TILELANG_TEMPLATE_PATHΒΆ
tilelang.env.TILELANG_HIP_SAVE_TEMP_FILESΒΆ