Skip to content
KernelIndex
Search⌘K

submission 702538

Bortlesboat · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

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

submission.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-amd-moe-mxfp4-702538?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
148.2µs
#163 of 782
2026-04-02

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:c85a48e3c7814b12bceca4d71feb5ecadadb3eb253b48be821e8cbe45ad6ff76
license declaredunknown
license concludedunknown
authorsBortlesboat
imported2026-08-15

Kernel source

submission.py56 lines
"""V935: Remove d2048 CK override. V911 default=336 vs forced=348."""
import os
os.environ["HIP_FORCE_DEV_KERNARG"] = "1"
import torch
from task import input_t, output_t
from aiter import ActivationType, QuantType
from aiter.fused_moe import fused_moe
import aiter.fused_moe as fmoe_mod

_WINS = {
    (256, 16, 7168, 256, 257, 9, 'ActivationType.Silu', 'torch.bfloat16', 'torch.float4_e2m1fn_x2', 'torch.float4_e2m1fn_x2', 'QuantType.per_1x32', 1, 0): {'block_m': 32, 'ksplit': 4, 'kernelName1': None, 'kernelName2': None, 'run_1stage': 0, '_tag': float('nan')},
    (256, 128, 7168, 256, 257, 9, 'ActivationType.Silu', 'torch.bfloat16', 'torch.float4_e2m1fn_x2', 'torch.float4_e2m1fn_x2', 'QuantType.per_1x32', 1, 0): {'block_m': 32, 'ksplit': 4, 'kernelName1': None, 'kernelName2': None, 'run_1stage': 0, '_tag': float('nan')},
    (256, 512, 7168, 256, 257, 9, 'ActivationType.Silu', 'torch.bfloat16', 'torch.float4_e2m1fn_x2', 'torch.float4_e2m1fn_x2', 'QuantType.per_1x32', 1, 0): {'block_m': 32, 'ksplit': 0, 'kernelName1': 'moe_ck2stages_gemm1_64x32x32x128_1x1_MulABScaleShuffled_v3_Nswizzle0_Quant3_MulRoutedWeight0_silu_FP4X2_FP4X2_B16', 'kernelName2': 'moe_ck2stages_gemm2_64x32x32x128_1x1_MulABScaleExpertWeightShuffled_v1_Nswizzle0_Quant3_MulRoutedWeight1_FP4X2_FP4X2_B16', 'run_1stage': 0, '_tag': float('nan')},
    (256, 16, 7168, 512, 33, 9, 'ActivationType.Silu', 'torch.bfloat16', 'torch.float4_e2m1fn_x2', 'torch.float4_e2m1fn_x2', 'QuantType.per_1x32', 1, 0): {'block_m': 64, 'ksplit': 2, 'kernelName1': None, 'kernelName2': None, 'run_1stage': 0, '_tag': float('nan')},
    (256, 128, 7168, 512, 33, 9, 'ActivationType.Silu', 'torch.bfloat16', 'torch.float4_e2m1fn_x2', 'torch.float4_e2m1fn_x2', 'QuantType.per_1x32', 1, 0): {'block_m': 64, 'ksplit': 2, 'kernelName1': None, 'kernelName2': None, 'run_1stage': 0, '_tag': float('nan')},
    (256, 512, 7168, 512, 33, 9, 'ActivationType.Silu', 'torch.bfloat16', 'torch.float4_e2m1fn_x2', 'torch.float4_e2m1fn_x2', 'QuantType.per_1x32', 1, 0): {'block_m': 32, 'ksplit': 0, 'kernelName1': 'moe_ck2stages_gemm1_256x32x128x128_1x4_MulABScaleShuffled_v3_Nswizzle0_Quant3_MulRoutedWeight0_silu_FP4X2_FP4X2_B16', 'kernelName2': 'moe_ck2stages_gemm2_64x32x32x128_1x1_MulABScaleExpertWeightShuffled_v1_Nswizzle0_Quant3_MulRoutedWeight1_FP4X2_FP4X2_B16', 'run_1stage': 0, '_tag': float('nan')},
}
_patched = False
def _ensure_patched():
    global _patched
    if _patched:
        return
    _patched = True
    try:
        _ = fmoe_mod.get_2stage_cfgs.__wrapped__(
            16, 7168, 256, 257, 9, torch.bfloat16,
            torch.float4_e2m1fn_x2, torch.float4_e2m1fn_x2,
            QuantType.per_1x32, True, ActivationType.Silu, False, 0, 0, True)
    except: pass
    cfg = fmoe_mod.cfg_2stages
    if cfg is not None:
        for key, val in _WINS.items():
            cfg[key] = val
    try:
        fmoe_mod.get_2stage_cfgs.cache_clear()
        fmoe_mod.get_block_size_M.cache_clear()
        fmoe_mod.get_ksplit.cache_clear()
    except: pass
try:
    from aiter import dtypes
    _ensure_patched()
except: pass

def custom_kernel(data: input_t) -> output_t:
    (hidden_states, guw, dw, guws, dws, guws_sh, dws_sh, guws_sc_sh, dws_sc_sh,
     topk_weights, topk_ids, config) = data
    _ensure_patched()
    return fused_moe(
        hidden_states, guws_sh, dws_sh, topk_weights, topk_ids,
        expert_mask=None, activation=ActivationType.Silu,
        quant_type=QuantType.per_1x32, doweight_stage1=False,
        w1_scale=guws_sc_sh, w2_scale=dws_sc_sh, a1_scale=None, a2_scale=None,
        hidden_pad=config["d_hidden_pad"] - config["d_hidden"],
        intermediate_pad=config["d_expert_pad"] - config["d_expert"],
    )
scrolls · 56 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