vllm.models.flint.ops.moe_gemv
¶
Expert-indexed small-M NVFP4 GEMV kernels (CuTe DSL) for the low-latency
decode MoE block, built on the dense GEMV design of nvfp4_gemv: each CTA
owns 16 output rows (the m16n8k16 M dimension, swap-AB), its warps split K and
reduce through shared memory, weights are dequantized exactly to BF16
(cvt.rn.bf16x2.e2m1x2 + mul.rn.bf16x2) and the fp32 global scale is
applied to the fp32 accumulator.
gate_up: one (token, expert) pair per CTA column of the grid; writes
bf16(silu(g) * u) from fp32 gate/up with FlashInfer's approximate sigmoid
(the shared expert rounds its gate/up to BF16 first and uses the exact SiLU,
as its dense GEMM does). Expert weights use FlashInfer's W4A16
layout ([up; gate] in 64-row groups, 6D MMA scales).
down_combine: per token and 16 output rows, the down GEMVs of the token's
top-k experts and of the shared expert, all weights prefetched before
griddepcontrol.wait; out = bf16(bf16(sum_j tw_j * y_j) + y_shared)
with y = bf16(acc * global_scale).
Functions:
-
down_combine–out[t] = bf16(bf16(sum_j tw * bf16(act_j @ W2[e_j]^T * alpha2)) +
-
gate_up–act[p] = silu_and_mul((x[p // topk] @ W1[ids[p]]^T) * alpha) on fp32
_compile(key, fakes, *scalars)
¶
Compile kernel key = (kind, h, inter, si, topk) into _compiled.
Source code in vllm/models/flint/ops/moe_gemv.py
_fakes(*specs)
¶
Compile-time tensors: (dtype, divisibility) is 1-D of symbolic size, (dtype, divisibility, shape) has that shape.
Source code in vllm/models/flint/ops/moe_gemv.py
_flat_bytes(t)
¶
The contiguous storage behind a (possibly permuted) scale view.
down_combine(act, ids, tw, w2, w2_sf, alpha2, sact, wsd, ssd, gssd, out)
¶
out[t] = bf16(bf16(sum_j tw * bf16(act_j @ W2[e_j]^T * alpha2)) + bf16(sact[t] @ Wsd^T * gssd)).
Source code in vllm/models/flint/ops/moe_gemv.py
gate_up(x, ids, w1, w1_sf, alpha, act, wsh, ssh, gssh, sact)
¶
act[p] = silu_and_mul((x[p // topk] @ W1[ids[p]]^T) * alpha) on fp32 gate/up for the FlashInfer-layout NVFP4 experts (w1 uint8 [E, 2I, H/2]), and in the same launch sact[t] = silu_and_mul(bf16((x[t] @ Wsh^T) * gssh)) for the shared expert (ModelOpt [gate; up] uint8 [2 SI, H/2], flat 128x4-swizzled scales).