Skip to content

[hipblaslt][G-F-A] fix MFMA_BF16_1K KeyError of install build - #6217

Merged
jinchen62 merged 1 commit into
ROCm:GemmFromAnywherefrom
jinchen62:fix_build
Apr 7, 2026
Merged

jinchen62 merged 1 commit into
ROCm:GemmFromAnywherefrom
jinchen62:fix_build

Conversation

@jinchen62

Copy link
Copy Markdown
Contributor

Fix KeyError: 'MFMA_BF16_1K' when building install.sh

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses install-time build failures caused by missing optional kernel fields (notably MFMA_BF16_1K) by making access more defensive, and extends custom-kernel naming support via an additional CustomKernelName field.

Changes:

  • Avoid KeyError: 'MFMA_BF16_1K' by switching to guarded access when checking BF16_1K MFMA capability.
  • Add CustomKernelName as an additional source of kernel/solution names and file base names.
  • Treat CustomKernelName as indicating a “custom kernel config” in isCustomKernelConfig.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
projects/hipblaslt/tensilelite/Tensile/SolutionStructs/Naming.py Adds CustomKernelName fallback for solution/kernel naming and file base generation.
projects/hipblaslt/tensilelite/Tensile/KernelWriter.py Prevents KeyError by using kernel.get("MFMA_BF16_1K") during MI capability checks.
projects/hipblaslt/tensilelite/Tensile/CustomKernels.py Expands custom-kernel detection to consider CustomKernelName.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

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.
Comment on lines 4744 to 4747
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))

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.
@jinchen62
jinchen62 merged commit 9ae2728 into ROCm:GemmFromAnywhere Apr 7, 2026
30 checks passed
@jinchen62
jinchen62 deleted the fix_build branch April 7, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants