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’shyper_connectionmodule. glm_hc_prerefuses more tokens thanmhc_mix_max_tokens(), the bound the loader sizes each site’smixscratch from.
Structs§
- Glm5
Next MhcKernels - 2026-09-25: Every kernel the GLM-5.3 hyper-connection launches.
Copy: the loader resolves them once and every layer holds a copy. - Glm5
Next MhcSite Weights - 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_tokensBF16 hidden rows into itshc_multFP32 highway streams. - glm_
hc_ post - 2026-09-25:
out[j] = post[j] * block_out + Σ_i comb[i][j] * residual[i]for each token.outmay aliasresidual: 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_multFP32 streams to one BF16 row iny_out, and write this site’spostandcomb, by launchinghc_mix(orhc_mix_bf16) thenhc_finish.streamsis read, not written, soglm_hc_postcan take it as its residual. Errors whennum_tokensexceedsmhc_mix_max_tokens(). - hc_
head_ mean - 2026-09-25: Collapse the highway to one BF16 row per token: the unweighted mean of the
hc_multstreams. It takes no weights, unlike DeepSeek-V4’sops::hc_head. - mhc_
mix_ max_ tokens - 2026-09-25: Token bound of each site’s
mixscratch,max(prefill_rows(), MHC_MIX_MAX_TOKENS), read once. The loader allocates the scratch from it andglm_hc_prerefuses more tokens than it, so the allocation and the check read one value. - mix_hc
- 2026-09-25: Row count of
hc_fnandhc_base,(2 + hc_mult) * hc_mult:hc_multrows each for pre and post, thenhc_mult * hc_multfor comb.