Repository navigation
[Triton/Gluon] Add config-aware repr to the MOE and fusion kernels - #5098
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags: |
There was a problem hiding this comment.
Pull request overview
This PR standardizes Triton and Gluon kernel naming by adding config-aware repr functions (via make_kernel_repr) to MOE routing/reduction/GEMM kernels and several fusion kernels, improving traceability of compiled specializations in profiling, caching, and debug artifacts.
Changes:
- Add
make_kernel_repr(...)definitions capturing relevanttl.constexpr/gl.constexprspecialization keys. - Attach those repr functions to entry kernels using
@triton.jit(repr=...)/@gluon.jit(repr=...). - Extend this across MOE kernels (routing, quant helpers, GEMMs) and fusion kernels (attention residual, KV cache, qk concat, mul-add, mHC).
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| aiter/ops/triton/_triton_kernels/moe/reduce.py | Add config-aware repr for _reduce_grouped and pass it to @triton.jit. |
| aiter/ops/triton/_triton_kernels/moe/quant_moe.py | Add config-aware reprs for quantize/downcast/upcast and smoothquant fused kernels. |
| aiter/ops/triton/_triton_kernels/moe/moe_routing/topk.py | Add config-aware reprs for _topk, _hash_routing, and _grouped_topk. |
| aiter/ops/triton/_triton_kernels/moe/moe_routing/routing.py | Add config-aware reprs for _combined_routing and _combined_routing_fused. |
| aiter/ops/triton/_triton_kernels/moe/moe_routing/minunique.py | Add config-aware repr for _keepk_sort0. |
| aiter/ops/triton/_triton_kernels/moe/moe_routing/bitmatrix.py | Add config-aware reprs for bitmatrix memset and row-sum kernels. |
| aiter/ops/triton/_triton_kernels/moe/moe_op_gemm_int8_smoothquant.py | Add config-aware repr for the Int8 SmoothQuant MoE GEMM kernel. |
| aiter/ops/triton/_triton_kernels/moe/moe_op_gemm_a8w8.py | Add config-aware repr for A8W8 MoE GEMM kernel. |
| aiter/ops/triton/_triton_kernels/moe/moe_op_gemm_a8w8_blockscale.py | Add config-aware repr for A8W8 blockscale MoE GEMM kernel. |
| aiter/ops/triton/_triton_kernels/moe/moe_op_gemm_a4w4.py | Add config-aware repr for the MXFP4 quant kernel. |
| aiter/ops/triton/_triton_kernels/fusions/mhc.py | Add config-aware reprs for multiple mHC fused/split/reduce/post kernels. |
| aiter/ops/triton/_triton_kernels/fusions/fused_qk_concat.py | Add config-aware reprs for q/k concat kernels (with and without RoPE). |
| aiter/ops/triton/_triton_kernels/fusions/fused_mul_add.py | Add config-aware repr for fused mul-add kernel. |
| aiter/ops/triton/_triton_kernels/fusions/fused_kv_cache.py | Add config-aware reprs for fused RoPE+reshape+cache kernels. |
| aiter/ops/triton/_triton_kernels/fusions/attn_res.py | Add config-aware repr for attnres_fwd_kernel and pass it to @triton.jit. |
| aiter/ops/triton/_gluon_kernels/gfx942/moe/moe_op_gemm_int8_smoothquant.py | Add config-aware repr for the Gluon Int8 SmoothQuant MoE GEMM kernel. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags & labels: |
31 launchable kernels across the MOE GEMMs, quant_moe, reduce, the moe_routing
package, and _triton_kernels/fusions/{attn_res,fused_kv_cache,fused_mul_add,
fused_qk_concat,mhc}.py.
Two of those are only reachable indirectly and a name grep misses them:
fused_kv_cache's _fused_qk_rope_cat_and_cache_mla_kernel and
_fused_qk_rope_reshape_and_cache_kernel are imported under aliases, bound to a
local behind a gfx1250 branch, and launched through that local.
31 jit device helpers are left alone. Two of them carry a _kernel suffix but
are not launchable: _store_kv_cache_kernel is called as a device function from
inside another kernel, and _dequant_int8_to_fp32_kernel has no references
anywhere in the tree.
Float tolerances are excluded from the key lists (eps, out_eps, scale, FP8_MAX
in attn_res; the four hc_* values in mhc) -- they would put raw floats in kernel
names without identifying a config, and mhc's existing repr already lists only
shape and block keys. ROUTED_SCALING is kept despite being a float: it is a
routing config with no companion flag, and logit_cap sets the precedent.
Key lists follow the neighbouring kernels in each subtree: tuned block/tile
sizes and the meaningful compile-time flags, with runtime pointers, strides and
grid-extent constexprs excluded (the launch site was checked before deciding on
each one). A key that is not a real parameter renders as NONE in every trace
name, so every list was re-parsed from the file and cross-checked against the
kernel signature, then rendered through the real make_kernel_repr to confirm no
NONE appears. Bare @triton.jit(repr=...) is used throughout, matching the
majority of the reprs already in the tree.
Full-tree ruff (0.16.0, the CI pin) and black report exactly the same findings
as main.
Keys whose value can be negative or a non-integral float are deliberately
excluded. make_kernel_repr renders the value into the kernel name, and Triton
then rejects the name -- "CompilationError: invalid function identifier" -- so
e.g. a 2.5 becomes "..._2.5" and the name breaks at the dot, and a -448 breaks
at the minus. Every key list here was checked against the values its launch
sites actually pass.
Dropped on that basis: ROUTED_SCALING on _topk / _hash_routing / _grouped_topk /
_keepk_sort0. It takes routed_scaling_factor straight from the caller, and the
routing tests pass 2.5 -- which is exactly the failure this note describes.
428aee1 to
26e62a7
Compare
One conflict, in _triton_kernels/fusions/mhc.py. #5149 reverted the Triton parts of #4978, which removed _mhc_asymmetric_sinkhorn_kernel and _mhc_head_kernel outright; this branch had added a repr to each. Took the deletion -- both kernels and both repr definitions are gone -- and kept the _mhc_fused_kernel repr, which sat in the same hunk and whose kernel main still has. 31 of the branch's 33 reprs survive; the two dropped are exactly the two whose kernels no longer exist. No reference to either name is left anywhere in the tree, and every remaining @triton.jit(repr=...) resolves to a definition.
No description provided.