Unverified Commit 1b4cd386 authored by M.D_v2.5's avatar M.D_v2.5 Committed by GitHub
Browse files

[Bugfix] Fix saving kernel source code where JITKernel.artifact is None (#921)

In cases where JITKernel.artifact is None, it'll spit error -
```
2025-10-01 01:06:18  [TileLang:tilelang:ERROR]: Error saving kernel source
code to disk: 'NoneType' object has no attribute 'kernel_source'
```

Looking at properties of JITKernel, it seems that `JITKernel.kernel_source`
is a better way to achieve this.
Ref:
https://github.com/tile-ai/tilelang/blob/main/tilelang/jit/kernel.py#L453-L455

Co-authored-by: default avatarDylan <miaoding.dai@plus.ai>
parent f737fa97
...@@ -172,9 +172,9 @@ class AutotuneResult: ...@@ -172,9 +172,9 @@ class AutotuneResult:
kernel_path = os.path.join(cache_path, KERNEL_PATH) kernel_path = os.path.join(cache_path, KERNEL_PATH)
if verbose: if verbose:
logger.debug(f"Saving kernel source code to file: {kernel_path}") logger.debug(f"Saving kernel source code to file: {kernel_path}")
if kernel.artifact.kernel_source is not None: if kernel.kernel_source is not None:
with open(kernel_path, "w") as f: with open(kernel_path, "w") as f:
f.write(kernel.artifact.kernel_source) f.write(kernel.kernel_source)
except Exception as e: except Exception as e:
logger.error(f"Error saving kernel source code to disk: {e}") logger.error(f"Error saving kernel source code to disk: {e}")
......
...@@ -267,9 +267,9 @@ class KernelCache: ...@@ -267,9 +267,9 @@ class KernelCache:
kernel_path = os.path.join(cache_path, KERNEL_PATH) kernel_path = os.path.join(cache_path, KERNEL_PATH)
if verbose: if verbose:
self.logger.debug(f"Saving kernel source code to file: {kernel_path}") self.logger.debug(f"Saving kernel source code to file: {kernel_path}")
if kernel.artifact.kernel_source is not None: if kernel.kernel_source is not None:
KernelCache._safe_write_file(kernel_path, "w", KernelCache._safe_write_file(kernel_path, "w",
lambda file: file.write(kernel.artifact.kernel_source)) lambda file: file.write(kernel.kernel_source))
except Exception as e: except Exception as e:
self.logger.error(f"Error saving kernel source code to disk: {e}") self.logger.error(f"Error saving kernel source code to disk: {e}")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment