Skip to content

[Triton/Gluon] Consolidate and reorganize ops/triton utils - #5061

Merged
Boss2002n merged 12 commits into
mainfrom
satya/cleanup-triton-utils
Aug 28, 2026
Merged

Boss2002n merged 12 commits into
mainfrom
satya/cleanup-triton-utils

Conversation

@Boss2002n

Copy link
Copy Markdown
Contributor

No description provided.

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).
@Boss2002n
Boss2002n requested review from brunomazzottiamd and a balanced review from Copilot August 27, 2026 21:43
@Boss2002n Boss2002n self-assigned this Aug 27, 2026
@Boss2002n
Boss2002n requested a review from a team August 27, 2026 21:43
@github-actions github-actions Bot changed the title Consolidate and reorganize ops/triton utils [Triton/Gluon] Consolidate and reorganize ops/triton utils Aug 27, 2026
@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
multigpu Aiter multi-GPU tests on the 8-GPU runner
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 5061 --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.

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.

Pull request overview

Consolidates Triton configuration utilities into config_utils.py, updates consumers, and adds gfx1250 tuning tables.

Changes:

  • Merges core, GEMM, Conv, MHC, and tuned-config helpers.
  • Makes backend-specific config resolution explicit.
  • Updates imports, tests, benchmarks, and gfx1250 configs.

Reviewed changes

Copilot reviewed 76 out of 76 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
op_tests/triton_tests/gemm/basic/test_gemm_afp8wfp8.py Updates config imports.
op_tests/triton_tests/gemm/basic/test_gemm_a8w8.py Updates config imports.
op_tests/triton_tests/fusions/test_mhc.py Updates MHC config imports.
op_tests/triton_tests/conv/test_conv2d.py Uses consolidated Conv config utilities.
op_tests/triton_tests/conv/_helpers.py Updates Conv helper import.
op_tests/op_benchmarks/triton/bench_moe_gemm_a8w8_blockscale.py Updates benchmark imports.
op_tests/op_benchmarks/triton/bench_mhc.py Updates MHC benchmark imports.
aiter/ops/triton/utils/tuned_config_utils.py Removes superseded tuned-config module.
aiter/ops/triton/utils/mhc_config_utils.py Removes superseded MHC config module.
aiter/ops/triton/utils/mha_kernel_utils.py Removes relocated MHA helper.
aiter/ops/triton/utils/gemm_config_utils.py Removes superseded GEMM config module.
aiter/ops/triton/utils/core.py Removes superseded config core.
aiter/ops/triton/utils/conv_config_utils.py Removes superseded Conv config module.
aiter/ops/triton/utils/config_utils.py Adds consolidated configuration infrastructure.
aiter/ops/triton/utils/_triton/tunning/ut_afp8wfp8_gemm_preshuffle.py Updates tuning import.
aiter/ops/triton/utils/_triton/tunning/ut_a8w8_gemm.py Updates tuning import.
aiter/ops/triton/moe/moe_op_gemm_a8w8.py Updates stage-selection import.
aiter/ops/triton/moe/moe_op_gemm_a8w4.py Adds backend-specific dispatch loading.
aiter/ops/triton/moe/moe_op_gemm_a4w4.py Selects Gluon dispatch config explicitly.
aiter/ops/triton/gluon/gemm_afp4wfp4.py Updates GEMM config import.
aiter/ops/triton/gemm/fused/fused_gemm_afp4wfp4_mul_add.py Updates config path import.
aiter/ops/triton/gemm/fused/fused_gemm_afp4wfp4_a16w16.py Updates config path import.
aiter/ops/triton/gemm/fused/fused_gemm_a8w8_blockscale_mul_add.py Updates split-K import.
aiter/ops/triton/gemm/batched/batched_gemm_bf16.py Updates GEMM config import.
aiter/ops/triton/gemm/basic/gemm_a8w8.py Updates GEMM config import.
aiter/ops/triton/gemm/basic/gemm_a8w8_blockscale.py Updates split-K import.
aiter/ops/triton/gemm/basic/gemm_a16w8_blockscale.py Updates split-K import.
aiter/ops/triton/gemm/basic/gemm_a16w16.py Updates GEMM config import.
aiter/ops/triton/gemm/basic/gemm_a16w16_atomic.py Updates default-config import.
aiter/ops/triton/fusions/mhc.py Uses consolidated MHC loaders.
aiter/ops/triton/fusions/fused_clamp_act_mul.py Uses consolidated config core.
aiter/ops/triton/conv/conv2d.py Uses consolidated Conv loaders.
aiter/ops/triton/conv/_launch.py Updates Conv formatter imports.
aiter/ops/triton/configs/gfx1250/triton/moe/a8w4/DEFAULT.json Adds gfx1250 Triton A8W4 dispatch entries.
aiter/ops/triton/configs/gfx1250/triton/gemm/gemm_afp4wfp4/DEFAULT.json Adds gfx1250 Triton AFP4 defaults.
aiter/ops/triton/configs/gfx1250/triton/attention/hstu_attn_fwd/DEFAULT.json Adds gfx1250 HSTU forward tuning.
aiter/ops/triton/configs/gfx1250/triton/attention/hstu_attn_bwd/DEFAULT.json Adds gfx1250 HSTU backward tuning.
aiter/ops/triton/attention/pa_mqa_logits.py Updates config path import.
aiter/ops/triton/_triton_kernels/gmm.py Uses consolidated GMM config resolution.
aiter/ops/triton/_triton_kernels/gemm/fused/fused_gemm_afp4wfp4_mul_add.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/fused/fused_gemm_afp4wfp4_a16w16.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/fused/fused_gemm_a8w8_blockscale_split_cat.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/fused/fused_gemm_a8w8_blockscale_mul_add.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/fused/fused_gemm_a8w8_blockscale_a16w16.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/fused/fused_gemm_a16w16_quant_x.py Updates GEMM helper imports.
aiter/ops/triton/_triton_kernels/gemm/feed_forward/ff_a16w16_fused_ungated.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/feed_forward/ff_a16w16_fused_gated.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/batched/batched_gemm_bf16.py Updates config imports.
aiter/ops/triton/_triton_kernels/gemm/batched/batched_gemm_afp4wfp4.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/batched/batched_gemm_a8w8.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/batched/batched_gemm_a8w8_a_per_token_group_prequant_w_per_batched_tensor_quant.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/batched/batched_gemm_a16wfp4.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/basic/gemm_afp8wfp8.py Defaults config lookup to Triton.
aiter/ops/triton/_triton_kernels/gemm/basic/gemm_afp4wfp4.py Defaults config lookup to Triton.
aiter/ops/triton/_triton_kernels/gemm/basic/gemm_a8wfp4.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/basic/gemm_a8w8.py Updates config imports.
aiter/ops/triton/_triton_kernels/gemm/basic/gemm_a8w8_per_token_scale.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/basic/gemm_a8w8_blockscale.py Defaults config lookup to Triton.
aiter/ops/triton/_triton_kernels/gemm/basic/gemm_a16wfp4.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/basic/gemm_a16w8_blockscale.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/basic/gemm_a16w16.py Updates config imports.
aiter/ops/triton/_triton_kernels/gemm/basic/gemm_a16w16_gated.py Updates config import.
aiter/ops/triton/_triton_kernels/gemm/basic/gemm_a16w16_atomic.py Updates config import.
aiter/ops/triton/_triton_kernels/conv/nchw_to_cblocked.py Updates Conv config import.
aiter/ops/triton/_triton_kernels/conv/conv_general.py Updates Conv config import.
aiter/ops/triton/_triton_kernels/conv/conv_3x3.py Updates Conv config import.
aiter/ops/triton/_triton_kernels/conv/conv_3x3_winograd_f4x3.py Updates Conv config import.
aiter/ops/triton/_triton_kernels/conv/conv_1x1.py Updates Conv config import.
aiter/ops/triton/_triton_kernels/chunk_delta_attn/chunk_delta_attn_utils.py Updates tuned-config import.
aiter/ops/triton/_triton_kernels/attention/mla_decode_rope.py Uses consolidated config resolver.
aiter/ops/triton/_triton_kernels/attention/mha.py Uses consolidated config resolver.
aiter/ops/triton/_triton_kernels/attention/mha_onekernel_bwd.py Uses consolidated config resolver.
aiter/ops/triton/_triton_kernels/attention/mha_fused_bwd.py Uses consolidated config resolver.
aiter/ops/triton/_triton_kernels/attention/hstu_attention.py Uses consolidated config resolver.
aiter/ops/triton/_triton_kernels/attention/extend_attention.py Uses consolidated config resolver.
aiter/ops/triton/__init__.py Updates utility compatibility mappings.
Suppressed comments (1)

aiter/ops/triton/utils/config_utils.py:806

  • This loader manually rebuilds the config path instead of using the newly centralized resolver. It consequently bypasses the resolver's backend/path validation and recreates the duplicated path logic this consolidation is intended to remove. Route this lookup through resolve_config_dir.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread aiter/ops/triton/__init__.py Resolved
Comment thread aiter/ops/triton/utils/config_utils.py Resolved
Copilot AI review requested due to automatic review settings August 27, 2026 21:47

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.

Pull request overview

Copilot reviewed 77 out of 77 changed files in this pull request and generated no new comments.

Suppressed comments (5)

Previously missed (3) — in code that hasn't changed since the last review.

aiter/ops/triton/utils/config_utils.py:806

  • This loader still hand-builds its config path, bypassing resolve_config_dir() and its centralized backend/op/name validation. That contradicts this module's stated “every loader” contract and leaves this path vulnerable to drifting from future layout changes. Resolve the family directory through the shared helper.
    aiter/ops/triton/configs/gfx1250/triton/moe/a8w4/DEFAULT.json:1
  • A new MOE table is being added under the nested <arch>/<backend>/moe/ layout via an operation-specific direct loader. The repository config contract requires MOE configs to remain in configs/moe/ until a shared nested MOE resolver lands; otherwise MOE families gain incompatible resolution conventions. Keep this table in the supported MOE layout, or include the shared resolver and full documented migration.
    aiter/ops/triton/utils/config_utils.py:108
  • resolve_config_dir() now changes the prior return type and removes cross-backend probing, but no focused tests cover that contract. Existing op tests exercise only available-device happy paths, so a wrong backend path or accidental fallback can escape detection. Add unit tests with a mocked architecture for both backends, missing files, and invalid path components.

aiter/ops/triton/init.py:143

  • This replaces the existing core compatibility key instead of retaining it. Because the finder only recognizes keys in this map, import aiter.ops.triton.core—explicitly supported for external repositories by this file—will now fail even though the implementation only moved. Keep the old key mapped to the consolidated module and add the new key separately.
    "config_utils": "utils.config_utils",

aiter/ops/triton/utils/config_utils.py:8

  • This convention-changing consolidation leaves both required guides stale: aiter/ops/triton/README.md still points to the deleted core.py, gemm_config_utils.py, and tuned_config_utils.py and documents backend=None probing, while .github/instructions/aiter-ops-triton.instructions.md still directs callers to utils.core. Update both documents with the new module and deterministic backend contract in this PR.

Copilot AI review requested due to automatic review settings August 27, 2026 21:52

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.

Pull request overview

Copilot reviewed 77 out of 77 changed files in this pull request and generated 2 comments.

Suppressed comments (3)

Previously missed (1) — in code that hasn't changed since the last review.

aiter/ops/triton/utils/config_utils.py:806

  • This loader reconstructs the config path instead of using resolve_config_dir(), bypassing the validation and single path-building contract introduced above. It will also diverge silently if the layout changes again. Route this lookup through the shared resolver as the module documentation requires.

aiter/ops/triton/init.py:143

  • Replacing the existing core entry removes the compatibility alias for import aiter.ops.triton.core. Because core.py is deleted in this PR, that documented backward-compat path now raises ModuleNotFoundError for downstream callers. Keep the old name mapped to the consolidated module in addition to the new config_utils alias.
    "config_utils": "utils.config_utils",

aiter/ops/triton/utils/config_utils.py:116

  • The new resolver is deterministic and backend-specific, but README.md and configs/CLAUDE.md still direct callers to the deleted gemm_config_utils.py, core.py, and tuned_config_utils.py, and still describe backend=None probing and MOE placement that this PR changes. Those instructions will now send contributors to nonexistent APIs and the wrong config layout; update both documents as part of this convention-changing refactor.

Comment thread aiter/ops/triton/utils/config_utils.py Resolved
…acade

config_utils.py becomes a thin facade and the single public import surface
(explicit re-exports + __all__); the implementations move into the private
utils/_config/ package (mirroring utils/_triton/), one small module per
concern: core.py (paths, load_config_json(), the validated deterministic
resolve_config_dir()), gemm.py, conv.py, mhc.py and tuned.py. Nothing
outside the facade imports _config directly (the conv unit test patches
the implementing module, since patching a re-export cannot reach it).
Formatting matches the CI toolchain (black stable, ruff 0.16.0 with the
repo pyproject) across every touched file.
Copilot AI review requested due to automatic review settings August 28, 2026 04:24

@github-actions github-actions Bot 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.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

ruff

⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import os
from enum import Enum
import torch
import triton
from aiter.ops.triton.conv._prepack import (
get_or_make_weight_pack,
get_or_make_weight_pack_3x3,
get_or_make_winograd_filter_f4x3,
prepack_nchw_to_cblocked,
)
from aiter.ops.triton.conv._utils import (
BLOCK_K,
_alloc_output,
_conv_dims,
_is_1x1_conv,
_is_3x3_conv,
_is_winograd_eligible,
_out_hw,
_prep_bias,
_require_winograd_eligible,
)
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.ops.triton.conv._launch import (
_launch_1x1,
_launch_3x3_cblocked,
_launch_3x3_nchw,
_launch_3x3_nhwc,
_launch_general,
_launch_winograd_f4x3,
_launch_winograd_f4x3_cblocked,
)
from aiter.ops.triton.utils.config_utils import (
conv_config_uses_exact_routes,
format_shape_key,
has_conv_config,
has_exact_conv_config,
)


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from __future__ import annotations
from typing import Literal
import torch
import triton
from aiter.ops.triton._gluon_kernels.gfx1250.fusions.fused_clamp_act_mul import (
_fused_clamp_silu_mul_kernel as _fused_clamp_silu_mul_gluon_kernel,
)
from aiter.ops.triton._triton_kernels.fusions.fused_clamp_act_mul import (
_fused_clamp_silu_mul_kernel,
)
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.ops.triton.utils.config_utils import (
AITER_TRITON_CONFIGS_PATH,
load_config_json,
)


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import torch
import triton
from aiter.ops.triton._triton_kernels.fusions import (
_mhc_fused_kernel,
_mhc_fused_split_kernel,
_mhc_post_kernel,
_mhc_post_pre_reduce_apply_kernel,
_mhc_post_pre_split_kernel,
_mhc_reduce_apply_kernel,
)
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.ops.triton.utils._triton import arch_info
from aiter.ops.triton.utils.config_utils import (
get_mhc_config,
get_mhc_post_config,
)


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import torch
import triton
from aiter.jit.utils.torch_guard import torch_compile_guard
from aiter.ops.triton.utils.common_utils import deserialize_str, serialize_dict
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.ops.triton._triton_kernels.gemm.basic.gemm_a16w16_atomic import (
_gemm_a16_w16_atomic_kernel,
_get_config,
)
from aiter.ops.triton.utils.config_utils import add_default_gemm_config_params


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import torch
import triton
from aiter.ops.triton._triton_kernels.common.splitk_reduce import (
_gemm_splitk_reduce_kernel,
)
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.ops.triton._triton_kernels.gemm.basic.gemm_a16w8_blockscale import (
_gemm_a16w8_blockscale_kernel,
_gemm_a16w8_blockscale_preshuffle_kernel,
_get_config,
)
from aiter.ops.triton.utils.config_utils import compute_splitk_params


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import torch
import triton
from aiter.ops.triton._triton_kernels.common.splitk_reduce import (
_gemm_splitk_reduce_kernel,
)
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.device_info import get_num_xcds
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.ops.triton.utils.types import (
get_scaled_dot_format_string,
torch_to_triton_dtype,
)
from aiter.ops.triton._triton_kernels.gemm.basic.gemm_a8w8 import (
_gemm_a8w8_kernel,
_get_config,
)
from aiter.ops.triton.utils.config_utils import get_gemm_config


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import math
import os
import torch
import triton
from aiter.ops.triton._triton_kernels.common.splitk_reduce import (
_gemm_splitk_reduce_kernel,
)
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.logger import AiterTritonLogger
from packaging.version import Version
from aiter.ops.triton._triton_kernels.gemm.basic.gemm_a8w8_blockscale import (
_gemm_a8w8_blockscale_kernel as triton_gemm_a8w8_blockscale_kernel,
)
from aiter.ops.triton._triton_kernels.gemm.basic.gemm_a8w8_blockscale import (
_gemm_a8w8_blockscale_preshuffle_kernel as triton_gemm_a8w8_blockscale_preshuffle_kernel,
)
from aiter.ops.triton._triton_kernels.gemm.basic.gemm_a8w8_blockscale import (
_get_config,
)
from aiter.ops.triton.utils.config_utils import compute_splitk_params


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import torch
import triton
from aiter.ops.triton._triton_kernels.common.splitk_reduce import (
_batched_gemm_splitk_reduce_kernel,
)
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.ops.triton._triton_kernels.gemm.batched.batched_gemm_bf16 import (
_batched_gemm_bf16_kernel,
_get_config,
)
from aiter.ops.triton.utils.config_utils import get_gemm_config


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import torch
import triton
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.ops.triton._triton_kernels.gemm.fused.fused_gemm_a8w8_blockscale_mul_add import (
_fused_gemm_a8w8_blockscale_mul_add_kernel,
_fused_gemm_a8w8_blockscale_mul_add_reduce_kernel,
_get_config,
)
from aiter.ops.triton.utils.config_utils import compute_splitk_params


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import os
import torch
import triton
from aiter.ops.triton.gemm.basic.gemm_afp4wfp4 import get_splitk
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.utility.triton.triton_metadata_redirect import AOTMetadataContext
from aiter.ops.triton._triton_kernels.gemm.fused.fused_gemm_afp4wfp4_a16w16 import (
_fused_gemm_afp4wfp4_a16w16_kernel,
_fused_gemm_afp4wfp4_a16w16_reduce_kernel,
_fused_gemm_afp4wfp4_preshuffle_a16w16_kernel,
_get_config,
)
from aiter.ops.triton.utils._triton import arch_info
from aiter.ops.triton.utils.config_utils import AITER_TRITON_CONFIGS_PATH


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import os
import torch
import triton
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.utility.triton.triton_metadata_redirect import AOTMetadataContext
from aiter.ops.triton._triton_kernels.gemm.fused.fused_gemm_afp4wfp4_mul_add import (
_fused_gemm_afp4wfp4_mul_add_kernel,
_fused_gemm_afp4wfp4_mul_add_reduce_kernel,
_fused_gemm_afp4wfp4_preshuffle_mul_add_kernel,
_get_config,
)
from aiter.ops.triton.utils._triton import arch_info
from aiter.ops.triton.utils.config_utils import AITER_TRITON_CONFIGS_PATH


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import torch
import triton
from aiter.ops.triton.utils._triton.pid_preprocessing import pid_grid, remap_xcd
from aiter.ops.triton.utils.logger import AiterTritonLogger
from triton.experimental import gluon
from triton.experimental.gluon import language as gl
from aiter.ops.triton.utils._triton import arch_info
from aiter.ops.triton.utils.config_utils import get_gemm_config


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import functools
import itertools
import torch
import triton
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a4w4 import (
_moe_gemm_a4w4_decode,
_moe_gemm_a4w4_prefill,
get_moe_a4w4_layouts_decode,
get_moe_a4w4_layouts_prefill,
)
from aiter.ops.triton._triton_kernels.moe.moe_op_gemm_a4w4 import (
_moe_gemm_a4w4,
_mxfp4_quant_kernel,
)
from aiter.ops.triton.moe.moe_routing.routing import RoutingData
from aiter.ops.triton.moe.reduce import reduce_grouped
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.config_utils import (
load_config_json,
pick_gemm_num_stages,
resolve_config_dir,
)


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import itertools
import torch
import triton
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4_decode as _moe_gemm_a8w4_decode_gluon,
)
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4_decode_persistent as _moe_gemm_a8w4_decode_persistent_gluon,
)
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4_prefill as _moe_gemm_a8w4_prefill_gluon,
)
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
get_moe_a8w4_layouts,
)
from aiter.ops.triton._triton_kernels.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4 as _moe_gemm_a8w4_triton,
)
from aiter.ops.triton.moe.moe_routing.routing import RoutingData
from aiter.ops.triton.moe.reduce import reduce_grouped
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.device_info import get_num_sms
from aiter.ops.triton.utils.config_utils import (
load_config_json,
pick_gemm_num_stages,
resolve_config_dir,
)


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import itertools
import torch
import triton
from aiter.ops.triton._triton_kernels.moe.moe_op_gemm_a8w8 import (
_moe_gemm_a8w8,
)
from aiter.ops.triton.moe.moe_routing.routing import RoutingData
from aiter.ops.triton.moe.reduce import reduce_grouped
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.config_utils import pick_gemm_num_stages


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import functools
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.ops.triton.utils._triton import arch_info


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import functools
import json
import os
import re
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.ops.triton.utils._triton import arch_info


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import copy
import functools
import itertools
import triton
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.ops.triton.utils._triton import arch_info


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import functools
import glob
import os
import re
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.ops.triton.utils._triton import arch_info


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import functools
import triton
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.ops.triton.utils._triton import arch_info


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import sys
############################################################
# <import>
import torch
from _utils import (
get_input_shape_and_config_list,
run_profile,
)
from aiter.ops.triton.utils.types import get_fp8_dtypes
from aiter.ops.triton.gemm.basic.gemm_a8w8 import gemm_a8w8
from aiter.ops.triton.utils.config_utils import compute_splitk_params
from op_tests.triton_tests.gemm.basic.test_gemm_a8w8 import (
generate_gemm_a8w8_inputs,
)


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import sys
############################################################
# <import>
import torch
from _utils import (
get_input_shape_and_config_list,
run_profile,
)
from aiter.ops.triton.gemm.basic.gemm_afp8wfp8 import gemm_afp8wfp8_preshuffle
from aiter.ops.triton.utils.types import get_fp8_dtypes
from aiter.ops.triton.utils.config_utils import compute_splitk_params
from op_tests.triton_tests.gemm.basic.test_gemm_afp8wfp8 import (
generate_inputs,
)


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from __future__ import annotations
import argparse
import enum
import logging
import sys
from itertools import product
from typing import Any, ClassVar
import torch
import triton
from aiter.test_common import checkAllclose
from op_tests.op_benchmarks.triton.utils.benchmark_utils import (
get_caller_name_no_ext,
print_vgpr,
)
from op_tests.triton_tests.utils.mhc_ref import (
generate_mhc_inputs,
mhc_e2e_ref,
)
from aiter.ops.triton.fusions.mhc import mhc, mhc_post
from aiter.ops.triton.utils.config_utils import hip_post_dispatch_block


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import aiter.jit.utils.chip_info as _aiter_chip_info
import aiter as _aiter


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import argparse
import csv
import inspect
import tempfile
from itertools import chain
from pathlib import Path
import torch
import triton.profiler as proton
from aiter.ops.triton.moe.moe_op_gemm_a8w8_blockscale import (
moe_gemm_a8w8_blockscale,
)
from aiter.ops.triton.moe.moe_routing.routing import routing
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.gemm.basic.gemm_a16w16 import gemm_a16w16
from aiter.ops.triton.utils.config_utils import (
compute_splitk_params,
get_gemm_config,
)


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import random
import traceback
from collections import namedtuple
from dataclasses import dataclass
import torch
import torch.nn.functional as F
from aiter.ops.triton.conv._utils import (
_is_1x1_conv,
_is_3x3_conv,
_out_hw,
)
from aiter.ops.triton.conv.conv2d import (
_select_3x3_method,
conv2d_nchw,
conv2d_nchw_3x3_direct,
conv2d_nchw_cblocked,
conv2d_nhwc,
conv2d_winograd_f4x3,
conv2d_winograd_f4x3_cblocked,
)
from aiter.ops.triton.utils.config_utils import has_conv_config


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import pytest
import torch
from aiter.ops.triton.utils._triton.arch_info import get_arch
import aiter.ops.triton.conv.conv2d as conv2d_module
from aiter.ops.triton.utils import config_utils
from aiter.ops.triton.utils._config import conv as conv_config_impl
from ._helpers import (
ALL_SUPPORTED_ARCHS,
ORDERED_METHODS,
TestSuite,
run_activations,
run_cross_method,
run_edge_cases,
run_no_bias,
run_random_fuzzing,
)


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import pytest
import torch
from aiter.test_common import checkAllclose
from op_tests.triton_tests.utils.mhc_ref import (
generate_mhc_inputs,
generate_mhc_post_inputs,
get_test_shapes,
is_doubly_stochastic,
mhc_e2e_ref,
mhc_post_torch,
mhc_torch,
)
from aiter.ops.triton.fusions.mhc import mhc, mhc_post, mhc_post_pre
from aiter.ops.triton.utils.config_utils import (
hip_post_dispatch_block as _hip_post_dispatch_block,
)


