Skip to content

Integration of the small-M decode GEMM kernels as the policy - #9075

Draft
vedenev-amd wants to merge 2 commits into
mainfrom
GEMM_small_M_hgemm_policy_SILOTIGER-669
Draft

vedenev-amd wants to merge 2 commits into
mainfrom
GEMM_small_M_hgemm_policy_SILOTIGER-669

Conversation

@vedenev-amd

Copy link
Copy Markdown
Contributor

…of the FlyDSL hgemm dispatch, because the review of #4114 asked for one dispatch path and one tuning space instead of a separate decode pipeline.

Summary

Motivation

Changes

Performance (if applicable)

Hardware Workload/configuration Before After Change

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

PR Self-Review

Reviewed revision

Behavior and intent

Validation and unverified scope

PR-specific question

Changed op tests

…of the FlyDSL hgemm dispatch, because the review of #4114 asked for one dispatch path and one tuning space instead of a separate decode pipeline.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vedenev-amd
vedenev-amd marked this pull request as draft December 2, 2026 11:58
@vedenev-amd vedenev-amd self-assigned this Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
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 (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu 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: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
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 9075 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@aiter-bot

Copy link
Copy Markdown

DRAFT — evaluation paused

PR Self-Review

Revision 88d02e24f5ce · mode shadow

This pull request is a draft, so readiness evaluation is paused and no verdict applies. Evaluation resumes when it is marked ready for review and the required CI completes.

@vedenev-amd vedenev-amd changed the title Start the integration of the small-M decode GEMM kernels as a policy … Integration of the small-M decode GEMM kernels as the policy Dec 2, 2026
…m, so they share the one FlyDSL dispatch path and tuning space instead of a separate decode pipeline, as the review of #4114 asked.

The hgemm kernel name keeps its fields and gains five optional ones that only these policies use: _eu (waves per EU), _rbp (ds_bpermute lane reduction), _ct (scalar or packed FP32 contraction), _lds (A staged in LDS) and _pn (persistent over N). A tuned small-M row applies only at its exact M. Outputs are bitwise equal to the #4114 kernels on all 72 gfx950 rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment on lines +5 to +39
import functools
from dataclasses import dataclass

import flydsl.compiler as flyc
import flydsl.expr as fx
from flydsl.expr import const_expr, gpu, range_constexpr
from flydsl.expr.typing import Int32

from .gemm_a16w16_small_m_common import (
MFMA_K,
WAVE_SIZE,
ActivationSource,
BlockMfmaDecodeConfig,
bf16x4_slice,
block_mfma_persistent_grid,
block_mfma_staged_k,
convert_bf16,
gemm_decode_kernel_name,
k_element,
load_scalar,
load_vector,
make_buffer_matrix,
make_buffer_vector,
make_vector_view,
masked_bf16_vector,
mfma_4x4x4_bf16,
padded_row_coordinates,
reduce_mfma_scalar,
wave_lane_coordinates,
)
from .tensor_shim import _run_compiled
from .gemm_a16w16_small_m_common import unused_tensor_arg


def _ceil_div(value: int, divisor: int) -> int:

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.

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

Suggested change
import functools
from dataclasses import dataclass
import flydsl.compiler as flyc
import flydsl.expr as fx
from flydsl.expr import const_expr, gpu, range_constexpr
from flydsl.expr.typing import Int32
from .gemm_a16w16_small_m_common import (
MFMA_K,
WAVE_SIZE,
ActivationSource,
BlockMfmaDecodeConfig,
bf16x4_slice,
block_mfma_persistent_grid,
block_mfma_staged_k,
convert_bf16,
gemm_decode_kernel_name,
k_element,
load_scalar,
load_vector,
make_buffer_matrix,
make_buffer_vector,
make_vector_view,
masked_bf16_vector,
mfma_4x4x4_bf16,
padded_row_coordinates,
reduce_mfma_scalar,
wave_lane_coordinates,
)
from .tensor_shim import _run_compiled
from .gemm_a16w16_small_m_common import unused_tensor_arg
def _ceil_div(value: int, divisor: int) -> int:
import functools
from dataclasses import dataclass
import flydsl.compiler as flyc
import flydsl.expr as fx
from flydsl.expr import const_expr, gpu, range_constexpr
from flydsl.expr.typing import Int32
from .gemm_a16w16_small_m_common import (
MFMA_K,
WAVE_SIZE,
ActivationSource,
BlockMfmaDecodeConfig,
bf16x4_slice,
block_mfma_persistent_grid,
block_mfma_staged_k,
convert_bf16,
gemm_decode_kernel_name,
k_element,
load_scalar,
load_vector,
make_buffer_matrix,
make_buffer_vector,
make_vector_view,
masked_bf16_vector,
mfma_4x4x4_bf16,
padded_row_coordinates,
reduce_mfma_scalar,
unused_tensor_arg,
wave_lane_coordinates,
)
from .tensor_shim import _run_compiled
def _ceil_div(value: int, divisor: int) -> int:

Comment on lines +5 to +34
from __future__ import annotations

import functools

import flydsl.compiler as flyc
import flydsl.expr as fx
from flydsl.expr import const_expr, gpu, range_constexpr

from .gemm_a16w16_small_m_common import (
ReductionMode,
WaveDecodeConfig,
contract_pair,
gemm_decode_kernel_name,
k_element,
load_vector,
make_buffer_matrix,
make_buffer_vector,
masked_bf16_vector,
pack_bf16x2,
prepare_pair,
reduce_wave_accumulator,
store_bf16,
wave_lane_coordinates,
zero_wave_accumulator,
)
from .tensor_shim import _run_compiled
from .gemm_a16w16_small_m_common import unused_tensor_arg


def _accumulate_vectors(

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.

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

Suggested change
from __future__ import annotations
import functools
import flydsl.compiler as flyc
import flydsl.expr as fx
from flydsl.expr import const_expr, gpu, range_constexpr
from .gemm_a16w16_small_m_common import (
ReductionMode,
WaveDecodeConfig,
contract_pair,
gemm_decode_kernel_name,
k_element,
load_vector,
make_buffer_matrix,
make_buffer_vector,
masked_bf16_vector,
pack_bf16x2,
prepare_pair,
reduce_wave_accumulator,
store_bf16,
wave_lane_coordinates,
zero_wave_accumulator,
)
from .tensor_shim import _run_compiled
from .gemm_a16w16_small_m_common import unused_tensor_arg
def _accumulate_vectors(
from __future__ import annotations
import functools
import flydsl.compiler as flyc
import flydsl.expr as fx
from flydsl.expr import const_expr, gpu, range_constexpr
from .gemm_a16w16_small_m_common import (
ReductionMode,
WaveDecodeConfig,
contract_pair,
gemm_decode_kernel_name,
k_element,
load_vector,
make_buffer_matrix,
make_buffer_vector,
masked_bf16_vector,
pack_bf16x2,
prepare_pair,
reduce_wave_accumulator,
store_bf16,
unused_tensor_arg,
wave_lane_coordinates,
zero_wave_accumulator,
)
from .tensor_shim import _run_compiled
def _accumulate_vectors(

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.

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

import itertools
from dataclasses import dataclass
import torch
from aiter.jit.utils.chip_info import get_gfx_runtime, get_lds_capacity_bytes
from .gemm_a16w16_band import band_stream_config
from .gemm_a16w16_cat_x_ring import ring_splitk_config, ring_splitk_tilings
from .gemm_a16w16_ring import ring_config, ring_supported, ring_tilings
from .kernels.gemm_a16w16_gfx950 import (
GEMM_A16W16_DTYPE_BF16,
GEMM_A16W16_DTYPE_FP16,
GEMM_A16W16_DTYPE_FP32,
make_gemm_a16w16_param_and_validate,
)
from .kernels.gemm_a16w16_kernel_gfx1250 import LDS_PAD_A, LDS_PAD_B
from .kernels.gemm_a16w16_skinny_gfx950 import skinny_config_error
from .gemm_a16w16_small_m import get_small_m_configs

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.

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

from __future__ import annotations
import functools
import re
import torch
from torch import Tensor
from aiter import logger
from aiter.jit.utils.chip_info import get_gfx_runtime
from aiter.utility.graph_alloc import capture_scoped_cache, persistent_alloc
from .aot_launch import aot_factory
from .gemm_a16w16_band import band_stream_name_supported, gemm_a16w16_band
from .gemm_a16w16_cat_x_ring import (
gemm_a16w16_ring_splitk,
ring_splitk_name_tiling,
)
from .gemm_a16w16_gfx1250 import gemm_a16w16 as gemm_a16w16_gfx1250
from .gemm_a16w16_ring import gemm_a16w16_ring, ring_name_tiling
from .kernels.gemm_a16w16_gfx950 import (
SPLIT_K_SEMAPHORE_MAX_LEN,
gemm_a16w16,
)
from .kernels.gemm_a16w16_skinny_gfx950 import gemm_a16w16_skinny
from .gemm_a16w16_small_m import (
SMALL_M_ARCHS,
SMALL_M_POLICIES,
gemm_a16w16_small_m,
)
from .kernels.gemm_a16w16_small_m_common import small_m_config_from_hgemm
from .kernels.tensor_shim import _run_compiled, current_stream_arg

This branch has not been deployed

No deployments
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.

2 participants