Skip to content

olmoe

olmoe

OLMoE (OlmoeForCausalLM).

Llama's tree and Llama's block: model.{embed_tokens, layers[i].{input_layernorm, self_attn, post_attention_layernorm, mlp}, norm} and lm_head, the residual added in the block, attention through the shared eager forward. The attention norms its queries and keys (q_norm, k_norm) across all heads before the rotary embedding, and optionally clamps them (clip_qkv); both happen before the interface call, so the queries and keys are read after them. Every MLP is a sparse mixture of experts that returns the routed hidden states as a bare tensor; its experts are intermediate_size wide.

RENAME module-attribute

RENAME = {'model.embed_tokens': 'embed_tokens', 'model.layers': 'layers', 'model.norm': 'norm', 'gate': 'router'}

ENVOYS module-attribute

ENVOYS = {OlmoeDecoderLayer: Layer, OlmoeAttention: Attention, OlmoeSparseMoeBlock: Mlp}

Mlp

Mlp(*args: Any, **kwargs: Any)

Bases: Moe

A mixture of experts: the module returns the routed hidden states as a bare tensor, so the base holds.