Files
composable_kernel/test/ck_tile
Anton Gorenko 7a710c3542 [rocm-libraries] ROCm/rocm-libraries#8423 (commit 8ad1035)
feat(ck): Extend and optimize Quant Gemm Kernel for Aiter
 a8w8 (#8423)

## Motivation

JIRA ID : ROCM-20362
JIRA ID : ROCM-26313

The main purpose of this PR is to allow using CK and CK Tile GEMM for
Aiter a8w8 (row-col quantization) and improve its performance.

## Technical Details

### Multiple D for Aiter a8w8 with bias

* Support multiple D (bias) in Quant GEMM kernel
* Extend CShuffleEpilogue
  * support int8 -> int32 WarpGemms with row-col quantization
* allow shuffling in fp32 before applying multiple D to prevent
precision loss

### Large tensors support

* Support large tensors in the Quant GEMM kernel by offsetting pointers
of matrices A, D and C.
This feature can be used when M is large, N and K are relatively small
and layout is RCR, it's currently enabled only row-col quantization.

* Allow broadcasting of D column vectors in the old CK's
`DeviceGemmMultiD_Xdl_CShuffle_V3` with large tensors, this case is used
to implement row-col quant scales in Aiter.

### Optimization and workarounds

* Use literal 0 as scales for unscaled 16x16x128 and 32x32x64 mfma: llvm
uses v_mfma for `__builtin_amdgcn_mfma_scale_f32_..._f8f6f4` instead of
v_mfma_scale only if scales are literal 0 values. These instruction
don't need loading scales and save vector registers. See
https://github.com/ROCm/llvm-project/blob/therock-7.13/llvm/lib/Target/AMDGPU/SIInstrInfo.td#L317-L327

* Add workaround for inefficient buffer_load to lds on 7.2
The 3rd argument of buffer_load_dwordx4 is a scalar register. But the
compiler generates a waterfall loop as if lanes can have a different
value, even though the original values comes from as scalar register.

* Use buffer_store_dwordx4 to store 8 bf16 values in epilogue instead of
two buffer_store_dwordx2

* Optimize eight waves pipeline:
  * Improve instruction scheduling
  * Remove unneeded barriers

* Use nontemporal store/load for C and D matrices in the Quant GEMM
kernel (they are used once per block but may consume cache that can be
better used for matrices A and B)

* Use more efficient padding in epilogue with CTransposed

## Test Plan

A new test is added for multiple D Quant Gemm
(`TestCkTileGemmRowColQuantMultiD/*.RowColQuantMultiDTest`):
```
ninja test_tile_gemm_quant_rowcol && bin/test_tile_gemm_quant_rowcol
```

Testing the large tensor support is not feasible with the current
testing infrastructure because of reference calculations on CPU - it
takes several minutes to run a single test case. Such cases are tested
manually in Aiter.

## Test Result

<!-- Briefly summarize test outcomes. -->

## Submission Checklist

- [ ] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
2026-07-10 12:03:47 +00:00
..

CK Tile Testing Guide

This document describes the test organization and available test targets for CK Tile operations.

Overview

CK Tile tests are organized with multiple levels of granularity to support different development workflows:

  1. Global test labels - Run tests across all operations
  2. Operation-specific umbrella targets - Run all tests for a specific operation
  3. Individual test executables - Run specific tests

Global Test Labels

These targets run tests across all CK operations (not just CK Tile):

ninja smoke

Run fast smoke tests (tests that complete within ~30 seconds on gfx90a).

ninja smoke

ninja regression

Run slower, more comprehensive regression tests.

ninja regression

ninja check

Run ALL available tests in the entire codebase.

ninja check

Operation-Specific Umbrella Targets

These targets allow you to run all tests for a specific CK Tile operation. This is useful when making changes to a particular operation and wanting to validate all related tests without running the entire test suite.

GEMM Operations

ck_tile_gemm_tests

Run all basic GEMM pipeline tests (memory, compute variants, persistent, etc.)

ninja ck_tile_gemm_tests

Test executables included:

  • test_ck_tile_gemm_pipeline_mem
  • test_ck_tile_gemm_pipeline_compv3
  • test_ck_tile_gemm_pipeline_compv4
  • test_ck_tile_gemm_pipeline_persistent
  • test_ck_tile_gemm_pipeline_compv6
  • test_ck_tile_gemm_pipeline_comp_async (gfx95 only)
  • test_ck_tile_gemm_pipeline_*_wmma variants (gfx11/gfx12 only)

ck_tile_gemm_block_scale_tests

Run all GEMM tests with block-scale quantization (AQuant, BQuant, ABQuant, etc.)

ninja ck_tile_gemm_block_scale_tests

Test executables included: 29 test executables covering:

  • AQuant tests (memory pipelines, base layouts, prefill, preshuffle, transpose)
  • ABQuant tests (base, padding, preshuffle)
  • BQuant tests (1D/2D variants, transpose)
  • BQuant with PreshuffleB (decode/prefill, 1D/2D)
  • BQuant with PreshuffleQuant (decode/prefill, 1D/2D)
  • RowColQuant and TensorQuant tests

ck_tile_gemm_streamk_tests

Run all GEMM StreamK tests (tile partitioner, reduction, smoke, extended)

ninja ck_tile_gemm_streamk_tests

Test executables included:

  • test_ck_tile_streamk_tile_partitioner
  • test_ck_tile_streamk_reduction
  • test_ck_tile_streamk_smoke
  • test_ck_tile_streamk_extended

ck_tile_grouped_gemm_quant_tests

Run all grouped GEMM quantization tests

ninja ck_tile_grouped_gemm_quant_tests

Test executables included:

  • test_ck_tile_grouped_gemm_quant_rowcol
  • test_ck_tile_grouped_gemm_quant_tensor
  • test_ck_tile_grouped_gemm_quant_aquant
  • test_ck_tile_grouped_gemm_quant_bquant
  • test_ck_tile_grouped_gemm_quant_bquant_preshuffleb

Other Operations

ck_tile_fmha_tests

Run all FMHA (Flash Multi-Head Attention) tests

ninja ck_tile_fmha_tests

Test executables included: Forward and backward tests for fp16, bf16, fp8bf16, fp32

ck_tile_reduce_tests

Run all reduce operation tests

ninja ck_tile_reduce_tests

Test executables included:

  • test_ck_tile_reduce2d
  • test_ck_tile_multi_reduce2d_threadwise
  • test_ck_tile_multi_reduce2d_multiblock

Individual Test Executables

You can also build and run individual test executables:

Build a specific test

ninja test_ck_tile_gemm_pipeline_mem

Run a specific test directly

./build/bin/test_ck_tile_gemm_pipeline_mem

Run a specific test through ctest

ctest -R test_ck_tile_gemm_pipeline_mem --output-on-failure