Module forward

Module forward 

Source
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§

Glm5NextMlpWorkspace
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_mR tier. Mirror of the ATLAS_MOE_BATCHM_ENTRY list in kernels/gb10/common/w4a16_gemv.cu and of the [KernelHandle; 7] in Glm5NextMlpKernels.
MOE_ROW_UNION_MAX_IDS
🪤 glm5next_moe_row_union is ONE block of rows * top_k threads. A CUDA block is capped at 1024 threads, but this kernel’s own scans are O(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 out whenever this rank shares the experts (EP) or the shared expert (TP) with anyone else.