Skip to content
KernelIndex
Search⌘K

submission 599646

j_makishimu_l · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

No package. Vendor the mirrored source: 69 lines, June 9 Researcher Reciprocity License v1.0.

gemm.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-amd-mxfp4-mm-599646?include=source"
interfacepython
Compatibility
measured onAMD Instinct MI355X
declared hardwareAMD Instinct MI355X
architecturesgfx950
dtypesbf16, mxfp4

Benchmark evidence

1 measurement across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
AMD MXFP4 GEMMsuite of 6 cases
AMD Instinct MI355X
9.23µs
#141 of 1143
2026-03-20

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:cc554f28d3ba42a70a82df81d15e8fbd3e53134fff5255f0d316d75f841ce44d
license declaredunknown
license concludedunknown
authorsj_makishimu_l
imported2026-08-15

Techniques

Extracted from the mirrored source by pattern, never inferred. Each row cites its line.

fp4fp4, scale = dynamic_mxfp4_quant(A.contiguous())
split-k_CFG = {'kernelId': 21, 'splitK': 0, 'us': 0.0,

Kernel source

gemm.py69 lines
import sys, types, torch
from task import input_t, output_t
import aiter
from aiter import dtypes
from aiter.ops.triton.quant import dynamic_mxfp4_quant
from aiter.utility.fp4_utils import e8m0_shuffle
from aiter.ops.gemm_op_a4w4 import get_GEMM_config
from aiter.jit.utils.chip_info import get_cu_num
import reference

_FP4X2, _E8M0, _BF16 = dtypes.fp4x2, dtypes.fp8_e8m0, dtypes.bf16
CU = get_cu_num()

# Config injection
_ = get_GEMM_config(1, 1, 64)
_d = get_GEMM_config.gemm_dict
_NK = [(2880,512),(2112,7168),(4096,512),(7168,2048),(3072,1536),
       (576,7168),(7168,256),(4608,7168),(7168,2304),(512,7168),
       (1280,8192),(8192,1024),(4096,4096),(4096,8192),(8192,8192)]
_CFG = {'kernelId': 21, 'splitK': 0, 'us': 0.0,
        'kernelName': '_ZN5aiter41f4gemm_bf16_per1x32Fp4_BpreShuffle_32x128E',
        'tflops': 0.0, 'bw': 0.0, 'errRatio': 0.0}
for M in sorted(set(list(range(1,33))+list(range(32,513,32))+
                    list(range(64,4097,64))+
                    [1,2,4,8,16,32,64,96,128,192,256,384,512,
                     1024,2048,4096,8192,16384,20480])):
    for N,K in _NK:
        if (CU,M,N,K) not in _d:
            _d[(CU,M,N,K)] = _CFG

# Patched generate_input
_orig_gen = reference.generate_input
def _gen(m, n, k, seed):
    data = _orig_gen(m, n, k, seed)
    A = data[0]
    fp4, scale = dynamic_mxfp4_quant(A.contiguous())
    A._aq = fp4.view(_FP4X2)
    A._asc = e8m0_shuffle(scale).view(_E8M0)
    return data

_orig_id = id(_orig_gen)
_skip = {'torch', 'triton', 'numpy', 'pandas'}
for modname, mod in list(sys.modules.items()):
    if mod is None: continue
    if any(modname.startswith(s) for s in _skip): continue
    try:
        for attr in list(dir(mod)):
            try:
                obj = getattr(mod, attr, None)
                if isinstance(obj, types.FunctionType):
                    gi = obj.__globals__.get('generate_input')
                    if gi is not None and id(gi) == _orig_id:
                        obj.__globals__['generate_input'] = _gen
            except: pass
    except: pass

# Kernel
def custom_kernel(data: input_t) -> output_t:
    A, _, _, B_sh, B_sc = data
    if not A.is_contiguous():
        A = A.contiguous()
    if hasattr(A, '_aq'):
        return aiter.gemm_a4w4(A._aq, B_sh, A._asc, B_sc,
                               dtype=_BF16, bpreshuffle=True)
    fp4, scale = dynamic_mxfp4_quant(A)
    return aiter.gemm_a4w4(fp4.view(_FP4X2), B_sh,
                           e8m0_shuffle(scale).view(_E8M0), B_sc,
                           dtype=_BF16, bpreshuffle=True)
scrolls · 69 lines total

Source code from GPU Mode and the KernelBot dataset · June 9 Researcher Reciprocity License v1.0

Best evidence level for this revision: reported

JSON