vllm.models.minimax_m3.nvidia.specialized_decode.kernels.moe
¶
The moe stage of the MiniMax-M3 specialized decode: the fused NVFP4 routed +
MXFP8 shared-expert engine
(CuTe DSL, kernel.py), its host (host.py), the weight views and mode-Q prep
(weights.py) and the stage
wrapper (stage.py). Importing this package does not import CuTe DSL; the kernel
module loads on first build.
Modules:
-
host–Host side of the fused MoE engine (kernel.py, 1..8 tokens): router, NVFP4 routed
-
kernel–The fused MiniMax-M3 MoE engine for 1..8 decode tokens on one TP rank, one CuTe DSL kernel (m3_moe_kernel).
-
stage–The
moestage: the fused MoE engine (TP4, 1..8 rows, mode Q) on the post's -
weights–MoE engine operands from vLLM's loaded MiniMax-M3 MoE layer, and the mode-Q FC2
Classes:
-
FusedMoeStage–See the module docstring.
-
MoeWeights–
Functions:
-
default_n_shared–Shared-expert CTAs for
rowstokens on the livesm_count -
engine_config–The engine's trace-time config for the TP4 mode-Q build.
-
from_vllm_moe–MoeWeights from a loaded
MiniMaxM3MoE(decoder_layer.block_sparse_moe) on -
prep_mode_q–Mode Q FC2 prep as new tensors (idempotent): fc31_scale_c = g1_alphas x 16,
FusedMoeStage
¶
See the module docstring.
Methods:
-
__call__–One engine launch.
hidden: bf16 [rows, 6144] (default: the hand-off's -
__init__–handoff: the post'sallreduce_norm.MoeHandoff(routes, x4, normed -
warmup–Compile with one eager call (no push). Must run before CUDA-graph capture,
Source code in vllm/models/minimax_m3/nvidia/specialized_decode/kernels/moe/stage.py
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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 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 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | |
__call__(hidden=None, out=None, push=False, rt_tab=None)
¶
One engine launch. hidden: bf16 [rows, 6144] (default: the hand-off's
normed rows, the shared-expert
input). push: also push the output into the boundary exchange (only when the
next consumer polls it,
e.g. the next layer's kernel front; an unconsumed push would collide with the
next step's).
Source code in vllm/models/minimax_m3/nvidia/specialized_decode/kernels/moe/stage.py
__init__(cfg, weights, *, transport=None, handoff=None, rt_tab=None, x4=None, x4sf=None, co_resident=(), device=None)
¶
handoff: the post's allreduce_norm.MoeHandoff (routes, x4, normed
rows). Tests without a post pass
rt_tab (ext_route=2) and x4 / x4sf (uint8 [16][3072] / [17][384],
row 16 = fp32 s_t) instead.
Source code in vllm/models/minimax_m3/nvidia/specialized_decode/kernels/moe/stage.py
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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
_seed_publish()
¶
The compile call consumes one route publish: align the post's row counters with the engine's epochs and publish experts 0..3 at weight 0.25 with tag = epoch + 1 (what the post's next publish would carry).
Source code in vllm/models/minimax_m3/nvidia/specialized_decode/kernels/moe/stage.py
warmup()
¶
Compile with one eager call (no push). Must run before CUDA-graph capture, outside any PDL chain.
Source code in vllm/models/minimax_m3/nvidia/specialized_decode/kernels/moe/stage.py
MoeWeights
dataclass
¶
Methods:
-
expert_args–The 11 positional operands of
M3MoeState.layer.
Source code in vllm/models/minimax_m3/nvidia/specialized_decode/kernels/moe/weights.py
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 160 161 162 163 164 165 166 167 168 169 | |
expert_args()
¶
The 11 positional operands of M3MoeState.layer.
Source code in vllm/models/minimax_m3/nvidia/specialized_decode/kernels/moe/weights.py
default_n_shared(rows, sm_count)
¶
Shared-expert CTAs for rows tokens on the live sm_count
(geometry.moe_n_shared: a bytes-per-CTA
model, or a measured override).
Source code in vllm/models/minimax_m3/nvidia/specialized_decode/kernels/moe/stage.py
engine_config(cfg)
¶
The engine's trace-time config for the TP4 mode-Q build.
Source code in vllm/models/minimax_m3/nvidia/specialized_decode/kernels/moe/stage.py
from_vllm_moe(moe)
¶
MoeWeights from a loaded MiniMaxM3MoE (decoder_layer.block_sparse_moe) on
the FLASHINFER_TRTLLM NVFP4
backend. Raises MoeWeightError with the reason when the layer is in any other
form.
Source code in vllm/models/minimax_m3/nvidia/specialized_decode/kernels/moe/weights.py
prep_mode_q(w)
¶
Mode Q FC2 prep as new tensors (idempotent): fc31_scale_c = g1_alphas x 16, fc2_alpha = w2_scale_2 / 16. Refuses non-placeholder routed FC1 input scales (mode Q's FC1 scale is the post's per-token s_t).