Skip to content
KernelIndex
Search⌘K

submission 563102

Nganga kamau · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

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

submission2.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-amd-mxfp4-mm-563102?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
24.3µs
#1015 of 1143
2026-03-15

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:a83f7396f281028740d5d159838def357a95181b1e5ee7145da1d7c88262ac9f
license declaredunknown
license concludedunknown
authorsNganga kamau
imported2026-08-26

Techniques

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

fp4MXFP4 GEMM for AMD MI355X.

Kernel source

submission2.py43 lines
"""
MXFP4 GEMM for AMD MI355X.

Reference impl (ref_kernel) shows exact API:
  1. dynamic_mxfp4_quant(A) -> (A_fp4, A_scale_e8m0)
  2. e8m0_shuffle(A_scale_e8m0) -> A_scale_sh  (shuffled scales)
  3. aiter.gemm_a4w4(A_q, B_shuffle, A_scale_sh, B_scale_sh,
                     dtype=dtypes.bf16, bpreshuffle=True)
"""
import torch
import aiter
from aiter import dtypes
from aiter.ops.triton.quant import dynamic_mxfp4_quant
from aiter.utility.fp4_utils import e8m0_shuffle


def custom_kernel(data: tuple) -> torch.Tensor:
    A, B, B_q, B_shuffle, B_scale_sh = data

    # Step 1: Quantize A to MXFP4 with per-1x32 block scales
    # dynamic_mxfp4_quant is the #975-patched kernel (correct vs fp4_utils.py)
    A_fp4, A_scale = dynamic_mxfp4_quant(A)

    # Step 2: Shuffle A scales to match the layout gemm_a4w4 expects
    A_scale_sh = e8m0_shuffle(A_scale)

    # Step 3: Cast to the dtypes gemm_a4w4 expects
    A_q = A_fp4.view(dtypes.fp4x2)
    A_scale_sh = A_scale_sh.view(dtypes.fp8_e8m0)

    # Step 4: MXFP4 x MXFP4 GEMM
    # B_shuffle: [N//16, K*16] pre-shuffled layout, bpreshuffle=True
    # B_scale_sh: already shuffled E8M0 scales from generate_input
    out = aiter.gemm_a4w4(
        A_q,
        B_shuffle,
        A_scale_sh,
        B_scale_sh,
        dtype=dtypes.bf16,
        bpreshuffle=True,
    )
    return out
scrolls · 43 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