Expand description
2026-09-25: The GLM-5.3 MLP forward over rows rows: the dense SwiGLU FFN (also used for the
shared expert) and the routed MoE site.
Owner: model-arch (GLM-5.3). Invariants:
forward_denseandforward_moeleave a partial sum inoutwhen the site is split over TP or EP ranks; the caller all-reduces.forward_moezeroesexpert_outbefore any expert writes it, so an expert another EP rank owns adds zero.
Structs§
- Glm5
Next MlpWorkspace - 2026-09-25: MLP scratch for up to
max_rowsrows, allocated once at load. The buffer sizes are listed inmlp_ws_bytes.
Constants§
- MOE_
ROW_ BATCH_ MAX_ ROWS - 2026-09-25: Widest compiled
w4a16_gemv_sw_moe_batchm_mRtier: theMETRALE_MOE_BATCHM_ENTRY(2..=8)instances inkernels/gb10/common/w4a16_gemv.cu, held at indexR - 2ofGlm5NextMlpKernels::w4a16_gemv_sw_moe_batchm.forward_moesplits a wider row group into sub-groups no wider than this. - MOE_
ROW_ UNION_ MAX_ IDS - 2026-09-25: Most ids
glm5next_moe_row_unionresolves: it runs as one block ofrows * top_kthreads, andforward_moedoes not take the row-batched path above this.
Functions§
- forward_
dense - 2026-09-25: A BF16 SwiGLU MLP of width
inter,down(clamped_swiglu(gate(x), up(x))), for a dense layer or the shared expert. Errors wheninterormdoes not fit the workspace. - forward_
moe - 2026-09-25: One routed MoE site over
rowsrows ofxintoout: router, top-k, routed experts, shared expert, and the weighted combine. - mlp_
ws_ bytes - 2026-09-25: Byte size of each
Glm5NextMlpWorkspacebuffer, in the ordernewallocates them: a_gate, a_up, a_act, logits, ids, wts, expert_out, shared_out, u_eid, u_slot, sorted_token_ids, sorted_expert_ids, expert_offsets, token_to_perm. The loader logs their sum.newcomputes the same sizes on its own, so the two must change together. - mlp_
ws_ shared - 2026-09-25: Whether the text layers share one MLP workspace: yes unless
METRALE_GLM_MLP_WS_SHARED=0. Read once. - mlp_
ws_ total_ bytes - 2026-09-25: Total device bytes of one MLP workspace of
max_rowsrows. - row_
batch_ max - 2026-09-25: Widest sub-group of the row-batched routed path:
METRALE_GLM_MOE_ROW_BATCH_MAX, defaultMOE_ROW_BATCH_MAX_ROWS, clamped to1..=MOE_ROW_BATCH_MAX_ROWS. Read once.