Repository navigation
Conversation
4afdaf0 to
34a91c8
Compare
brunomazzottiamd
left a comment
There was a problem hiding this comment.
Address pending discussions from other PRs:
Why merging all these files into a single file?
aiter/ops/triton/utils/conv_config_utils.pyaiter/ops/triton/utils/core.pyaiter/ops/triton/utils/gemm_config_utils.pyaiter/ops/triton/utils/mha_kernel_utils.pyaiter/ops/triton/utils/mhc_config_utils.pyaiter/ops/triton/utils/tuned_config_utils.py
PS: I still need to check aiter/ops/triton/utils/config_utils.py, everything else looks good.
34a91c8 to
3604c09
Compare
3604c09 to
d82baef
Compare
utils/ reorganized for reuse: ONE config_utils.py absorbs core.py and the gemm/conv/mhc/tuned config_utils modules, laid out in five clearly-banded sections (shared core, GEMM, conv, MHC, tuned kernel entries) so each op family stays visibly separate inside the single import surface. The duplicate utils/mha_kernel_utils.py is dropped in favor of the byte-equal utils/_triton copy; every importer tree-wide is updated. gmm_common stays put under utils/ so tests and benchmarks keep importing a public module. resolve_config_dir() gets the contract the #4947/#5019 reviews asked for, hardened: an Args/Returns/Raises/Example docstring; every argument validated against a whitelist with assertions (op, config_name and the programmer-written arch= override must match strict identifier patterns, the driver-derived running arch tolerates vendor formats but must stay path-safe, backend is checked against ("triton", "gluon")) so a bad value fails closed instead of resolving an escaped or wrong directory; a single str return value (the unused name_prefix tuple element is gone, no caller unpacks a tuple); and fully deterministic behavior -- the directory is built, never probed, and the legacy escape hatches are deleted, so nothing silently returns a bogus last candidate: a missing required table fails loudly in load_config_json() naming the exact nested path, and optional tables pass required=False. The MOE dispatch loaders now declare their backend per dispatch path (a8w4's triton path resolves backend="triton", the gluon paths "gluon"; a4w4 is gluon-only), and gfx1250 gains byte-identical triton seeds copied from gfx950 (GEMM-AFP4WFP4, moe A8W4, HSTU fwd/bwd) so the one resolution the caller-declared policy changes -- triton GEMM-AFP4WFP4 on gfx1250 no longer borrowing gluon tables -- stays launchable until gfx1250 is tuned natively. Gluon configs are never copied across arches. Conv's section carries the variant-aware walk from #4869 unchanged (its M-bounds renamed CONV_STANDARD_M_BOUNDS to coexist with GEMM's).
d82baef to
97d6c20
Compare
There was a problem hiding this comment.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
ruff
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/conv/conv2d.py
Lines 4 to 42 in 97d6c20
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/fusions/fused_clamp_act_mul.py
Lines 4 to 22 in 97d6c20
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/fusions/mhc.py
Lines 4 to 20 in 97d6c20
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/gemm/basic/gemm_a16w16_atomic.py
Lines 4 to 14 in 97d6c20
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/gemm/basic/gemm_a16w8_blockscale.py
Lines 4 to 16 in 97d6c20
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/gemm/basic/gemm_a8w8.py
Lines 4 to 21 in 97d6c20
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/gemm/basic/gemm_a8w8_blockscale.py
Lines 4 to 25 in 97d6c20
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/gemm/batched/batched_gemm_bf16.py
Lines 4 to 16 in 97d6c20
Import block is un-sorted or un-formatted
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/gemm/fused/fused_gemm_afp4wfp4_a16w16.py
Lines 4 to 19 in 97d6c20
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/gemm/fused/fused_gemm_afp4wfp4_mul_add.py
Lines 4 to 18 in 97d6c20
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/gluon/gemm_afp4wfp4.py
Lines 1 to 9 in 97d6c20
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/moe/moe_op_gemm_a4w4.py
Lines 4 to 27 in 97d6c20
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/moe/moe_op_gemm_a8w4.py
Lines 4 to 32 in 97d6c20
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/moe/moe_op_gemm_a8w8.py
Lines 4 to 15 in 97d6c20
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/utils/_triton/tunning/ut_a8w8_gemm.py
Lines 1 to 16 in 97d6c20
Import block is un-sorted or un-formatted
Import block is un-sorted or un-formatted
aiter/aiter/ops/triton/utils/config_utils.py
Lines 31 to 42 in 97d6c20
Import block is un-sorted or un-formatted
aiter/op_tests/op_benchmarks/triton/bench_mhc.py
Lines 31 to 53 in 97d6c20
Import block is un-sorted or un-formatted
aiter/op_tests/op_benchmarks/triton/bench_mhc.py
Lines 60 to 62 in 97d6c20
Import block is un-sorted or un-formatted
Import block is un-sorted or un-formatted
aiter/op_tests/triton_tests/conv/_helpers.py
Lines 35 to 57 in 97d6c20
Import block is un-sorted or un-formatted
aiter/op_tests/triton_tests/conv/test_conv2d.py
Lines 35 to 51 in 97d6c20
Import block is un-sorted or un-formatted
aiter/op_tests/triton_tests/fusions/test_mhc.py
Lines 25 to 41 in 97d6c20
Import block is un-sorted or un-formatted
aiter/op_tests/triton_tests/fusions/test_mhc.py
Lines 751 to 756 in 97d6c20
Import block is un-sorted or un-formatted
aiter/op_tests/triton_tests/fusions/test_mhc.py
Lines 782 to 787 in 97d6c20
Import block is un-sorted or un-formatted
aiter/op_tests/triton_tests/gemm/basic/test_gemm_a8w8.py
Lines 4 to 20 in 97d6c20
Import block is un-sorted or un-formatted
aiter/op_tests/triton_tests/gemm/basic/test_gemm_afp8wfp8.py
Lines 4 to 16 in 97d6c20
Import block is un-sorted or un-formatted
aiter/op_tests/triton_tests/gemm/basic/test_gemm_afp8wfp8.py
Lines 281 to 284 in 97d6c20
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 76 out of 76 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
aiter/ops/triton/init.py:145
- The backward-compatibility map for old flat module names no longer includes the legacy
coreentry (it previously redirectedaiter.ops.triton.coreto the utils core module). Any external callers still importingaiter.ops.triton.corewill now fail, even though the rest of this file is explicitly meant to preserve those old paths.
# Utils modules (utils/)
"common_utils": "utils.common_utils",
"config_utils": "utils.config_utils",
"device_info": "utils.device_info",
"gmm_common": "utils.gmm_common",
aiter/ops/triton/utils/config_utils.py:9
- This PR deletes
utils/core.py,utils/gemm_config_utils.py,utils/conv_config_utils.py,utils/mhc_config_utils.py, andutils/tuned_config_utils.py, butaiter/ops/triton/README.mdand.github/instructions/aiter-ops-triton.instructions.mdstill reference those paths and behaviors (e.g.utils/gemm_config_utils.py::get_gemm_config(..., backend=None, ...),utils/core.py::load_config_json, and the MOE nested-layout resolver status). These docs should be updated in the same PR to avoid directing new callers to removed modules.
| def _mhc_config_dir(dev: str, config_name: str) -> str: | ||
| """``dev``'s nested config directory for the ``config_name`` family.""" | ||
| return resolve_config_dir("mhc", config_name, backend="triton", arch=dev) |
| import aiter.jit.utils.chip_info as _aiter_chip_info | ||
|
|
||
| import aiter as _aiter | ||
| except ImportError: # pragma: no cover |
There was a problem hiding this comment.
Import block is un-sorted or un-formatted
| import aiter.jit.utils.chip_info as _aiter_chip_info | |
| import aiter as _aiter | |
| except ImportError: # pragma: no cover | |
| import aiter as _aiter | |
| import aiter.jit.utils.chip_info as _aiter_chip_info | |
| except ImportError: # pragma: no cover |
| from op_tests.triton_tests.utils.mhc_ref import ( | ||
| generate_mhc_post_inputs, | ||
| mhc_post_torch, | ||
| ) | ||
|
|
||
| from aiter.ops.triton.fusions.mhc import mhc_post | ||
|
|
There was a problem hiding this comment.
Import block is un-sorted or un-formatted
| from op_tests.triton_tests.utils.mhc_ref import ( | |
| generate_mhc_post_inputs, | |
| mhc_post_torch, | |
| ) | |
| from aiter.ops.triton.fusions.mhc import mhc_post | |
| from aiter.ops.triton.fusions.mhc import mhc_post | |
| from op_tests.triton_tests.utils.mhc_ref import ( | |
| generate_mhc_post_inputs, | |
| mhc_post_torch, | |
| ) | |
| from op_tests.triton_tests.utils.mhc_ref import ( | ||
| generate_mhc_post_inputs, | ||
| mhc_post_torch, | ||
| ) | ||
|
|
||
| from aiter.ops.triton.fusions.mhc import mhc_post | ||
|
|
There was a problem hiding this comment.
Import block is un-sorted or un-formatted
| from op_tests.triton_tests.utils.mhc_ref import ( | |
| generate_mhc_post_inputs, | |
| mhc_post_torch, | |
| ) | |
| from aiter.ops.triton.fusions.mhc import mhc_post | |
| from aiter.ops.triton.fusions.mhc import mhc_post | |
| from op_tests.triton_tests.utils.mhc_ref import ( | |
| generate_mhc_post_inputs, | |
| mhc_post_torch, | |
| ) | |
| from aiter.ops.triton._gluon_kernels.gfx1250.gemm.basic.gemm_mxfp8 import ( | ||
| cga_bases, | ||
| ) | ||
| from triton._C.libtriton.gluon_ir import make_cga_layout | ||
|
|
There was a problem hiding this comment.
Import block is un-sorted or un-formatted
| from aiter.ops.triton._gluon_kernels.gfx1250.gemm.basic.gemm_mxfp8 import ( | |
| cga_bases, | |
| ) | |
| from triton._C.libtriton.gluon_ir import make_cga_layout | |
| from triton._C.libtriton.gluon_ir import make_cga_layout | |
| from aiter.ops.triton._gluon_kernels.gfx1250.gemm.basic.gemm_mxfp8 import ( | |
| cga_bases, | |
| ) | |
There was a problem hiding this comment.
Import block is un-sorted or un-formatted
aiter/op_tests/op_benchmarks/triton/bench_mhc.py
Lines 31 to 53 in 318e96f
There was a problem hiding this comment.
Import block is un-sorted or un-formatted
aiter/op_tests/triton_tests/conv/_helpers.py
Lines 35 to 57 in 318e96f
There was a problem hiding this comment.
Import block is un-sorted or un-formatted
aiter/op_tests/triton_tests/conv/test_conv2d.py
Lines 35 to 51 in 318e96f
There was a problem hiding this comment.
Import block is un-sorted or un-formatted
aiter/op_tests/triton_tests/fusions/test_mhc.py
Lines 25 to 41 in 318e96f
There was a problem hiding this comment.
Import block is un-sorted or un-formatted
aiter/op_tests/triton_tests/gemm/basic/test_gemm_a8w8.py
Lines 4 to 20 in 318e96f
There was a problem hiding this comment.
Import block is un-sorted or un-formatted
aiter/op_tests/triton_tests/gemm/basic/test_gemm_afp8wfp8.py
Lines 4 to 16 in 318e96f
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 76 out of 76 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
aiter/ops/triton/utils/config_utils.py:714
- MHC config selection treats "M_LEQ_" buckets as lower bounds (picks the largest threshold <= M), but the shipped MHC DEFAULT.json uses M_LEQ_* as upper bounds. For example, gfx942 mhc_fused_sinkhorn has M_LEQ_32 and M_LEQ_64; with M=48 this code incorrectly selects M_LEQ_32 instead of M_LEQ_64, changing which kernel tile is used.
aiter/ops/triton/utils/config_utils.py:9 - This refactor deletes utils/core.py and consolidates config loading into utils/config_utils.py, but the repo documentation still references the old paths (e.g.
.github/instructions/aiter-ops-triton.instructions.mdrecommendsaiter.ops.triton.utils.core.load_config_json). Please update the contributor docs (andaiter/ops/triton/README.mdif it mentions the old modules) so new code follows the new import path.
| "common_utils": "utils.common_utils", | ||
| "core": "utils.core", | ||
| "config_utils": "utils.config_utils", |
|
Deprecated in favor of #5061. |
Structure
utils/config_utils.py (new) absorbs, in this order:
utils/core.py -> "Shared core" section
utils/gemm_config_utils.py -> "GEMM"
utils/conv_config_utils.py -> "Conv"
utils/mhc_config_utils.py -> "MHC"
utils/tuned_config_utils.py -> "Tuned kernel entries"
All five are deleted. One module means one import line per caller and
one place where the nested-layout probe lives.
resolve_config_dir() now returns just the directory string. The second element of the old tuple was the legacy arch-prefix, which is always empty now that every config family has moved to the nested layout, so every call site was unpacking a constant.