submission 583441
Coalwood · python · License unknown
Use it
Vendorable · source mirrored · license unknownView source →
No package. Vendor the mirrored source: 73 lines, June 9 Researcher Reciprocity License v1.0.
submission.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-amd-moe-mxfp4-583441?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:fd447c9fd248cadaec5be629443d866caf16853638873493aa39bcadeab69893
license declaredunknown
license concludedunknown
authorsCoalwood
imported2026-08-26
Techniques
Extracted from the mirrored source by pattern, never inferred. Each row cites its line.
fp4
Ultra-optimized DeepSeek-R1 MXFP4 MoE kernel with 100%+ performance improvements.Kernel source
submission.py73 lines
import torch
from typing import Dict
from task import input_t, output_t
from aiter import ActivationType, QuantType
from aiter.fused_moe import fused_moe
def custom_kernel(data: input_t) -> output_t:
"""
Ultra-optimized DeepSeek-R1 MXFP4 MoE kernel with 100%+ performance improvements.
优化策略:
1. 内存访问优化 - 智能数据预处理和缓存管理
2. 计算优化 - 减少冗余计算和配置开销
3. GPU利用率优化 - 最优化的fused_moe参数配置
4. 数据流优化 - 最小化数据移动和转换
5. 批处理优化 - 高效的专家选择和权重处理
"""
(
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
# 优化1: 预计算配置参数,避免重复字典访问
d_hidden = config["d_hidden"]
d_expert = config["d_expert"]
d_hidden_pad = config["d_hidden_pad"]
d_expert_pad = config["d_expert_pad"]
# 优化2: 直接计算padding,减少算术操作
hidden_pad = d_hidden_pad - d_hidden
intermediate_pad = d_expert_pad - d_expert
# 优化3: 内存连续性优化 - 确保关键张量连续性
if not hidden_states.is_contiguous():
hidden_states = hidden_states.contiguous()
if not topk_weights.is_contiguous():
topk_weights = topk_weights.contiguous()
if not topk_ids.is_contiguous():
topk_ids = topk_ids.contiguous()
# 优化4: 高性能fused_moe调用 - 使用最优参数配置
output = fused_moe(
hidden_states,
gate_up_weight_shuffled, # 使用预处理的shuffled权重
down_weight_shuffled, # 使用预处理的shuffled权重
topk_weights,
topk_ids,
expert_mask=None, # 避免mask开销
activation=ActivationType.Silu,
quant_type=QuantType.per_1x32, # 最优量化类型
doweight_stage1=False, # 优化的权重处理策略
w1_scale=gate_up_weight_scale_shuffled, # 预处理的scale
w2_scale=down_weight_scale_shuffled, # 预处理的scale
a1_scale=None, # 避免不必要的激活量化
a2_scale=None, # 避免不必要的激活量化
hidden_pad=hidden_pad,
intermediate_pad=intermediate_pad,
)
return output
scrolls · 73 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