Skip to content

[Triton/Gluon] bf16 persistent gemm - #4860

Merged
brunomazzottiamd merged 65 commits into
mainfrom
amemoore/bf16-persistent-gemm
Sep 14, 2026
Merged

brunomazzottiamd merged 65 commits into
mainfrom
amemoore/bf16-persistent-gemm

Conversation

@amirumoAMD

@amirumoAMD amirumoAMD commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

bf16 persistent gemm kernel, more performant than triton and non-persistent

Technical Details

gluon and triton persistent kernels, gluon throughput measured on performant GPU is ~1800TF

Test Plan

Performance compared with triton and non-persistent, unit tests against torch

Test Result

Persistent gemms show more performance, gluon persistent shows more performance than triton persistent

Submission Checklist

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 4860 --add-label <label>

PR title tags:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf] and op tags like [MLA] are left untouched. Add the no-auto-title label to opt this PR out of title tagging.

@amirumoAMD amirumoAMD changed the title Amemoore/bf16 persistent gemm bf16 persistent gemm Aug 19, 2026
@amirumoAMD
amirumoAMD marked this pull request as ready for review August 19, 2026 15:08
@amirumoAMD
amirumoAMD requested a review from a team August 19, 2026 15:08
@github-actions github-actions Bot changed the title bf16 persistent gemm [Triton/Gluon] bf16 persistent gemm Aug 19, 2026
@zufayu
zufayu requested a review from vgokhale August 20, 2026 00:53
@amirumoAMD
amirumoAMD force-pushed the amemoore/bf16-persistent-gemm branch 2 times, most recently from 59446ff to eb0eb18 Compare August 26, 2026 14:13
@github-actions github-actions Bot changed the title [Triton/Gluon] bf16 persistent gemm [Triton/Gluon] [CK] bf16 persistent gemm Aug 26, 2026
@Boss2002n
Boss2002n force-pushed the amemoore/bf16-persistent-gemm branch from 5f9f336 to 0738045 Compare September 1, 2026 22:55
@github-actions github-actions Bot changed the title [Triton/Gluon] [CK] bf16 persistent gemm [Triton/Gluon] bf16 persistent gemm Sep 1, 2026
@github-actions github-actions Bot removed the CK label Sep 1, 2026
@Boss2002n
Boss2002n force-pushed the amemoore/bf16-persistent-gemm branch from 310c523 to 346fa8f Compare September 2, 2026 15:43
@amirumoAMD
amirumoAMD force-pushed the amemoore/bf16-persistent-gemm branch from f5d9da1 to 4ed384b Compare September 2, 2026 19:46
@Boss2002n
Boss2002n force-pushed the amemoore/bf16-persistent-gemm branch from eb7046c to 5e2547e Compare September 3, 2026 19:38

@brunomazzottiamd brunomazzottiamd 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.

Publishing some comments...

I didn't check aiter/ops/triton/_gluon_kernels/gfx1250/gemm/basic/gemm_a16w16_persistent.py. I'll do it tomorrow. It'd be nice to have another reviewer for this Gluon kernel because I have no experience with gfx1250.

PS: I didn't meticulously check all the config files. There are a lot of config files!

@brunomazzottiamd brunomazzottiamd 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.

LGTM! Please get someone else to double check aiter/ops/triton/_gluon_kernels/gfx1250/gemm/basic/gemm_a16w16_persistent.py.

@omuhamma
omuhamma self-requested a review September 11, 2026 20:41

@brunomazzottiamd brunomazzottiamd 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.

Approving on behalf of ROCm/team_aiter (given @omuhamma approval of the gfx1250 Gluon kernels).

@brunomazzottiamd
brunomazzottiamd merged commit 2693202 into main Sep 14, 2026
71 checks passed
@brunomazzottiamd
brunomazzottiamd deleted the amemoore/bf16-persistent-gemm branch September 14, 2026 17:03
@Boss2002n
Boss2002n requested a balanced review from Copilot September 14, 2026 18:50

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.

🟡 Changes recommended

Persistent dispatch fails on gfx942, and several tuning changes are incomplete or bypass existing Gluon specializations.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 55/55 changed files
  • Comments generated: 5
  • Review effort level: Balanced

