default¶
default
¶
The best-effort family, for a model_type no family module covers.
nnterp.families.lookup falls back to this module, with a warning, when the
checkpoint's model_type has neither a module here nor a registered family;
no model_type names it.
It serves what a name guess makes safe. RENAME maps Llama's names over the
spellings the shipped families use for the containers (model,
transformer, gpt_neox, model.decoder, backbone, a multimodal
model.language_model or language_model.model), the embedding, the
blocks, the final norm, the head, and a block's attention, MLP and norms; a key
that does not resolve on a checkpoint is skipped, so one dict serves every
architecture. ENVOYS is keyed on the standard names: nnsight matches a
string key against a module's alias paths as well as its native one, so
"self_attn" reaches GPT-2's attn once RENAME has aliased it, and
"layers.*" reaches every block.
Served: layer_output, the root values, the sizes, and the attention
interior wherever the module calls transformers' shared attention interface
(the base Attention's reads). Not served: attention_output,
mlp_output and project_on_vocab, since what a sublayer adds to the
stream, and what follows lm_head, depend on code a name does not show; nor
any mixture, recurrent-mixer or per-family value. Those need a family module
(docs/extending/adding-a-family.md). check runs at load and raises
UnsupportedFamily when the guess does not hold.
CONTAINERS
module-attribute
¶
CONTAINERS = ('model', 'transformer', 'gpt_neox', 'model.decoder', 'backbone', 'model.language_model', 'language_model.model')
EMBEDDINGS
module-attribute
¶
NORMS
module-attribute
¶
NORMS = ('norm', 'final_layernorm', 'final_layer_norm', 'ln_f', 'norm_f', 'layer_norm', 'final_norm', 'out_norm', 'ln_out')
RENAME
module-attribute
¶
RENAME = {**{f'{container}.{name}': 'embed_tokens' for container in CONTAINERS for name in EMBEDDINGS}, **{f'{container}.{name}': 'layers' for container in CONTAINERS for name in BLOCKS}, **{f'{container}.{name}': 'norm' for container in CONTAINERS for name in NORMS}, 'embed_out': 'lm_head', 'language_model.lm_head': 'lm_head', 'attn': 'self_attn', 'attention': 'self_attn', 'self_attention': 'self_attn', 'norm_attn_norm.attn': 'self_attn', 'feed_forward': 'mlp', 'ffn': 'mlp', 'block_sparse_moe': 'mlp', 'ln_1': 'input_layernorm', 'ln_2': 'post_attention_layernorm', 'norm_1': 'input_layernorm', 'norm_2': 'post_attention_layernorm', 'self_attn_layer_norm': 'input_layernorm', 'out_proj': 'o_proj', 'dense': 'o_proj', 'wo': 'o_proj', 'attn.c_proj': 'attn.o_proj', 'mlp.c_proj': 'mlp.down_proj', 'act': 'act_fn', 'activation_fn': 'act_fn', 'activation': 'act_fn', 'gelu_impl': 'act_fn', 'fc2': 'down_proj', 'dense_4h_to_h': 'down_proj', 'fc_out': 'down_proj', 'w2': 'down_proj', 'output_linear': 'down_proj'}
CONTRIBUTION
module-attribute
¶
CONTRIBUTION = 'the default family cannot tell what this sublayer adds to the stream; add a family module (docs/extending/adding-a-family.md)'
MIXTURE
module-attribute
¶
MIXTURE = 'a mixture of experts (the module has experts, a router or a gate): no single activation or down projection; add a family module (docs/extending/adding-a-family.md)'
LENS
module-attribute
¶
LENS = 'the default family cannot tell what follows lm_head; add a family module (docs/extending/adding-a-family.md)'
project_on_vocab
¶
Not served: what the model does past lm_head (a softcap, a scale) is code a name does not show.
check
¶
Confirm the default's guess on a freshly built model; called by StandardizedTransformer at load.
Raises UnsupportedFamily when the root lacks one of REQUIRED or no
block is a Layer; when, on a shape-only scan (fake tensors, so nothing
loads or computes), block 0 does not take and the blocks do not return a
[batch, seq, hidden_size] stream or the logits do not start [batch,
seq]; and when the scan itself fails, naming the error. Records on each
block whether it returns a tuple.
intermediate_size
¶
The first dense MLP's width off the module (a config can carry a key the model never reads), else the config's intermediate_size / ffn_dim / ffn_hidden_size / n_inner.
An MLP with experts, a router or a gate is a mixture, whose
module width is one expert's, so the config answers there.