submission 513713
ooousay · 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.
submission.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-amd-moe-mxfp4-513713?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
Reported · How evidence levels are derived →
Source and license
sourceavailable
revision digestsha256:84718e88df2dbeb8efda9c2ec1200cc8e5311db11cdf745ff41377267d1102f7
license declaredunknown
license concludedunknown
authorsooousay
imported2026-08-15
Kernel source
submission.py69 lines
import os
# OPUS variant of MoE sorting kernel: 3-6% improvement
os.environ["AITER_USE_OPUS_MOE_SORTING"] = "1"
import torch
import aiter
from aiter import ActivationType, QuantType, dtypes
from aiter.fused_moe import fused_moe, get_2stage_cfgs
from task import input_t, output_t
_current_ksplit = None
def custom_kernel(data: input_t) -> output_t:
global _current_ksplit
(
hidden_states,
gate_up_weight,
down_weight,
gate_up_weight_scale,
down_weight_scale,
gate_up_weight_shuffled,
down_weight_shuffled,
gate_up_weight_scale_shuffled,
down_weight_scale_shuffled,
topk_weights,
topk_ids,
config,
) = data
M = hidden_states.shape[0]
E = gate_up_weight_shuffled.shape[0]
# Adaptive ksplit: cktile kernels with split-K=2 are much faster
# for small batch sizes with few experts (E=33, M<=128).
# For large batches, default ksplit=0 is better (less reduction overhead).
want_ksplit = "2" if (E <= 64 and M <= 128) else None
if want_ksplit != _current_ksplit:
if want_ksplit:
os.environ["AITER_KSPLIT"] = want_ksplit
else:
os.environ.pop("AITER_KSPLIT", None)
get_2stage_cfgs.cache_clear()
_current_ksplit = want_ksplit
hidden_pad = config["d_hidden_pad"] - config["d_hidden"]
intermediate_pad = config["d_expert_pad"] - config["d_expert"]
output = fused_moe(
hidden_states,
gate_up_weight_shuffled,
down_weight_shuffled,
topk_weights,
topk_ids,
expert_mask=None,
activation=ActivationType.Silu,
quant_type=QuantType.per_1x32,
doweight_stage1=False,
w1_scale=gate_up_weight_scale_shuffled,
w2_scale=down_weight_scale_shuffled,
a1_scale=None,
a2_scale=None,
hidden_pad=hidden_pad,
intermediate_pad=intermediate_pad,
)
return output
scrolls · 69 lines total
Source code from GPU Mode and the KernelBot dataset · June 9 Researcher Reciprocity License v1.0
Changes from previous submission
Against this author's previous submission submission 513651.
+ import os+ # OPUS variant of MoE sorting kernel: 3-6% improvement+ os.environ["AITER_USE_OPUS_MOE_SORTING"] = "1"+import torchimport aiterfrom aiter import ActivationType, QuantType, dtypes- from aiter.fused_moe import fused_moe+ from aiter.fused_moe import fused_moe, get_2stage_cfgsfrom task import input_t, output_t+ _current_ksplit = None+def custom_kernel(data: input_t) -> output_t:+ global _current_ksplit(hidden_states,gate_up_weight,⋯ 9 unchanged linesconfig,) = data+ M = hidden_states.shape[0]+ E = gate_up_weight_shuffled.shape[0]++ # Adaptive ksplit: cktile kernels with split-K=2 are much faster+ # for small batch sizes with few experts (E=33, M<=128).+ # For large batches, default ksplit=0 is better (less reduction overhead).+ want_ksplit = "2" if (E <= 64 and M <= 128) else None++ if want_ksplit != _current_ksplit:+ if want_ksplit:+ os.environ["AITER_KSPLIT"] = want_ksplit+ else:+ os.environ.pop("AITER_KSPLIT", None)+ get_2stage_cfgs.cache_clear()+ _current_ksplit = want_ksplit+hidden_pad = config["d_hidden_pad"] - config["d_hidden"]intermediate_pad = config["d_expert_pad"] - config["d_expert"]
scrolls · 42 diff lines total
Best evidence level for this revision: reported
JSON