⚠️ [ruff] <I001> reported by reviewdog 🐶
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


⚠️ [ruff] <I001> reported by reviewdog 🐶
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


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import functools
import importlib
import sys
import pytest
import torch
import torch.nn.functional as F
from aiter.ops.shuffle import shuffle_weight
from aiter.ops.triton.utils.types import get_fp8_dtypes, str_to_torch_dtype
from aiter.ops.triton.gemm.basic.gemm_a8w8 import gemm_a8w8 as triton_gemm_a8w8
from aiter.ops.triton.gemm.basic.gemm_a8w8 import gemm_a8w8_preshuffle
from aiter.ops.triton.utils._triton import arch_info
from aiter.ops.triton.utils.config_utils import (
compute_splitk_params,
get_gemm_config,
)


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import copy
import pytest
import torch
from aiter.ops.shuffle import shuffle_weight
from aiter.ops.triton.gemm.basic.gemm_afp8wfp8 import (
gemm_afp8wfp8,
gemm_afp8wfp8_preshuffle,
)
from aiter.test_common import checkAllclose
from aiter.ops.triton.utils._triton import arch_info
from aiter.ops.triton.utils.config_utils import get_gemm_config


⚠️ [ruff] <I001> reported by reviewdog 🐶
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

This comment was marked as outdated.

config_utils.py becomes the shared core of the config machinery -- the
config-tree paths, load_config_json(), and the validated deterministic
resolve_config_dir() (Args/Returns/Raises/Example docstring; every
argument whitelist-asserted so a bad value fails closed; a single str
return; no probing and no last-candidate fallback: a missing required
table fails loudly in load_config_json() naming the exact nested path).
The per-family loaders keep their own modules -- gemm_config_utils,
conv_config_utils, mhc_config_utils, tuned_config_utils -- each built on
that core; the resolver moves out of gemm_config_utils, utils/core.py
dissolves into config_utils.py, and the byte-identical duplicate
utils/mha_kernel_utils.py is dropped for the utils/_triton copy. Every
function keeps exactly one home and only callers that used utils.core or
reached the resolver through the GEMM module change.

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 stays launchable until gfx1250 is
tuned natively. Formatting matches the CI toolchain (black stable, ruff
0.16.0 with the repo pyproject) across every touched file; this also
supersedes the interim single-module layout from the earlier commits on
this branch.
Copilot AI review requested due to automatic review settings August 28, 2026 04:44

@github-actions github-actions Bot 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.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

ruff

⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from __future__ import annotations
from typing import Literal
import torch
import triton
from aiter.ops.triton._gluon_kernels.gfx1250.fusions.fused_clamp_act_mul import (
_fused_clamp_silu_mul_kernel as _fused_clamp_silu_mul_gluon_kernel,
)
from aiter.ops.triton._triton_kernels.fusions.fused_clamp_act_mul import (
_fused_clamp_silu_mul_kernel,
)
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.ops.triton.utils.config_utils import (
AITER_TRITON_CONFIGS_PATH,
load_config_json,
)


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import os
import torch
import triton
from aiter.ops.triton._triton_kernels.gemm.fused.fused_gemm_afp4wfp4_a16w16 import (
_fused_gemm_afp4wfp4_a16w16_kernel,
_fused_gemm_afp4wfp4_a16w16_reduce_kernel,
_fused_gemm_afp4wfp4_preshuffle_a16w16_kernel,
_get_config,
)
from aiter.ops.triton.gemm.basic.gemm_afp4wfp4 import get_splitk
from aiter.ops.triton.utils._triton import arch_info
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.utility.triton.triton_metadata_redirect import AOTMetadataContext
from aiter.ops.triton.utils.config_utils import AITER_TRITON_CONFIGS_PATH


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import os
import torch
import triton
from aiter.ops.triton._triton_kernels.gemm.fused.fused_gemm_afp4wfp4_mul_add import (
_fused_gemm_afp4wfp4_mul_add_kernel,
_fused_gemm_afp4wfp4_mul_add_reduce_kernel,
_fused_gemm_afp4wfp4_preshuffle_mul_add_kernel,
_get_config,
)
from aiter.ops.triton.utils._triton import arch_info
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.utility.triton.triton_metadata_redirect import AOTMetadataContext
from aiter.ops.triton.utils.config_utils import AITER_TRITON_CONFIGS_PATH


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import functools
import itertools
import torch
import triton
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a4w4 import (
_moe_gemm_a4w4_decode,
_moe_gemm_a4w4_prefill,
get_moe_a4w4_layouts_decode,
get_moe_a4w4_layouts_prefill,
)
from aiter.ops.triton._triton_kernels.moe.moe_op_gemm_a4w4 import (
_moe_gemm_a4w4,
_mxfp4_quant_kernel,
)
from aiter.ops.triton.moe.moe_routing.routing import RoutingData
from aiter.ops.triton.moe.reduce import reduce_grouped
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.config_utils import (
load_config_json,
resolve_config_dir,
)
from aiter.ops.triton.utils.gemm_config_utils import pick_gemm_num_stages


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import itertools
import torch
import triton
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4_decode as _moe_gemm_a8w4_decode_gluon,
)
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4_decode_persistent as _moe_gemm_a8w4_decode_persistent_gluon,
)
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4_prefill as _moe_gemm_a8w4_prefill_gluon,
)
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
get_moe_a8w4_layouts,
)
from aiter.ops.triton._triton_kernels.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4 as _moe_gemm_a8w4_triton,
)
from aiter.ops.triton.moe.moe_routing.routing import RoutingData
from aiter.ops.triton.moe.reduce import reduce_grouped
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.device_info import get_num_sms
from aiter.ops.triton.utils.config_utils import (
load_config_json,
resolve_config_dir,
)
from aiter.ops.triton.utils.gemm_config_utils import pick_gemm_num_stages

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.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.

Suppressed comments (2)

aiter/ops/triton/init.py:143

  • Replacing the core compatibility entry removes the old aiter.ops.triton.core import even though this map explicitly preserves reorganized paths for external consumers; deleting utils/core.py also breaks direct aiter.ops.triton.utils.core imports. Keep core as an alias/shim to config_utils while adding the new name.
    "config_utils": "utils.config_utils",

aiter/ops/triton/configs/gfx1250/triton/moe/a8w4/DEFAULT.json:1

  • The repository config rules keep MOE tables in configs/moe/ with an arch-prefixed filename until the shared MOE resolver and whole-family migration exist. Adding this isolated nested MOE table leaves MOE families on incompatible resolution schemes; either keep it in the legacy MOE location or complete the documented resolver/migration first (CodingGuidelineID 1000002).
{

Comment thread aiter/ops/triton/utils/config_utils.py Resolved
Comment thread aiter/ops/triton/utils/config_utils.py Resolved
Copilot AI review requested due to automatic review settings August 28, 2026 04:48
Copilot AI review requested due to automatic review settings August 28, 2026 05:00

@github-actions github-actions Bot 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.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

ruff

⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from __future__ import annotations
from typing import Literal
import torch
import triton
from aiter.ops.triton._gluon_kernels.gfx1250.fusions.fused_clamp_act_mul import (
_fused_clamp_silu_mul_kernel as _fused_clamp_silu_mul_gluon_kernel,
)
from aiter.ops.triton._triton_kernels.fusions.fused_clamp_act_mul import (
_fused_clamp_silu_mul_kernel,
)
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.config_utils import (
AITER_TRITON_CONFIGS_PATH,
load_config_json,
)
from aiter.ops.triton.utils.logger import AiterTritonLogger


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import os
import torch
import triton
from aiter.ops.triton._triton_kernels.gemm.fused.fused_gemm_afp4wfp4_a16w16 import (
_fused_gemm_afp4wfp4_a16w16_kernel,
_fused_gemm_afp4wfp4_a16w16_reduce_kernel,
_fused_gemm_afp4wfp4_preshuffle_a16w16_kernel,
_get_config,
)
from aiter.ops.triton.gemm.basic.gemm_afp4wfp4 import get_splitk
from aiter.ops.triton.utils._triton import arch_info
from aiter.ops.triton.utils.config_utils import AITER_TRITON_CONFIGS_PATH
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.utility.triton.triton_metadata_redirect import AOTMetadataContext


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import os
import torch
import triton
from aiter.ops.triton._triton_kernels.gemm.fused.fused_gemm_afp4wfp4_mul_add import (
_fused_gemm_afp4wfp4_mul_add_kernel,
_fused_gemm_afp4wfp4_mul_add_reduce_kernel,
_fused_gemm_afp4wfp4_preshuffle_mul_add_kernel,
_get_config,
)
from aiter.ops.triton.utils._triton import arch_info
from aiter.ops.triton.utils.config_utils import AITER_TRITON_CONFIGS_PATH
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.utility.triton.triton_metadata_redirect import AOTMetadataContext


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import itertools
import torch
import triton
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a4w4 import (
_moe_gemm_a4w4_decode,
_moe_gemm_a4w4_prefill,
get_moe_a4w4_layouts_decode,
get_moe_a4w4_layouts_prefill,
)
from aiter.ops.triton._triton_kernels.moe.moe_op_gemm_a4w4 import (
_moe_gemm_a4w4,
_mxfp4_quant_kernel,
)
from aiter.ops.triton.moe.moe_routing.routing import RoutingData
from aiter.ops.triton.moe.reduce import reduce_grouped
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.gemm_config_utils import pick_gemm_num_stages
from aiter.ops.triton.utils.moe_config_utils import get_moe_dispatch


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import itertools
import torch
import triton
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4_decode as _moe_gemm_a8w4_decode_gluon,
)
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4_decode_persistent as _moe_gemm_a8w4_decode_persistent_gluon,
)
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4_prefill as _moe_gemm_a8w4_prefill_gluon,
)
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
get_moe_a8w4_layouts,
)
from aiter.ops.triton._triton_kernels.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4 as _moe_gemm_a8w4_triton,
)
from aiter.ops.triton.moe.moe_routing.routing import RoutingData
from aiter.ops.triton.moe.reduce import reduce_grouped
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.device_info import get_num_sms
from aiter.ops.triton.utils.gemm_config_utils import pick_gemm_num_stages
from aiter.ops.triton.utils.moe_config_utils import get_moe_dispatch


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import argparse
import io
import json
import logging
import os
import re
import shlex
from abc import ABC, abstractmethod
from collections.abc import Callable
from contextlib import redirect_stderr, redirect_stdout
from typing import TypeAlias
import matplotlib.pyplot as plt
import pandas as pd
from aiter.ops.triton.utils._triton import arch_info
from op_tests.op_benchmarks.triton.bench_batched_gemm_a8w8 import (
main as bench_batched_gemm_a8w8_main,
)
from op_tests.op_benchmarks.triton.bench_batched_gemm_a16wfp4 import (
main as bench_batched_gemm_a16wfp4_main,
)
from op_tests.op_benchmarks.triton.bench_batched_gemm_afp4wfp4 import (
main as bench_batched_gemm_afp4wfp4_main,
)
from op_tests.op_benchmarks.triton.bench_gemm_a8w8_blockscale import (
main as bench_gemm_a8w8_blockscale_main,
)
from op_tests.op_benchmarks.triton.bench_gemm_a8w8_per_token_scale import (
main as bench_gemm_a8w8_per_token_scale_main,
)
from op_tests.op_benchmarks.triton.bench_gemm_a16w16 import (
main as bench_gemm_a16w16_main,
)
from op_tests.op_benchmarks.triton.bench_gemm_afp4wfp4 import (
main as bench_gemm_afp4wfp4_main,
)
from op_tests.op_benchmarks.triton.bench_mha import main as bench_mha_main
from op_tests.op_benchmarks.triton.bench_mla_decode import main as bench_mla_main
from op_tests.op_benchmarks.triton.bench_moe_gemm_a4w4 import (
main as bench_moe_gemm_a4w4_main,
)
from op_tests.op_benchmarks.triton.bench_moe_gemm_a8w4 import (
main as bench_moe_gemm_a8w4_main,
)
from op_tests.op_benchmarks.triton.bench_moe_gemm_a8w8 import (
main as bench_moe_gemm_a8w8_main,
)
from op_tests.op_benchmarks.triton.bench_moe_gemm_a8w8_blockscale import (
main as bench_moe_gemm_a8w8_blockscale_main,
)
from op_tests.op_benchmarks.triton.bench_rmsnorm import main as bench_rmsnorm_main
from op_tests.op_benchmarks.triton.bench_rope import main as bench_rope_main
from op_tests.op_benchmarks.triton.bench_unified_attention import (
main as bench_unified_attention_main,
)
from triton.runtime.errors import OutOfResources

Docs only: the shared-core docstring lists the per-family loader modules
built on it; add the new moe_config_utils alongside gemm/conv/mhc/tuned.

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.

Pull request overview

Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.

Suppressed comments (6)

aiter/ops/triton/init.py:143

  • Replacing this entry removes the compatibility alias for aiter.ops.triton.core, even though this map exists specifically for external users of the old flat paths; deleting utils/core.py also makes direct imports of the former canonical module fail with ModuleNotFoundError. Keep core mapped to utils.config_utils while adding the new alias, and retain a thin re-export shim if aiter.ops.triton.utils.core must remain compatible.
    "config_utils": "utils.config_utils",

aiter/ops/triton/utils/gemm_config_utils.py:18

  • logger is initialized before this import, so Ruff reports E402 (“module level import not at top of file”) and the pre-check fails. Keep all imports together, then initialize the logger.
logger = AiterTritonLogger()

