Expand description
2026-09-25: Glm5NextLayer, the GLM-5.3 decoder layer behind TransformerLayer: a KDA or
DSA mixer, a dense or routed-MoE MLP, and the mHC hyper-connection.
Owner: model-arch (GLM-5.3). Invariants:
- Every norm launches
rms_norm_vanilla(x * w / rms), neverrms_norm, which scales by1 + w. - Highway slots are per token:
decodeuses slot 0,prefillgives prompt tokentslott, anddecode_batchedgives verify rowtslott. - The last text layer collapses the highway with
hc_head_mean, which takes no weights. - Any all-reduce of a mixer or MLP output happens before
hc_postfolds that output into the highway.
One mHC site, as forward_one and forward_k run it:
layer 0 only: hc_expand(hidden) -> streams [hc_mult, hidden] FP32
each site: hc_pre(streams) -> y (into hidden), post, comb
rms_norm_vanilla(y, site norm) -> normed
sublayer(normed) -> out
hc_post(out, residual = streams, post, comb) -> streams
last layer: hc_head_mean(streams) -> hiddenhc_pre only reads streams, so hc_post takes the same buffer as its residual and writes
its result over it.
Re-exports§
pub use state::alloc_kda_ssm_state;
Modules§
- profile
- 2026-09-25: Per-section decode timing for the GLM-5.3 layers, enabled by
METRALE_GLM_PROFILE. - state
- 2026-09-25: Pool-free allocation of a GLM-5.3 KDA layer’s per-sequence state.
Structs§
- Glm5
Next Layer - 2026-09-25: One bound GLM-5.3 decoder layer.
- Glm5
Next Mhc - 2026-09-25: The layer’s hyper-connection: the kernels, each site’s weights, and the config’s
hc_mult,hc_sinkhorn_itersandhc_eps.
Enums§
- Glm5
Next Mixer - 2026-09-25: The layer’s mixer. KDA’s
decodeis an inherent method that takes aKdaSeqStateand a workspace and leaves its output inws.final_out; DSA’sdecodeis theTransformerLayermethod and writes its output over the buffer it was given.Glm5NextLayer::mixer_forwardhandles both. - Glm5
Next MlpSite - 2026-09-25: The layer’s MLP: dense for the layers the config lists in
mlp_only_layers, routed MoE for the rest.
Functions§
- prefill_
rows - 2026-09-25:
PREFILL_ROWS, overridable at launch withMETRALE_GLM_PREFILL_ROWS(values below 1 or unparsable are ignored).1selects the per-token walk:Glm5NextLayer::prefilltakes the batched sub-chunk path only whenrows > 1. A width aboveDENSE_GEMV_BATCHM_MAX_Mchanges the projection numerics as well as the speed.