Expand description
2026-09-25: GLM-5.3-Flash MLP: the dense SwiGLU FFN and the routed NVFP4 MoE, their kernels and per-rank geometry.
Owner: model-arch (GLM-5.3). Invariants:
Glm5NextMlpConfig::from_configreturns a config only when the dense and shared widths divide overtp_world_size,num_expertsdivides overep_world_size, andvalidatepasses.- For such configs, the
local_expert_ranges of ranks0..ep_world_sizepartition0..num_experts, andlocal_slotisNonefor every id outside this rank’s range.
§One all-reduce for both EP and TP
With TP or EP above 1, a routed site’s output is a partial sum on every rank: the shared
expert is TP-sharded (local_shared_intermediate) and each rank runs only the experts it
owns. forward::forward_moe adds the shared output and the routed slots in one combine
kernel, and the layer then reduces that output once. The combine has to come before the
reduce: adding a TP-sharded shared expert after the reduce would drop the other ranks’
part of it.
§Numerics the kernels rely on
- The SwiGLU clamp is asymmetric:
gateis bounded above only,upon both sides. The limit isModelConfig::swiglu_limit, which theglm5_nextparser refuses to default. - The router’s correction bias steers selection only. The emitted weight is the chosen expert’s unbiased sigmoid score.
routed_scaling_factormultiplies the top-k weights; the shared expert is added unscaled.- Every rank holds the whole router and ranks all
num_experts, so for the same input every rank selects the same ids. Sharding the router would give each rank different partial logits and a different top-k. num_expertsis the full routed-expert count;local_expertsis this rank’s share.glm5next_router_topkmust be given the full count.
Re-exports§
pub use weights::Glm5NextDenseMlpWeights;pub use weights::Glm5NextExpertWeights;pub use weights::Glm5NextMoeWeights;
Modules§
- build
- 2026-09-25: Bind one GLM-5.3 MLP site for a rank: TP-slice the dense FFN or shared expert, and build the routed experts’ pointer tables over GLOBAL expert ids.
- forward
- 2026-09-25: The GLM-5.3 MLP forward over
rowsrows: the dense SwiGLU FFN (also used for the shared expert) and the routed MoE site. - forward_
prefill_ gemm - 2026-09-25: Routed-MoE prefill for GLM-5.3 through the shared grouped W4A16 GEMM
(
moe_w4a16_grouped_gemm_ptrtableand its tile variants): one launch per projection for all experts.tile.rsholds the tile table and the env levers,dispatch.rsthe launch. - weights
- 2026-09-25: Device weight handles for one GLM-5.3 MLP site, already sharded for this rank.
Structs§
- Glm5
Next MlpConfig - 2026-09-25: GLM MLP geometry for one rank, built by
Self::from_config. - Glm5
Next MlpKernels - 2026-09-25: The kernels a GLM MLP site launches.
Enums§
- Glm5
Next MlpKind - 2026-09-25: Which MLP a layer runs; the same variants as
crate::glm5next_skeleton::Mlp.
Constants§
- FFN_
MODULE - 2026-09-25: Module of
kernels/gb10/common/glm5next_ffn.cu. A.cufile not listed incommon/KERNEL.toml’s[modules]resolves under its file stem; the listed ones below do not, so each module name here is checked against that table. - GEMM_
MODULE - 2026-09-25:
[modules]:dense_gemm_bf16 = "gemm". - KERNEL_
MAX_ TOP_ K - 2026-09-25: The most experts
glm5next_router_topkcan select per token: its per-token selection lives in the shared arrayssel_id[16]andsel_w[16]. - MOE_
GROUPED_ MODULE - 2026-09-25:
[modules]:moe_w4a16_grouped_gemm = "moe_w4a16", the tensor-core grouped W4A16 GEMM. - MOE_
MODULE - 2026-09-25:
[modules]:moe_permute = "moe", the token sort / permute / unpermute kernels. - W4A16_
GEMV_ MODULE - 2026-09-25: Module of
w4a16_gemv.cu(not in[modules], so its file stem). Its GEMV kernels run every routed-expert projection except the grouped prefill GEMM. - W4A16_
MODULE - 2026-09-25:
[modules]:w4a16_gemm = "w4a16".