from aiter.ops.triton.utils.config_utils import (

aiter/ops/triton/utils/conv_config_utils.py:16

  • logger is initialized before this import, so Ruff reports E402 (“module level import not at top of file”) and the pre-check fails. Keep all imports together, then initialize the logger.
logger = AiterTritonLogger()

from aiter.ops.triton.utils.config_utils import (

aiter/ops/triton/utils/mhc_config_utils.py:19

  • logger is initialized before this import, so Ruff reports E402 (“module level import not at top of file”) and the pre-check fails. Keep all imports together, then initialize the logger.
logger = AiterTritonLogger()

from aiter.ops.triton.utils.config_utils import (

aiter/ops/triton/utils/tuned_config_utils.py:17

  • logger is initialized before this import, so Ruff reports E402 (“module level import not at top of file”) and the pre-check fails. Keep all imports together, then initialize the logger.
logger = AiterTritonLogger()

from aiter.ops.triton.utils.config_utils import (

aiter/ops/triton/utils/config_utils.py:82

  • This changes the resolver contract to a deterministic string path with no probing and adds nested MOE resolution, but the repository guidance still documents backend=None fallback, tuple returns, utils.core, and “MOE has no nested resolver” (README.md:84-100, configs/CLAUDE.md:80-120,207-310, and .github/instructions/aiter-ops-triton.instructions.md:68-70,126-130). Contributors following it will add or load configs through paths this implementation no longer uses. Update all config-layout and loader documentation as part of this convention change.
def resolve_config_dir(
    op: str,
    config_name: str,
    backend: str = "triton",
    arch: str | None = None,
) -> str:

Comment thread aiter/ops/triton/utils/config_utils.py Resolved
Copilot AI review requested due to automatic review settings August 28, 2026 05:06
The gemm_afp4wfp4, gemm_afp8wfp8 and gemm_a8w8_blockscale kernels'
_get_config(..., backend=None) forwarded None into get_gemm_config(),
which the validated resolver rightly rejects -- every wrapper that calls
them without a backend crashed (AssertionError: unknown backend None).
Default them to "triton", matching get_gemm_config()'s own default and
the old probing behavior (triton was always probed first and every one of
these families ships triton tables, including the seeded gfx1250
GEMM-AFP4WFP4). Public wrappers that auto-pick gluon still pass their
choice explicitly. Verified: 72-case A/B of the omitted-backend paths
(3 families x 4 arches x shuffle x shapes) against the old probing
resolver -- identical configs.

Also re-aligns the latest formatting pass with the CI toolchain (ruff
0.16.0 import order) on the files it touched, same as before.
Copilot AI review requested due to automatic review settings August 28, 2026 12:48

@github-actions github-actions Bot 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.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

ruff

⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from __future__ import annotations
from typing import Literal
import torch
import triton
from aiter.ops.triton._gluon_kernels.gfx1250.fusions.fused_clamp_act_mul import (
_fused_clamp_silu_mul_kernel as _fused_clamp_silu_mul_gluon_kernel,
)
from aiter.ops.triton._triton_kernels.fusions.fused_clamp_act_mul import (
_fused_clamp_silu_mul_kernel,
)
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.config_utils import (
AITER_TRITON_CONFIGS_PATH,
load_config_json,
)
from aiter.ops.triton.utils.logger import AiterTritonLogger


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import os
import torch
import triton
from aiter.ops.triton._triton_kernels.gemm.fused.fused_gemm_afp4wfp4_a16w16 import (
_fused_gemm_afp4wfp4_a16w16_kernel,
_fused_gemm_afp4wfp4_a16w16_reduce_kernel,
_fused_gemm_afp4wfp4_preshuffle_a16w16_kernel,
_get_config,
)
from aiter.ops.triton.gemm.basic.gemm_afp4wfp4 import get_splitk
from aiter.ops.triton.utils._triton import arch_info
from aiter.ops.triton.utils.config_utils import AITER_TRITON_CONFIGS_PATH
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.utility.triton.triton_metadata_redirect import AOTMetadataContext


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import os
import torch
import triton
from aiter.ops.triton._triton_kernels.gemm.fused.fused_gemm_afp4wfp4_mul_add import (
_fused_gemm_afp4wfp4_mul_add_kernel,
_fused_gemm_afp4wfp4_mul_add_reduce_kernel,
_fused_gemm_afp4wfp4_preshuffle_mul_add_kernel,
_get_config,
)
from aiter.ops.triton.utils._triton import arch_info
from aiter.ops.triton.utils.config_utils import AITER_TRITON_CONFIGS_PATH
from aiter.ops.triton.utils.logger import AiterTritonLogger
from aiter.utility.triton.triton_metadata_redirect import AOTMetadataContext


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import itertools
import torch
import triton
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a4w4 import (
_moe_gemm_a4w4_decode,
_moe_gemm_a4w4_prefill,
get_moe_a4w4_layouts_decode,
get_moe_a4w4_layouts_prefill,
)
from aiter.ops.triton._triton_kernels.moe.moe_op_gemm_a4w4 import (
_moe_gemm_a4w4,
_mxfp4_quant_kernel,
)
from aiter.ops.triton.moe.moe_routing.routing import RoutingData
from aiter.ops.triton.moe.reduce import reduce_grouped
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.moe_config_utils import get_moe_dispatch
from aiter.ops.triton.utils.gemm_config_utils import pick_gemm_num_stages


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import itertools
import torch
import triton
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4_decode as _moe_gemm_a8w4_decode_gluon,
)
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4_decode_persistent as _moe_gemm_a8w4_decode_persistent_gluon,
)
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4_prefill as _moe_gemm_a8w4_prefill_gluon,
)
from aiter.ops.triton._gluon_kernels.gfx1250.moe.moe_op_gemm_a8w4 import (
get_moe_a8w4_layouts,
)
from aiter.ops.triton._triton_kernels.moe.moe_op_gemm_a8w4 import (
_moe_gemm_a8w4 as _moe_gemm_a8w4_triton,
)
from aiter.ops.triton.moe.moe_routing.routing import RoutingData
from aiter.ops.triton.moe.reduce import reduce_grouped
from aiter.ops.triton.utils._triton.arch_info import get_arch
from aiter.ops.triton.utils.device_info import get_num_sms
from aiter.ops.triton.utils.moe_config_utils import get_moe_dispatch
from aiter.ops.triton.utils.gemm_config_utils import pick_gemm_num_stages


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import argparse
import io
import json
import logging
import os
import re
import shlex
from abc import ABC, abstractmethod
from collections.abc import Callable
from contextlib import redirect_stderr, redirect_stdout
from typing import TypeAlias
import matplotlib.pyplot as plt
import pandas as pd
from aiter.ops.triton.utils._triton import arch_info
from op_tests.op_benchmarks.triton.bench_batched_gemm_a8w8 import (
main as bench_batched_gemm_a8w8_main,
)
from op_tests.op_benchmarks.triton.bench_batched_gemm_a16wfp4 import (
main as bench_batched_gemm_a16wfp4_main,
)
from op_tests.op_benchmarks.triton.bench_batched_gemm_afp4wfp4 import (
main as bench_batched_gemm_afp4wfp4_main,
)
from op_tests.op_benchmarks.triton.bench_gemm_a8w8_blockscale import (
main as bench_gemm_a8w8_blockscale_main,
)
from op_tests.op_benchmarks.triton.bench_gemm_a8w8_per_token_scale import (
main as bench_gemm_a8w8_per_token_scale_main,
)
from op_tests.op_benchmarks.triton.bench_gemm_a16w16 import (
main as bench_gemm_a16w16_main,
)
from op_tests.op_benchmarks.triton.bench_gemm_afp4wfp4 import (
main as bench_gemm_afp4wfp4_main,
)
from op_tests.op_benchmarks.triton.bench_mha import main as bench_mha_main
from op_tests.op_benchmarks.triton.bench_mla_decode import main as bench_mla_main
from op_tests.op_benchmarks.triton.bench_moe_gemm_a4w4 import (
main as bench_moe_gemm_a4w4_main,
)
from op_tests.op_benchmarks.triton.bench_moe_gemm_a8w4 import (
main as bench_moe_gemm_a8w4_main,
)
from op_tests.op_benchmarks.triton.bench_moe_gemm_a8w8 import (
main as bench_moe_gemm_a8w8_main,
)
from op_tests.op_benchmarks.triton.bench_moe_gemm_a8w8_blockscale import (
main as bench_moe_gemm_a8w8_blockscale_main,
)
from op_tests.op_benchmarks.triton.bench_rmsnorm import main as bench_rmsnorm_main
from op_tests.op_benchmarks.triton.bench_rope import main as bench_rope_main
from op_tests.op_benchmarks.triton.bench_unified_attention import (
main as bench_unified_attention_main,
)
from triton.runtime.errors import OutOfResources

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.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated no new comments.

Suppressed comments (3)

aiter/ops/triton/configs/gfx1250/triton/moe/a8w4/DEFAULT.json:1

  • This adds an MOE table under the nested <arch>/<backend>/moe/ tree, which violates the repository's current MOE config convention: MOE tables must remain in configs/moe/ with an arch-prefixed filename until the MOE layout is migrated as a whole. A narrow dispatch loader leaves MOE families split between incompatible resolution schemes and outside the documented tuning workflow. Keep this table in the legacy MOE layout, or make the full MOE migration and convention updates separately.
{

aiter/ops/triton/utils/config_utils.py:91

  • This changes config resolution to a deterministic backend-specific nested path, but the required convention docs were not updated. README.md:84-100 still says MOE has no nested resolver and backend=None probes Triton then Gluon, configs/CLAUDE.md:80-120,207-218 documents the old probe/loaders, and .github/instructions/aiter-ops-triton.instructions.md:128 still references utils.core. Contributors following those contracts will place configs or import helpers incorrectly. Update the README, config guide, and repository instructions in this PR.
    The path is deterministic: it is built, never probed for, and there is
    no search across backends, so a family tuned only for the other backend
    on this arch is never silently borrowed.

aiter/ops/triton/init.py:143

  • The backward-compatibility table is explicitly used by external repositories, but replacing the core key removes aiter.ops.triton.core; deleting utils/core.py also removes the direct aiter.ops.triton.utils.core path. Existing consumers now fail at import time. Preserve core as an alias to utils.config_utils and retain a deprecated utils/core.py re-export shim for one compatibility window.
    "config_utils": "utils.config_utils",

Copilot AI review requested due to automatic review settings August 28, 2026 12:52

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.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.

Suppressed comments (8)

Previously missed (1) — in code that hasn't changed since the last review.

aiter/ops/triton/utils/tuned_config_utils.py:41

  • This loader still imports the private _dtype_dir helper and reconstructs the nested path manually, despite the new shared resolver being intended for every loader. That duplicates path semantics and can diverge on future layout changes; use resolve_config_dir(op, config_name, backend=backend) here instead.
    dtype_dir = _dtype_dir(config_name)
    config_path = (
        f"{AITER_TRITON_CONFIGS_PATH}/{arch}/{backend}/{op}/{dtype_dir}/DEFAULT.json"
    )

aiter/ops/triton/init.py:143

  • Replacing the core entry removes the compatibility alias this table explicitly provides to external callers. With utils/core.py deleted too, both import aiter.ops.triton.core and the previously documented aiter.ops.triton.utils.core path now fail; preserve core as an alias/shim while adding config_utils.
    "config_utils": "utils.config_utils",

aiter/ops/triton/utils/gemm_config_utils.py:23

  • This import occurs after the module-level logger assignment, which triggers Ruff E402 under the repository's default rule set and fails the style check. Keep all imports before logger initialization.
from aiter.ops.triton.utils.config_utils import (
    USE_LRU_CACHE,
    load_config_json,
    resolve_config_dir,
)

aiter/ops/triton/utils/conv_config_utils.py:20

  • This import occurs after the module-level logger assignment, which triggers Ruff E402 under the repository's default rule set and fails the style check. Keep all imports before logger initialization.
from aiter.ops.triton.utils.config_utils import (
    USE_LRU_CACHE,
    load_config_json,
    resolve_config_dir,
)

aiter/ops/triton/utils/mhc_config_utils.py:23

  • This import occurs after the module-level logger assignment, which triggers Ruff E402 under the repository's default rule set and fails the style check. Keep all imports before logger initialization.
from aiter.ops.triton.utils.config_utils import (
    USE_LRU_CACHE,
    load_config_json,
    resolve_config_dir,
)

aiter/ops/triton/utils/tuned_config_utils.py:22

  • This import occurs after the module-level logger assignment, which triggers Ruff E402 under the repository's default rule set and fails the style check. Keep all imports before logger initialization.
from aiter.ops.triton.utils.config_utils import (
    AITER_TRITON_CONFIGS_PATH,
    USE_LRU_CACHE,
    _dtype_dir,
    load_config_json,

aiter/ops/triton/utils/config_utils.py:91

  • The referenced config documentation now contradicts this implementation: README.md still documents backend probing, utils/core.py, and no nested MOE resolver, while configs/CLAUDE.md and the Triton review instructions describe the old tuple-returning resolver and legacy MOE-only layout. This convention-changing refactor must update those documents in the same PR so future config changes follow the actual resolver contract.
    The nested layout (see configs/CLAUDE.md) keys every family by
    architecture, backend, op and family:
    ``<configs>/<arch>/<backend>/<op>/<d_type>``, with the ``<d_type>`` leaf
    derived by ``_dtype_dir()`` (``GEMM-AFP4WFP4`` -> ``gemm_afp4wfp4``).
    The path is deterministic: it is built, never probed for, and there is
    no search across backends, so a family tuned only for the other backend
    on this arch is never silently borrowed.

aiter/ops/triton/configs/gfx1250/triton/moe/a8w4/DEFAULT.json:1

  • This adds an MOE config under <arch>/<backend>/moe/ even though the current repository contract requires MOE configs to remain in configs/moe/ with an arch-prefixed filename. The new helper only ports the A4W4/A8W4 dispatch tables while the other MOE loaders remain legacy, leaving two competing MOE layout conventions; either keep this table in the legacy layout or complete and document the coordinated migration.
{

@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! Let's wait for CI to pass!

@Boss2002n
Boss2002n merged commit 0200ada into main Aug 28, 2026
80 checks passed
@Boss2002n
Boss2002n deleted the satya/cleanup-triton-utils branch August 28, 2026 15:24
JiaoliangYu added a commit that referenced this pull request Sep 3, 2026
* [Config] Retune the GLM-5.2 a8w8 and BF16 GEMMs for gfx950 (#5069)

The a8w8 rows in this file were tuned before #4151 renamed the FlyDSL
kernels, and that PR retuned four CSVs but not this one. All 49 of its
FlyDSL rows have failed to parse ever since: _parse_flydsl_kernel_name
returns None for the old five-field name and the caller quietly falls
back to the default CK kernel, so those shapes have been running
untuned. Retuning is what actually fixes them; the parse-failure path
is silent by design and is left for a separate change.

Split-K is now in the search space (#5007), and 47 of the 134 rows pick
splitK > 0. Running the op under each config on the 49 shapes -- old
being the CK fallback those rows really reach today, not the kernel they
name -- puts the new config ahead by 3606 -> 2702us in total, a median
of 22.8%, with no shape behind by more than 0.2%. M=2 N=2624 K=6144 goes
13.9 -> 6.9us.

Measuring this needs one non-obvious step. gen_instances.py compiles the
tuned CSV into the lookup table that ck and cktile dispatch through, but
its output is not part of the JIT build signature, so editing a tuned
CSV never invalidates an existing module. Against a module built before
these rows existed, all fourteen ck and cktile rows miss the table and
land on rowwise_heuristic_dispatch, which returns one fixed kernel
regardless of M -- the cktile rows measure 10.6-11.7us that way against
the 2.6-3.9us the tuner recorded. Deleting aiter/jit/module_*.so and
aiter/jit/build/module_*/ after updating a config rebuilds the table;
the numbers above are from a rebuilt module. FlyDSL rows are immune
because they reconstruct the kernel from kernelName at runtime.

GLM-5.2 TP4 gsm8k scores 0.9704 +/- 0.0047 exact_match on both
flexible-extract and strict-match, 1319/1319 answered.

New shapes for both TP4 and TP8: a8w8 gains N=2688/K=6144 and
N=6144/K=12288 (TP4) plus N=2048/K=2048, N=3072/K=6144 and
N=3584/K=512 (TP8); BF16 gains N=160, N=256 and N=38720 at K=6144 (TP4)
plus N=19360 (TP8). BF16 keeps only powers of two for M on the two
widest new groups, where the intermediate sizes are not shapes the
model runs.

Two BF16 shapes stay untuned, M=384 and M=768 at N=256 K=6144: each
carries ~10.6k FlyDSL candidates and the JIT runs out of code-region
memory partway through, independently of host RAM or VRAM. They are
left in the untuned CSV so a later run retries them.

Co-authored-by: Claude Opus 5 <[email protected]>

* Upgrade gfx1250 MLA 64nx1 code objects and their host launch contract (#5065)

The 16mx4_64nx1 decode code objects returned wrong results for some combinations
of context length and KV split count. Replace all three (qh16, qh64, qh128) with
current builds.

qh128 additionally needs the host side brought in line with the new code object:

  - ABI: qh128 no longer takes the legacy 288B kernarg block. Every gfx1250 MLA
    kernel now uses the 120B packed preload ABI, so the qh128 exception in the
    dispatch layer is removed.

  - Launch strategy: for gqa=128 the two workgroups per (batch, KV split) are
    now issued along x (gdx = 2) instead of along z, and z carries only the KV
    split id. get_meta_param's occupancy multiplier is unchanged -- the
    workgroup count per (batch, split) is still 2 -- so only its comment needed
    updating to name the new axis.

Verified on gfx1250: the previously failing (context, split) combinations now
match the fp32 reference at the fp8 quantization floor (cos_diff 1.4e-4..2.3e-4,
no element outside a 6e-2 tolerance) for qh64 (36 configs), qh16 64nx1 (20
configs) and qh128 (29 configs), partially filled last pages included. qh8 and
qh32 32nx4_3p are unaffected.

Co-authored-by: Cursor <[email protected]>

* Tune MoE GEMM A8W8 (#5033)

* [ASM] [HIP] [CK] feat(mha): gfx950 hd256 FP8 LINEAR paged-varlen asm prefill (#4971)

* feat: add gfx950 hd256 FP8 LINEAR paged-varlen asm prefill

Select the PAGED_VARLEN asm kernel for gfx950 FP8 hd256 page_size=64, then fall back to CK.

* fix: honor use_ext_asm and tighten paged-prefill tests

Skip page64 asm off gfx950, drop the redundant page16 case, clamp empty-page seqlen_k, and use the file's FP8 threshold.

* style: match FAV3 eligibility checks in batch-prefill asm

Fold the -1 ladder into one compound if like fmha_fwd_v3, and restore the CK kUseGlobalLoad comment.

* Tune M=48 for the GLM-5.2 a8w8 bpreshuffle GEMM shapes (#5078)

Every row in this config uses a power-of-two M, so an M=48 request has no
tuned entry and get_CKGEMM_config pads it to the M=64 row. That row was
tuned for a different width, so it is only incidentally a good fit. This
adds a tuned M=48 row for eight of the nine (N,K) groups, including three
that predate #5069, so the layer is covered at M=48 rather than borrowing
from M=64.

Tuned with --libtype all -k --shape_grouped on gfx950 (cu_num=256) in a
worktree pinned to the merge commit of #5069, so the FlyDSL candidate list
matches what the config is resolved against. All eight winners are FlyDSL
with errRatio 0; the widest-K groups pick splitK 2 or 4, which is where
most of the gain comes from.

Measured against the padded-to-M=64 behaviour, three runs, per-shape
median of 100 iterations after 20 warmup, one GPU:

  N=2048  K=2048    5.838 -> 5.080us  +12.98%
  N=3584  K=512     4.162 -> 3.138us  +24.60%
  N=6144  K=12288  20.505 -> 18.898us  +7.84%
  N=4096  K=2048    6.035 -> 5.622us   +6.85%
  N=3072  K=6144    9.643 -> 9.176us   +4.84%
  N=7168  K=512     4.232 -> 4.067us   +3.90%
  N=2688  K=6144    8.916 -> 8.773us   +1.60%
  N=2624  K=6144    8.757 -> 8.784us   -0.31%  (within run-to-run spread)

N=6144 K=4096 is deliberately left out. Its M=64 row uses a tile_m=32
kernel, and the FlyDSL candidate generator offers tile_m in {16, 48, 128,
256} for M=48 -- 32 is not among them. So the best of the 2208 candidates
timed for that shape (9.943us) still loses to what padding already gives
it (9.579us median), and adding the row would cost 3.07%. Leaving the
shape out keeps it on the M=64 row it uses today. Its untuned entry is
removed as well so a later re-run does not silently re-add the regression;
it is worth revisiting if the candidate set grows a tile_m=32 variant.

No existing row is modified -- the diff is eight added lines per file.

Co-authored-by: Claude Opus 5 <[email protected]>

* [Triton/Gluon] [ASM] [HIP] Block-sparse MHAv4 with load-balancing (#5005)

* perf(mha_v4): avoid copying odd-tail FP6 V inputs

Signed-off-by: jcaraban <[email protected]>

* feat(mha_v4): support grouped query attention

Signed-off-by: jcaraban <[email protected]>

* feat(mha_v4): add MXFP8 raw entrypoint

Signed-off-by: jcaraban <[email protected]>

* docs(mha_v4): clarify grouped-query attention contract

Signed-off-by: jcaraban <[email protected]>

* feat(mha_v4): add gfx942 native FP8 kernel

Signed-off-by: jcaraban <[email protected]>

* fix(mha_v4): canonicalize rotated FP8 preprocessing

Signed-off-by: jcaraban <[email protected]>

* refactor(bench): simplify MHA v4 quantized runners

Signed-off-by: jcaraban <[email protected]>

* perf(mha_v4): deploy gfx942 XCD-swizzled kernels

Signed-off-by: jcaraban <[email protected]>

* perf(mha_v4): deploy gfx942 block kernels

Signed-off-by: jcaraban <[email protected]>

* fix(mha_v4): handle singleton-head rotation strides

Signed-off-by: jcaraban <[email protected]>

* perf(mha_v4): deploy retimed gfx942 I8/FP8 kernels

Signed-off-by: jcaraban <[email protected]>

* fix(mha_v4): deploy corrected gfx942 PV LDS waits

Signed-off-by: jcaraban <[email protected]>

* fix(fmha): deploy gfx942 V staging

Signed-off-by: jcaraban <[email protected]>

* fix(fmha): update gfx942 I8FP8 kernel

Signed-off-by: jcaraban <[email protected]>

* feat(mha): add bf16 to mha v4

Add raw BF16/NONE dispatch and the gfx950 block kernel to the MHA v4 manifest. Generalize launcher strides to byte units, preserve the v3 aiter_bf16 benchmark, rename v4 benchmark providers to mha4_*, and cover BF16 recipe, finite output, and compiled parity.

Signed-off-by: jcaraban <[email protected]>

* perf(fmha): deploy optimized gfx942 block kernels

Signed-off-by: jcaraban <[email protected]>

* style(mha_v4): apply repository formatting

Signed-off-by: jcaraban <[email protected]>

* test(mha_v4): isolate compile parity cases

Signed-off-by: jcaraban <[email protected]>

* fix ruff warnings

Signed-off-by: jcaraban <[email protected]>

* fix(mha_v4): enforce contiguous rotation layout

Dense rotation kernels flatten all leading dimensions into rows, so their row stride is the last dimension width rather than stride(-2). PyTorch permits arbitrary stride metadata on singleton dimensions, which made contiguous [B, S, 1, D] inputs report a misleading head-axis stride and caused incorrect row addressing.

Require contiguous dense inputs and outputs, use canonical input/output row widths, and validate output shapes, devices, auxiliary tensors, and empty inputs. Add regression coverage for singleton heads and rejected unsupported layouts.

* fix(mha_v4): update deterministic BF16 kernel

* Revert "fix(mha_v4): handle singleton-head rotation strides"

This reverts e79b1c8 and adds rotate_activation_hd128() to mha_v4 own .cu

Signed-off-by: jcaraban <[email protected]>

* Sparse MHAv4 initial commit

Signed-off-by: Niko Säkkinen <[email protected]>

* Enable sparse GQA. Fix rebase issues. Fix rotate_activations bug

Signed-off-by: Niko Säkkinen <[email protected]>

* Give MHA v4 its own hd128 rotation instead of calling into dsv4

The FP8 raw recipe rotated Q and K through module_dsv4_rotate_quant,
which registers no aiter_tensor_t and so rejects the instance
torch_to_aiter_pybind builds from module_aiter_core. Every mha_v4()
call with an FP8 q/k format failed on that TypeError, block-sparse
ones included. The MX quantizers here already run the same rotation
before quantizing, so hadamard_rotate_kernel stops where they diverge
and emits it in the input dtype: bitwise identical to the dsv4 kernel
it replaces, and not gated on gfx950 since the FP8 recipe also runs on
gfx942.

A new test pins the transform against an explicit Hadamard matmul. An
autouse fixture resets Dynamo per test, because the FP8 compile parity
tests no longer die early and so exhausted the shared recompile limit,
breaking whichever test compiled next.

Signed-off-by: Niko Säkkinen <[email protected]>

* Cut the fixed cost of the sorted-sparse work table

Rebuilt on every call at a cost independent of sparsity, so it came to
dominate the packed call as density dropped. Two device syncs came from
reading lut_count back to detect uniform counts, and thirteen ATen ops
packed a few hundred elements. A stable descending sort yields the
identity permutation for uniform counts without that readback, and the
packing is now one kernel. On the shape measured the sparse call is
~2.6x faster at 2% density and ~1.2x at full.

Signed-off-by: Niko Säkkinen <[email protected]>

* Build small sorted-sparse work tables in one kernel

Order and pack the table by counting each entry's rank in LDS instead of
calling ATen's sort and packing in a separate launch. The key packs the LUT
length with the slot index, so ranks are distinct and stable by construction,
and the low half is already the permutation the packing needs. Build time at
512 entries drops from ~23us to 9us. The quadratic rank count loses to ATen
past ~1024 entries, so larger tables keep the sort path.

Also expose the builder and test its ordering. A wrong order only unbalances
the waves rather than changing the result, so no attention test can see it.

Signed-off-by: Niko Säkkinen <[email protected]>

* Rank work table entries across a wave instead of a thread

Each entry's rank was counted by a single thread walking every key, which costs
O(n) per thread and lost to ATen's sort above about 1024 entries. Split the
count across a wave and reduce it, so per-lane work is n/64 and the build stays
near 6us from 512 entries to 4096. That moves the fused cutoff to 8192, which is
where a workgroup's 64KB of LDS runs out.

Wan 720p self-attention at 5 heads needs 1480 entries and so was on the fallback
branch at 25.7us; it now builds in 5.9us, taking the whole call from 176us to
157us at 1.6% density.

Signed-off-by: Niko Säkkinen <[email protected]>

* fix(mha_v4): restore BF16 dense dispatch and launcher byte strides

Re-hook mha_v4() through mha_v4_packed for BF16/NONE, reject sparse BF16
explicitly, and pass byte strides (skipping descale setup) in populate_dense_kernarg.

Signed-off-by: Niko Säkkinen <[email protected]>

* style: run black, ruff, and clang-format on block-sparse MHA v4 changes

Signed-off-by: Niko Säkkinen <[email protected]>

* docs(mha_v4): trim sparse section implementation detail

Drop kernarg offsets, bit-packing formulas, and duplicate sparse GQA
text from mha_v4.md; keep API contracts and move sparse GQA notes into
Sparse Contract.

Signed-off-by: Niko Säkkinen <[email protected]>
Co-authored-by: Cursor <[email protected]>

* Add gfx942 sorted-sparse MHA v4 kernels

The gfx942 FP8/FP8 and INT8/FP8 sparse rows use a 256x64 tile rather
than gfx950's 256x128, so sparse geometry is no longer arch-invariant:
mask shapes go through mha_v4_kv_tile(), and the key-length check reads
cfg.ts_kv instead of a literal 128.

Signed-off-by: Niko Säkkinen <[email protected]>

* fix(mha_v4): guard sparse launches by device, validate LUT contents

The sparse launcher installed HipDeviceGuard after build_sorted_work_table,
whose raw HIP kernels take the current device rather than Q's, so a launch
with Q on a non-current GPU faulted; mha_v4_sparse_work_table had no guard
and silently returned zeros. Move the guard above every device query and
launch, and add one to the work-table op.

Also reject non-bool and wrong-device block_mask, bound kv_block_indices
against the row count, and add opt-in AITER_MHA_V4_VALIDATE_LUT=1 for
device-side checks. Empty LUT rows fault in the ASM rather than acting as
no-ops, so document them as invalid. Add tests proving sparse selection
follows the LUT per tile, per head, and across query tiles.

Signed-off-by: Niko Säkkinen <[email protected]>

* fix(mha_v4): make an empty sparse LUT row write zeros

lut_count == 0 faulted the sorted-sparse ASM, so the launcher declared empty rows
illegal. Rebuild the ten sparse code objects with the prologue reads clamped and
the row's KV traversal skipped, then follow through on the host: drop the
kLutEmptyRow rejection, and relax the unconditional kv_block_indices bound, which
was derived from the one-block-per-row assumption and would now reject a valid
tightly-packed LUT. The buffer must still be non-empty, since the kernels
dereference the row base even for a row that selects nothing.

Signed-off-by: Niko Säkkinen <[email protected]>

* perf(mha_v4): rebuild the gfx942 i8fp8 sparse object without the hot-path clamp

Signed-off-by: Niko Säkkinen <[email protected]>

* test(mha_v4): cover a partial query tile with an empty sparse row

Every sparse case used a whole number of 256-row query tiles, so the tail masking
the empty-row no-op is built on was never exercised alongside a short tile. Add
one case at 64/128/200 trailing rows that checks the short tile still reads the KV
blocks its row names and that an all-False row on it returns zero.

Signed-off-by: Niko Säkkinen <[email protected]>

* fix(bench_sage): pass the sparse LUT for the MX MHA v4 recipes

mha4_mxfp4/f4f4/mxfp6/f6f4 called mha_v4_packed directly instead of the
launch_mha_v4_packed wrapper that injects the LUT kwargs, so --block-sparsity was
silently ignored and every density measured dense.

Signed-off-by: Niko Säkkinen <[email protected]>

* refactor(mha_v4): rebuild the gfx950 f4f4 sparse object with a prologue-only clamp

Signed-off-by: Niko Säkkinen <[email protected]>

* mha_v4: take the sparse KV tile from the manifest

mha_v4_kv_tile() restated ts_kv as per-arch constants while the launcher read it
from the manifest row it dispatches on. Read the CSV instead (mode=1 rows), behind
torch_compile_guard since Dynamo traces a cached body and open() broke fullgraph
on the block_mask path. Adds the compile test, and moves the work-table build
measurements into mha_v4.md.

Signed-off-by: Niko Säkkinen <[email protected]>

---------

Signed-off-by: jcaraban <[email protected]>
Signed-off-by: Niko Säkkinen <[email protected]>
Co-authored-by: jcaraban <[email protected]>
Co-authored-by: Cursor <[email protected]>

* [HIP] [DCP] Enable fused indexer QK preparation (#5066)

* [DCP] Enable fused indexer QK preparation

* format

* fix uncondition clamp

* modify case

* [ASM] [HIP] [CI] Mxfp6 gemms (#4859)

* deploy mxfp6 gemms

* fix mxfp6 accuracy

* fix mxfp6 source formatting

Remove trailing whitespace so the clean branch passes git diff checks.

Co-authored-by: Cursor <[email protected]>

* Add MXFP6 GEMM tuning and shape-based dispatch

* refactor

* fix

* ruff

* replaces per-element log2/exp2 encoding with mathematically equivalent piecewise E2M3 encoding.

* co-pilot comments fix

* improved hip quantization

* fix MXFP6 backend and buffer validation

* Apply suggestions from code review

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* fix broken copilot suggestions

* fix A6W6 ASM default kernel selection

* cover all A6W6 kernels and padding paths in CI

---------

Co-authored-by: Cursor <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* [Triton/Gluon] Consolidate and reorganize ops/triton utils (#5061)

* [Triton/Gluon] Add two fused ops for diffusion transformer blocks (#4659)

* [triton] Add two fused ops for diffusion transformer blocks

A DiT block spends its non-GEMM, non-attention time in two patterns that torch
runs as long chains of elementwise ops. Both are memory bound, and both are
dominated by temporaries the maths does not need.

fused_rmsnorm_indexed_adaln

    out[m] = rmsnorm(x[m], weight) * (1 + scale[idx[m]]) + shift[idx[m]]

Adaptive layernorm: every token indexes a small table of modulation vectors,
one row per (modality, timestep). Unfused, the normalised activation is written
and immediately re-read, and both table gathers are materialised at [M, N] --
680 MB each at a 63k-token request. One program owns a block of rows and walks
each row in column tiles, once to accumulate the sum of squares and once to
normalise and modulate, so x is read once and out written once.

Two details that matter for this workload. Rows are tiled rather than padded to
the next power of two, because a 5376-wide row would mask off a third of every
access at 8192. And a block of consecutive tokens usually shares one modulation
index -- packed sequences are laid out in runs of one modality -- so the kernel
checks for that and collapses the [BLOCK_M, BLOCK_N] gather to a single
[BLOCK_N] load broadcast in registers.

fused_qk_norm_rope_cached

    q[t, h] = rope(rmsnorm(q[t, h], q_weight), cos_sin_cache[t])   (and k)

Per-head RMSNorm followed by partial NeoX RoPE, on q and k, in place. The
existing rope ops do not cover this case: they assume the rotated subspace is
the whole head or half of it, and diffusion transformers rotate fractions in
between (96 of 128 for MiniMax-H3), while the cache-write variants want a paged
KV cache that a diffusion model does not have.

One program owns a token. A token's heads are contiguous, so the [H, D] tile is
one coalesced run and the token's cos/sin row is read once for all heads rather
than being broadcast into a [T, H, D] temporary. Only each token's [H, D] block
must be contiguous, so q and k can be strided views into a packed qkv
projection and are rotated in place, never materialised.

Measured on MI355X, bf16, at MiniMax-H3's shapes:

    rmsnorm + indexed adaln, 63232 x 5376     1.708 ms -> 0.329 ms   5.2x
    qk norm + rope, 63232 x 56 x 128         11.690 ms -> 1.262 ms   9.3x

Both hold their speedup across the token counts one rank sees at Ulysses 1/2/4/8.

Accuracy: both keep the row in fp32 across the whole fusion, so they are nearer
the fp32 result than the op chain they replace, which rounds to bf16 at each
step. Against that chain on a real 50-layer model, one forward agrees to
cosine 1.0000000 with max relative error 1.3e-4.

58 tests: every table row exercised individually (a kernel that broadcast row 0
would pass a uniform-index test), the uniform and scattered index paths checked
against each other, q and k given different norm weights, the unrotated tail
checked for passthrough, and the strided-qkv-view case checked to leave v
untouched.

* Address review comments on the diffusion adaLN / RoPE fusions

Test fixes:

- test_uniform_and_scattered_indices_agree asserted nothing. Both index
  tensors were torch.full((M,), 2), so `fast` and `slow` were the same call on
  the same input and assert_close(atol=0) could not fail. That left the
  kernel's `uniform = tl.min(idx) == tl.max(idx)` branch -- which broadcasts one
  modulation row instead of gathering [BLOCK_M, BLOCK_N] -- with no coverage at
  all. The intent was also unreachable as written: with a single index value no
  arrangement is ever non-uniform.

  Two table entries are now made identical, so the same modulation is reachable
  both uniformly (broadcast branch) and alternating (gather branch) and the two
  must agree bit for bit. Verified by breaking the uniform branch on purpose
  (broadcast table row 0 rather than the block's index): the old assertion still
  passed, the new one fails.

- Every call whose output is asserted on now states `eps=1e-5` rather than
  leaning on the wrapper default, matching the `reference` calls beside them.
  The default is that same value, so nothing was computing the wrong thing, but
  the tests should not depend on it staying put. The two `pytest.raises` calls
  keep the default, where eps plays no part.

Kernels and wrappers:

- 1.0 / tl.sqrt -> tl.rsqrt in both kernels. Checked rather than assumed: all
  58 tests pass unchanged, including the fp32 cases at 2e-6 / 2e-5.
- Lazy %-style logging instead of eagerly built f-strings. This needed
  AiterTritonLogger to forward *args -- its methods took (self, msg) only,
  which is why the f-string pattern is everywhere in the Triton kernels. The
  change is additive, so existing single-argument callers are unaffected.
- The one assert in the adaLN wrapper without an error message now has one.
- Dropped the `if M == 0` / `if T == 0` guards. They were speculative; no
  framework hands these ops empty tensors.
- The RoPE wrapper docstring showed only the q equation; k was missing.

* fix(dist): make raw IPC input pools usable — remove init_dist_env's vestigial signal/buffer block, add explicit raw-pool override (#4924)

* fix(dist): init_dist_env no longer breaks raw IPC input pools

Under PYTORCH_HIP_ALLOC_CONF=expandable_segments:True -- the very
configuration the raw_cached input pool exists for (#4174) -- init
failed twice over in init_dist_env's signal/buffer block (#4921):

  * register_input_buffer(signal) exports the signal tensor's pointer via
    hipIpcGetMemHandle, but the torch.zeros signal is VMM-backed under
    expandable segments and the export dies at custom_all_reduce.cu:417
    with 'invalid argument';
  * ca_comm.buffer = ca_comm._pool["input"].tensor raises by design,
    because the raw_cached pool is a plain hipMalloc region with no
    backing torch.Tensor.

The block is removed rather than repaired, because all of it was
vestigial:

  * ca_comm.signal / ca_comm.buffer are never read anywhere in the tree;
  * C++ register_input_buffer only inserts a pointer-translation entry
    keyed by the registered tensor's own address, which is consulted only
    when an allreduce is invoked with that exact tensor as input --
    something that never happens for the signal tensor (open_ipc_handle's
    handle cache is filled on demand, so no pre-warming is lost either);
  * gfx1250 has skipped the entire block since its VMM bring-up (the
    vmm_exchange rendezvous deadlocks) and works without it.

CustomAllreduce.__init__ already builds its own meta/input pools and
forces the copy-in path under expandable segments, so nothing here was
load-bearing.

get_tp_group stays imported: this module is a re-export surface
(downstream engines import set_custom_all_reduce through it).

Adds op_tests/multigpu_tests/test_init_dist_env.py: brings up
init_dist_env per rank under both allocator modes (default torch pool,
and expandable_segments -> raw_cached) and checks one allreduce. The
existing test_custom_allreduce.py performs its own init and never
executes init_dist_env, which is how the regression shipped.

Fixes #4921.

Co-Authored-By: Claude Fable 5 <[email protected]>

* feat(dist): AITER_CUSTOM_AR_RAW_INPUT_POOL forces the raw IPC input pool

The raw (plain-hipMalloc) input pool previously had exactly one trigger:
PyTorch expandable segments. But expandable segments break custom
allreduce later anyway -- every capture-time output is a fresh
torch.empty_like whose VMM pointer get_output_buffer_RD records for
post-capture IPC export, which then fails in get_graph_buffer_ipc_meta
-- so the raw pool's one trigger leads to an unusable configuration
(#4921, third failure mode; #4621's copy-in guard covers inputs only).

The override gives the raw pool a trigger that works: co-resident
engines on one node, where a second engine's torch.empty input pool can
fail hipIpcGetMemHandle outright. Under the default allocator everything
else (meta pool, capture-time outputs, graph flush) stays exportable, so
only the input pool needs to move to hipMalloc.

Extends test_init_dist_env.py with a raw_override mode that asserts the
flag actually selects the raw pool and allreduce stays correct.

Co-Authored-By: Claude Fable 5 <[email protected]>

* feat(dist): log the input-pool allocation mode at init

A silently-inert pool trigger is indistinguishable from a working one by
behaviour alone -- the engine serves fine single-engine either way, and
the failure modes this pool exists to avoid (#4921) only appear in
specific modes under specific co-residency. One INFO line per rank makes
every run self-document which pool it actually got, so a mislabeled
measurement is catchable from the log rather than by re-deriving the
allocator state.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(dist): honor capture registration setting in fused AR

---------

Co-authored-by: ThomasNing <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>

* [FlyDSL] [opt][rope] optimize qk norm rope Ep decoding case specially for T512 (#5070)

* perf: TDM prefill bandwidth opt — K=5 occupancy + position prefetch

Two changes to improve TDM prefill kernel bandwidth at small T:

1. Reduce LDS buffer count from K=6 (192KB) to K=5 (160KB) when
   num_rows <= 65536. On gfx1250 with 320KB LDS per CU this allows
   2 WGs/CU instead of 1, doubling occupancy.

2. Prefetch position buffer_load before the hot loop: issue the first
   group's position load before TDM prologue, and each subsequent
   group's position load after the prior group's last tile compute.
   This overlaps the position→cos/sin serial dependency chain with
   TDM tile transfers and compute, reducing loadcnt stalls by ~41%.

ATT trace confirms total stall cycles drop 36% (72K → 46K), with
loadcnt (HBM) stalls down 41% and dscnt (LDS) stalls down 70%.

Measured kernel times (gfx1250, H=128 D=512 RD=64 BF16):
  T=512:   16.5us → 11.9us  (+39%)  8.2 → 11.4 TB/s
  T=16384: 302us  → 274us   (+10%)  14.3 → 15.8 TB/s

Co-Authored-By: Claude <[email protected]>

* perf: drop TDM prefill rotation to K=4 at small T

At num_rows <= 65536 (T=512, H=128) CT=8 yields gx_q=256 workgroups for
256 CUs -- exactly one WG per CU. LDS is therefore never the limiter at
this shape, which invalidates the reasoning behind the previous K=5
choice (it was picked to keep the arena at 160 KB so two WGs would fit,
but a second WG never exists here). With K free to pick on latency
alone, K=4 measures faster.

T=512 H=128 D=512 RD=64 BF16, gfx1250, three runs each:
  K=5:  15.728  15.647  15.683  -> 15.69 us  (8636 GB/s)
  K=4:  15.357  15.360  15.220  -> 15.31 us  (8874 GB/s)

Non-overlapping ranges, ~2.4% faster. T=16384 is unaffected (it takes
the num_rows > 131072 branch at K=6): 302.6 / 307.5 us, unchanged.

The mechanism behind the shallower rotation winning is not understood --
it is not LDS or occupancy driven -- so the docstring records the
measurement and warns against extrapolating to other shapes.

Also measured and rejected on this shape:
  - CT=4 to reach 2 WG/CU: 14.97 vs 14.86 us, no gain. Doubling the wave
    count doubles the per-wave cold-start cost, cancelling the extra
    latency hiding.
  - Issuing the position load before the TDM prologue: 15.63 vs 15.68 us,
    within noise. The K descriptor setups are far too few instructions to
    cover a ~1700-cycle DRAM miss.
  - TDM store (LDS -> global) in place of buffer_store, tried with a
    reused input buffer, one dedicated output buffer, and two rotating
    output buffers: 16.04 vs 15.27 us at matched K=4, ~5% slower. The
    LDS round trip (ds_write plus tensorcnt sync) costs more than the
    s_wait_xcnt it removes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* docs: erratum for 53d67009b — its perf claims and attribution were wrong

53d67009b ("perf: TDM prefill bandwidth opt — K=5 occupancy + position
prefetch") is already published, so its message is left in place and
corrected here instead. Four claims in it are wrong. The code it shipped
is fine and is kept; only the reasoning and the numbers were bad.

1. "Prefetch position buffer_load before the hot loop ... reducing
   loadcnt stalls by ~41%"

   The prefetch is a no-op. issue_pos() is followed immediately by the
   trunci that consumes it, in the same statement, so there is no
   distance for the load to cover its miss:

       pending_pos[0] = issue_pos(tok_of(tile_base + i + 1))
       cs_cache[0], cs_cache[1] = _cs_from_pos(
           fx.Int32(pending_pos[0].trunci(i32)))

   An ATT capture of the shipped code shows group 1's position still
   stalling 5249 cycles despite being "prefetched". The loadcnt
   reduction came entirely from K=6 -> K=5.

2. "K=5 (160KB) allows 2 WGs/CU instead of 1, doubling occupancy"

   At num_rows=65536 (T=512, H=128), CT=8 gives gx_q=256 workgroups for
   256 CUs, so a second WG per CU never exists and LDS was never the
   limiter. 034220f3a already replaced this reasoning in the
   _tdm_tiles_per_wg docstring.

3. "T=512: 16.5us -> 11.9us (+39%)"

   The 11.9us came from a hand-rolled L2-warm timing loop and is not
   comparable to the 16.5us op_test figure it was subtracted from.
   Measured on one path (op_tests/test_flydsl_qk_norm_rope_quant.py),
   idle GPU, five runs each:

     K=6  16.333 16.434 16.386 16.463 16.441  -> 16.41 us
     K=5  15.674 15.688 15.618 15.668 15.639  -> 15.66 us   (+4.6%)
     K=4  15.332 15.227 15.281 15.239 15.422  -> 15.30 us   (+2.3%)

   So 53d67009b was worth +4.6%, not +39%, and the two commits together
   are worth +6.8% (16.41 -> 15.30 us).

4. "T=16384: 302us -> 274us (+10%)"

   53d67009b does not touch that path. For num_rows > 131072,
   _tdm_tiles_per_wg returns (TILES_PER_WG, NUM_BUFFERS) = (40, 6),
   identical to the pre-commit default of CT=40 with the builder's
   num_buffers=NUM_BUFFERS. T=16384 measures ~305 us both before and
   after; the reported gain is spurious.

Root cause of 3 and 4: numbers from two different timing harnesses were
compared against each other. Only same-harness, same-session, repeated
measurements are used above.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* perf+fix: TDM prefill — 8-wave workgroups, and tighten the drain-phase wait

Two changes, found together while investigating why smaller workgroups
appeared to help.

1. Correctness: the drain phase under-waited on its TDM loads.

   Tile i consumes TDM load #i; loads are issued in tile order, K in the
   prologue then one per iteration while i + K < CT. In steady state K+i
   are outstanding, so tensor_wait(K-1) leaves exactly #0..#i retired --
   correct. Once the issues stop, the issued count freezes at CT and
   K-1 is too loose: #i is only guaranteed retired with at most CT-1-i
   left, which has to reach 0 on the last tile. The wait is now
   min(K-1, CT-1-i); both operands are compile-time constants in the
   unrolled loop, so this costs nothing.

   This was latent, not new. With ROWS_PER_TILE=32 the per-tile compute
   happened to outlast the load, so the shipped kernel got away with it.
   Shrinking the tiles exposed it: at RT=8/CT=16 the output was wrong in
   exactly the last three tiles of every workgroup (tile%CT histogram
   [0]*13 + [53,53,49]), with all 512 columns of those rows wrong --
   i.e. the LDS input itself, not the RoPE tail. err_q 0.027 -> 5.96e-08
   with the fix, same config, same build.

   Measured cost at the shipped shape (T=512 H=128, three runs each):
     without: 15.389 15.254 15.281
     with:    15.308 15.393 15.304

2. Perf: ROWS_PER_TILE 32 -> 8, and CT 8 -> 16 for num_rows <= 65536.

   gx_q = num_rows / (ROWS_PER_TILE * CT) has to stay at or above the 256
   CUs. At the low end of the TDM range it did not: num_rows=32768
   (T=256, H=128) gave gx_q=128, so half the CUs sat idle. RT=8 restores
   full coverage there and doubles it at num_rows=65536.

   T=512 H=128, five runs each:
     RT=32: 15.295 15.233 15.270 15.344 15.305  -> 15.29 us
     RT=8:  15.090 14.937 14.929 15.009 14.936  -> 14.98 us   (-2.0%)

   T=256 H=128, four runs each:
     RT=32: 12.610 12.587 12.581 12.645  -> 12.61 us
     RT=8:  10.904 10.499 10.587 11.065  -> 10.76 us          (-14.6%)

   Across the TDM path (H=128 unless noted):
     T=256   -16.3%    T=512   -2.5%
     T=1024   -6.5%    T=16384 -2.2%   T=16384 H=16  -0.9%

   Shapes below TDM_MIN_ROWS=32768 take the r32_w32 path and are
   untouched by ROWS_PER_TILE; the +-1-3% seen on those in a sweep is
   run-to-run noise.

   At RT=8, GROUP = H/RT = 16 and TILES_PER_WG=40 is not a multiple of
   it, so cos/sin hoisting turns off for the largest shapes. That is not
   a regression -- T=16384 still improves -2.2% -- consistent with the
   separate finding that the position->cos/sin chain is worth ~2.6% of
   wall clock despite being 36% of stall cycles.

Validated on 20 (T, H, q_weight) combinations plus the SWA direct/paged
and decode paths: all err_q/err_kv <= 1.3e-06, 16/16 checkAllclose pass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* perf(flydsl): optimize qk norm rope decode

* perf: fuse FP8 quant into TDM prefill and tune gfx1250 occupancy

Keep 2 WGs/WGP on the T=512 path, use 16-row tiles only for short prefill, and stream FP8 (grouped/e8m0) through the TDM kernel so Q write traffic drops without falling back to the slower direct path.

Co-authored-by: Cursor <[email protected]>

* perf(flydsl): TDM reads KV strided, and drops to K=2 on deep grids

Two independent changes to the gfx1250 TDM path.

1. Read KV with a row stride.

The TDM kernel indexed KV as `tok * D`, so the wrapper had to force
kv.contiguous(). The V4 call site slices KV out of a wider qkv_a tensor,
so that fired a full elementwise copy kernel on every invocation.
get_trace_perf sums all device kernels, so the copy landed inside the
number the op-test reports: 3.52us on top of a 12.20us kernel at T=512,
22% of the reported total, for nothing -- fused-kernel time is identical
whether KV arrives strided or contiguous. Thread kv_in_row_stride through,
matching what the wave32 and wave64 paths already do.

2. TDM buffer depth K=6 -> K=2 from num_rows >= 131072.

K sets the length of the load-only prologue. Once the grid is deep enough
that one workgroup's prologue overlaps another's steady state, the shallow
K=2 wins; below that a workgroup must cover its own load latency and the
deeper prologue pays for itself. Measured on top of 46ee44bc6, public API,
rotate=4, interleaved medians:

  num_rows   32768 (T=256)   K=2 +31.9%    131072 (T=1024)  K=2 -3.0%
             49152 (T=384)   K=2  +9.8%    262144 (T=2048)  K=2 -5.1%
             65536 (T=512)   K=2  +4.1%   1048576 (T=8192)  K=2 -4.3%
                                          2097152 (T=16384) K=2 -2.9%

Note the crossover sits above T=512: with 46ee44bc6's occupancy tuning in
the base, K=6 is now correct for the decode shape, so the T=512 gain here
comes from (1) alone.

T=512 on this gfx1250, same harness and rotation as the pre-change baseline:

  qw off  15.72us -> 11.07us
  qw on   16.48us -> 12.16us

The runperf script's own sweep reports 10.74us / 10.83us for the same two
rows; it launches through a tighter loop, so treat the pair above as the
comparable figure.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* test: runperf script sets PYTHONPATH and prints a combined summary table

`python op_tests/foo.py` puts op_tests/ on sys.path rather than the repo
root, so `import aiter` failed unless the shell already exported
PYTHONPATH. Set it from the script's own directory.

Also tee both sweeps to a log and replay every markdown table at the end
under its original heading, so the T=16384 and T=512 runs can be compared
without scrolling back through two sweeps of output.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* test(flydsl): make the qk_norm_rope %peak column arch-aware

_PEAK_BW_GBPS was a single 22000.0 labelled "MI355X HBM3e peak", but
22 TB/s is the gfx1250 figure -- MI355X (gfx950) is 8 TB/s and MI300X
(gfx942) is 5.3. The column was therefore only meaningful on gfx1250,
and silently wrong on the other two archs the file already lists in
SUPPORTED_GFX.

Look the peak up per arch instead. Unknown archs report None rather than
a fabricated percentage.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* style: apply black to qk_norm_rope_quant.py

CI runs black[colorama]==26.5.1 and this file was the only one in the
branch it wanted to reformat. Formatting only -- verified the AST is
identical before and after.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* chore: drop the local perf harness from the repo root

runperf-qknormrope-bs16-t16384.sh is a personal benchmark driver for one
shape on one machine, not something the repo should carry at its root.
It is kept locally alongside the other measurement tooling.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* perf(flydsl): let the TDM path take the fused SWA write

`use_tdm` excluded kv_write and paged outright, so any caller that passes
swa_kv fell back to the wave32 kernel. That is what the model does, so the
decode shapes were running qk_norm_rope_H128_D512_RD64_kvw_r32_w32_flydsl
and none of the TDM tuning reached them. The op-test did not show this:
its headline rows pass no swa_kv, and its SWA sweep is pinned to T=8..96
by the paged fixture's capacity, so it never reaches a TDM-eligible size.

Port the scatter into the TDM kernel's KV path. The gates are copied from
the wave32 sibling unchanged -- bid<0, pos<0, paged blk past the table,
table entry -1, resolved row past the pool -- and the row index is widened
to 64 bits before the byte multiply, as there too.

gfx1250, public API, rotate=4, interleaved medians:

           wave32     TDM     gain
  direct   T=512    17.65us  11.61us  -34.2%
           T=1024   32.61us  23.59us  -27.7%
  paged    T=512    17.46us  11.39us  -34.8%
           T=1024   32.07us  23.72us  -26.0%

Verified against the wave32 path at T=512/1024 in both modes: the pool is
byte-identical to kv_out at every resolved row, rows nobody targets stay
zero, and guard rows either side of the pool are untouched. Each skip gate
is covered by its own case.

Not covered: pos<0. It is not a legal input -- the main path indexes
cos/sin with the raw position long before the scatter -- and the wave32
path faults on it identically, so this is not a new exposure.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(flydsl): address q_out past 4 GiB in the TDM path

A buffer descriptor's num_records is 32-bit, so one descriptor reaches
4 GiB. q_out crosses that at T*H*D*2 >= 4 GiB -- T>=32768 at H=128,
D=512 -- and every row past the limit was dropped or wrapped.

The failure started exactly on the boundary: at T=32768 the first bad row
was 4194303, whose last byte sits at 0xFFFFFFFF, one past num_records, so
precisely 4 elements were lost. Beyond 4 GiB it degraded fast -- 0.05% of
q_out wrong at T=32776, 38.9% at T=40960, NaN in both.

Bias the descriptor base per workgroup instead, the same trick the SWA
scatter in this file already uses. A workgroup owns CT*RT rows, so the
32-bit offset then spans 128 KB rather than the whole tensor. The bias is
computed once per workgroup, outside the tile loop.

This predates the TDM work: the wave32 path fails identically at these
sizes, it is simply unreachable there now that TDM covers num_rows >=
32768. The op-test's default sweep includes T=65540 and had been failing
on it.

  T=65540, H=128: err 1.4e-07 (was garbage), 12524 GB/s
  T=40960: 0 bad elements (was 1.04e9)

No measurable cost -- T=512 11.40us, T=2048 40.66us, T=16384 330.25us,
all within run-to-run spread of the previous commit.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* style: collapse the SWA store guard (ruff SIM102)

The `do_swa is not None` guard was redundant -- None is already falsy, so
the two ifs fold into the one the wave32 path next door already uses:

    if const_expr(kv_write) and do_swa:

Short-circuiting still keeps the const_expr and the runtime predicate
apart: kv_write=False never evaluates do_swa, emit_q passes None so no
store is traced, and emit_kv passes the predicate so scf.if is emitted as
before. Re-ran the SWA scatter checks (10/10) and the op-test (465 passed)
to confirm codegen did not shift.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* perf(flydsl): halve the TDM workgroup when the grid is too thin

RT sets the workgroup size and therefore how many of them the grid holds:
gx_q = num_rows / (RT * CT). Below 2 workgroups per CU there is no
neighbour whose steady state can cover a workgroup's own load latency,
and RT=8 sits under that line for num_rows < 65536 -- at num_rows=32768
it yields exactly one workgroup per CU.

Halving RT there doubles the grid and pays for itself. It stops paying at
65536 (exactly 2 WGs/CU, a wash) and turns negative past it, where the
smaller workgroup costs more than the extra parallelism returns (+2.4% at
num_rows=262144), so RT=8 holds from 65536 up.

This is the same question K already answers, one level up: can a
workgroup's latency be hidden by a neighbour, or must it cover its own?

gfx1250, public API, rotate=4, interleaved medians, before -> after:

  decode (fused SWA)        prefill (no SWA)
    T=256   6.82 -> 6.65      T=256   6.85 -> 6.66
    T=384   9.55 -> 8.53      T=384   9.30 -> 8.76
    T=512  11.47 -> 11.45     T=512  11.16 -> 11.16
    T=2048 41.34 -> 41.27     T=2048 41.23 -> 41.19
    T=16384 333.53 -> 334.22  T=16384 331.43 -> 334.31

T>=512 is untouched by construction -- the geometry it selects is
unchanged, so those rows are noise. Prefill only reaches RT=4 on prompts
shorter than 512 tokens, where it is also a win.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* style(flydsl): trim the comments this branch added

The tuning rationale had grown into paragraphs sitting on top of two-line
functions. The measurements behind each threshold are in the commits that
introduced them, so the source only needs to say what the knob does.

Also folds emit_kv's inlined position load back into a load_pos() helper
that load_cs() now shares.

Net -26 lines. No behaviour change: op-test 465 passed, SWA scatter checks
10/10, T=512 decode 11.43us.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Satya Nikhil Kodukula <[email protected]>
Co-authored-by: Cursor <[email protected]>

* [Tune] Add GLM-5.3 BF16 GEMM configs for gfx950 (#5060)

* [Triton/Gluon] [HIP] Dev lumen (#4978)

* Add lumen triton kernels and custom ops (clean cherry-pick)

Cherry-pick of 4e19b8e3e (ZhangDanyang-AMD) onto upstream/main.
Only new files preserved; upstream existing code left untouched.
Adds: triton quant kernels, FP8/MXFP8 attention, MoE GEMM variants,
cross_entropy, fused_norm_quant_gemm, AOT precompiled kernels,
moe_sorting test cases.
Registers cross_entropy and mxfp8_attention in triton __init__.py.

* add large-M/small-N RMSNorm backward specialization

* add gfx942 (MI308X, 80CU) blockscale bpreshuffle GEMM configs

* add requant_fp8_row_to_col, chunked cross-entropy, add gfx942 per-shape GEMM configs

compile_ops type-check fix omitted — upstream already has _is_tensor_like fix.

* add gfx942 preshuffle GEMM configs for llama2-7b/13b/70b and qwen3-8b

* add MoE weight gradient Triton kernel (moe_wgrad)

Adds a fused Triton kernel for MoE weight gradients that operates
directly on sorted_token_ids/expert_ids from moe_align_block_size,
eliminating the need for sort+pad+bmm and CPU-GPU sync in backward.

Co-Authored-By: Claude Opus 4 <[email protected]>

* add is_cdna4() arch probe for gfx950 family

Co-Authored-By: Claude Opus 4 <[email protected]>

* add DSV4 sparse MLA training and indexer ops for DeepSeek-V4-Flash

- Sparse MLA: fused Triton fwd/bwd kernels with CSR-based dKV gather (no atomics)
- Indexer: BLAS-based scoring via torch.einsum (hipBLASLt) + PyTorch autograd
- Correctness tests: 84 sparse MLA tests + 48 indexer tests, all passing

Co-Authored-By: Claude Opus 4 <[email protected]>

* add Triton MHC forward and backward support

Co-authored-by: Cursor <[email protected]>

* integrate SonicMoE pure-Triton grouped GEMM MoE with full autograd

Port SonicMoE's pure-Triton MoE implementation from sonic-moe into aiter-lumen.
Provides trainable MoE layer with fused router + grouped GEMM + activation,
supporting forward and backward passes for all 7 activation types.

New files:
- _triton_kernels/moe/sonicmoe/: 9 kernel modules (grouped GEMM, activations,
  routing metadata, reduction, forward/backward autograd functions)
- aiter/ops/triton/sonicmoe.py: public API wrapper
- configs/moe/gfx942-MOE-SONICMOE-BF16.json: autotune configs for MI308X
- op_tests/test_sonicmoe.py: correctness + benchmark tests

Correctness verified on MI308X (T=64, H=128, I=64, E=4, K=2, BF16):

| Activation | output rel err | dx rel err | dw1 rel err | dw2 rel err | Status |
|------------|---------------|------------|-------------|-------------|--------|
| swiglu     | 0.0097        | 0.0132     | 0.0138      | 0.0104      | PASS   |
| geglu      | 0.0014        | 0.0089     | 0.0100      | 0.0000      | PASS   |
| reglu      | 0.0014        | 0.0103     | 0.0098      | 0.0000      | PASS   |
| gelu       | 0.0014        | 0.0134     | 0.0140      | 0.0000      | PASS   |
| relu       | 0.0014        | 0.0155     | 0.0168      | 0.0000      | PASS   |
| silu       | 0.0014        | 0.0146     | 0.0150      | 0.0000      | PASS   |
| relu_sq    | 0.0014        | 0.0104     | 0.0117      | 0.0000      | PASS   |

All relative errors < 2%, well within BF16 tolerance.

Co-Authored-By: Claude Opus 4 <[email protected]>

* fix tests: call existing topk_softmax and drop redundant RMSNorm 65536x128

The cherry-picked pytest imported a non-existent softmax_topk API; retarget it at ASM topk_softmax. 65536x128 duplicated 16384/364800 coverage of the large-M/small-N bwd path.

Co-authored-by: Cursor <[email protected]>

* fix style: format PR Python with Black and satisfy Ruff 0.16

Unblocks Checks so check-signal can let HIP/Triton CI run. Also add missing torch/_get_activation_from_str imports in gemm_a16w16_agnostic.

Co-authored-by: Cursor <[email protected]>

* drop files already removed on origin/main instead of resurrecting them

Cherry-picks had re-added pre-ctypes pybind/headers, AOT hsaco, and a
redundant bpreshuffle tuner. Keep gfx942 rows in the existing CSV.

Co-authored-by: Cursor <[email protected]>

* move gfx942 GEMM tunes into nested config layout so they actually load

Place llama2-7b/13b/70b, llama3-8b qkv, and qwen3-8b N/K tables next to
each family's DEFAULT.json. Legacy configs/gemm/ paths are ignored once
the nested default exists.

Co-authored-by: Cursor <[email protected]>

* load gfx942 SonicMoE JSON at launch instead of autotuning those kernels

Pick N/K/E and H buckets from {arch}-MOE-SONICMOE-BF16.json so production shapes skip the autotune search; fall back to the old autotune lists when the file is missing.

Co-authored-by: Cursor <[email protected]>

* fix ruff C408 in SonicMoE launch kwargs

Rewrite dict() calls as literals so Checks reviewdog stops failing the PR.

Co-authored-by: Cursor <[email protected]>

* format PR mxfp8/moe GEMM modules for Black 26

Remove extra blank lines after module docstrings so psf/black@stable in Checks passes on CI.

Co-authored-by: Cursor <[email protected]>

* drop gfx942 CK GEMM row that duplicates DSV4 opus tune

Merge keys are gfx/cu_num/M/N/K, so ck vs opus for 2048x4096x1024 on 80 CU fails wheel prebuild. Keep the faster opus entry from the DSV4 table.

Co-authored-by: Cursor <[email protected]>

* load SonicMoE JSON from nested gfx942/triton/moe layout

Co-authored-by: Cursor <[email protected]>

* format sonicmoe_config_utils for Black 26

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: ZhangDanyang-AMD <[email protected]>
Co-authored-by: leiwu0812 <[email protected]>
Co-authored-by: Claude Opus 4 <[email protected]>
Co-authored-by: Cursor <[email protected]>

* [CI] Avoid direct github.event interpolation in run: blocks (SEC-00830) (#5109)

Mythos scan finding SEC-00830 (ROCM-26711) flags GitHub Actions event
context interpolated straight into `run:` shell blocks, where the value is
pasted into the script text before the shell parses it.

aiter-test.yaml already uses the `env:`-indirection pattern in most steps
(15 `env:` blocks; `${GITHUB_EVENT_NAME}` at lines 50/537). This brings the
five remaining spots in line:

- 3x `if [ "${{ github.event_name }}" = "schedule" ]`
    -> `${GITHUB_EVENT_NAME}` (GitHub's built-in, same as lines 50/537)
- 2x `BASE_REF="${{ github.event.pull_request.base.ref || github.ref_name }}"`
    -> hoisted into a step-level `env:` block

After this change no `${{ github.event* }}` remains inside any `run:` block.

Note this is hardening, not a fix for an exploitable bug. The scanner's stated
attack surface (`github.event.pull_request.title`) does not appear in any
`run:` block. Of the five occurrences, three were `github.event_name` (an
enumerated value) and two were `base.ref` — the PR's *target* branch, which
this workflow constrains to `main` via `branches: [main]` and which an external
contributor cannot name. The point is to keep the pattern out of the file so a
future edit cannot turn it into a real injection.

actionlint: clean before and after.

Refs: ROCM-26711 / SEC-00830

* [CI] Drop registry credentials after jobs on persistent runners (SEC-00837) (#5110)

Mythos scan finding SEC-00837 (ROCM-26712): self-hosted runners are
non-ephemeral, so `docker login` credentials written by one job stay in
~/.docker/config.json and are readable by whatever runs next on that machine.

aiter-test.yaml has three `Docker login` steps and no `docker logout` anywhere:

  build_aiter_wheels  runs-on: build-only-aiter      (no cleanup step at all)
  standard            runs-on: ${{ matrix.runner }}  (has "Cleanup container")
  multi-gpu           runs-on: ${{ matrix.runner }}  (has "Cleanup container")

This adds `docker logout` to the two existing `Cleanup container` steps and
gives build_aiter_wheels the cleanup step it was missing. All three run under
`if: always()`.

This is the immediate mitigation the ticket calls for, not the fix. It narrows
the window but does not close it: credentials still exist on disk between login
and logout, and a cancelled job may skip cleanup entirely. The actual fix is to
register the runners with `--ephemeral` (or `ephemeral: true` under
actions-runner-controller) so every job starts from a clean machine. That lives
in the runner infrastructure, not in this repository.

Existing partial mitigation, unchanged by this PR: all three `Docker login`
steps are already gated on `!github.event.pull_request.head.repo.fork`, so fork
PRs never write credentials in the first place.

actionlint: clean.

Refs: ROCM-26712 / SEC-00837

* [HIP] [ROCm][Perf] Add head_dim 512 + weightless V-norm to fused_qk_norm_rope_cache_pts_quant_shuffle (#5027)

* [ROCm][Perf] Add head_dim 512 + weightless V-norm to fused_qk_norm_rope_cache_pts_quant_shuffle

Enable the fused QK-norm + RoPE + KV-cache op for Gemma4, whose full-attention
layers use head_dim 512 and whose every attention layer applies a weightless
v_norm (RMSNorm with has_weight=false).

- rope_common.h: add warp_rms_norm_no_weight_ (RMS normalize a head with no
  learned gamma); apply it to V in fused_mrope_rms_kv_kernel when the new
  runtime flag v_norm is set, before the KV-cache write. Add case 512 to the
  fused_rope_rms_set_kv head_size switch (VEC_SIZE=16 at 512) and relax the
  head_size guard. The mrope-3D launcher is unchanged (passes v_norm=false).
- fused_qk_norm_rope_cache_quant.cu / .h / rocm_ops.hpp: thread the trailing
  bool v_norm (default false) through the pts entrypoint and pybind.
- ops/fused_qk_norm_rope_cache_quant.py: add v_norm to the python wrapper.

Validated with a standalone call at head_dim 256 and 512: the 512 template
instantiates/compiles, and the V-cache matches a weightless-norm reference at
bf16 rounding tolerance for both widths.

Co-authored-by: Claude <[email protected]>

* [ROCm][Perf][Test] Cover weightless V-norm + head_dim 512 in pts fused op

Add test_fused_qk_norm_rope_cache_pts_v_norm: exercise
fused_qk_norm_rope_cache_pts_quant_shuffle with v_norm on/off at head_dim 256
(Gemma4 sliding) and 512 (Gemma4 full). Asserts the V written to the cache is
weightless RMS-normalized when v_norm=True and raw otherwise.

Co-authored-by: Claude <[email protected]>

* [ROCm][Perf][Test] Address review: guard shuffle K write + real v_scale coverage

Fix two issues from PR review:

- Guard the shuffle-layout K write against silent cache corruption. That
  path does a single contiguous vec_t store of VEC_SIZE = head_size /
  WARP_SIZE elements and get_shuffle_layout_k_base() assumes they all land
  in one x-wide chunk (VEC_SIZE <= x). At head_size=512 / WARP_SIZE=32 that
  is VEC_SIZE=16, which exceeds x=8 for a bf16/fp16 cache and would corrupt
  K for block_size>1. Reject that config with an AITER_CHECK. An fp8 cache
  (x=16) still satisfies the bound, so shuffle layout at head_dim 512 with
  fp8 KV is unaffected.

- Rework the v_norm op test to follow the file convention and add real
  scale coverage. The per-tensor v_scale only divides V on the fp8 quant
  write path -- a same-dtype cache copies V verbatim, so the previous
  bf16-cache test never exercised the scale. The test now uses @benchmark,
  is wired into __main__ with a markdown summary table, and sweeps head_dim
  256/512, v_norm on/off, and (bf16, [email protected], [email protected]) cache/scale pairs to
  check norm-then-quantize ordering.

Co-authored-by: Claude <[email protected]>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: root <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* [HIP] fix(topk): add acquire fence for mb radix barrier last block (#4841)

* fix(topk): add acquire fence for mb radix barrier last block

`radix_kernel_persistent` uses a per-row cross-block barrier in the multi-block radix top-k path. The waiting blocks observe `pass_done` with an acquire load, which also invalidates their cache state before they reload the global histogram for the next pass. The elected "last" block, however, only publishes `pass_done` with a release store and then falls through to the same plain histogram reload without ever doing an acquire/invalidate.

On MI355X this can let the elected block reload stale histogram lines from the persistent workspace. If that block computes a different `local_len` / `local_k` from its peer blocks, it can leave the pass loop early while another block continues into the next barrier. The early-exiting block can then be elected in the self-reset epilogue and zero `pass_done` while its peer is still spinning on it, producing a permanent GPU wedge in the GLM-5.2 DSA indexer path.

Add a `__threadfence()` plus CTA sync after the release store in the elected last-block branch. This gives the last block the missing acquire-equivalent ordering before it reloads the histogram, making both sides of the barrier observe consistent global memory before computing the next pass state.

This fixes the production hang seen with GLM-5.2 TP4 + DP attention + LMCache + atomesh `dp_sticky`, where one DP rank could wedge inside `aiter::mb::radix_kernel_persistent` and then stall the whole service through DP-attention collectives while `/health` stayed green.

Validation:
- unpatched stock kernel soak reproduced 5 wedges in 213,400 launches / 27.3M row-launches.
- fixed stock kernel soak completed 1,914,200 launches / 245.0M row-launches with 0 wedges, 8.97x the baseline exposure.
- detector build changed the failure signature from `passes=[2,2,1,0]` with `STUCK` to 0 `STUCK` events over 131.4M row-launches.
- end-to-end GLM-5.2 TP4 + DPA + LMCache + atomesh aiperf run has passed warmup and entered 3600s profiling without the previous hang signature.

Signed-off-by: Phi-C <[email protected]>
Co-authored-by: Cursor <[email protected]>

* perf(topk): use acquire-only mb radix barrier fence

The elected last block needs device-scope cache invalidation before reloading the global histogram, but does not need release/writeback semantics. Use an agent-scope acquire fence to preserve correctness while avoiding the unnecessary release overhead of threadfence.

Signed-off-by: Phi-C <[email protected]>
Co-authored-by: Cursor <[email protected]>

* fix(topk): drain mb histogram atomics before barrier

Ensure every wave completes no-return histogram atomics before block arrival, then establish agent-scope visibility after relaxed polling to prevent cross-block divergence.

Co-authored-by: Cursor <[email protected]>

---------

Signed-off-by: Phi-C <[email protected]>
Co-authored-by: Cursor <[email protected]>

* [aiter_opus_plus] detorch (#4958)

* [FlyDSL] 1250 clean moe aux kernel codes and ir, add ut (#5112)

* [CI] Mirror PR title component tags as auto-managed labels (#5057)

* [CI] Mirror PR title component tags as auto-managed labels

* address comments

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Xin Huang <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* Tune the new Kimi-K3 a8w8 bpreshuffle and bf16 GEMM shapes (#5124)

Adds five a8w8 bpreshuffle (N,K) groups -- 1536x1536, 2048x512, 3584x7168,
7168x1024, 7168x1792 -- and three bf16 groups -- 896x7168, 7168x35840,
20480x7168. Each group covers M as every power of two from 1 to 32768 plus
M=48, so a 48-row request resolves to its own entry instead of padding up
to M=64. None of these had a gfx950 row before: the bf16 file carries rows
for two of the three groups, but only for gfx1250.

Existing rows are untouched. The tuners ran without --all, so only the
newly added shapes were considered, and a key-wise comparison against the
pre-tune files confirms zero modified and zero removed rows.

a8w8, --libtype all -k --shape_grouped on gfx950 (cu_num=256): 85 rows,
78 FlyDSL / 4 CK / 3 CK-tile. Seventeen land on the FlyDSL 8wave pipeline
and nine use splitK, all of them on 3584x7168 where K is large enough for
the extra parallelism to pay off at small M.

Measured against today's behaviour (no tuned row, default kernel), three
runs, per-shape median of 100 iterations after 20 warmup, one GPU, with
the CK and CK-tile lookup tables rebuilt from the new config first:

  N=1536  K=1536    322.2us ->  248.2us   +22.99%
  N=2048  K=512     241.9us ->  175.7us   +27.36%
  N=3584  K=7168   1797.2us -> 1373.5us   +23.58%
  N=7168  K=1024    876.3us ->  631.4us   +27.94%
  N=7168  K=1792   1192.0us ->  910.8us   +23.59%
  total            4429.6us -> 3339.6us   +24.61%

Best single shape is M=2 N=7168 K=1792 at 16.28 -> 6.24us. Two shapes on
1536x1536 first looked like small regressions; a seven-run recheck put
both sides within 0.5% of each other, which is inside the noise for a
4.5us kernel, so they are kept.

bf16, csrc/gemm_a16w16/gemm_a16w16_tune.py without --with-hipblaslt, run
under --compare --update_improved so a row is only written when it beats
the default kernel by at least 3%. Twenty of the 51 candidate shapes
cleared that bar; the other 31 are already at what the default dispatch
picks and are left out. The largest win is M=1 N=896 K=7168 at
14.69 -> 6.64us (54.8%).

op_tests/tuning_tests/test_config_shape_collision.py and
test_csv_validation.py pass (30 tests, 37 subtests).

* Fix PR title tag workflow syntax (#5134)

* [CI] Document and automate the AITER release plan (#4424)

* Document and automate release plan

* Harden AITER release automation

* Update release notes after asset upload

* fix: harden release automation checks

* Fix manual release Docker login

* Adjust release cadence anchor

* Fix reusable release Docker login

Signed-off-by: Xin Huang <[email protected]>

---------

Signed-off-by: Xin Huang <[email protected]>

* [Triton/Gluon] combine routing early exit (#5053)

* [Triton/Gluon] [gfx950] gated_delta_rule: drop removed tl.make_block_ptr (#4950)

* [Triton] fix(gated_delta_rule): replace removed tl.make_block_ptr for Triton 3.8

Triton 3.8 removed block pointers. tl.make_block_ptr still exists as a symbol
but raises at trace time:

  NotImplementedError: Block pointers have been removed in favor of the
  tensor descriptor API

so every gated_delta_rule kernel using it fails to compile. This is an API
removal, not a GPU issue - it reproduces identically on gfx950 and gfx942, and
is what makes op_tests/test_gdn_prepare.py fail on both MI35X and MI300X.

Convert all 128 block accesses to plain pointer arithmetic with explicit bounds
masks, reproducing the previous boundary_check=(0, 1) semantics:

  prefill/chunk_o.py                     42 sites (6 kernels)
  prefill/fused_solve_tril_recompute.py  41
  utils/solve_tril.py                    35
  prefill/fused_cumsum_kkt.py            10
  utils/cumsum.py                         2

The 2-D helper in chunk_o.py takes both strides so the transposed (K, T) views
with stride (1, H * K) convert without a special case. Stores keep their
fp_downcast_rounding="rtne" behaviour.

Validation on gfx950 with triton 3.8.0+amd.rocm7.1.0.gitf6a045ff:
  op_tests/test_gdn_prepare.py   28 rows, max |err| = 0.0, all shapes / all
                                 three hidden backends (triton/flydsl/hip)

* fix(gated_delta_rule): convert remaining l2norm/wy_representation block ptrs

l2norm.py (4 sites) and wy_representation.py (11) still used tl.make_block_ptr,
which Triton 3.8 removed. Both are on live e2e inference paths that
op_tests/test_gdn_prepare.py does not exercise:

  gated_delta_rule.py: l2norm_fwd(q/k) when use_qk_l2norm_in_kernel=True
  prefill/chunk.py:109: recompute_w_u_fwd (non-fused w/u path)

so a real GDN forward raises NotImplementedError at trace time. Under
torch.compile this surfaces as a masked backend-compile failure.

Convert both with the same plain-pointer-arithmetic pattern. Verified on gfx950:
chunk_gated_delta_rule(use_qk_l2norm_in_kernel=True) now runs to finite output;
l2norm_fwd matches its torch reference (max |err| 9.7e-04).

* [Triton/Gluon] Gluon MXFP4 Fuse Reduce Quant (#3937)

* Initial first verison of fuse_reduce_rms_mxfp4_quant_kernel(). Included changes to api call and relevant op_test.

* Moved tensors descriptors for second phase into relevant section. Removed redundant layout descriptor. Removed placeholder comment.

* Code Style check.

* Included _mxfp4_quant_op from triton with gluon adaption. Added barrier() to sync threads. Added warning for calling gluon without proper arch.

* Ruff checks

* [Triton/Gluon] Revert Triton parts of #4978 (Dev lumen) (#5149)

Reverts everything PR #4978 (f4e7c7509) changed under `aiter/ops/triton/`
back to its pre-merge state (4ad998328), plus the top-level op_tests that
exercise only those Triton ops.

Reverted:
  - aiter/ops/tr…
junhaha666 pushed a commit that referenced this pull request Sep 8, 2026
…hem (#5289)

* validate-kernel-pr: record non-SystemExit failures in the execution receipt

`main()` caught SystemExit only, so a target dying on an uncaught AssertionError
-- the standard shape of aiter's op_tests -- left `status` at 0 and the `finally`
block wrote a receipt claiming `pytest_exitstatus: 0` before the exception
propagated. The process exit code was right; the evidence on disk was not, and a
red run was indistinguishable from a green one to anything reading the receipt.

Reproduced with two script targets, one passing and one asserting:

  before   ok exit=0 receipt=0   fail exit=1 receipt=0
  after    ok exit=0 receipt=0   fail exit=1 receipt=1

Re-raising keeps the traceback and the exit code intact; SystemExit(3) still
records 3.

* validate-kernel-pr: count untracked files as kernel changes

`kernel_files_changed` came from `git diff --name-only HEAD`, which never lists
untracked files, and the script has no `git add`/`--intent-to-add` anywhere. Files
that `git apply` introduces as new therefore did not exist as far as the test-policy
analyzer was concerned: a PR whose whole point is a new kernel read as touching no
kernel code, and a tolerance widened alongside it was reported under the weaker
finding.

Reproduced on a scratch repo carrying one modified test and one added kernel:

  before   changed=['op_tests/test_thing.py']                  kernel_changed=False
  after    changed=[..., 'csrc/kernels/new_kernel.cu']         kernel_changed=True

`--exclude-standard` keeps .gitignore'd build output out; the index is untouched.

* review-pr: derive the applicable rule set from the diff, and split the Tier table

Step 3 was a 20-type checklist mapping onto 44 rules, applied by the model to
itself. A model asked to read all 44 attends to none of them, and Step 1 already
had the diff in hand and was already running Python over it, so the classification
costs nothing to derive structurally.

triage.py has two modes. `rules` emits only the families the diff triggers.
`evidence` answers the question those families actually turn on: for a removed
guard or a changed signature, how the symbol is handled ON HEAD -- fetched, rather
than left to a prose reminder to go and grep. That reminder was already in Step 1
and was read and not acted on, producing a withdrawn `q_out is not None` finding on
aiter#5143; `q_out` is std::optional on both sides, every call site is
`has_value() ? data_ptr() : nullptr`, and the kernel guards `if(is_q && q_out !=
nullptr)`. The collector puts those three lines in front of the reviewer.

Measured over 597 open aiter PRs (every open PR at the time, diffs fetched from the
API):

  rules read   median 12 of 44 (27%), max 29, none needed the full set
  coverage     597/597 matched at least one family
  precision    most common family fires on 48%, none above half

Derivation is conservative -- a family it cannot decide structurally is included,
never dropped -- and it degrades rather than failing: an unparseable diff, an empty
diff, or GitHub refusing to serve one over 20000 lines all fall back to the full
44-rule set, which is the pre-derivation behaviour.

D9 is deliberately absent from the emitted sets. scan_index_width.py already decides
that family structurally and its candidate list is the input to the finding;
re-reading the prose adds nothing and costs attention the scanner-less families need.

Step 4's Tier table listed `aiter/ops/*.py (any)` as Tier 1. By the table's own Q1
test that is defensible -- `__init__.py` does `from .ops.xxx import *`, so breaking
any one of them breaks `import aiter` -- but there are 200+ files under aiter/ops/,
and putting every single-kernel wrapper in the same tier as jit/core.py empties the
tier of meaning: measured across the same 597 PRs it fires on 71% of them, and a
mandatory full assessment demanded of 71% of PRs stops being performed at all.
Tier 1 is now jit/core.py and __init__.py, whose failure mode is every op; a wrapper
is Tier 3, whose blast radius is its own op, and the import-chain risk it does share
is covered by the B6 export check attached to the ops-wrapper family. The full Step 4
assessment now fires on 6%.

* review-pr: sweep the diff's added imports against the merge target

`triage.py` grew a `symbols` mode that resolves every first-party import a diff
adds, but nothing invoked it and the SKILL never mentioned it, so the code was
dead. Step 1b now runs it against a fresh checkout of the branch the PR merges
INTO -- not the PR base, and not whatever the reviewer has on disk.

The root is the whole check. aiter#4994 added
`from aiter.ops.flydsl.utils import is_flydsl_available`; #5116 (3b2a9ce6) had
deleted that module from main 19 hours earlier. Resolved against #4994's own base
the import is fine and the sweep returns clean; resolved against main-at-merge-time
it reports. #4994 merged green (83571d9b) and was reverted 5.5 hours later
(283e1d4b). A stale root reproduces exactly the silence that let it through.

Two corrections that fall out of that:

- The finding is a REBASE signal, not an accusation of invention. Renamed
  HALLUCINATED-SYMBOL to UNRESOLVED-IMPORT; a reviewer who reads "hallucinated"
  about an import that was valid when written will dismiss the whole class.

- `from pkg import sub` binds a submodule, which need not appear in the package's
  `__init__.py`. Searching only the __init__ text called four real imports
  invented across the 600-PR corpus (aiter.jit/core, aiter.jit.utils/chip_info,
  flydsl.kernels/{buffer_ops,vector}). Report rate over that corpus drops from
  14% to 10%, and every module-level hit that remains is a module absent from
  today's main.

Verified: reports on #4994 against main, silent against the pre-deletion tree,
silent on #5143.

* review-pr: pin every step to the PR's own commits, not the reviewer's checkout

Three ways the same PR produced different results, or no result, depending on who
ran the skill and what they happened to have on disk.

1. `$BASE_SHA` and `$HEAD_SHA` were referenced in Step 1b and assigned nowhere.
   Under `set -u` that aborts the block, so the cross-file evidence collector --
   the thing added specifically because prose telling a reviewer to go and grep
   was read and not acted on -- never ran for anyone, and neither did any step
   after it. Both are now assigned once in Step 1 from the API: the base branch
   tip already fetched into base_head.txt, and headRefOid from the PR metadata.

2. `git fetch origin ...` assumed the remote named `origin` is the repo under
   review. Anyone who has pushed a branch has a fork there instead, and
   `origin refs/pull/N/head` then resolves against the FORK's pull refs: a
   different PR's head, or nothing. Every fetch now names $REPO_URL explicitly.

3. The evidence collector prefixed changed paths with $PROJECT_ROOT, reading the
   reviewer's WORKING TREE -- whatever branch is checked out, plus uncommitted
   edits -- rather than the PR's head. It now materialises head blobs under $WORK
   and names the ones it could not get.

Measured on the 600-PR corpus, resolving against a checkout one day stale rather
than the base tip changes the symbol sweep's answer on 33 PRs, 31 of them missed
reports -- the aiter#4994 failure mode, arrived at silently.

Verified end to end against live PRs (#5240/#5242/#5244 clean, #4166/#4441 report
their flydsl.utils import) from two checkouts: current main, and one 130 commits
stale with a fork origin, a dirty tree, and the deleted module still present.
Byte-identical output from both.

* review-pr: make the rule pass produce an artifact the skill can check

Step 5 asked the model to work 44 rules -- now a derived 12 -- and marked them off
to itself. Nothing downstream could tell a run that adjudicated every rule from one
that read the list and went straight to the card, and the skill already has its own
evidence that the second is what happens under load: on a 14-PR controlled run the
revised D9 text caught 0 of 3 known overflow defects and the scanner it names was
never invoked once. That is why the D9 scan was moved into Step 1. This applies the
same move to the rule pass itself.

Step 5 now writes one line per derived rule to $WORK/verdicts.txt:

    <RULE-ID> FIRE|CLEAR|N/A — <reason naming file:line, symbol, or condition>

and Step 8 will not write a card until `triage.py ledger` is green. The gate reports
UNADJUDICATED for a derived rule with no line and NO-EVIDENCE for a verdict with no
reason, and fails closed on an empty rules.txt -- the state of a run whose Step 1b
never happened, which must not be the cheapest path to a verdict.

It checks that each rule was answered, not that the answer is right. Answering
wrongly is a review error a human can see in the card; not answering is invisible,
and invisible is the one that scales.

Verified against the four shapes of skipping: no Step 1b (exit 1, LEDGER UNUSABLE),
card without a rule pass (exit 1, 4 UNADJUDICATED), two rules cherry-picked (exit 1),
every rule stamped "ok" (exit 1, 4 NO-EVIDENCE). A real adjudication passes 4/4.

* review-pr: give Triton kernels their own rule families

Triton is 195 of the 600 open aiter PRs in the replay corpus, and the derivation
said almost nothing about them: `ops-wrapper` fired on 88% and `modified-kernel` on
79%, so a Triton PR arrived labelled rather than triaged. The generic families were
tuned on the whole corpus, and this is the subpopulation where that shows.

Four families, mined from what the 195 diffs actually contain, each firing on at
most 52% of Triton PRs and 17% of all of them:

  triton-mask-bounds  T1 T2   27%  unmasked tl.load/tl.store; mask= without other=
  triton-launch-cfg   T3 T4   52%  num_warps/num_stages/num_ctas; waves_per_eu,
                                   matrix_instr_nonkdim, kpack across archs
  triton-accum-prec   T5      25%  tl.dot, .to(tl.float32), allow_tf32
  triton-grid-map     T6      27%  host grid vs the kernel's program_id mapping

`tl.load`/`tl.store` arguments are extracted paren-balanced rather than by regex:
`[^)]*` stops at the first close paren, so `tl.load(p, mask=(a<b), other=0.0)` reads
as having no `other=`. Twenty of the 195 contain that shape; the balanced scan drops
the mask family from 55 PRs to 52, all three of them false.

T1/T5/T6 are 🔴-eligible and carry their own FP self-checks -- an unmasked load is
fine when the axis is a constexpr multiple of the block, and T3 is a perf finding
that needs a base-vs-head number or it is `[inferred]` per Step 8.

Full-corpus replay with the six new rules in: median 13/49 (27%, unchanged --
the additions did not dilute), coverage 598/598, no family over half.

* review-pr: anchor a FIRE verdict to a file the PR actually changes

The ledger checked that every derived rule had a reason, which closes "did not
answer" but not "wrote something plausible". A reason is free text and mostly
unjudgeable, but one part of it points outside the model: the path it cites.

`ledger` now takes the diff and rejects a FIRE whose reason names a file this PR
does not touch -- a defect claimed against untouched code is either carried over
from another review or invented.

Only FIRE is checked, deliberately. A CLEAR legitimately cites files outside the
diff: "E5 CLEAR: aiter/__init__.py unchanged" is a correct reason precisely because
that file is absent, and flagging it would teach the reviewer to stop citing
anything -- worse than not checking. Reasons that name no file are not flagged.
This narrows the gap between "answered" and "answered honestly"; it does not close
it, and nothing here judges whether a CLEAR is correct.

Verified: a fabricated FIRE citing aiter/fused_moe.py on a PR that changes only
aiter/mla.py and op_tests/test_mla_persistent.py exits 1 with UNTOUCHED-CITATION,
while the same ledger with the FIRE moved onto aiter/mla.py:120 passes 4/4, and the
two CLEARs citing untouched files pass in both.

* review-pr: take the rule bodies and Step 1 out of the entry file

SKILL.md went 487 -> 632 -> 1372 lines between 2026-07-09 and 2026-09-03, and almost
none of that was instructions. At 1210 lines, 825 were inside code fences and 299
were prose; Step 1 alone was 828 lines, 95% of it bash. It was a ~300-line skill
wrapped around a 785-line shell script, and a reader had to scroll past the script
to reach the part written for them.

Two moves, same principle: what is conditional gets derived, what is executable gets
called, and only what every review needs stays resident.

- Rule bodies move verbatim to rules.md, byte-identical to the span they came from.
  `triage.py expand` writes $WORK/rules_expanded.txt: the full text of exactly the
  derived rules, under their headings, nothing else. Cutting which rules the reviewer
  is TOLD to check from 44 to a median of 12 while still shipping all 44 texts was
  half a fix -- 383 lines of bodies against a median need of 103. Corpus replay: 0/600
  expansion failures, median 117 lines against a fixed 410 (29%).

- Step 1 and 1b move verbatim to fetch.sh, which SKILL.md calls in three lines and
  which prints its scratch dir for the steps that follow.

SKILL.md: 1210 -> 440 lines, below the 487 it started at, with everything added since
still in force.

Two shapes the expander had to learn, both found by running it over 600 real PRs
rather than by reading the file: Housekeeping rules are table ROWS, not `**HKn — **`
blocks (parsing only blocks reported HK4/HK6/HK9 as undocumented on 277 PRs -- they
are documented, the parser was wrong), and STEP4 names Step 4 rather than a rule body.
A rule whose body genuinely cannot be found is a hard failure naming the ids, because
emitting 11 of 12 bodies reads exactly like emitting 12.

Verified equivalent, not assumed: fetch.sh and the previous inline blocks were run
against aiter#5222 and #4166 from the same checkout. stdout matches line for line and
pr.diff, rules.txt, rules_expanded.txt, symbols.txt, evidence.txt,
validation_requirement.json and base_head.txt are byte-identical.

The move broke four tests in validate-kernel-pr that assert on strings in review-pr's
SKILL.md. The contracts are right -- perf-harness detection must agree across both
skills, the scanner must be required, the identity gate must be the one shipped --
they were reading half the skill. They now read SKILL.md and fetch.sh together, and
the gate block is selected by containing `expected_verdict` rather than by being the
second heredoc, which is not a property anyone maintains.

Mutation-testing those repairs found two holes. `assertIn("fetch.sh", step1_block)`
was satisfied by the COMMENT above the call, so breaking the call site left it green;
it now requires a non-comment line. And the identity gate had no test at all: every
case fed it `headRefOid` copied from the report under test, so replacing
`actual_head != expected_head` with `if False` -- a gate accepting a report from any
checkout -- kept all 88 tests green. test_review_gate_rejects_a_report_for_another_head
feeds a mismatched head and is confirmed to fail against that mutant.

rules.md and fetch.sh are force-added: .gitignore line 21 ignores .claude/ wholesale,
and everything already tracked under it was force-added too. Without -f these two
files stayed untracked while SKILL.md was committed calling them.

89 validator tests, 241s.

* review-pr: test what the deriver produces, and budget the entry file

Mutation testing over triage.py: 170 predicate flips, 20 caught. `and` to `or`, a
dropped `not`, `p.count("/") == 1` to `!=` -- 150 of 170 mutants left the suite green.
Those predicates decide which rules a reviewer is shown, so any edit could silently
change every review with nothing failing. The 600-PR corpus existed, but as something
run by hand, not as a test.

corpus.tgz pins 59 real PRs: 19 chosen so every one of the 31 families fires at least
once, 40 more drawn with a fixed seed. expected.json holds their exact `rules` and
`symbols` output. When a deriver change is intended, re-bless with bless.py and commit
the diff -- that diff names which real PRs would now be triaged differently, and it is
the review. Two invariants beyond byte-equality: every corpus PR derives at least one
rule (an empty result silently clears a PR), and median expansion stays under 45% of
rules.md (the derivation can stop discriminating while every individual output still
looks reasonable).

That took the score to 38%, and the survivors clustered. A third sat in
sweep_symbols/symbol_defined/resolve_module, because only 6 of the 59 corpus PRs emit
any UNRESOLVED-IMPORT line -- the paths that decide NOT to report were barely reached,
and those are the ones that fail silently. Nine cases cover them directly: namespace
package, submodule binding, star-import and __all__ re-export, module added by the PR
itself, symbol added by the PR itself, deleted-import lines, third-party and relative
imports, and the two genuine misses. Every one had been hand-verified when written and
then not encoded. Eight more cover check_citations, where seven mutants survived:
nested paths, no line number, a FIRE naming no file at all (demanding one would push
the reviewer to invent a citation), CLEAR and N/A citing untouched files, and the
two-argument call with no diff to judge against.

The structural half holds the shape the entry file was losing: SKILL.md budgeted at
500 lines, no code fence over 30 lines, every rule id the deriver can emit has a body
in rules.md, every family expands to something, and fetch.sh's `required ... missing`
guards must each be followed by a non-zero exit -- mutation turned all six of those
into `exit 0`, so a missing scanner or schema would have let the run continue and
report nothing, and nothing failed. That last one is a lint over the script's text,
not an execution test; running fetch.sh needs a GitHub round trip.

Both structural limits were confirmed to bite by pushing the file past them. Without
the budget this comes back: nothing stopped the file growing the first time, so it
grew. Raising the number is now a commit that has to say why.

35 tests, 5.4s, stdlib only, no GPU and no network.

* review-pr: close the gaps found by reviewing ten real PRs

Reviewing a random ten of the 619 open aiter PRs, one at a time, the way the skill is
actually used. Two PRs carry defects that would land: #5220 inserts two ints into the
middle of a kargs struct whose layout is pinned by `static_assert(sizeof == 112)` plus
one `offsetof` per field, in the same translation unit it edits, so all three assertions
fail; #4146 imports `aiter.ops.triton.utils.core`, which #5061 renamed to
`utils.config_utils`, so it is a ModuleNotFoundError on merge. Seven open PRs still
import that module and 41 still import the deleted `aiter.ops.flydsl.utils`.

Five gaps in the skill, each found by using it rather than by reading it:

- **No rule covered struct layout at all.** D11 fires when a struct in C-like source
  gains or loses a field and the diff touches no `offsetof`/`static_assert(sizeof`
  line -- derivable purely from the diff, 3% of the corpus, 40 such assertions across 37
  files in csrc/. It does not fire when the PR updates the table in the same diff, which
  is the correct shape. The struct declaration usually lives in the hunk header's scope
  context rather than the hunk body, which is why detection reads `@@ ... @@ struct X`.

- **The sweep skipped relative imports entirely.** `from .chip_info import ...` inside
  aiter/jit/utils/asm_guard.py resolves to aiter.jit.utils.chip_info. Skipping them left
  the case where an unresolvable import is worst: a Tier-1 PR wiring a new module into
  aiter/__init__.py, where it breaks `import aiter` outright. #5107's chain is sound, but
  only because it was checked by hand. Corpus report rate 9% -> 13%, all of it the same
  deleted modules reached through a second syntax. The `mod.startswith(".")` skip is now
  dead and removed.

- **The sweep read non-Python files.** docs/tutorials/add_new_op.rst walks a reader
  through writing an op, imports and all, and two PRs were reported for a module named in
  a tutorial.

- **HK9 fired on benchmark scripts.** PROF_WARMUP/PROF_ITERS in
  op_tests/flydsl_tests/profile_flydsl_bwd.py are not permanent runtime knobs; HK9 exists
  because aiter reverted one that was. The family now reads runtime files only.

- **The evidence collector ignored the most common shape of the finding it serves.** The
  invariant-removed family fires on a deleted `.contiguous()`, but the collector only
  extracted symbols from assert/*_CHECK lines, so a removed contiguity normalisation
  produced no evidence and the reviewer was back to grepping -- which is what the
  collector exists to stop. #5235 relocates two of them; the answer is "it moved", and
  now the collector shows it.

Also generated: Step 3's type -> rule table moves to MAPPING.md, emitted by
`triage.py mapping`. The hand-written copy had drifted -- it claimed D9 was derived when
D9 is scanner-backed and deliberately is not, and omitted 21 rules that are, including
every Triton rule. A mapping the reviewer is told not to apply by hand should not be
maintained by hand.

Step 6's first structural check asked the model to list every new symbol and grep it;
`triage.py symbols` had already done that, so it now points at $WORK/symbols.txt and
scopes the manual work to what the static sweep cannot judge. The other five checks write
one line each into $WORK/ai_diagnostic.txt, and Step 8 runs answers, diagnostic and ledger
before a card may be written.

600 PRs: median 15/50 rules (30%), 600/600 covered, no family over half, symbols 13%.
99 structural tests, 89 validator tests. Mutation score on triage.py 93% of 137 code
mutants; the nine survivors are equivalent mutants, listed and not papered over with
tests that cannot kill them.

* review-pr: put the redundancy and test-quality evidence on screen

Asked why a ten-PR pass reported no redundant code, no AI slop and no weak op_tests,
the answer was that none of those has a detector. Step 6 asks for all three in prose --
"identify mirrored code ... compare it field by field", "is the reference impl
structurally a twin", "is atol/rtol loosened with no justification" -- and prose asking
for a search is the shape that does not happen, which is why D9's scan moved into Step 1
and why the rule pass grew a ledger.

Two collectors, both evidence rather than verdicts, because measuring first showed a
verdict would be wrong more often than right:

- `twins` names the file each new file was copied from, with the overlap ratio. 3% of the
  600-PR corpus adds a file at least 60% identical to one already in the tree:
  fused_gemm_a16w16_copy_x.py against _quant_x.py at 65%, test_opus_gmem_gfx1100.cu
  against _gfx1201.cu at 75%. The pair is not the finding -- an arch-specific variant is
  the normal shape -- the asymmetry between them is, and that needs a human diff.

- `testquality` prints, per added test file, the number of assertion primitives, the
  tolerances and the shapes. It does NOT conclude "this test asserts nothing", because
  that is not decidable from a diff: assertions routinely live in a shared helper
  (`run_fp8(..., verify=True)`), and the first two corpus cases inspected under a firing
  rule were both false. The strict form -- a whole new test file with no assertion
  primitive anywhere -- fires on 2 of 600, one of which is a benchmark. A zero count is
  printed with the reason it is not yet a finding.

Measured and rejected as rules, recorded here so they are not re-proposed: intra-diff
six-line duplication (30% of PRs, no discrimination), test bodies with no assert (over
half false), and a reference implementation calling the op under test (1 of 600).

112 structural tests, 89 validator tests.

* review-pr: HK12, a test file pytest collects nothing from

Batch two. aiter#4821 ships op_tests/flydsl_tests/test_dispatch_tdm.py and
compile_dispatch_tdm.py: both named like tests, both written as `main()` scripts with
`_check()` helpers, neither containing a single `def test_`. pytest imports them and
collects zero tests. HK6 asks a new op to ship `op_tests/test_*.py` and this satisfies it
by name while contributing nothing to CI.

The rule is deliberately narrow. aiter's tree already holds such files, so the style is
tolerated and the file is not itself a defect; HK12 fires only when the PR ships no
collectable test at all -- the case where HK6 reads as satisfied and the new code is in
fact untested. 3.8% of the 600-PR corpus, against 4.3% that add such a file at all.

The evidence collectors added for batch one earned their place immediately on batch two,
in both directions:

- test_quality flagged `atol, rtol = 0.125, 0.125` in aiter#3940, and the four lines above
  it in the diff derive that number from e4m3's three mantissa bits. Not a finding, and it
  took one look rather than a grep -- which is what putting the number on screen is for.

- test_quality reported `test functions added : 0` for #4821's two files, which is what
  led to HK12.

Median rules 15/51 (29%), HK12 3.8%, 117 structural tests.

* review-pr: check whether a new test will ever run, not whether it looks like one

Challenged on the HK12 finding from batch two -- "op test CI should pick all of those
up, did you judge it wrong" -- and the answer is yes, the mechanism was wrong and the
real one is worse.

.github/scripts/split_tests.sh shard-scans `op_tests` with `-maxdepth 1` and
`op_tests/triton_tests` recursively. Nothing else is scanned by anything:

  op_tests/*.py            127 files   aiter shard, runs by default
  op_tests/triton_tests/** 107         triton shard, runs by default
  op_tests/opus/             1         opus-test.yaml
  op_tests/multigpu_tests/  29         only with the `multigpu` label, skipped by default
  op_tests/flydsl_tests/     5         no workflow scans it at all

So aiter#4821's two files would not run even if every function in them were a
`def test_`. The absence of `def test_` was a real observation about the wrong thing.

`triage.py citest` answers the question that matters -- will a CI job run this file --
and answers it from .github/ rather than from a table here, because a copy of the shard
script would drift the way Step 3's rule table did. 9% of the 600-PR corpus adds a test
that never runs: 48 into unscanned directories, 6 label-gated.

One trap on the way: a path MENTIONED in a workflow is not a path that gets RUN.
pr-title-tags.yaml names op_tests/flydsl_tests/ to choose a label, and counting that as
coverage reported #4821 as covered -- the exact case the collector exists to catch. Only
lines that execute something count now, and a test pins that.

HK12 is now about location and is evidence-backed, listed in UNREACHABLE_BY_DESIGN
alongside D9 since the diff alone cannot answer it. The original observation survives as
HK12b at 📝, explicitly secondary: check where the file lives before asking what is in it,
because a file in an unscanned directory does not run whatever it contains.

The unreachable-rule invariant caught this during the edit -- HK12 documented with no
family emitting it -- which is what it was added for. Lettered HK ids (HK12b) needed the
id pattern widened; the expander was silently dropping them.

124 structural tests, 89 validator tests.

* review-pr: list the perf claims that name no baseline

P1 asks for a number with its units and its comparison, and P6 asks for base-vs-head.
Neither had anything reading the description, so a claim with no other side to it reached
the reviewer as prose.

`triage.py perfclaims` reads the PR body, lists every numeric claim, and marks the ones
that say nothing about what they are measured against. Four things it deliberately does
not flag, each found by running it rather than by reasoning about it:

- Markdown table rows whose header says `before | after | speedup`. aiter#4443 ships six
  such rows and judging each row alone called all six unbaselined.
- Signed deltas. `+8.64% end-to-end` compares against not having the change, which is a
  stated baseline in ordinary English; interrogating it is the pedantry that makes a check
  ignorable.
- Shares. `33.07% of GPU time`, `81.8% prefill by GPU time` say where the time goes.
- GPU counts. `8x MI355X` is eight cards. Substituting the model name away first left a
  bare `8x` reading as a speedup.

Scoped to the description on purpose: reading claims out of kernel comments over the
600-PR corpus was 61% noise -- `4x DS_READ`, `<4 x i32>`, `num_tokens x 384 x 7168`,
`5% of elements`. The claim lives in the description, which is where P1 and P3 ask for it.

Measured and rejected in the same pass, recorded so they are not re-proposed:

- Comment density. Median 7% of added code lines across 409 PRs, P90 21%. The five PRs
  over 35% were all read: aiter#4061 repeats one explanatory line across 140 generated CK
  files, #3557 is a section banner for the RDNA4 WMMA path, #2814 explains non-temporal
  loads. High density tracks codegen and documented kernels, not slop.
- "Comment restates the next line", 12% of PRs. Inspected: it is mostly matching two
  adjacent comment lines, and the one real comment-then-code case was a useful comment
  above an assert.

132 structural tests, 89 validator tests.

* review-pr: D11 asks the tree whether a layout is pinned, not the diff

Batch five caught the rule added in batch one being noisy. aiter#5223 changes six
headers and D11 fired, because the family was "a struct field moved and no assertion
line changed" -- which is true of any struct field churn anywhere. None of those headers
has an assertion within reach.

A layout change is a defect only when something asserts the layout, and that is a fact
about the tree. `triage.py structabi` extracts the struct names whose fields moved, then
looks for `offsetof(<name>` or `static_assert(sizeof(<name>))` in the repository, and
reports only the ones it finds. Corpus report rate 3% -> 0.3%: two PRs, both touching
`pa_sparse_prefill_kargs`, which is the struct that actually carries the table. The true
positive from batch one, aiter#5220, survives the tightening.

D11 joins D9 and HK12 in UNREACHABLE_BY_DESIGN, all three for the same reason: the diff
alone cannot answer the question, so a Step 1b collector answers it and the rule reads
the artifact.

Also from batch three: BASELINE was English-only, and aiter's descriptions are partly
Chinese. aiter#5043's table is headed `场景 | 输入数据 | 时间 | TFLOPS` and correctly
flagged -- it reports absolute times for a new ASM kernel whose own description says the
shape previously fell back to CK/Triton, with no measurement of what it replaces -- but a
table headed `优化前 | 优化后 | 提速` would have been flagged too. Both directions pinned.

136 structural tests, 89 validator tests.

* review-pr: reduce a comment-only diff to the lines that are not comments

Batch nine. aiter#4062, "docs(python): condense verbose comments", is 252 files and
7963 changed lines. A reviewer either skims it or spends hours on it, and both of those
miss whatever code is hiding in it. The answer turns out to be: nothing. It is worth
being able to say that in one line.

`triage.py commentonly` fires only when a diff is at least 90% comment churn and at
least 60 lines -- 2 of the 600-PR corpus -- and prints the changed lines that are not
prose. Three passes were needed before it told the truth about #4062:

- Trailing comments are stripped before comparing. `REVISION = 25  # rev24, drop the
  token-major path` becoming `REVISION = 25  # g layout fixed head-major` changes no
  code, and #4062 read as four code lines until that was handled.
- `/* ... */` continuation lines with no leading `*` are prose. aiter#4061's rewritten
  quant_utils.cuh header is exactly that, and every prose line in it was listed as
  something to review.
- Those lines are marked as prose rather than dropped, because the floor and the ratio
  are about the whole diff; dropping them made a 6000-line comment rewrite look like a
  two-line diff that fell under the floor.

Both PRs now reduce to zero code lines, which is the truthful answer.

Same batch, a smaller correction: `invariant-removed` matched `assert` / `.contiguous()`
in deleted COMMENT lines, so #4062 fired D4 on prose about asserts. Measured across the
corpus this is 3 of 71 fires, so it was noise rather than a hole -- fixed because it is
free, not because it was urgent.

144 structural tests, 89 validator tests.

* review-pr: a fourth gate that asks whether each finding is nailed down

answers, diagnostic and ledger all check that the work happened. None of them looks at
the card, which is the one artifact a reader actually gets -- so a review could
adjudicate 27 rules honestly and then write a finding that came from none of them. And
the red threshold, "before firing any red, write down the concrete input that triggers
it", was prose with nothing reading it.

`triage.py card` checks three things per finding and only three:

- UNTOUCHED-FINDING: it cites a file this PR does not change.
- UNBACKED-FINDING: it carries a rule id no verdict marked FIRE, or names files that
  appear in no verdict, diagnostic or blind-spot line.
- UNPROVEN-RED: a red naming neither a value nor two code identifiers.

Whether a finding is correct is not checked and cannot be; that is what a human reads
the card for.

The concreteness test needed a second pass. Requiring a digit rejected a real finding --
"row=(tail_blk*num_kv_heads+kv_head_idx)*BLOCK_M against nrows=tail*num_kv_heads*BLOCK_M"
is as concrete as a finding gets and contains none. Two distinct code identifiers is the
line between that and "the reduce kernel looks racy".

Adding the gate pushed SKILL.md to 512 lines and the budget test failed, which is what it
is for. The budget was not raised: Step 1b had grown a paragraph per artifact, nine of
them, each restating what the artifact prints about itself. They condense to a table --
file, what it answers, the trap it exists for -- and the entry file lands at 477, twenty
under where it started this session and thirty under the budget.

152 structural tests, 89 validator tests.

* review-pr: a relative import inside __init__.py resolves to that package

Batch eleven. aiter#4515 was reported twice for the same module under two names, one of
which does not exist anywhere: `aiter.ops.kernels.pa_mqa_logits_fp4`. The resolver
stripped `.__init__` from `aiter/ops/flydsl/__init__.py` to get the package name and then
dropped a component as well, which is right for `aiter/ops/flydsl/x.py` and wrong for the
package's own `__init__.py` -- the containing package IS aiter.ops.flydsl there.

Corpus report rate 13% -> 10%, 144 lines -> 104: fifteen PRs were being reported for
imports that resolve fine one level up.

The remaining finding on #4515 survives and is real: `pa_mqa_logits_fp4.py` was deleted by
#4609's raw-dialect cleanup and the kernels live under `mqa_logits/` now, so the PR
modifies a file that no longer exists on main -- a modify/delete conflict on merge, and
imports pointing at nothing. That is the fifteenth distinct module broken by a
reorganisation in the open queue.

Same batch, worth recording rather than fixing: aiter#4848 fixes MoE expert addressing
past 4 GB -- a 32-bit overflow class -- and ships
op_tests/flydsl_tests/test_flydsl_moe_4gib_addressing.py, which lands in the directory no
CI job scans. The test for a subtle addressing bug will never run. ci_coverage caught it,
which is what it was added for.

154 structural tests, 89 validator tests.

* review-pr: pull the subject out of a removed guard whatever shape it takes

Batch twelve. aiter#4255 deletes `assert gfx_version in ("gfx942", "gfx950", "gfx1250")`
and the invariant-removed family fired, correctly. The answer is one line away and was
not on screen: the assert is REPLACED, by `assert _is_gluon_pa_mqa_logits_supported(
gfx_version)`, which is a stronger guard than the allowlist it replaces. The evidence
collector said nothing, so clearing it meant grepping by hand -- which is the thing the
collector exists to stop.

It extracted symbols from exactly two shapes, `X is not None` and `X->`. Across the
corpus, 57 PRs delete a guard and 51 of them -- 89% -- produced no evidence at all:

  assert causal, "Only causal attention is supported"     -> causal
  assert WQ.dtype == dtypes.fp8, "only fp8"               -> WQ
  assert num_head_qo % 16 == 0                            -> num_head_qo
  assert gfx_version in ("gfx942", "gfx950")              -> gfx_version
  TORCH_CHECK(out.is_contiguous(), "out must be ...")     -> out

The subject of a guard is the first identifier after the keyword, skipping the words that
are never a subject (`not`, `is`, `None`, `len`, `isinstance`, dtype namespaces). 89% ->
4%, averaging 3.6 symbols per PR.

This is the third time the same shape of gap has appeared: a family fires on a pattern
wider than the collector serving it understands. First `.contiguous()` removals, then
comment lines, now every assert that is not `X is not None`. The family and its collector
are written in different places and drift apart; both are now covered by cases that name
the shapes explicitly.

Rest of batch twelve was quiet: no unresolved imports, no twins, no unrun tests, no
pinned-layout changes, no unbaselined claims.

156 structural tests, 89 validator tests.

* review-pr: the card gate now runs in both directions, and fails closed

Asked whether the "is this nailed down" step was actually nailed into the skill, the
answer was no. Probing my own gate found three ways past it:

- A missing $WORK/card.md read as an empty card, which read as no findings, which
  passed. Not writing the card was the cheapest way past the check. Now a hard failure.
- A card with no findings passed while the ledger held nine FIRE verdicts. I had checked
  that findings trace back to work and not that work reaches the card, which is the
  inverse and the one that matters more: a review can adjudicate nine rules FIRE, report
  none of them, and look clean.
- A card carrying only a heading passed the same way.

FIRE now means it goes in the card. The 5-finding cap is a real reason to leave one out,
so the escape is `-- not reported: <reason>` appended to the verdict line -- written down
rather than silent. Verified against the real aiter#5157 ledger: nine FIRE, five on the
card, two withdrawn in writing, and the gate holds out for the remaining two until they
are accounted for.

One test had to change rather than the product: a note citing aiter/mla.py with nothing
in any verdict, diagnostic or blind-spot line mentioning it is a finding from nowhere,
and Step 7.5 is where free-form observations get written down. Both directions are now
covered -- a note grounded in the blind-spot answer passes, one from nowhere does not.

161 structural tests, 89 validator tests.

* review-pr: a benchmark with no assertions is a benchmark

Batch thirteen. One evidence line across ten PRs, and it was noise: aiter#4016 ships
op_tests/triton_tests/bench_gdn_chunk_prepare.py beside a real test, and test_quality
told the reviewer its zero assertions "may be in a helper, or there may be none". A
benchmark measures; it asserts nothing by design. 68 of 682 rows over the corpus are
that shape.

bench_*/profile_* files and anything under op_benchmarks/ are now labelled, and their
zero count reads "expected for a benchmark". The same count on a real test still asks
about the helper, because there it is a real question.

Batch thirteen otherwise clean: no unresolved imports, no twins, no unrun tests, no
pinned-layout changes, no unbaselined claims, no comment-dominated diffs.

While adding the tests, a behaviour worth pinning turned up: a test file with no tests,
no assertions, no tolerances and no shapes is not listed at all. There is nothing to put
in front of the reviewer, and that is right, but nothing said so.

165 structural tests, 89 validator tests.

* review-pr: T8, a launch knob hardcoded past the config system

aiter#5137 was reverted on one review comment: "Please change the config file jsons
instead of hardcoding it in the code waves_per_eu=2". T4 already covers a knob forced
across archs; this is the single-arch case and a different failure. The config system
exists so a tuning sweep and the code disagree loudly, and a literal in kernel source is
invisible to the sweep -- the next sweep either overwrites it or fights it, and neither
shows up in a diff. #5137 carried a six-line justification for the value; the
justification was not the problem, the location was.

Fires on waves_per_eu / matrix_instr_nonkdim / kpack / num_stages / num_warps / num_ctas
set to a literal in a .py outside configs/ and op_tests/. 11% of the 600-PR corpus.
Exempt: a knob read from a config (`num_warps=config["num_warps"]`, `**cfg`), a literal
in a config file, a test pinning a knob deliberately, and a commented-out line.

Recorded with it: the pipeline is lenient. Measured across all 600 PRs, 77% produce no
evidence line at all from symbols, twins, citest, structabi, commentonly or the
test-quality flags. Some of that is correct -- most PRs are config bumps and tuning rows --
but 77% is not a number to be comfortable with, and the next passes should be spent
raising recall rather than trimming noise.

171 structural tests, 89 validator tests.

* review-pr: run the fail-closed guards instead of reading them

* review-pr: Step 4 writes down which backbone files it cleared, and why

* review-pr: stop tracking __pycache__

* review-pr: ask about a parameter that left, and a kernel that shipped untested

Two of eleven candidates measured against the 600-PR corpus survived being read.

api-signature required a `def`/`void`/`template` line on BOTH sides of the diff -- a
signature rewritten in place. Deleting one line of a multi-line signature never touches
the `def` line, so B6/E1/E5 were never asked about it. Reported as 9.3% of the corpus;
9.3% is what the shape scores before it is read. A hunk header names the ENCLOSING def,
so `transpose_out=True,` passed to a call inside `def asm_moe(` counted as a dropped
parameter of asm_moe, and the same line pattern over C++ reads
`std::optional<Tensor>& fp8_out,` as a parameter named `std`. Walking the old side back
to an unbalanced `(`, and staying out of C++, leaves 3.5% (21/600) at roughly 8 in 10 on
a sample of ten. It moves the family from 17.5% to 20.3% of the corpus, and four PRs in
the pinned 59 now derive it -- 1831, 2577, 2592, 4997, each a real kernel parameter.
That is the whole blessed diff; symbols and MAPPING are untouched.

HK6 already fired on new-kernel but was prose, so the reader established the absence of
a test by hand. kernel_tests.txt does it: 6.5% (39/600) add a kernel with no test pytest
would collect. Collectibility is decided by filename, which is the rule pytest uses -- an
op_tests/-only whitelist called aiter#3991 untested while it added five test files under
aiter/aot/flydsl/tests/, and excluding any path containing "bench" called aiter#2889
untested on the strength of test_rmsnorm_bench_against_aiter.py, which holds two
collectible tests. An evidence line that states a falsehood is worse than one that says
nothing, so the corpus is checked for that specific lie and reports none.

Rejected, with the numbers, so it is not proposed again: added `except` blocks whose body
is only pass/continue/return. 10.7% of the corpus, and reported at 4/4 true. 38 of the 64
PRs match nothing but a capability probe -- `except ImportError: return False` is correct
code -- and six sampled from the narrowed pass/continue set were all deliberate: a barrier
timeout whose comment explains that hanging is the alternative, `int(os.environ["MAX_JOBS"])`
falling through to a default, a ROCm-discovery fallback chain, a best-effort rmtree, a
tuning loop skipping unsupported configs. That is the shape of the weak no-assertion check
this project already rejected: high rate, plausible story, false on reading.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* review-pr: why A1 still has no evidence behind it

A1 asks whether a sibling kernel has the same bug and has never had a forensic answer, so
the candidate for one was measured: deleted lines still present verbatim in a file this PR
does not touch, three or more times. 13.2% of 600 open PRs, 10.0% once the line is required
to carry an operation instead of being a declaration, a bare `for`, or a docstring.

Eight read: about half are what A1 means -- variant MoE ops sharing
`A_scale.stride(0) if A_scale is not None and A_scale.ndim == 2 else 0,` across
moe_op_silu_fused.py and moe_op_gelu.py, where fixing one and not the other is the defect.
The rest are boilerplate two files share for no reason: `for(int i = 0; i < 4; i++)`, an
OptionalHIPGuardMasqueradingAsCUDA line, `HEAD_DIMENSION_OPTIONS = [128]`.

Narrowing does not fix it. It silenced two of the four known-noise hits, left the stream
guard and the config constant firing, and cost one of the three real ones. That is the
shape of the problem rather than a tuning depth: a sibling that needs the same fix and a
sibling that shares boilerplate emit the same evidence, because it is the same line.
Verbatim identity is the wrong signal.

A1's own example -- PR#3841, a decode kernel fixed while `_prefill_opt` beside it was not
-- is same-FILE. Sibling FUNCTIONS within the changed file is the direction that has not
been tried, and it needs its own numbers before it goes in. Recorded in the rule body so
the next pass starts there instead of re-measuring this.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* review-pr: hand A1 the variant it is asking about

A1 asks whether the sibling kernel carries the same bug and has never had a forensic
answer. Its own example is aiter#3841 -- a decode kernel fixed while `_prefill_opt` beside
it was not -- which is two functions in ONE file, and twins compares whole files. So the
last attempt looked across files for a deleted line still present verbatim somewhere
untouched: 13.2%, half of eight read were boilerplate two files share for no reason, and
narrowing cost a real hit for every two noise hits removed. That is recorded in the rule
body; this is the version scoped the way A1 means.

Same file, and the two function names must share an eight-character stem.
`_moe_gemm_a8w4_decode` against `_moe_gemm_a8w4_prefill`; `_stage1_ragged_k` against
`_ragged_k`, still carrying `mask = context_idx + tl.arange(0, ChunkK) <= context_length`,
which is the bounds check A1 names; `mla_decode_fwd` against `mla_v40_decode_fwd` over
`and q.dtype == dtypes.fp8`. 18.0% of 600 open PRs. Without the stem, any two functions
sharing a file qualify and it is 23.3%, mostly helpers that merely sit together.

The stem is deliberately not a list of variant suffixes. Adding one -- _opt, _v2, _prefill,
_decode, _fwd -- gives a tidier 10.8%, and 43 of the 43 it drops include
kernel_unified_attention_2d against _3d three times over and select_2d_config against
select_3d_config. Those are the shape the rule exists for. D9's body already records this
lesson from the other end: it was a name list, it missed three real defects, and it is now
an AST pass with no names in it. Do not add the suffix list back.

Python only. Every hit was Python, and splitting C bodies by brace depth is a heuristic
that earned nothing -- it produced a span bug that matched a function's own `def` line
inside another function.

Evidence, not a finding: a variant legitimately diverges. What is handed over is the pair,
so that the judgement gets made instead of skipped. Checked on ten PRs outside the corpus
(batch 23): it fires on aiter#2478, "Fix GPU memory access fault in CK MoE FP4 kernel",
pointing at `_flydsl_moe_sorting` still holding the allocation-size line that
`_moe_sorting_impl` just had fixed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* review-pr: run D11's worked example instead of believing it

A sweep reported that D11's example was fiction: aiter#5220 adds two ints to
`pa_sparse_prefill_kargs`, the rule body says three assertions in the same translation
unit fail, and grepping the tree for `offsetof(` near that struct finds nothing. The
header does hold twelve static_asserts and every one of them is tile or vector
arithmetic, which made the conclusion look doubly confirmed. I rewrote the docstring and
the rule body around it -- #5220 recast as the case D11 correctly stays silent on.

Both greps read /mnt/raid0/zufa/aiter, a second checkout sitting on af81aa0bc from
2026-07-13. On the branch under review, `pa_sparse_prefill_opus_kernels.cu` asserts
`sizeof(pa_sparse_prefill_kargs) == 112` and fixes every field offset through the
PA_GFX1250_CO_ABI macro -- which is the second disguise, because a literal `offsetof(`
does not appear either. Given the right root, `triage.py structabi` on #5220 prints
PINNED-LAYOUT. The rule was right and the measurement was stale, so the rewrite is
reverted and only the test survives.

The test is the point: the example is now executed, not asserted in prose. One case pins
that the struct really is pinned in this tree, one runs #5220's shape through the detector
and requires PINNED-LAYOUT, one requires silence when the same diff updates the assertion.
If the tree moves, the failure says so and names which passage to rewrite. The tree is
found from the skill's own location, so there is no second checkout to pick wrong.

Also corrects sibling_variants: 18.0% was measured against that same stale tree, and the
merge target gives 18.3%. The conclusion does not move. Nothing else needs re-measuring --
dropped_parameter and untested_new_kernel read the diff and never the tree, and fetch.sh
takes PROJECT_ROOT from `git rev-parse --show-toplevel`, so every artifact under /tmp/rev
was always computed against the right root. Only the hand-run measurements were wrong.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* review-pr: say which tree a forensic just read

symbols, twins, citest, structabi and siblings all answer questions about the merge
target -- is this struct pinned, does a CI job scan this path, does a variant still carry
this line. Pointed at a second checkout they answer about that one instead, in the same
shape, with nothing to show the reader which repository was consulted.

That cost a rule last week. A sweep read /mnt/raid0/zufa/aiter, 53 days behind, found
nothing pinning `pa_sparse_prefill_kargs`, and reported D11's worked example as fiction.
The follow-up confirmed it against the same checkout -- twice over, since the offsets are
pinned through a macro and a literal `offsetof(` is absent from both trees -- and the rule
body was rewritten around the mistake before a test caught it.

So the modes print, on stderr, when the root they were handed is not the tree this file
ships from, with both HEADs and their dates beside each other. Silent in normal use:
fetch.sh derives PROJECT_ROOT from `git rev-parse --show-toplevel`, so it always passes
the tree the skill lives in. It is the measurement run by hand that picks the wrong one.

stderr specifically, and there is a test for that: fetch.sh tees these modes into
$WORK/*.txt, and a warning on stdout would be filed as evidence. Another walks the CLI
block and fails if a root-taking mode reads argv without the guard, because the one that
skips it is the one that goes wrong quietly.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* review-pr: refuse to review a diff that was never fetched

`gh pr diff > $WORK/pr.diff` was unchecked. When it fails the file is empty and the run
carries on: the deriver answers `underivable` and emits all 52 rules, which is the
intended fail-open and does not come back looking clean -- it comes back as 52 rules that
cannot be answered against a diff that is not there, while the reason sits on a stderr
line a batch run discards.

The reason also names the wrong cause. GitHub refuses a diff over 20000 lines with
`HTTP 406: could not find pull request diff`, which reads as a bad PR number. aiter#4961
is one of the 240 open PRs scanned so far and is exactly this: a live cross-repo PR, 27k
lines, reported as not found.

An eighth guard, in the shape of the other seven. Over the cap it says so, says it is not
a missing PR, and says to review from a local checkout of the head ref instead. Any other
failure quotes gh's own stderr line by line rather than replacing it with a summary.

0.4% of PRs scanned, which is below the rate at which detection candidates have been
turned down here -- and the rate is the wrong test for it. A detector at 0.4% finds
almost nothing; this is not finding anything, it is refusing to proceed on nothing, and
it has no false-positive side. Verified on aiter#4961, which now exits 1 with the cap
named, and on aiter#5120, which still fetches and derives 15 rules. Dropping the
emptiness check turns one of the four new tests red.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* review-pr: make T5 and T6 fire on the shape, not on the language

Both are red rules and both were triggered by tokens that say "this is Triton code".

`tl.cdiv(` was one of T6's triggers. It is ceiling division: of the seven firings it
produced on its own across the corpus's 232 Triton PRs, all seven were a tile count, a
block-pointer `shape=`, a mask bound or a loop bound. None computed a grid. T6 asks whether
the host grid disagrees with the kernel's program_id axes, and a diff that merely divides
something upward is not being asked anything. 27% of Triton PRs to 24%.

A bare `.to(tl.float32)` was one of T5's. It produced 20 of that family's 54 firings and
every one sampled was an upcast on a load, a store, or a quantisation max --
`m = tl.max(tl.abs(x)).to(tl.float32)` -- which is the correct direction, the opposite of
the accumulator left in fp16 that T5 is about. 23% to 19%.

Naming the accumulator instead is not only subtraction. `acc +=` and `acc = tl.zeros` bring
in aiter#3613, `acc_sq += gl.sum(out_h * out_h, axis=1)` in a Gluon kernel with no `tl.dot`
anywhere in the diff -- T5's first failure shape exactly, and invisible to the old trigger.
The blessed corpus moves on two PRs: 3613 gains the family, 4268 loses it.

Not landed, with the numbers, so the next pass does not repeat it: a forensic for T6 that
reads both halves out of the tree and compares grid arity against the highest program_id
axis. Four versions, mismatch rates of 50%, 40%, 34%, each drop a parsing bug of mine
rather than a real narrowing. What ended it was that the same kernel and grid recurred
across seven unrelated PRs -- so the "mismatch" was a property of the tree, and a real one
would be a live bug on main that everyone hits. The cause is that resolving `kernel[grid](`
means finding which `grid` binding is live at that call site, and a line-based search finds
the first one in the file. That needs a scope-aware pass, which is what D9's scanner had to
become for the same reason. The trigger-precision finding above does not depend on any of
it: only 46% of T6's firings carry both halves in the diff at all, and only 50% of T5's
carry a dot.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* review-pr: say what became of each guard the diff deletes

D4 is red, `invariant-removed` fires on 69 of 600 open PRs, and the only forensic behind
it collects symbols from deleted guards and greps for them. Its own docstring says the
usual answer is "it moved" -- which the reviewer then has to establish by hand, on every
one of the 69.

This started as a filter and the numbers supported one: 14.5% of those PRs add every
deleted guard straight back verbatim, and another quarter return them in a form that
shares the subject, so about 40% looked like it could be dropped before the reviewer ever
saw it.

Reading seven of that second group is what changed the design. aiter#4295 replaces
`AITER_CHECK(valid_split_count != nullptr && ...->data_ptr() != nullptr)` with a size
check, and the null guard is simply gone. aiter#4279 turns
`TORCH_CHECK(hidden_size >= (tile_k * split_k) * 2)` into the same check without the `* 2`.
aiter#5168 widens `assert d_qk_v == (...)` to a set membership. Three of seven were real
weakenings. "The check came back" and "the check was weakened" produce identical evidence
under any same-subject test, and the second is the finding, so filtering on it would have
deleted D4's best cases as noise.

So it prints the pair instead. Each deleted guard is sorted into moved unchanged, returned
changed, or gone, and the changed ones come out as before/after lines. Across the corpus:
14.5% are entirely moves and have nothing to review, 58% drop at least one guard outright,
46% return at least one changed. Two of the tests are aiter#4295's and aiter#4279's real
lines, so the case for printing rather than filtering is pinned where the next person
tempted to filter will run into it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* review-pr: run the symbol sweep's worked example too

sweep_symbols explains itself with aiter#4994: it added
`from aiter.ops.flydsl.utils import is_flydsl_available`, #5116 had deleted that module
from main 19 hours earlier, and #4994 merged green and was reverted 5.5 hours later.
Whether the check fires at all depends on which tree it resolves against, which is
precisely what prose cannot hold onto -- D11's example was prose in the same way, and
reading it against a checkout two months stale produced a confident wrong conclusion that
the rule was fiction. Four cases now: the named module is still absent from this tree, a
module that exists is not reported, a module the diff itself adds is not reported, and a
third-party import is left alone. The second is the control; without it the first passes
against a sweep that flags everything.

No gap this round. Replaying the sweep over the corpus reproduces the population it was
built for: 61 of 600 open PRs import something unresolvable, 57 at module level across 26
modules, `aiter.ops.flydsl.utils` in 32 of them and `aiter.ops.triton.utils.core` in 7.
Recall against that set is complete.

Measured and turned down: the reverse direction, a PR deleting a module the tree still
imports. 3 of 600 raw, and all three are the same false positive -- the PR deletes the
importing line as well, which aiter#5145 shows on its face with
`-from aiter.ops.flydsl.kernels.hgemm_dispatch import compile_flydsl_hgemm_kernel`. 0 of
600 real. The cross-PR case that actually bites -- one PR deleting a module 32 open PRs
import -- needs the open-PR set, which fetch.sh does not have and would cost 600 diffs to
get; the symptom side is already covered on each of those 32 when they are reviewed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* review-pr: FlyDSL is a kernel backend, so derive the kernel rules for it

KERNEL_PY lists `aiter/ops/triton/`, `_triton_kernels/`, `_gluon_kernels/` and `/gluon/`.
A FlyDSL kernel matches none of them, so it reached `flydsl` -- D10 and D10b, which are
about what happens to a compile result -- and nothing else. 108 of 600 open PRs edit
`aiter/ops/flydsl/kernels/*.py`; 95 of them derive neither kernel family. A1's sibling
variant, D1's uninitialised accumulator, D8's missing contiguous check and P6's unmeasured
cost were never put to an entire backend.

The siblings forensic had been pairing `_flydsl_stage1_wrapper` against
`_flydsl_stage2_wrapper` in exactly these files for three commits. The evidence was being
produced and no rule was asking for it.

A separate family rather than another entry in KERNEL_PY, because FlyDSL is not Triton and
`modified-kernel` would say it is. B2 is deliberately not in the set: it is `tl.load` or
`tl.store` without a mask, and there is no tl here. Median rules per PR stays 15 and the
mean moves 14.7 to 15.1 -- these PRs already carried most of what this adds. Eight of the
pinned 59 gain the family and none loses anything.

Found while auditing something else, which is worth recording: `perf` fires on a title
keyword, and `fuse` accounts for 43 of its 90 firings on its own. Every one of twelve read
was a kernel NAME -- "Expose the fused_moe activation dtype resolution", "Add `repr` to DiT
fused kernels" -- not a claim about speed. Dropping `fuse` and `%` takes the family from
15% to 7.5%, and the reason that is not in this commit is that it interacts with this one:
some of what it drops was reaching P6 only through `perf`, and now reaches it through
`flydsl-kernel` instead. It needs re-measuring against this baseline, not the old one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* validate-kernel-pr: say when another validator holds the GPU

Two of these suites at once make a third of the run look broken. The validator claims a
GPU with `flock -n` on /tmp/gpu-N.lock; a second one finds every candidate locked,
degrades to NO_GPU, skips the runtime stages and returns INCONCLUSIVE. That is correct,
and the report says so -- "GPU claim raced with another process". What the reader sees is
`'PASS' != 'INCONCLUSIVE'` on five or six tests, which names the symptom and hides the
cause one file away.

Run alone: 89 passed, six separate times. Two runs overlapping: 5 failures and 6. Both of
the overlaps were mine -- a run started with a bare `&`, then a second launched before it
finished, twice. I spent several sessions reporting this suite as flaky and proposing to
isolate the timing-sensitive tests, which would have deleted a true signal from a suite
that was working. The reason never reached me because I had been piping the output through
`tail -3`, so the one line that explained it was cut off every time.

The guard asks the lock rather than the process list: it tries to flock each
/tmp/gpu-*.lock and reports the ones it cannot take. Written first as
`pgrep -af validate_pr.sh`, which matched the shell running the pgrep -- the string is in
its own argv. Verified by holding a lock and watching it fail with the right message.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* review-pr: fix what four end-to-end runs found

Everything until now was measured against the 600-PR corpus, which exercises the deriver
and the forensics and never writes a card. Four full Step 1-8 reviews -- aiter#4295 and
#2478 for signal, #3836 and #5072 as controls -- found six defects in one pass. Both
controls returned NO FINDINGS, so the gates are not manufacturing work; what they were
doing was corrupting the reviews that had something to say.

The citation gates punished the forensics the rules ask for. card and ledger rejected any
finding naming a file the diff does not change, and three of the four runs hit it
independently. aiter#2478's two strongest findings rest on the mask contract in
csrc/include/moe_sorting_opus.h -- an unchanged header, and the only place the convention
and the local-id derivation are written down -- so the review deleted the filename and
described the header in prose to get through. E4's own rule body sends the reader to
.github/workflows/*.yaml to check a label, and doing so tripped the same gate. Both now
require an anchor: at least one cited file the PR changes, with everything else free. A
finding citing nothing from the diff is still rejected, which is what these were for.

The card gate demanded rule codes that SKILL.md forbids. It matched a finding to its FIRE
by a leading `D8:`, and SKILL.md line 466 says "Do NOT use rule codes (P1, D4, A1...) in
output -- they are internal labels only". Every card written to spec reported every fired
rule as UNREPORTED-FIRE. A finding naming a file the verdict cited is the same claim
without the label.

`torch.cuda.device(...)` parsed as a file called torch.cu, and `x.contiguous.cuda()` as
x.contiguous.cu. Those are the two most ordinary expressions in a HIP review.

SKILL.md told the reviewer that a runtime change with no test target is a finding in its
own right. Triage calls anything under aiter/ a runtime surface, so both control PRs --
a tuner input CSV and a tuned-config table, neither loaded at run time -- arrived carrying
a defect the reviewer was instructed to report. That is a fabrication inducer on the
family of PRs where the deriver has least to say.

Two artifacts could not say they had run. An empty symbols.txt means "this axis was not
checked" per SKILL.md, and a clean sweep wrote zero bytes; ci_coverage said "every new
test file lands where a CI job will run it" on a PR that adds no test file, which reads as
a pass. And the artifacts line promised evidence.txt unconditionally though it is written
only for guard or signature diffs, while never learning about guards.txt, siblings.txt or
kernel_tests.txt -- three files I added, three commits apart, without touching that line.

Also drops two .pyc files that had been force-added into validate-kernel-pr. They are
build output and would land in any upstream PR.

Not fixed, recorded for the next pass: twins compares within a language, so aiter#4295 --
a .cu to .py port, which is twin divergence by definition -- got "no new file closely
mirrors an existing one" while the review found three divergences by hand; perf_claims
par…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants