Skip to content

Commit 398d985

Browse files
ozturkosuassistant-librarian[bot]
authored andcommitted
[rocm-libraries] ROCm/rocm-libraries#12216 (commit 72144cb)
fix(ck-tile): honor the gfx1250 unified-framework gate in bridge kernel builds (#12216) ## Summary `projects/composablekernel/CMakeLists.txt:230-232` force-defines `USE_NEW_UNIFIED_FRAMEWORK=0` for gfx1250 targets, because the unified ck_tile framework does not support gfx1250 yet. That gate is an `add_compile_definitions` call, so it only reaches targets of that CMake project. The dispatcher bridges never saw it: they assemble their own per-kernel `hipcc` command lines, outside CMake entirely. This was harmless while the framework default was `0`. PR #11646 flipped that default to `1`, after which every bridge kernel compiled for gfx1250 failed on the `getCMakeCompilerTarget` static assertion in `arch.hpp:509`, leaving `tile_engine` unable to build or benchmark any GEMM on gfx1250. This adds a shared `unified_framework_flags()` helper in `dispatcher_common.py` and applies it at each of the 21 sites that build a kernel compile line. The flag is emitted **only** for gfx1250. Fixes the blocker reported in AICK-2268. ## Motivation Without this, the documented gfx1250 tuning workflow does not function at all: the shipped `configs/default_ci_config_gfx1250.json` sweep reports `0/4 configs -> .so` and produces no measurements. Only `gemm_utils.py` is exercised by that sweep, but all 21 compile-line construction sites have the identical gap, so the remaining operators would fail the same way as soon as anyone benchmarks them on gfx1250. Fixing them together via one helper avoids leaving 17 latent copies of the same bug. ## Design note The helper mirrors the CMake gate rather than replacing it. A longer-term cleanup would move the gate out of `CMakeLists.txt` into a header, so that every compile path observes one consistent value instead of two places having to agree. That is deliberately out of scope here. Worth noting for reviewers: the dispatcher static library is built by a separate CMake project (`project(ck_tile_dispatcher ...)` at `dispatcher/CMakeLists.txt:6`), so it also does not inherit the gfx1250 gate and is compiled with the framework default of 1, while the kernels this PR fixes are compiled with 0. That mix was verified to work correctly on hardware -- the dispatcher translation units do not instantiate the affected templates -- so no CMake change is required here. This restores the legacy WarpGemm path on gfx1250, which is what CMake already intends today. Making the unified framework genuinely work on gfx1250 is separate follow-up work. ## Changes - `dispatcher_common.py`: new `unified_framework_flags(arch)` helper. - 18 bridge modules: emit the helper's flags alongside `-DGFX_ARCH` at each compile-line site. 19 files changed, 54 insertions, 2 deletions. ## Test plan Verified on gfx1250 hardware against a pristine tree at the commit named in AICK-2268, with this PR as the only local change, and with the dispatcher built exactly as the ticket documents (no extra CMake flags). Reproduced on a second gfx1250 node on a different ROCm build to rule out version specificity. - [x] Baseline reproduces the reported failure: `0/4 configs -> .so` - [x] With this PR applied: `4/4 configs -> .so`, **0 compile failures** - [x] Full bf16 sweep across all four layouts (rcr, rrr, crr, ccr): **64 configs, 0 compile failures, 320/320 measurements, 0 failures** - [x] Numerical correctness via `--verify` against the fp32 reference: **320/320 `verified=True`**, worst `max_rel` 0.003789, zero all-zero-output rows - [x] Kernels execute on device and emit native matrix instructions: 40 x `v_wmma_f32_16x16x32_bf16`, no fallback dummy-exec path - [x] Non-gfx1250 unaffected: generated compile command for gfx942 and gfx950 is byte-identical to before (27 args, no added flag); gfx1250 gets 28 - [x] All 21 dispatcher python modules import cleanly - [ ] CI sweep on gfx942 / gfx950 to confirm no regression - [ ] CI smoke check that builds at least one gfx1250 tile_engine kernel, so this cannot silently regress again Co-authored-by: Muhammed Emin Ozturk <3836908+ozturkosu@users.noreply.github.com>
1 parent 6f6a4cf commit 398d985

22 files changed

Lines changed: 215 additions & 3 deletions

dispatcher/python/batched_contraction_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
3-char a/b/e layout, num_dim_g/m/n/k, num_d_tensors == 0 (PassThrough).
2323
"""
2424

25+
from dispatcher_common import unified_framework_flags
2526
import concurrent.futures
2627
import ctypes
2728
import functools
@@ -557,7 +558,7 @@ def _compile_kernel(hpp: Path, so: Path, arch: str) -> bool:
557558
_HIPCC, "-c", "-fPIC", "-O3", "-std=c++17",
558559
f"-I{ck_root}/include", f"-I{ck_root}",
559560
"-DCK_TILE_SINGLE_KERNEL_INCLUDE", f"-include{hpp}",
560-
"-D__HIP_PLATFORM_AMD__", f"--offload-arch={arch}", f'-DGFX_ARCH="{arch}"',
561+
"-D__HIP_PLATFORM_AMD__", f"--offload-arch={arch}", f'-DGFX_ARCH="{arch}"', *unified_framework_flags(arch),
561562
# Match Tile Engine's AMDGPU codegen flags exactly so the bridge .so
562563
# produces the same machine code as Old-TE (inlining, register
563564
# allocation, occupancy). Without these, persistent kernels size their

dispatcher/python/batched_gemm_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"""
3333

3434
from __future__ import annotations
35+
from dispatcher_common import unified_framework_flags
3536

3637
import ctypes
3738
import multiprocessing
@@ -604,6 +605,7 @@ def _build_batched_compile_jobs(
604605
"-D__HIP_PLATFORM_AMD__",
605606
f"--offload-arch={gfx_arch}",
606607
f'-DGFX_ARCH="{gfx_arch}"',
608+
*unified_framework_flags(gfx_arch),
607609
# Byte-identical AMDGPU backend flags to the single-problem bridge and
608610
# Old-TE (see gemm_utils._tile_engine_codegen_flags) -- required for a
609611
# fair A/B parity comparison.

dispatcher/python/contraction_multi_abd_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
result = runner.run(As, Bs, Ds, problem)
2727
"""
2828

29+
from dispatcher_common import unified_framework_flags
2930
import ctypes
3031
import json
3132
import logging
@@ -734,6 +735,7 @@ def _compile_kernel(
734735
"-DCK_TILE_SINGLE_KERNEL_INCLUDE", "-w",
735736
f"--offload-arch={gfx_arch}",
736737
f"-DGFX_ARCH=\"{gfx_arch}\"",
738+
*unified_framework_flags(gfx_arch),
737739
*arch_defines,
738740
"-include", str(hpp_path),
739741
str(_CTYPES_LIB_SRC),

dispatcher/python/ctypes_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
check = validator.check(result.C, C_reference)
2727
"""
2828

29+
from dispatcher_common import unified_framework_flags
2930
import ctypes
3031
import subprocess
3132
import numpy as np
@@ -2039,6 +2040,7 @@ def _rebuild_library_for_config(
20392040
"-D__HIP_PLATFORM_AMD__",
20402041
f"--offload-arch={config.gfx_arch}",
20412042
f'-DGFX_ARCH="{config.gfx_arch}"', # Pass arch as string for gemm_ctypes_lib.cpp
2043+
*unified_framework_flags(config.gfx_arch),
20422044
"-mllvm",
20432045
"-enable-noalias-to-md-conversion=0",
20442046
"-Wno-undefined-func-template",
@@ -2131,6 +2133,7 @@ def build_libraries_parallel(
21312133
"-D__HIP_PLATFORM_AMD__",
21322134
f"--offload-arch={config.gfx_arch}",
21332135
f'-DGFX_ARCH="{config.gfx_arch}"',
2136+
*unified_framework_flags(config.gfx_arch),
21342137
"-mllvm",
21352138
"-enable-noalias-to-md-conversion=0",
21362139
"-Wno-undefined-func-template",
@@ -2891,6 +2894,7 @@ def setup_multiple_gemm_dispatchers(
28912894
"-D__HIP_PLATFORM_AMD__",
28922895
f"--offload-arch={c.gfx_arch}",
28932896
f'-DGFX_ARCH="{c.gfx_arch}"',
2897+
*unified_framework_flags(c.gfx_arch),
28942898
"-mllvm",
28952899
"-enable-noalias-to-md-conversion=0",
28962900
"-Wno-undefined-func-template",

dispatcher/python/dispatcher_common.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,21 @@ def detect_gpu_arch(fallback: str = "gfx942") -> str:
101101
return fallback
102102

103103

104+
def unified_framework_flags(arch: Optional[str]) -> List[str]:
105+
"""Extra defines a per-kernel hipcc line needs to match CK's CMake gate.
106+
107+
``projects/composablekernel/CMakeLists.txt`` force-defines
108+
``USE_NEW_UNIFIED_FRAMEWORK=0`` for gfx1250 targets, because the unified
109+
ck_tile framework does not support gfx1250 yet. That gate is an
110+
``add_compile_definitions`` call, so it only reaches targets of that CMake
111+
project. The bridges build their own hipcc command lines outside it and
112+
would otherwise pick up the header default of 1, which does not compile.
113+
"""
114+
if normalize_arch(arch) == "gfx1250":
115+
return ["-DUSE_NEW_UNIFIED_FRAMEWORK=0"]
116+
return []
117+
118+
104119
# ============================================================================
105120
# fp8 / bf8 encoding format per architecture
106121
# ============================================================================

dispatcher/python/fmha_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
result = runner.run(Q, K, V, problem)
1717
"""
1818

19+
from dispatcher_common import unified_framework_flags
1920
import ctypes
2021
import json
2122
import os
@@ -1206,6 +1207,7 @@ def fmha_compile_flags(arch: str, hipcc: str = "", family: str = "") -> List[str
12061207
- CK_USE_XDL: enables MFMA (matrix fused multiply-add) instructions
12071208
- CK_TILE_USE_WMMA: 0 for CDNA (uses MFMA instead)
12081209
- CK_TILE_FLOAT_TO_BFLOAT16_DEFAULT=3: BWD bf16 conversion mode
1210+
- USE_NEW_UNIFIED_FRAMEWORK=0: preserves the gfx1250 CMake gate for every TU
12091211
"""
12101212
if not hipcc:
12111213
hipcc = _find_hipcc()
@@ -1217,6 +1219,7 @@ def fmha_compile_flags(arch: str, hipcc: str = "", family: str = "") -> List[str
12171219
"-O3",
12181220
"-DNDEBUG",
12191221
f"--offload-arch={arch}",
1222+
*unified_framework_flags(arch),
12201223
"-std=c++17",
12211224
f"-I{root.parent / 'include'}",
12221225
f"-I{root / 'include'}",

dispatcher/python/gemm_abquant_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
result = runner.run(A, B, AQ, BQ, ABQuantGemmProblem(M=128, N=128, K=256))
3535
"""
3636

37+
from dispatcher_common import unified_framework_flags
3738
import ctypes
3839
import json
3940
import logging
@@ -626,6 +627,7 @@ def _compile_abquant_kernel(
626627
"-DCK_TILE_SINGLE_KERNEL_INCLUDE", "-w",
627628
f"--offload-arch={gfx_arch}",
628629
f"-DGFX_ARCH=\"{gfx_arch}\"",
630+
*unified_framework_flags(gfx_arch),
629631
*arch_defines,
630632
*perf_flags,
631633
"-include", str(hpp_path),

dispatcher/python/gemm_aquant_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
result = runner.run(A, AQ, B, AQuantGemmProblem(M=16, N=64, K=256))
2424
"""
2525

26+
from dispatcher_common import unified_framework_flags
2627
import ctypes
2728
import json
2829
import logging
@@ -510,6 +511,7 @@ def _compile_aquant_kernel(
510511
"-DCK_TILE_SINGLE_KERNEL_INCLUDE", "-w",
511512
f"--offload-arch={gfx_arch}",
512513
f"-DGFX_ARCH=\"{gfx_arch}\"",
514+
*unified_framework_flags(gfx_arch),
513515
*arch_defines,
514516
*_te_perf_flags(hipcc),
515517
"-include", str(hpp_path),

dispatcher/python/gemm_bquant_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
result = runner.run(A, B, BQ, BQuantGemmProblem(M=16, N=64, K=256))
2626
"""
2727

28+
from dispatcher_common import unified_framework_flags
2829
import ctypes
2930
import json
3031
import functools
@@ -876,6 +877,7 @@ def _compile_bquant_kernel(
876877
"-DCK_TILE_SINGLE_KERNEL_INCLUDE", "-w",
877878
f"--offload-arch={gfx_arch}",
878879
f"-DGFX_ARCH=\"{gfx_arch}\"",
880+
*unified_framework_flags(gfx_arch),
879881
*arch_defines,
880882
*codegen_flags,
881883
"-include", str(hpp_path),

dispatcher/python/gemm_rowcolquant_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
result = runner.run(A, B, AQ, BQ, RowColQuantGemmProblem(M=16, N=64, K=256))
2929
"""
3030

31+
from dispatcher_common import unified_framework_flags
3132
import ctypes
3233
import json
3334
import logging
@@ -528,6 +529,7 @@ def _compile_rowcolquant_kernel(
528529
"-DCK_TILE_SINGLE_KERNEL_INCLUDE", "-w",
529530
f"--offload-arch={gfx_arch}",
530531
f"-DGFX_ARCH=\"{gfx_arch}\"",
532+
*unified_framework_flags(gfx_arch),
531533
*arch_defines,
532534
*_te_perf_flags(hipcc),
533535
"-include", str(hpp_path),

0 commit comments

Comments
 (0)