Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions aiter/aot/flydsl/moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ def _precompile_to_cache(
a_scale_one: bool = False,
xcd_swizzle: int = 0,
enable_bias: bool = False,
# Stage2-only kernel tuning knobs (registered by the production-variant
# entries in `get_flydsl_stage2_kernels`). Forwarded into
# `compile_flydsl_moe_stage2` for stage 2 AOT compilation.
use_async_copy: bool = False,
cu_num_mul: int = 1,
**kwargs,
):
"""Trigger MLIR compilation with dummy tensors and COMPILE_ONLY=1.
Expand Down Expand Up @@ -505,6 +510,9 @@ def _precompile_silu_fused():
accumulate=accumulate,
persist_m=_persist_m,
sort_block_m=sort_block_m,
waves_per_eu=waves_per_eu,
use_async_copy=use_async_copy,
cu_num_mul=cu_num_mul,
b_nt=b_nt,
xcd_swizzle=xcd_swizzle,
enable_bias=enable_bias,
Expand Down
2 changes: 2 additions & 0 deletions aiter/configs/model_configs/dsv3_fp4_tuned_fmoe.csv
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ cu_num,token,model_dim,inter_dim,expert,topk,act_type,dtype,q_dtype_a,q_dtype_w,
256,16384,7168,512,257,9,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,32,0,1082.6229,moe_ck2stages_gemm1_256x32x128x128_1x4_MulABScaleShuffled_v3_Nswizzle0_Quant3_MulRoutedWeight0_silu_FP4X2_FP4X2_B16,0.0,1997.4238,moe_ck2stages_gemm2_64x32x32x128_1x1_MulABScaleExpertWeightShuffled_v1_Nswizzle0_Quant3_MulRoutedWeight1_FP4X2_FP4X2_B16,0.0284,3080.0467,0,0.0,0.0,flydsl_fallback
256,32768,7168,512,257,9,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,64,0,1633.0245,moe_ck2stages_gemm1_256x64x128x128_1x4_MulABScaleShuffled_v3_Nswizzle0_Quant3_MulRoutedWeight0_silu_FP4X2_FP4X2_B16,0.0,4180.9635,moe_ck2stages_gemm2_64x64x128x128_1x1_MulABScaleExpertWeightShuffled_v3_Nswizzle0_Quant3_MulRoutedWeight1_FP4X2_FP4X2_B16,0.0291,5813.988,0,0.0,0.0,flydsl_fallback
256,2,7168,256,257,9,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,32,0,25.0445,moe_ck2stages_gemm1_64x32x32x128_1x1_MulABScaleShuffled_v3_Nswizzle0_Quant3_MulRoutedWeight0_silu_FP4X2_FP4X2_B16,0.0,9.0041,moe_ck2stages_gemm2_64x32x32x128_1x1_MulABScaleExpertWeightShuffled_v1_Nswizzle0_Quant3_MulRoutedWeight1_FP4X2_FP4X2_B16,0.0144,34.0486,0,0.0,0.0,flydsl_fallback
256,32768,7168,2048,64,8,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,128,0,4655.916200000001,moe_ck2stages_gemm1_256x128x128x128_1x4_MulABScaleShuffled_v3_Nswizzle0_Quant3_MulRoutedWeight0_silu_FP4X2_FP4X2_B16,0.0%,4252.6419,flydsl_moe2_afp4_wfp4_bf16_t128x128x256_atomic_persist,6.8%,8908.5581,0,2591.86,395.49,
256,32768,7168,2048,64,8,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,128,0,4655.916200000001,moe_ck2stages_gemm1_256x128x128x128_1x4_MulABScaleShuffled_v3_Nswizzle0_Quant3_MulRoutedWeight0_silu_FP4X2_FP4X2_B16,0.0,6110.1531,moe_ck2stages_gemm2_256x128x128x128_1x4_MulABScaleExpertWeightShuffled_v3_Nswizzle0_Quant3_MulRoutedWeight1_FP4X2_FP4X2_B16,0.0681,10766.0693,0,0.0,0.0,flydsl_fallback
14 changes: 13 additions & 1 deletion aiter/fused_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,16 @@ def _flydsl_stage2_wrapper(
bias2=None,
**_kwargs,
):

# `parsed` is the static per-kernel params dict registered at
# import time by `get_flydsl_stage2_kernels` (see
# aiter/ops/flydsl/moe_kernels.py) and pre-populated into
# `_KERNEL_PARAMS` by `_register_all_configs()`. Variant-specific
# knobs that live on the kernel name (e.g. the
# `..._persist_async_w4_cumul3` production variant adds
# `use_async_copy=True / waves_per_eu=4 / cu_num_mul=3`) are
# already baked into this dict, so the `parsed.get(..., default)`
# calls below pick up the registered values for that kernel name
# rather than always falling back to defaults.
parsed = aiter.ops.flydsl.moe_kernels.get_flydsl_kernel_params(kernelName)
if parsed is None:
raise ValueError(f"Invalid FlyDSL kernel name: {kernelName}")
Expand All @@ -794,6 +803,9 @@ def _flydsl_stage2_wrapper(
a2_scale=a2_scale,
sorted_weights=sorted_weights,
sort_block_m=parsed.get("sort_block_m", 0),
waves_per_eu=parsed.get("waves_per_eu", None),
Comment thread
lalala-sh marked this conversation as resolved.
Resolved
use_async_copy=parsed.get("use_async_copy", False),
cu_num_mul=parsed.get("cu_num_mul", 1),
b_nt=parsed.get("b_nt", 0),
persist=parsed.get("persist", None),
bias=bias2,
Expand Down
Loading
Loading