Skip to content
KernelIndex
Search⌘K

submission 689739

ZheWang · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

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

submission_v4.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-amd-mxfp4-mm-689739?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.0µs
#836 of 1143
2026-04-01

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:6334f57c22a45d1059aa1b7dc7b54566c547f4cb28ad10a7ccae96336385f552
license declaredunknown
license concludedunknown
authorsZheWang
imported2026-08-26

Kernel source

submission_v4.py55 lines
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

from task import input_t, output_t


def quant_mxfp4(x):
    x_fp4, bs_e8m0 = dynamic_mxfp4_quant(x)
    bs_e8m0 = e8m0_shuffle(bs_e8m0)
    return x_fp4.view(dtypes.fp4x2), bs_e8m0.view(dtypes.fp8_e8m0)


def custom_kernel(data: input_t) -> output_t:
    """
    Optimized kernel wrapper
    """

    A, _, _, B_shuffle, B_scale_sh = data

    if not A.is_contiguous():
        A = A.contiguous()

    m_orig, k_orig = A.shape

    if m_orig < 32:
        A_q, A_scale_sh = quant_mxfp4(A)
        out = aiter.gemm_a4w4(
            A_q, B_shuffle, A_scale_sh, B_scale_sh,
            dtype=dtypes.bf16, bpreshuffle=True,
        )
        return out

    pad_m = (32 - m_orig % 32) % 32
    if pad_m > 0:
        # Padding A 矩阵
        A = torch.nn.functional.pad(A, (0, 0, 0, pad_m))

    A_q, A_scale_sh = quant_mxfp4(A)

    out = aiter.gemm_a4w4(
        A_q,
        B_shuffle,
        A_scale_sh,
        B_scale_sh,
        dtype=dtypes.bf16,
        bpreshuffle=True,
    )

    if  pad_m > 0:
        out = out[:m_orig, :]

    return out
scrolls · 55 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