Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion projects/hipblaslt/tensilelite/Tensile/CustomKernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import os

def isCustomKernelConfig(config):
return "CustomKernel" in config and config["CustomKernel"]["name"]
if "CustomKernel" in config and config["CustomKernel"]["name"]:
return True
return bool(config.get("CustomKernelName", ""))
Comment on lines +33 to +35

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isCustomKernelConfig now returns True when CustomKernelName is set, but multiple call sites assume True implies config["CustomKernel"]["name"] exists (e.g. Tensile/TensileLogic/HandleCustomKernel.py:52 immediately indexes sol["CustomKernel"]["name"]). With this change, configs that only set CustomKernelName will trigger a KeyError/TypeError downstream.

Suggested fix: either (1) keep isCustomKernelConfig strictly tied to the presence of CustomKernel.name, or (2) update downstream code to consistently derive the name via config.get("CustomKernelName") or config.get("CustomKernel", {}).get("name") and, if needed, populate config["CustomKernel"]["name"] when only CustomKernelName is provided.

Suggested change
if "CustomKernel" in config and config["CustomKernel"]["name"]:
return True
return bool(config.get("CustomKernelName", ""))
customKernel = config.get("CustomKernel", {})
return bool(customKernel.get("name"))

Copilot uses AI. Check for mistakes.

def getCustomKernelFilepath(name, directory=CUSTOM_KERNEL_PATH):
flat = os.path.join(directory, (name + ".s"))
Expand Down
2 changes: 1 addition & 1 deletion projects/hipblaslt/tensilelite/Tensile/KernelWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4743,7 +4743,7 @@ def readWriteVectors(mat, vw, kernel):
elif not ( self.states.asmCaps["HasMFMA"] or self.states.asmCaps["HasWMMA"]):
raise RuntimeError("MatrixInstruction not supported for {0}".format(self.states.version))

if kernel["MFMA_BF16_1K"] and not self.states.asmCaps["HasMFMA_bf16_1k"]:
if kernel.get("MFMA_BF16_1K") and not self.states.asmCaps["HasMFMA_bf16_1k"]:
raise RuntimeError("BF16_1k MatrixInstruction not supported for {0}".format(self.states.version))
Comment on lines 4744 to 4747

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes MFMA_BF16_1K optional (kernel.get(...)) to avoid a KeyError. There doesn't appear to be a unit test covering the previously failing case (kernel dict missing MFMA_BF16_1K). Adding a regression test that exercises kernel generation with a minimal kernel config lacking this key would help prevent future reintroductions.

Copilot uses AI. Check for mistakes.

if kernel["ProblemType"]["Sparse"] and not self.states.asmCaps["HasSMFMA"]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def _getName(state, requiredParameters: frozenset, splitGSU: bool, ignoreInterna

if "CustomKernel" in state and state["CustomKernel"]["name"]:
return state["CustomKernel"]["name"]
if state.get("CustomKernelName", ""):
return state["CustomKernelName"]

gsuBackup = state["GlobalSplitU"]
ggBackup = state["ProblemType"]["GroupedGemm"]
Expand Down Expand Up @@ -171,6 +173,8 @@ def shortenFileBase(splitGSU, kernel):
def getKernelFileBase(splitGSU: bool, kernel):
if "CustomKernel" in kernel and kernel["CustomKernel"]["name"]:
fileBase = kernel["CustomKernel"]["name"]
elif kernel.get("CustomKernelName", ""):
fileBase = kernel["CustomKernelName"]
else:
fileBase = shortenFileBase(splitGSU, kernel)
return fileBase
Expand Down
Loading