vllm.models.kimi_k3.nvidia.specialized_decode.cutedsl.moe.ep.layer
¶
DEP (TP1 attention, EP over all ranks) latent-MoE layer.
EpMoeLayer is the per-batch schedule of one MoE layer on a DEP rank (every op
memory-bound at decode, so the schedule's job is to keep HBM streaming):
main [shared gate_up | latent down] in ONE split-K GEMM (both read x; one weight
stream instead of two cuBLAS launches) -> routed experts (routed)
side FP32 router GEMM + sigmoid top-16 beside the front GEMM; the shared SiTU and
down-projection beside the routed experts
main latent RMSNorm + up-projection accumulated into the shared output (cuBLAS
addmm: one rounding, as stock)
The routed callable is the deployment's EP kernel: the stock DeepGEMM MegaMoE (one
fused dispatch / FC1 / FC2 / combine kernel; it requires every SM, so the side stream
fills its gaps) or EpRouted. Precision is stock: BF16 GEMMs with FP32
accumulation (split-K reduces in FP32), FP32 router logits.
EpRouted is the split EP path: NVLink dispatch of the MXFP8 latent (bit-identical
to mxfp8_quantize) -> trtllm-gen MXFP4 x MXFP8 experts over the received rows ->
NVLink combine fused with the latent RMSNorm (comm.py).
Classes:
-
EpMoeLayer–One DEP MoE layer's specialized schedule over the stock module's weights.
-
EpRouted–The routed experts of one DEP rank for every MoE layer (buffers are shared by
Functions:
-
combine_grid–CTAs of the combine: enough to push the received rows (~N T / 2 at DEP16) and
-
front_tactic–Split-K tactic (weight rows, token tile, split, stages) of a DEP projection at
-
pack_front–One [shared gate_up | latent down] BF16 weight [12288 + 3584, 7168]; the stock
EpMoeLayer
¶
One DEP MoE layer's specialized schedule over the stock module's weights.
weights: gate [896, 7168] BF16 + e_score_correction_bias FP32, front
(pack_front), shared down [7168, 6144], latent norm [3584], up [7168, 3584]; act
the stock SiTU-and-mul; routed(latent, topk_weights, topk_ids) -> BF16 latent
the EP experts. Batches above FRONT_MAX tokens (or unprepared) run the stock
order.
Methods:
-
gate_up–The shared gate_up columns of the packed front as contiguous rows: the
-
stock_order–Batches the split-K front does not serve: the stock op sequence on one
-
topk–The stock router's sigmoid top-16 (one group) of the FP32 logits.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/layer.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
gate_up(front)
¶
The shared gate_up columns of the packed front as contiguous rows: the stock SiTU-and-mul CUDA kernel reads row r at r * 2I, while the packed front's rows are 2I + 3584 apart.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/layer.py
stock_order(x)
¶
Batches the split-K front does not serve: the stock op sequence on one stream (cuBLAS GEMMs, FP32 router logits).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/layer.py
topk(x, logits)
¶
The stock router's sigmoid top-16 (one group) of the FP32 logits.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/layer.py
EpRouted
¶
The routed experts of one DEP rank for every MoE layer (buffers are shared by the layers: each layer's combine completes before the next dispatch).
Methods:
-
experts_trtllm–trtllm-gen over the N stride(T) receive rows (empty rows are non-local).
-
prepare–Every rank of the group must run the same
tokensin a step (vLLM pads -
routed–Latent [T, 3584] BF16 -> RMSNorm(routed latent) [T, 3584] BF16.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/layer.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
experts_trtllm(tokens, w13, s13, w2, s2)
¶
trtllm-gen over the N stride(T) receive rows (empty rows are non-local).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/layer.py
prepare(tokens)
¶
Every rank of the group must run the same tokens in a step (vLLM pads
DP ranks to one batch): the receive rows are addressed by stride(tokens).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/layer.py
routed(latent, ids, weights, norm_weight, normed, experts)
¶
Latent [T, 3584] BF16 -> RMSNorm(routed latent) [T, 3584] BF16.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/layer.py
combine_grid(tokens)
¶
CTAs of the combine: enough to push the received rows (~N T / 2 at DEP16) and reduce the own tokens in one or two rounds.
front_tactic(tokens, rows=64, split=1)
¶
Split-K tactic (weight rows, token tile, split, stages) of a DEP projection at
tokens rows (GB300, TP1 MoE shapes, tactic sweep: 64-row
weight tiles, one K split, the deepest pipeline that fits).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/moe/ep/layer.py
pack_front(moe)
¶
One [shared gate_up | latent down] BF16 weight [12288 + 3584, 7168]; the stock parameters become views of it (no extra memory).