Skip to content
KernelIndex
Search⌘K

submission 722023

Ayush Gupta · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

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

submission_v13.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-amd-moe-mxfp4-722023?include=source"
interfacepython
Compatibility
measured onAMD Instinct MI355X
declared hardwareAMD Instinct MI355X
architecturesgfx950
dtypesbf16, fp32, fp8_e8m0, int32, mxfp4

Benchmark evidence

1 measurement across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
AMD MXFP4 MoEsuite of 7 cases
AMD Instinct MI355X
185.2µs
#612 of 782
2026-04-04

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:69aae66854c81ab0ab91941ec19d8b36d6553b6b0a7e3cfc6cca7e8db1a0fd72
license declaredunknown
license concludedunknown
authorsAyush Gupta
imported2026-08-26

Kernel source

submission_v13.py67 lines
#!POPCORN leaderboard amd-moe-mxfp4
#!POPCORN gpu MI355X

import os
import torch
from task import input_t, output_t
from aiter import ActivationType, QuantType
from aiter.fused_moe import fused_moe

# Keep strict MXFP4 path.
torch.backends.cuda.matmul.allow_tf32 = False
torch.backends.cudnn.allow_tf32 = False

# Prefer opus sorting path for faster dispatch.
os.environ.setdefault("AITER_USE_OPUS_MOE_SORTING", "1")

_PAD_CACHE = {}

def _get_pads(config):
    d_hidden = config["d_hidden"]
    d_hidden_pad = config["d_hidden_pad"]
    d_expert = config["d_expert"]
    d_expert_pad = config["d_expert_pad"]
    
    key = (d_hidden, d_hidden_pad, d_expert, d_expert_pad)
    pads = _PAD_CACHE.get(key)
    if pads is None:
        pads = (
            int(d_hidden_pad - d_hidden),
            int(d_expert_pad - d_expert),
        )
        _PAD_CACHE[key] = pads
    return pads

def custom_kernel(data: input_t) -> output_t:
    hidden_states = data[0]
    w1 = data[5]
    w2 = data[6]
    s1 = data[7]
    s2 = data[8]
    topk_weights = data[9]
    topk_ids = data[10]
    config = data[11]

    hidden_pad, intermediate_pad = _get_pads(config)

    # Calling fused_moe without forcing `block_size_M` or `moe_sorting_dispatch_policy`
    # This avoids the Memory Access Fault, falling back to AITER's internal defaults 
    # and safely handling dynamically tuned parameters from aiter's model_configs csvs.
    return fused_moe(
        hidden_states,
        w1,
        w2,
        topk_weights,
        topk_ids,
        expert_mask=None,
        activation=ActivationType.Silu,
        quant_type=QuantType.per_1x32,
        doweight_stage1=False,
        w1_scale=s1,
        w2_scale=s2,
        a1_scale=None,
        a2_scale=None,
        hidden_pad=hidden_pad,
        intermediate_pad=intermediate_pad,
    )
scrolls · 67 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