Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
192c88d
opus_gemm gfx950: a16w16 4-wave pinned pipeline for NT/NN/TT/TN
Fyzyukk Nov 13, 2026
33f2601
opus_gemm a16w16 4wave: bf16 output only
Fyzyukk Nov 13, 2026
1190549
opus_gemm a16w16 4wave: pin only large tiles
Fyzyukk Nov 13, 2026
61d5a96
opus_gemm a16w16 4wave: move the kernel body into a __device__ function
Fyzyukk Nov 13, 2026
d6fc69a
opus_gemm gfx950: register a16w16 4-wave kids 1000-1015, build their …
Fyzyukk Nov 13, 2026
fd2abad
opus_gemm gfx950: host launchers, loader and python routing for the 4…
Fyzyukk Nov 13, 2026
3e8b8fa
opus_gemm gfx950 splitk_reduce: keep the last bias column for odd N
Fyzyukk Nov 13, 2026
de07716
opus_gemm gfx950 4wave: merge the kids in the gfx950 registry literal…
Fyzyukk Nov 13, 2026
6a17b37
opus docs: mention the gfx950 a16w16 4-wave kids and their loader
Fyzyukk Nov 13, 2026
bf08b64
opus_gemm a16w16 4wave: any N for the direct kids
Fyzyukk Nov 13, 2026
00d6088
opus_gemm a16w16 4wave: no bias on the direct kids
Fyzyukk Nov 13, 2026
fbd795b
opus docs: restore the upstream READMEs
Fyzyukk Nov 13, 2026
e452446
op_tests: drop the 4wave test from the branch
Fyzyukk Nov 13, 2026
fd2b8d5
splitk_reduce: revert the odd-N bias fix (to be submitted separately)
Fyzyukk Nov 13, 2026
06f8746
opus_gemm gfx950 4wave: put bf16 in the kernel names
Fyzyukk Nov 13, 2026
b11822a
opus_gemm gen_co: rename the gfx950 kid table to co_kernels_gfx950_bf…
Fyzyukk Nov 13, 2026
6547959
opus a16w16: NT/NN/TT/TN direction APIs
Fyzyukk Nov 13, 2026
1a6e1a0
opus_gemm gfx950 4wave: drop bf16 from the kernel names again
Fyzyukk Nov 13, 2026
566a7a6
opus_gemm gfx950 4wave: trim the registry, tuner and builder glue
Fyzyukk Nov 13, 2026
058d055
opus a16w16: NT/NN/TT/TN branches in the main flow
Fyzyukk Nov 13, 2026
2fd1a0a
opus a16w16: keep only the main-flow direction branches
Fyzyukk Nov 13, 2026
8357407
opus_gemm gfx950 4wave: drop checks duplicated by the C++ launcher / …
Fyzyukk Nov 13, 2026
4b2e1e2
opus_gemm a16w16 4wave: explicit A/B operand layouts, plain async_load
Fyzyukk Nov 13, 2026
cdc0c9d
opus a16w16: drop _four_wave; the route checks NT-only kids
Fyzyukk Nov 13, 2026
b98643c
opus a16w16: per-layout execute functions with their own checks
Fyzyukk Nov 13, 2026
cf9ec2d
opus a16w16: launch picks the layout, one execute per layout
Fyzyukk Nov 13, 2026
bcdfc41
opus a16w16: thin per-layout checks over the original _execute_a16w16
Fyzyukk Nov 13, 2026
04d67ad
opus_gemm a16w16 4wave: M/N-contiguous operands as opus layouts
Fyzyukk Nov 13, 2026
3de546f
opus_gemm a16w16 4wave: M/N read bases built once (restores the sched…
Fyzyukk Nov 13, 2026
6944c24
opus_gemm a16w16 4wave: separate A/B layouts per direction (24)
Fyzyukk Nov 13, 2026
84236a4
opus_gemm a16w16 4wave: one NT layout set for A and B
Fyzyukk Nov 13, 2026
8e85ed3
opus_gemm a16w16 4wave: one TN layout set for A and B
Fyzyukk Nov 13, 2026
8b7da33
opus_gemm a16w16 4wave: 6 layout builders with an operand tag
Fyzyukk Nov 13, 2026
cd62517
opus_gemm a16w16 4wave: element addressing, per-MFMA operands, all ti…
Fyzyukk Nov 14, 2026
e77e3e4
opus_gemm: black / ruff (import order) formatting of the a16w16 4wave…
Fyzyukk Nov 14, 2026
1e344fa
opus_gemm gen_co: the gfx950 kid table notes that every tile is pinned
Fyzyukk Nov 14, 2026
38d4883
ci: retrigger checks (flaky test_flydsl_hgemm graph replay on MI35X s…
Fyzyukk Nov 15, 2026
32f8b96
opus_gemm a16w16 4wave: move the gfx950 .co images to gen_co/gfx950/a…
Fyzyukk Nov 16, 2026
f96792d
Merge upstream main into fyz/opus_bf16_nt/nn/tt/tn_gemm
Fyzyukk Nov 20, 2026
8599966
opus_gemm a16w16 4wave: use the shared gfx950 CO loader interface
Fyzyukk Nov 20, 2026
3bbd648
Merge remote-tracking branch 'upstream/main' into fyz/opus_bf16_nt/nn…
Fyzyukk Nov 23, 2026
636ace7
opus_gemm build_co: default family for _default_co_output_dir
Fyzyukk Nov 23, 2026
5c6ce84
opus_gemm gen_instances: keep main's split-K reduce bucketing
Fyzyukk Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 65 additions & 6 deletions aiter/ops/opus/gemm_op_a16w16.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import torch

from aiter import logger
from csrc.opus_gemm.opus_gemm_common import OpusGemmInstance
from csrc.opus_gemm.opus_gemm_common import OpusGemmInstance, get_kernel_instance

from ...jit.core import compile_ops
from ._arch import _device_arch_and_cu
from .launch_plan import _get_cached_a16w16_launch_plan
from .launch_plan import GFX950_4WAVE_TAGS, _get_cached_a16w16_launch_plan

# ---- Low-level A16W16 backend --------------------------------------------

Expand Down Expand Up @@ -154,8 +154,7 @@ def _execute_a16w16(
route_cu_num: int | None = None,
instance: OpusGemmInstance | None = None,
) -> torch.Tensor:
"""Validate, plan, and launch one exact 3D A16W16 operation."""
_check_a16w16_launch_layout(XQ, WQ, Y)
"""Plan and launch one exact 3D A16W16 operation (layout checked by _execute_a16w16_<layout>)."""
batch, M, K = XQ.shape
N = Y.shape[2]

Expand Down Expand Up @@ -217,6 +216,58 @@ def _execute_a16w16(
return Y


# NT / NN / TT / TN: _launch_a16w16_gemm / _bmm pick the layout from the operand strides (batch-first
# XQ [B,M,K] / WQ [B,N,K]); each _execute_a16w16_<layout> checks its contract, then runs _execute_a16w16.
# NN / TT / TN need a kid whose launcher takes M/N-contiguous operands (gfx950 4-wave; it loads that
# layout's image and checks the strides).
# NT: XQ (K,1) WQ (K,1) NN: XQ (K,1) WQ (1,N)
# TT: XQ (1,M) WQ (K,1) TN: XQ (1,M) WQ (1,N)
def _a16w16_operand_transposed(tensor: torch.Tensor) -> bool:
"""True if the [.., rows, K] operand is stored [K, rows] (rows contiguous)."""
rows, K = tensor.shape[-2:]
stride_row, stride_k = tensor.stride()[-2:]
return rows > 1 and stride_row == 1 and not (stride_k == 1 and stride_row >= K)


def _require_layout_kid(
layout, XQ, *, kid, instance=None, route_arch=None, route_cu_num=None, **_
):
if instance is None:
arch, cu_num = route_arch, route_cu_num
if arch is None or cu_num is None:
arch, cu_num = _device_arch_and_cu(XQ.device)
instance = get_kernel_instance(arch, "a16w16", int(kid), cu_num=cu_num)
if instance is None or instance.kernel_tag not in GFX950_4WAVE_TAGS:
raise NotImplementedError(
f"opus_gemm_a16w16_launch: {layout} operands need a gfx950 a16w16 4-wave kid "
f"(tags {sorted(GFX950_4WAVE_TAGS)}); kid {kid} takes K-contiguous XQ/WQ only"
)


def _execute_a16w16_nt(XQ, WQ, Y, bias=None, **kwargs):
"""NT: XQ stored [M,K], WQ stored [N,K]; every kid."""
_check_a16w16_launch_layout(XQ, WQ, Y)
return _execute_a16w16(XQ, WQ, Y, bias, **kwargs)


def _execute_a16w16_nn(XQ, WQ, Y, bias=None, **kwargs):
"""NN: XQ stored [M,K], WQ the [N,K] view of a [K,N] weight."""
_require_layout_kid("NN", XQ, **kwargs)
return _execute_a16w16(XQ, WQ, Y, bias, **kwargs)


def _execute_a16w16_tt(XQ, WQ, Y, bias=None, **kwargs):
"""TT: XQ the [M,K] view of a [K,M] activation, WQ stored [N,K]."""
_require_layout_kid("TT", XQ, **kwargs)
return _execute_a16w16(XQ, WQ, Y, bias, **kwargs)


def _execute_a16w16_tn(XQ, WQ, Y, bias=None, **kwargs):
"""TN: XQ / WQ views of [K,M] / [K,N] storage."""
_require_layout_kid("TN", XQ, **kwargs)
return _execute_a16w16(XQ, WQ, Y, bias, **kwargs)


def _launch_a16w16_gemm(
XQ: torch.Tensor,
WQ: torch.Tensor,
Expand All @@ -236,7 +287,11 @@ def _launch_a16w16_gemm(
"opus_gemm A16W16 expects 2D XQ/WQ/Y; use opus_bmm for "
"batch-first 3D tensors"
)
_execute_a16w16(
execute = (
(_execute_a16w16_nt, _execute_a16w16_nn),
(_execute_a16w16_tt, _execute_a16w16_tn),
)[_a16w16_operand_transposed(XQ)][_a16w16_operand_transposed(WQ)]
execute(
XQ.unsqueeze(0),
WQ.unsqueeze(0),
Y.unsqueeze(0),
Expand Down Expand Up @@ -270,7 +325,11 @@ def _launch_a16w16_bmm(
"opus_bmm A16W16 expects batch-first 3D XQ/WQ/Y; use "
"opus_gemm for logical 2D tensors"
)
return _execute_a16w16(
execute = (
(_execute_a16w16_nt, _execute_a16w16_nn),
(_execute_a16w16_tt, _execute_a16w16_tn),
)[_a16w16_operand_transposed(XQ)][_a16w16_operand_transposed(WQ)]
return execute(
XQ,
WQ,
Y,
Expand Down
15 changes: 15 additions & 0 deletions aiter/ops/opus/launch_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import torch

from csrc.opus_gemm.opus_gemm_common import (
_A16W16_4WAVE_GFX950_TAGS,
GFX942_BF16WS_EXACT_N,
GFX942_EVEN_LOOP_SPLITK_TAGS,
GFX942_MAX_AUTO_SPLIT_K,
Expand All @@ -32,6 +33,9 @@
_GFX1250_CO_TAGS = frozenset(
{"a16w16_4wave_co", "a16w16_4wave_wl_co", "a16w16_4wave_wlr_co"}
)
# gfx950 a16w16 4-wave (pre-built .co): direct and fp32 split-K workspace kids.
GFX950_4WAVE_TAGS = _A16W16_4WAVE_GFX950_TAGS
_GFX950_4WAVE_B_K = 64


@dataclass(frozen=True)
Expand Down Expand Up @@ -78,6 +82,10 @@ def _supports_a16w16_shape(
if instance.kernel_tag == "a16w16_mono_tile":
return N % instance.B_N == 0 and K % instance.B_K == 0

if instance.kernel_tag in GFX950_4WAVE_TAGS:
# K tiles of 64, at least 2 per split; any M and N.
return K % _GFX950_4WAVE_B_K == 0 and K >= 2 * _GFX950_4WAVE_B_K

if not instance.has_oob:
return M % instance.B_M == 0 and N % instance.B_N == 0
return True
Expand Down Expand Up @@ -164,6 +172,11 @@ def _plan_gfx950_split_k(
return abi_split_k


def _plan_gfx950_4wave_split_k(*, K: int, requested: int) -> int:
"""Mirror of the 4wave workspace launcher clamp: >= 2 K tiles per split."""
return min(max(1, requested), (K // _GFX950_4WAVE_B_K) // 2)


def _plan_gfx1250_split_k(
instance: OpusGemmInstance,
*,
Expand Down Expand Up @@ -385,6 +398,8 @@ def _build_a16w16_launch_plan(
cu_num=cu_num,
requested=requested_split_k,
)
elif instance.kernel_tag == "a16w16_4wave_ws":
abi_split_k = _plan_gfx950_4wave_split_k(K=K, requested=requested_split_k)
elif registry_arch == GFX950:
abi_split_k = _plan_gfx950_split_k(
instance,
Expand Down
3 changes: 3 additions & 0 deletions csrc/opus_gemm/codegen/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
# Pre-built gfx1250 device images. Their generated host launchers reuse the
# ordinary five-argument non-workspace exact-kid ABI.
*_A16W16_CO_TAGS,
# Pre-built gfx950 4-wave images: direct / split-K workspace.
"a16w16_4wave",
"a16w16_4wave_ws",
) + _GFX942_A16W16_TAGS

EMIT_REGISTRY = {}
Expand Down
Loading
Loading