Skip to content

add a8w8 fp8 ck gemm tune support - #1782

Merged
solinzby1 merged 10 commits into
mainfrom
so/fp8_a8w8_ck
Jan 12, 2026
Merged

solinzby1 merged 10 commits into
mainfrom
so/fp8_a8w8_ck

Conversation

@solinzby1

Copy link
Copy Markdown
Contributor

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

@solinzby1
solinzby1 requested review from a team and Copilot January 7, 2026 07:31

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 adds FP8 (8-bit floating point) support to the CK GEMM tuning infrastructure, expanding beyond the existing INT8 quantization. The changes enable tuning and execution of GEMM operations with FP8 quantized inputs while maintaining the existing INT8 functionality.

Key changes:

  • Extended instance generation to support both INT8 and FP8 kernel variants during tuning
  • Added FP8 data generation and reference computation paths in the Python tuning script
  • Modified the CUDA kernel dispatcher to handle both INT8 and FP8 input types with appropriate template parameters

Reviewed changes

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

File Description
csrc/ck_gemm_a8w8/gen_instances.py Refactored instance generation to create separate I8 and F8 kernel instances for tuning with appropriate dtype template parameters
csrc/ck_gemm_a8w8/gemm_a8w8_tune.py Added quant_dtype parameter support, FP8 data generation logic, and updated reference computation to handle both I8 and FP8 quantization types
csrc/ck_gemm_a8w8/gemm_a8w8_tune.cu Updated kernel dispatcher to detect input dtype (I8 vs FP8) and dispatch to appropriate kernel templates with matching scale dtypes

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

Comment thread csrc/ck_gemm_a8w8/gemm_a8w8_tune.cu Resolved
@solinzby1
solinzby1 requested review from yadaish and yzhou103 January 7, 2026 11:16
@yadaish

yadaish commented Jan 8, 2026 •

Copy link
Copy Markdown
Contributor

LGTM

yadaish
yadaish previously approved these changes Jan 8, 2026
Comment thread aiter/ops/gemm_op_a8w8.py Resolved
@yzhou103

Copy link
Copy Markdown
Contributor

LGTM

@yadaish
yadaish self-requested a review January 12, 2026 06:01
@ROCm ROCm deleted a comment from Copilot AI Jan 12, 2026
@ROCm ROCm deleted a comment from Copilot AI Jan 12, 2026
@solinzby1
solinzby1 merged commit 2e39dbe into main Jan 12, 2026
@solinzby1
solinzby1 deleted the so/fp8_a8w8_ck branch January 12, 2026 06:24
zhuyuhua-v pushed a commit that referenced this pull request Jan 14, 2026
* add a8w8 fp8 tune support

* add q_dtype_w to deal with different type and refine config csv file

---------

Co-authored-by: solin <[email protected]>
Co-authored-by: yzhou103 <[email protected]>
valarLip pushed a commit that referenced this pull request Mar 18, 2026
* add a8w8 fp8 tune support

* add q_dtype_w to deal with different type and refine config csv file

---------

Co-authored-by: solin <[email protected]>
Co-authored-by: yzhou103 <[email protected]>
ThomasNing pushed a commit to ThomasNing/aiter that referenced this pull request Sep 19, 2026
…pandas

get_CKGEMM_config's own default raises. Calling it as documented --
get_CKGEMM_config(M, N, K), no tuned_file -- loads
configs/a8w8_tuned_gemm.csv and dies with

    ValueError: DataFrame index must be unique for orient='index'

which names neither the file, nor the shapes, nor the reason.

The reason is a schema that grew a key column and only one reader
learned. ROCm#1782 (2026-01-12) added q_dtype_w to a8w8_tuned_gemm.csv, so it
holds an int8 row and an fp8 row for the same shape -- for gfx950/256 at
M=1 N=1280 K=8192, 17.69 us on a8w8_rowwise_256x16x64x512 and 7.68 us on
a8w8_rowwise_128x16x32x128. Both are correct; they are different kernels
for different weight dtypes. ROCm#2645 (2026-04-17) then gave
get_CKGEMM_config a (gfx, cu_num, M, N, K) index, five columns for a
six-column key. 42 shapes collide. get_GEMM_config_with_quant_type keys
on all six and reads the file correctly.

This has been latent since April because every in-tree caller passes an
explicit tuned_file. It surfaces here because this branch's miss
recorder has a `uses_quant_schema = tuned_file is None` path that is
unreachable -- the load raises before any miss can be recorded.

So the load now says what is wrong:

    /app/aiter-test/aiter/configs/a8w8_tuned_gemm.csv is not uniquely
    keyed by ('gfx', 'cu_num', 'M', 'N', 'K'): 42 shape(s) carry more
    than one row. Its rows are distinguished by q_dtype_w
    (torch.float8_e4m3fn, torch.int8), which this lookup does not key on
    -- use get_GEMM_config_with_quant_type() for this table.

Deliberately not changed: the default tuned_file, and which rows win.
Silently picking one of two kernels that differ 2.3x would be worse than
refusing. This makes the existing failure legible; choosing a default
that works is a separate decision with an owner.

The two index branches also collapse into one -- they differed only in
the column list and the warning.

Tests: the colliding table produces a message naming the file, the shape
count, q_dtype_w and the right function; and a uniquely-keyed table is
accepted, so the guard can distinguish the two rather than always
firing. 16 passed on MI350X, and the production blockscale-bpreshuffle
lookup is unaffected.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants