Repository navigation
[Triton/Gluon] [Config] gfx950: tune gemm_a16w16 configs for DeepSeek-V4 GEMMs (K=7168) - #6601
Conversation
Add tuned GEMM-A16W16 configs on gfx950 for the bf16 GEMMs that
DeepSeek-V4-Pro (TP8) runs on ROCm with hidden size K=7168:
N=512, 1024, 2048, 2560 compressor score projections, bf16 x bf16 -> fp32
(CSA indexer / CSA main / HCA main / fused C4)
N=64 indexer weights_proj, bf16 x bf16 -> bf16
Buckets M_LEQ_1 ... M_LEQ_512 are tuned per M. The M=8192 winner is
stored as "any", and each file sets
"M_BOUNDS": [1, 4, 8, 16, 32, 64, 128, 256, 512], so every M > 512 gets
the prefill-tuned config. Without M_BOUNDS, DEFAULT_FALLBACK would serve
DEFAULT.json's untuned M_LEQ_2048 for M = 513 ... 2048. Note that
write_best_configs.py recopies "any" from DEFAULT.json on any
re-install, so re-apply this after re-tuning these shapes.
Tuned time in us (speedup vs the previously used DEFAULT.json), tuner
timing (24-call graph replay, cold inputs, split-K reduce included),
MI355X (256 CUs):
M N=64 N=512 N=1024 N=2048 N=2560
1 4.7 (2.42x) 6.0 (1.98x) 7.2 (1.66x) 9.2 (1.38x) 10.1 (1.32x)
4 5.6 (2.06x) 7.1 (1.67x) 8.0 (1.50x) 9.6 (1.33x) 10.9 (1.22x)
8 5.3 (2.18x) 6.7 (1.78x) 7.8 (1.56x) 9.4 (1.36x) 10.7 (1.26x)
16 5.6 (1.99x) 7.0 (1.63x) 8.0 (1.45x) 10.1 (1.21x) 11.1 (1.14x)
32 5.8 (2.94x) 7.5 (2.30x) 8.8 (1.99x) 11.3 (1.61x) 12.8 (1.46x)
64 6.0 (3.81x) 8.7 (2.71x) 10.3 (2.30x) 13.0 (1.88x) 15.8 (1.58x)
128 6.3 (5.22x) 10.3 (3.08x) 12.5 (2.54x) 17.0 (1.93x) 21.7 (1.53x)
256 8.5 (5.21x) 11.9 (3.70x) 16.1 (2.75x) 23.4 (1.87x) 29.8 (1.48x)
512 9.5 (5.56x) 16.0 (2.96x) 23.8 (1.97x) 33.6 (1.36x) 43.9 (1.03x)
8192 30.7 (3.34x) 77.8 (1.34x) 110.9 (1.00x) 201.7 (1.03x) 293.7 (1.00x)
How these were tuned: aiter/ops/triton/utils/_triton/tuning/sweep_configs.py
with a local kernel entry (not part of this commit) that times the
real call: no bias, and fp32 output for the compressor shapes (the
upstream gemm_a16w16 entry times bf16 output with a bias). Its
should_skip also narrows the search, for sweep time:
- BLOCK_SIZE_K <= 32 skipped at every M: never in the top 50, and
~80% of the M=256 sweep time plus every compiler crash
- BLOCK_SIZE_M limited to 64..256 at M=256/512 and to 128..256 at M=8192
- at M=8192 only BLOCK_SIZE_N >= 64 and NUM_KSPLIT in {1, 4}
To reproduce, add the entries below to tuning/kernels.py and run, per N:
PYTHONPATH=<aiter> python3 sweep_configs.py gemm_a16w16_fp32out \
--M 1 4 8 16 32 64 128 256 512 8192 --N <N> --K 7168 --gpu <g>
(N=64: gemm_a16w16_bf16out)
then move M_LEQ_8192 to "any" and set M_BOUNDS as described above.
Tuner entries used (tuning/kernels.py, commented out):
# def _gemm_a16w16_dsv4(shape, backend, out_dtype):
# """gemm_a16w16 as DeepSeek-V4 calls it on ROCm: bf16 x bf16 -> out_dtype, no bias.
#
# Shares the GEMM-A16W16 config files with gemm_a16w16 (they are keyed by N and K only).
# """
# import torch
#
# from aiter.ops.triton.gemm.basic.gemm_a16w16 import gemm_a16w16 as gemm
# from op_tests.triton_tests.gemm.basic.test_gemm_a16w16 import (
# generate_gemm_a16w16_inputs,
# )
#
# M, N, K = shape["M"], shape["N"], shape["K"]
# x, w, _, _, _ = generate_gemm_a16w16_inputs(
# M, N, K, torch.bfloat16, output=False, bias=False
# )
# y = torch.empty((M, N), dtype=out_dtype, device=x.device)
# # Same kernel and asserts as gemm_a16w16, so reuse its should_skip rules.
# _, _, base_skip = gemm_a16w16(shape, backend)
# # Search policy for the large DSV4 Ms (prefill / high-concurrency decode): only these
# # BLOCK_SIZE_M values are swept. Smaller Ms sweep the full table.
# block_m_range = {256: (64, 256), 512: (64, 256), 8192: (128, 256)}.get(M)
#
# def should_skip(config):
# # BLOCK_SIZE_K <= 32 never placed in the top 50 at any swept M (K=7168) and took
# # ~80% of the M=256 sweep time (plus every compiler crash), so it is not swept.
# if config["BLOCK_SIZE_K"] <= 32:
# return True
# if block_m_range is not None:
# lo, hi = block_m_range
# if not lo <= config["BLOCK_SIZE_M"] <= hi:
# return True
# # M=8192 (prefill): narrow N tiles and deep split-K never came close (N=512 sweep:
# # best BLOCK_N=8 351 us / split-K 28 321 us vs 81.5 us winner at BLOCK_N=128, split-K 1)
# # but cost most of the time (one BLOCK_N=8 candidate takes ~1-3 ms per call).
# if M == 8192 and (config["BLOCK_SIZE_N"] < 64 or config.get("NUM_KSPLIT", 1) not in (1, 4)):
# return True
# return base_skip(config) if base_skip is not None else False
#
# def call(config, x, w, y):
# if backend == "triton":
# add_splitk_block_size(config, K)
# return gemm(
# x, w, bias=None, dtype=out_dtype, y=y, config=config, backend=backend
# )
#
# return call, (x, w, y), should_skip
#
#
# @kernel(
# "GEMM-A16W16",
# gluon_archs=("gfx1250",),
# gluon_default_archs=("gfx1250",),
# gluon_ignored_keys=("persistent",),
# )
# def gemm_a16w16_fp32out(shape, backend):
# """DSV4 compressor-score / router GEMMs: bf16 x bf16 -> fp32, no bias."""
# import torch
#
# return _gemm_a16w16_dsv4(shape, backend, torch.float32)
#
#
# @kernel(
# "GEMM-A16W16",
# gluon_archs=("gfx1250",),
# gluon_default_archs=("gfx1250",),
# gluon_ignored_keys=("persistent",),
# )
# def gemm_a16w16_bf16out(shape, backend):
# """DSV4 indexer weights_proj: bf16 x bf16 -> bf16, no bias."""
# import torch
#
# return _gemm_a16w16_dsv4(shape, backend, torch.bfloat16)
#
#
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
🟡 Changes recommended
Existing tests do not exercise the new shape-specific configs or their FP32-output dispatch use.
2 open issues
What changed in this PR
This PR adds gfx950 Triton tuning configs for DeepSeek-V4 GEMMs with K=7168, using AITER’s existing config loader and model dispatch table.
Changes:
- Add five shape-specific GEMM configs with M buckets and tuned split-K settings.
- Add a B=2 batched GEMM config and cache-modifier fields in its defaults.
- Add model dispatch rows for BF16-input, FP32-output Triton GEMMs.
| File | Description |
|---|---|
aiter/ops/triton/configs/gfx950/triton/gemm/gemm_a16w16/GEMM-A16W16-N=64-K=7168.json |
Add tuning for N=64. |
aiter/ops/triton/configs/gfx950/triton/gemm/gemm_a16w16/GEMM-A16W16-N=512-K=7168.json |
Add tuning for N=512. |
aiter/ops/triton/configs/gfx950/triton/gemm/gemm_a16w16/GEMM-A16W16-N=2560-K=7168.json |
Add tuning for N=2560. |
aiter/ops/triton/configs/gfx950/triton/gemm/gemm_a16w16/GEMM-A16W16-N=2048-K=7168.json |
Add tuning for N=2048. |
aiter/ops/triton/configs/gfx950/triton/gemm/gemm_a16w16/GEMM-A16W16-N=1024-K=7168.json |
Add tuning for N=1024. |
aiter/ops/triton/configs/gfx950/triton/gemm/batched_gemm_a16w16/DEFAULT.json |
Add default cache-modifier fields. |
aiter/ops/triton/configs/gfx950/triton/gemm/batched_gemm_a16w16/BATCHED_GEMM-A16W16-B=2-N=1024-K=4096.json |
Add batched GEMM tuning for K=4096. |
aiter/configs/model_configs/dsv4_bf16_tuned_gemm.csv |
Add gfx950 FP32-output Triton dispatch rows. |
Review effort: Balanced

Add tuned GEMM-A16W16 configs on gfx950 for the bf16 GEMMs that DeepSeek-V4-Pro (TP8) runs on ROCm with hidden size K=7168:
Tuned time in us (speedup vs the previously used DEFAULT.json), tuner timing (24-call graph replay, cold inputs, split-K reduce included), MI355X (256 CUs):