pub struct Glm5NextMlpConfig {Show 14 fields
pub hidden: usize,
pub local_dense_intermediate: usize,
pub moe_intermediate: usize,
pub local_shared_intermediate: usize,
pub num_experts: usize,
pub local_experts: usize,
pub ep_rank: usize,
pub top_k: usize,
pub routed_scale: f32,
pub renormalize: bool,
pub swiglu_limit: f32,
pub router_bf16_ladder: bool,
pub tp_world_size: usize,
pub ep_world_size: usize,
}Expand description
GLM MLP geometry for one rank, read from the checkpoint config — never defaulted.
Fields§
§local_dense_intermediate: usizeintermediate_size — the dense layers’ FFN width, this rank’s share.
moe_intermediate: usizemoe_intermediate_size — one routed expert’s width. Never TP-sharded: an expert is
owned whole by one EP rank.
n_shared_experts * moe_intermediate_size, this rank’s share.
num_experts: usizeFULL routed-expert count (288). Not the local count — see the module header.
local_experts: usizeExperts this rank owns, as a contiguous range [ep_rank * local, +local).
ep_rank: usize§top_k: usize§routed_scale: f32routed_scaling_factor. 🪤 Applied to the top-k WEIGHTS, never to the shared expert.
renormalize: boolnorm_topk_prob — renormalise the top-k weights (with a 1e-20 epsilon, not 1e-6).
swiglu_limit: f32🪤 Asymmetric. See the module header.
router_bf16_ladder: boolTrue reproduces vLLM’s bf16 router ladder; false is HF 5.16.1’s fp32 semantics and the production default. Semantic, not precision — the two select different experts.
tp_world_size: usizeTP ranks the dense/shared FFN is split over. > 1 ⇒ the site output is a partial sum.
ep_world_size: usizeEP ranks the routed experts are split over. > 1 ⇒ the routed sum is a partial sum.
Implementations§
Source§impl Glm5NextMlpConfig
impl Glm5NextMlpConfig
Sourcepub fn from_config(config: &ModelConfig) -> Result<Self>
pub fn from_config(config: &ModelConfig) -> Result<Self>
config carries GLOBAL MoE counts; the TP division of the dense/shared widths and the EP
division of the expert set are applied here, in one place.
Sourcepub fn local_expert_range(&self) -> Range<usize>
pub fn local_expert_range(&self) -> Range<usize>
The half-open global expert-id range this rank owns.
Sourcepub fn local_slot(&self, global_id: usize) -> Option<usize>
pub fn local_slot(&self, global_id: usize) -> Option<usize>
Global expert id → local slot, or None when another rank owns it.
🪤 The whole EP scheme rests on this: a remote id must contribute zero, not be clamped into a local slot. Indexing a local array with a global id is the silent version of that mistake and yields a real expert’s weights for the wrong token.
Sourcepub fn needs_all_reduce(&self) -> bool
pub fn needs_all_reduce(&self) -> bool
Whether the site output leaves this rank as a partial sum needing all_reduce(SUM).
pub fn validate(&self) -> Result<()>
Trait Implementations§
Source§impl Clone for Glm5NextMlpConfig
impl Clone for Glm5NextMlpConfig
Source§fn clone(&self) -> Glm5NextMlpConfig
fn clone(&self) -> Glm5NextMlpConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more