Module glm5next_mhc

Module glm5next_mhc 

Source
Expand description

2026-09-25: Host launchers for the GLM-5.3 mHC kernels: expand, pre (the hc_mix + hc_finish pair), post, and the head mean.

Owner: model-arch (GLM-5.3). Invariants:

  • Every kernel resolves from GLM5NEXT_MHC_MODULE, none from DeepSeek-V4’s hyper_connection module.
  • glm_hc_pre refuses more tokens than mhc_mix_max_tokens(), the bound the loader sizes each site’s mix scratch from.

Structs§

Glm5NextMhcKernels
2026-09-25: Every kernel the GLM-5.3 hyper-connection launches. Copy: the loader resolves them once and every layer holds a copy.
Glm5NextMhcSiteWeights
2026-09-25: One mHC site’s weights; a layer has one set for the attention site and one for the FFN site.

Constants§

GLM5NEXT_MHC_MODULE
2026-09-25: The kernel module every GLM mHC kernel resolves from.
MHC_MIX_MAX_TOKENS
2026-09-25: The lower bound of mhc_mix_max_tokens().

Functions§

glm_hc_expand
2026-09-25: Broadcast each of num_tokens BF16 hidden rows into its hc_mult FP32 highway streams.
glm_hc_post
2026-09-25: out[j] = post[j] * block_out + Σ_i comb[i][j] * residual[i] for each token. out may alias residual: the kernel reads every residual stream of an element before it writes that element.
glm_hc_pre
2026-09-25: Collapse each token’s hc_mult FP32 streams to one BF16 row in y_out, and write this site’s post and comb, by launching hc_mix (or hc_mix_bf16) then hc_finish. streams is read, not written, so glm_hc_post can take it as its residual. Errors when num_tokens exceeds mhc_mix_max_tokens().
hc_head_mean
2026-09-25: Collapse the highway to one BF16 row per token: the unweighted mean of the hc_mult streams. It takes no weights, unlike DeepSeek-V4’s ops::hc_head.
mhc_mix_max_tokens
2026-09-25: Token bound of each site’s mix scratch, max(prefill_rows(), MHC_MIX_MAX_TOKENS), read once. The loader allocates the scratch from it and glm_hc_pre refuses more tokens than it, so the allocation and the check read one value.
mix_hc
2026-09-25: Row count of hc_fn and hc_base, (2 + hc_mult) * hc_mult: hc_mult rows each for pre and post, then hc_mult * hc_mult for comb.