Repository navigation
[Triton/Gluon] bf16 persistent gemm - #4860
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags: |
59446ff to
eb0eb18
Compare
5f9f336 to
0738045
Compare
310c523 to
346fa8f
Compare
f5d9da1 to
4ed384b
Compare
eb7046c to
5e2547e
Compare
brunomazzottiamd
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
LGTM! Please get someone else to double check aiter/ops/triton/_gluon_kernels/gfx1250/gemm/basic/gemm_a16w16_persistent.py.
brunomazzottiamd
left a comment
There was a problem hiding this comment.
Approving on behalf of ROCm/team_aiter (given @omuhamma approval of the gfx1250 Gluon kernels).
There was a problem hiding this comment.
🟡 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
| config, _ = get_gemm_config( | ||
| "GEMM-A16W16-PERSISTENT", M, N, K, backend=backend | ||
| ) |
| "M_LEQ_8": { | ||
| "BLOCK_SIZE_M": 16, | ||
| "BLOCK_SIZE_N": 32, | ||
| "BLOCK_SIZE_K": 256, | ||
| "num_warps": 4, |
| "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 |
| if backend == "triton": | ||
| config["NUM_KSPLIT"] = 1 | ||
| config = compute_splitk_params(config, K) |
| if config is None: | ||
| config, _ = get_gemm_config("GEMM-A16W16", M, N, K) | ||
| config, _ = get_gemm_config("GEMM-A16W16", M, N, K, backend="gluon") |
* 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]>
#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.
…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]>
…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]>
…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]>
…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]>
…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.
…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.
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