Comment on lines +142 to +144
config, _ = get_gemm_config(
"GEMM-A16W16-PERSISTENT", M, N, K, backend=backend
)
Comment on lines +2 to +6
"M_LEQ_8": {
"BLOCK_SIZE_M": 16,
"BLOCK_SIZE_N": 32,
"BLOCK_SIZE_K": 256,
"num_warps": 4,
Comment on lines +3 to +9
"BLOCK_SIZE_M": 16,
"BLOCK_SIZE_N": 16,
"BLOCK_SIZE_K": 512,
"num_warps": 2,
"GROUP_SIZE_M": 1,
"NUM_KSPLIT": 1,
"cache_modifier": null
Comment on lines +145 to +147
if backend == "triton":
config["NUM_KSPLIT"] = 1
config = compute_splitk_params(config, K)
Comment on lines 376 to +377
if config is None:
config, _ = get_gemm_config("GEMM-A16W16", M, N, K)
config, _ = get_gemm_config("GEMM-A16W16", M, N, K, backend="gluon")
sammysun0711 pushed a commit to sammysun0711/aiter that referenced this pull request Sep 16, 2026
* draft

* gluon + wire persistent gemm into test file

* wired test + config

* num tiles is regular parameter and implemented kernel as in the bf16 gemm host

* warp bases removed from kernel

* TN/TT support

* add logger statements

* test

* default configs for triton kernels

* restructure config files

* move config file

* working config for persistent + default configs

* fix wiring

* tuned gluon config

* tuned triton config

* update default

* clean up

* shared layouts in kernel

* restructure

* black

* new config

* config restructure

* OOM fix

* config changes

* file dir change

* model benchmark tuned configs

* fix num wgs

* added default triton config

* tuned configs, persistent faster

* updated configs for persistent gemm

* tuned configs and split-k support

* enable kernel type

* tune compute bound shape and kernel optimization

* hardcode 256 wgs

* minor changes

* new config + M=8192

* add prefetching beta

* remove clusters

* remove cluster and add buffer store

* add TDM store

* remove num buffers asserts

* new solution, 1660TF, prefetching and tdm store allowed but not ideal perf

* config changes for non-persistent bf16 gemm

* rebase main fix

* black

* config changes for persistent gemm

* config update to pass CI

* add config files to folder for triton kernel

* spills to zero

* touchups

* fix to abide by repo rules

* tuned configs

* fix triton configs to use triton keys

* update_tensor_descriptor + compute overlap, some perf uplift

* copilot suggestions

* ruff + black

* add large M small N bw bound kernel

* reorder for better perf

* addressed review comments

* black

* wmma bug

* removed comment

* addressed review comments

Signed-off-by: Xiake Sun <[email protected]>
vgokhale added a commit that referenced this pull request Sep 17, 2026
#4860 moved the gluon a16w16 dispatcher to backend="gluon" and created
configs/gfx1250/gluon/gemm/gemm_a16w16/ holding only DEFAULT.json. The 24
per-shape tuned files stayed in the triton directory, which gfx1250 never
reads since gluon is auto-selected on this arch, so every shape silently
resolved to the default: bandwidth_bound with NUM_BUFFERS=2 in place of
compute_bound at the tuned pipeline depth.

Restore the pre-#4860 configs into the gluon directory. Gluon now has a
single config family: each entry carries a persistent flag next to the params
tuned for the kernel it selects, so the persistent variant needs no second
lookup and its gluon config directory is removed. Triton keeps its own
persistent family, which gfx942 and gfx950 still use.
ZhengGong-amd added a commit to ZhengGong-amd/aiter that referenced this pull request Sep 17, 2026
…ings

get_gemm_config() hands every caller a copy.deepcopy() of the bucket dict it
got from the lru_cache'd loader. GEMM bucket entries are flat mappings of
scalar tuning values -- 2574 entries across 393 shipped tables are int, str,
None or bool, with no container among them -- so dict(entry) gives the caller
exactly the same isolation from the cached object, for a twentieth of the cost.

This is the rule the repo already states in two places (configs/CLAUDE.md and
.github/instructions/aiter-ops-triton.instructions.md: "dict(...) for flat
entries, copy.deepcopy for nested ones"), and the one get_conv_config() already
follows -- its docstring says it is modeled on get_gemm_config() and that "a
deep copy only adds hot-path overhead". This brings the GEMM loader in line,
and updates all three documents so they describe the same convention.

Flatness is an invariant rather than an observation, so add a guard over the
shipped tables: a bucket entry that gained a nested container would be shared
between the cache and the caller, and a caller mutating it in place would
poison every later lookup of that shape. A second test class drives
get_gemm_config() itself, so the isolation is exercised rather than inferred
from the tables -- returned dict is not the cached object, caller mutation does
not reach the cache, two callers hold independent objects.

Also convert the two remaining eager _LOGGER.info f-strings on the MXFP4
dispatch path -- gemm_afp4wfp4_() and dynamic_mxfp4_quant() -- to lazy
%-formatting. AiterTritonLogger forwards *args exactly so callers can avoid
building a message and its tuple(x.shape) temporaries below the configured
level; gemm_a16w16 was converted in ROCm#4860 and these two were left behind.

Same configs, same kernels. The two converted log lines do change their
rendering: "%s" on a torch.Size prints torch.Size([M, K]) where the f-string
printed (M, K). That is the rendering ROCm#4860 already introduced for
gemm_a16w16's lines in this same family, so this makes the MXFP4 sites
consistent with main rather than introducing a new format, and both are
INFO-level diagnostics that are off at the default WARNING level.

Generated-by: Hyperloom
Co-authored-by: Claude
Signed-off-by: Zheng Gong <[email protected]>
Co-authored-by: Cursor <[email protected]>
ZhengGong-amd added a commit to ZhengGong-amd/aiter that referenced this pull request Sep 17, 2026
…ings

get_gemm_config() hands every caller a copy.deepcopy() of the bucket dict it
got from the lru_cache'd loader. GEMM bucket entries are flat mappings of
scalar tuning values -- 2574 entries across 393 shipped tables are int, str,
None or bool, with no container among them -- so dict(entry) gives the caller
exactly the same isolation from the cached object, for a twentieth of the cost.

This is the rule the repo already states in two places (configs/CLAUDE.md and
.github/instructions/aiter-ops-triton.instructions.md: "dict(...) for flat
entries, copy.deepcopy for nested ones"), and the one get_conv_config() already
follows -- its docstring says it is modeled on get_gemm_config() and that "a
deep copy only adds hot-path overhead". This brings the GEMM loader in line,
and updates all three documents so they describe the same convention.

Flatness is an invariant rather than an observation, so add a guard over the
shipped tables: a bucket entry that gained a nested container would be shared
between the cache and the caller, and a caller mutating it in place would
poison every later lookup of that shape. A second test class drives
get_gemm_config() itself, so the isolation is exercised rather than inferred
from the tables -- returned dict is not the cached object, caller mutation does
not reach the cache, two callers hold independent objects.

Also convert the two remaining eager _LOGGER.info f-strings on the MXFP4
dispatch path -- gemm_afp4wfp4_() and dynamic_mxfp4_quant() -- to lazy
%-formatting. AiterTritonLogger forwards *args exactly so callers can avoid
building a message and its tuple(x.shape) temporaries below the configured
level; gemm_a16w16 was converted in ROCm#4860 and these two were left behind.

Same configs, same kernels. The two converted log lines do change their
rendering: "%s" on a torch.Size prints torch.Size([M, K]) where the f-string
printed (M, K). That is the rendering ROCm#4860 already introduced for
gemm_a16w16's lines in this same family, so this makes the MXFP4 sites
consistent with main rather than introducing a new format, and both are
INFO-level diagnostics that are off at the default WARNING level.

Generated-by: Hyperloom
Co-authored-by: Claude
Signed-off-by: Zheng Gong <[email protected]>
Co-authored-by: Cursor <[email protected]>
ZhengGong-amd added a commit to ZhengGong-amd/aiter that referenced this pull request Sep 17, 2026
…ings

get_gemm_config() hands every caller a copy.deepcopy() of the bucket dict it
got from the lru_cache'd loader. GEMM bucket entries are flat mappings of
scalar tuning values -- 2574 entries across 393 shipped tables are int, str,
None or bool, with no container among them -- so dict(entry) gives the caller
exactly the same isolation from the cached object, for a twentieth of the cost.

This is the rule the repo already states in two places (configs/CLAUDE.md and
.github/instructions/aiter-ops-triton.instructions.md: "dict(...) for flat
entries, copy.deepcopy for nested ones"), and the one get_conv_config() already
follows -- its docstring says it is modeled on get_gemm_config() and that "a
deep copy only adds hot-path overhead". This brings the GEMM loader in line,
and updates all three documents so they describe the same convention.

Flatness is an invariant rather than an observation, so add a guard over the
shipped tables: a bucket entry that gained a nested container would be shared
between the cache and the caller, and a caller mutating it in place would
poison every later lookup of that shape. A second test class drives
get_gemm_config() itself, so the isolation is exercised rather than inferred
from the tables -- returned dict is not the cached object, caller mutation does
not reach the cache, two callers hold independent objects.

Also convert the two remaining eager _LOGGER.info f-strings on the MXFP4
dispatch path -- gemm_afp4wfp4_() and dynamic_mxfp4_quant() -- to lazy
%-formatting. AiterTritonLogger forwards *args exactly so callers can avoid
building a message and its tuple(x.shape) temporaries below the configured
level; gemm_a16w16 was converted in ROCm#4860 and these two were left behind.

Same configs, same kernels. The two converted log lines do change their
rendering: "%s" on a torch.Size prints torch.Size([M, K]) where the f-string
printed (M, K). That is the rendering ROCm#4860 already introduced for
gemm_a16w16's lines in this same family, so this makes the MXFP4 sites
consistent with main rather than introducing a new format, and both are
INFO-level diagnostics that are off at the default WARNING level.

Generated-by: Hyperloom
Co-authored-by: Claude
Signed-off-by: Zheng Gong <[email protected]>
Co-authored-by: Cursor <[email protected]>
ZhengGong-amd added a commit to ZhengGong-amd/aiter that referenced this pull request Sep 21, 2026
…ings

get_gemm_config() hands every caller a copy.deepcopy() of the bucket dict it
got from the lru_cache'd loader. GEMM bucket entries are flat mappings of
scalar tuning values -- 2574 entries across 393 shipped tables are int, str,
None or bool, with no container among them -- so dict(entry) gives the caller
exactly the same isolation from the cached object, for a twentieth of the cost.

This is the rule the repo already states in two places (configs/CLAUDE.md and
.github/instructions/aiter-ops-triton.instructions.md: "dict(...) for flat
entries, copy.deepcopy for nested ones"), and the one get_conv_config() already
follows -- its docstring says it is modeled on get_gemm_config() and that "a
deep copy only adds hot-path overhead". This brings the GEMM loader in line,
and updates all three documents so they describe the same convention.

Flatness is an invariant rather than an observation, so add a guard over the
shipped tables: a bucket entry that gained a nested container would be shared
between the cache and the caller, and a caller mutating it in place would
poison every later lookup of that shape. A second test class drives
get_gemm_config() itself, so the isolation is exercised rather than inferred
from the tables -- returned dict is not the cached object, caller mutation does
not reach the cache, two callers hold independent objects.

Also convert the two remaining eager _LOGGER.info f-strings on the MXFP4
dispatch path -- gemm_afp4wfp4_() and dynamic_mxfp4_quant() -- to lazy
%-formatting. AiterTritonLogger forwards *args exactly so callers can avoid
building a message and its tuple(x.shape) temporaries below the configured
level; gemm_a16w16 was converted in ROCm#4860 and these two were left behind.

Same configs, same kernels. The two converted log lines do change their
rendering: "%s" on a torch.Size prints torch.Size([M, K]) where the f-string
printed (M, K). That is the rendering ROCm#4860 already introduced for
gemm_a16w16's lines in this same family, so this makes the MXFP4 sites
consistent with main rather than introducing a new format, and both are
INFO-level diagnostics that are off at the default WARNING level.

Generated-by: Hyperloom
Co-authored-by: Claude
Signed-off-by: Zheng Gong <[email protected]>
Co-authored-by: Cursor <[email protected]>
zhanglx13 added a commit that referenced this pull request Oct 2, 2026
…mm_a8w8_blockscale

Both benchmarks crash before printing a single result on current main.

bench_moe_gemm_int8_smoothquant passes add_residual=False to
moe_gemm_int8_smoothquant, but the MXFP8 GEMM and A8W4 MoE optimization (#3292)
renamed that argument to swiglu_add_residual. The meaning is unchanged:
both compute s * (linear + 1) when set. The call now fails with
"unexpected keyword argument 'add_residual'".

bench_moe_gemm_a8w8_blockscale builds the routing GEMM inputs in fp32
(xg = x.to(torch.float32), and wg with the default dtype) and passes them
to gemm_a16w16. Since #4860, gemm_a16w16 asserts fp16/bf16 activations
and weights. Build both in bf16, as bench_moe_gemm_a8w8 and
bench_moe_gemm_int8_smoothquant already do.
azaidy pushed a commit that referenced this pull request Oct 5, 2026
…mm_a8w8_blockscale (#6071)

Both benchmarks crash before printing a single result on current main.

bench_moe_gemm_int8_smoothquant passes add_residual=False to
moe_gemm_int8_smoothquant, but the MXFP8 GEMM and A8W4 MoE optimization (#3292)
renamed that argument to swiglu_add_residual. The meaning is unchanged:
both compute s * (linear + 1) when set. The call now fails with
"unexpected keyword argument 'add_residual'".

bench_moe_gemm_a8w8_blockscale builds the routing GEMM inputs in fp32
(xg = x.to(torch.float32), and wg with the default dtype) and passes them
to gemm_a16w16. Since #4860, gemm_a16w16 asserts fp16/bf16 activations
and weights. Build both in bf16, as bench_moe_gemm_a8w8 and
bench_moe_gemm_int8_smoothquant already do.
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.

4 participants