pub struct EpMap {
pub n_experts: usize,
pub ranks: usize,
pub entry_rank: usize,
pub layers: BTreeMap<usize, Vec<u8>>,
}Expand description
One parsed placement map: per layer, owners[expert] = rank.
Fields§
§n_experts: usize§ranks: usize§entry_rank: usizeThe first-hop card of the law: the rank the always-active bundle is pinned to. The glm5 TP-2 loader requires 0 (root).
layers: BTreeMap<usize, Vec<u8>>layer index -> owner rank per expert (n_experts entries, each < ranks).
Implementations§
Source§impl EpMap
impl EpMap
Sourcepub fn even_owners(n_experts: usize, ranks: usize) -> Vec<u8> ⓘ
pub fn even_owners(n_experts: usize, ranks: usize) -> Vec<u8> ⓘ
The even split this map format generalizes: rank = expert / (n/ranks),
contiguous halves — byte-for-byte the pre-map arm_moe_ep ownership, and
exactly the tool’s even strategy (the control arm).
Sourcepub fn parse(text: &str) -> Result<EpMap, String>
pub fn parse(text: &str) -> Result<EpMap, String>
Fail-closed parse of a memra-ep-map-v1 JSON document. Every refusal names
the field and the law it broke.
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Deterministic minimal serialization (gate harnesses and tests emit through
this; carries exactly the load-bearing fields, keys in the tool’s sorted
order). The MINT tool is the artifact producer in production — this exists so
the gate’s skew/red maps are real memra-ep-map-v1 documents.
Sourcepub fn validate_layer_cover(&self, ep_layers: &[usize]) -> Result<(), String>
pub fn validate_layer_cover(&self, ep_layers: &[usize]) -> Result<(), String>
Loader-side cover law: the map’s layer set must EXACTLY match the EP-armed MoE layers of the load. A missing layer would silently fall to the even split (the trap this refusal exists for); an extra layer is a map minted for a different arrangement.