expert_router_bytes

Function expert_router_bytes 

Source
pub fn expert_router_bytes(
    cfg: &ModelConfig,
    expert_keys: &[(usize, ExpertProj)],
    router_layers: &[usize],
    max_rank: usize,
) -> usize
Expand description

Pure padded-byte estimator for the (separate) expert/router pool, used by the VRAM preflight and pinned by a golden unit test — mirrors super::pool_slot_bytes but over the audited routed-expert + router key set (real adapters target a SUBSET, so this is sized from the audit, never from num_experts × num_layers maxima). Per (layer, expert, proj) and per router layer: (stride·in + out·stride)·2 BF16 bytes, where stride is the DERIVED uint4-aligned expert_pack::packed_stride of max_rank — the same derivation the pack loop uses (SSOT), so sizing and packing agree byte-for-byte even at a non-multiple-of-8 rank cap.