Expand description
The GLM MLP decode forward — dense FFN and routed MoE, one token.
Launch geometry is lifted verbatim from the two gated microtests
(examples/glm5next_{ffn,moe}_microtest.rs, Slice-10 gates 3/4/6/7), which measured this
exact sequence against HF 5.16.1 on real layer-0 and layer-3 weights. Nothing here
re-derives the equations.
Structs§
- Glm5
Next MlpWorkspace - Scratch for one MLP site, allocated once and reused every decode step.
Constants§
- MOE_
ROW_ BATCH_ MAX_ ROWS - Widest compiled
w4a16_gemv_sw_moe_batchm_mRtier. Mirror of theATLAS_MOE_BATCHM_ENTRYlist inkernels/gb10/common/w4a16_gemv.cuand of the[KernelHandle; 7]inGlm5NextMlpKernels. - MOE_
ROW_ UNION_ MAX_ IDS - 🪤
glm5next_moe_row_unionis ONE block ofrows * top_kthreads. A CUDA block is capped at 1024 threads, but this kernel’s own scans areO(T^2)/O(T^3)over that extent and the tier family was sized around 64, so 64 is the contract. Threads past a block never run: exceeding it would SILENTLY drop union entries, so the dispatch refuses instead.
Functions§
- forward_
dense - A BF16 SwiGLU MLP of width
inter:down(clamped_swiglu(gate(x), up(x))). - forward_
moe - One routed MoE site, one token. Leaves a partial sum in
outwhenever this rank shares the experts (EP) or the shared expert (TP) with anyone else.