nnterp · encyclopedia arcee · nnterp.families.arcee

family arcee

Arcee AFM

Llama's block whose MLP has no gate: up_proj, a squared ReLU and down_proj, so a neuron is exactly zero wherever its pre-activation is negative.

The block

01 · the residual stream

One block of the stack. Hover any part for its nnterp name; click to pin the card.

embed_tokenstoken_embeddings
→
layers× 36
→
normfinal_norm_output
→
lm_headlm_head_output
→
logitsthe output
i = 0

identity layers[i].input + self_attn.attention_output + mlp.mlp_output == layer_output

The API

02 · support()

Values, by host

⚠︎ marks a value this checkpoint has only under some load: hover it for the condition.

model ArceeForCausalLMlayoutwhat it isread at
logits Logits [batch seq vocab_size] The logits the model returns, after anything it does past lm_head (a softcap, a scale)

the module's own output

token_embeddings Residual [batch seq hidden_size] The embedding module's output; layers[0].input is what enters the first block

the child module embed_tokens's output

final_norm_output Residual [batch seq hidden_size] The residual stream after the final norm, what lm_head reads

the child module norm's output

lm_head_output Logits [batch seq vocab_size] The head's logits before anything the model does past lm_head (a softcap, a scale)

the child module lm_head's output

next_token_probs NextTokenProbs [batch vocab_size] The next-token distribution at the last position; derived, read-only

the module's own output

input_ids Tokens [batch seq] The token ids the model was called with

the module's own input

attention_mask Tokens [batch seq] The attention mask the model was called with; zeros are padding

the module's own input

input_size scalar [batch, seq] of the current call; read-only

the module's own input

model.layers[i] ArceeDecoderLayerlayoutwhat it isread at
layer_input Residual [batch seq hidden_size] The residual stream entering the block

the module's own input

attention_norm_output Residual [batch seq hidden_size] The normed stream entering the attention

the child module input_layernorm's output

layer_mid Residual [batch seq hidden_size] The residual stream after the attention add

the child module post_attention_layernorm's input

mlp_norm_output Residual [batch seq hidden_size] The normed stream entering the MLP

the child module post_attention_layernorm's output

mlp_input Residual [batch seq hidden_size] What the MLP is called with

the child module mlp's input

layer_output Residual [batch seq hidden_size] The residual stream leaving the block, a tensor even when the block returns a tuple

the module's own output

model.layers[i].self_attn ArceeAttentionlayoutwhat it isread at
⚠︎attention_queries Queries [batch num_heads seq qk_head_dim] The queries entering attention

inside the forward: the arguments of attention_interface_1, element 1

⚠︎attention_keys Keys [batch num_kv_heads seq qk_head_dim] The keys entering attention

inside the forward: the arguments of attention_interface_1, element 2

⚠︎attention_values Values [batch num_kv_heads seq head_dim] The values entering attention

inside the forward: the arguments of attention_interface_1, element 3

⚠︎attention_scores Pattern [batch num_heads query key] The attention scores entering the softmax, masked

inside the forward: the input of nn_functional_softmax_0 inside attention_interface_1

attention_premix HeadOutputs [batch seq num_heads head_dim] Every head's output side by side, as the output projection takes it

the child module o_proj's input

attention_output Residual [batch seq hidden_size] What the attention adds to the residual stream

the module's own output

⚠︎attention_probabilities Pattern [batch num_heads query key] The attention pattern the values are mixed with

inside the forward: the output of nn_functional_dropout_0 inside attention_interface_1

⚠︎attention_head_outputs HeadOutputs [batch seq num_heads head_dim] The per-head outputs before the output projection

inside the forward: the output of attention_interface_1, element 0

model.layers[i].mlp ArceeMLPlayoutwhat it isread at
mlp_activation Neurons [batch seq intermediate_size] The activation function's output

the child module act_fn's output

mlp_neurons Neurons [batch seq intermediate_size] What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise

the child module down_proj's input

mlp_output Residual [batch seq hidden_size] What the MLP adds to the residual stream

the module's own output

Printout

What print(model) shows on arcee-ai/AFM-4.5B-Base: the native modules, standard names and every standard value with its layout.

ArceeForCausalLM(
  (lm_head): Linear(in_features=2560, out_features=128004, bias=False)
  (generator): Generator(
    (streamer): Streamer()
  )
  (embed_tokens): Embedding(128004, 2560)
  (layers): ModuleList(
    (0-35): 36 x ArceeDecoderLayer(
      (self_attn): ArceeAttention(
        (q_proj): Linear(in_features=2560, out_features=2560, bias=False)
        (k_proj): Linear(in_features=2560, out_features=512, bias=False)
        (v_proj): Linear(in_features=2560, out_features=512, bias=False)
        (o_proj): Linear(in_features=2560, out_features=2560, bias=False)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp): ArceeMLP(
        (up_proj): Linear(in_features=2560, out_features=18432, bias=False)
        (down_proj): Linear(in_features=18432, out_features=2560, bias=False)
        (act_fn): ReLUSquaredActivation()
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream
      )
      (input_layernorm): ArceeRMSNorm((2560,), eps=1e-05)
      (post_attention_layernorm): ArceeRMSNorm((2560,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
  )
  (norm): ArceeRMSNorm((2560,), eps=1e-05)
  (logits) -> Logits [batch seq vocab_size]: The logits the model returns, after anything it does past lm_head (a softcap, a scale)
  (token_embeddings) -> Residual [batch seq hidden_size]: The embedding module's output; layers[0].input is what enters the first block
  (final_norm_output) -> Residual [batch seq hidden_size]: The residual stream after the final norm, what lm_head reads
  (lm_head_output) -> Logits [batch seq vocab_size]: The head's logits before anything the model does past lm_head (a softcap, a scale)
  (next_token_probs) -> NextTokenProbs [batch vocab_size]: The next-token distribution at the last position; derived, read-only
  (input_ids) -> Tokens [batch seq]: The token ids the model was called with
  (attention_mask) -> Tokens [batch seq]: The attention mask the model was called with; zeros are padding
  (input_size): [batch, seq] of the current call; read-only
)

Config

model.num_layers36
model.hidden_size2560
model.num_heads20
model.num_kv_heads4
model.head_dim128
model.qk_head_dim128
model.vocab_size128004
model.intermediate_size18432
architecturesArceeForCausalLM
num_hidden_layers36
hidden_size2560
intermediate_size18432
num_attention_heads20
num_key_value_heads4
head_dim128
vocab_size128004
max_position_embeddings65536
hidden_actrelu2
rms_norm_eps1e-05
tie_word_embeddingsFalse
dtypebfloat16
attention_biasFalse

The Notes

03 · what to know before you run

The block, in order

h   = x + self_attn(input_layernorm(x))
out = h + mlp(post_attention_layernorm(h))
mlp(z) = down_proj(relu(up_proj(z)) ** 2)

Llama's names and Llama's two pre-norms. The MLP has two projections where Llama's has three: there is no gate_proj, and up_proj widens the normed stream to intermediate_size (18432 on 4.5B, 7.2 × hidden_size).

The contributions are the modules' outputs

attention_output is self_attn.output[0] and mlp_output is mlp.output, added to the stream with nothing in between. The identity holds exactly in float32 on the pinned checkpoint:

with model.trace(prompt):
    x = model.layers[1].input.save()
    attn = model.layers[1].self_attn.attention_output.save()
    mlp = model.layers[1].mlp.mlp_output.save()
    out = model.layers[1].layer_output.save()

torch.testing.assert_close(x + attn + mlp, out)

A neuron is relu(x)², exactly zero below zero

hidden_act is relu2 on every checkpoint, so mlp.act_fn is a ReLUSquaredActivation and a neuron's activation is relu(up_proj(z))². The activation is exactly zero wherever the pre-activation is negative, so a neuron that is off on a token has no effect on that token and receives no gradient from it, since the derivative of relu(x)² is 2 · relu(x). Where the neuron is on, its activation grows with the square of the pre-activation. mlp.down_proj.input holds the activations and mlp.up_proj.output the pre-activations:

mlp = model.layers[1].mlp
with model.trace(prompt):
    pre = mlp.up_proj.output.save()
    acts = mlp.down_proj.input.save()

torch.equal(acts, torch.relu(pre) ** 2)   # True

Grouped-query attention, 128-wide heads

The 4.5B checkpoints have 20 query heads over 4 key/value heads, each 128 wide (head_dim), so num_heads × head_dim equals hidden_size (2560). attention_keys and attention_values are read before repeat_kv, [batch, 4, seq, 128], and an edit to key/value head j reaches query heads 5j to 5j + 4. No projection has a bias (attention_bias and mlp_bias are false).

Loading and positions

The six attention interior values need attn_implementation="eager". There is no softcap, window or sink, so the default sdpa load computes the same function. AFM-4.5B, Base and Preview stretch the rotary with YaRN, factor 20 over 4096 original positions, to 65536. Transformers warns at load that max_position_embeddings / original_max_position_embeddings is 16 and uses the explicit 20. AFM-4.5B-Base-Pre-Anneal has the plain rotary and 4096 positions. rope_theta is 10000 throughout.

Tokenizer and templates

Every tokenizer prepends <|begin_of_text|> (id 128000), and " Paris" is one token. The embedding matrices differ in size (vocab_size): 128004 rows on Base, 128005 on AFM-4.5B, 128064 on Preview (whose tokenizer has 128005 ids), 128256 on Pre-Anneal. AFM-4.5B's chat template is ChatML (<|im_start|>, <|im_end|>) and writes a default system turn naming the model when the messages have none; its eos_token is <|im_end|>, Base's <|end_of_text|>.

What loads as this family

AFM-4.5B, its Base, Preview and Base-Pre-Anneal are arcee. The AFM-4.5B-Base-KDA-Only and -KDA-NoPE conversions are arcee_kda, a remote-code architecture, and Arcee's Trinity models are the afmoe family.

From the family module

04 · nnterp/families/arcee.py

Arcee (AFM) (ArceeForCausalLM).

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 MLP has no gate: down_proj(act(up_proj(x))) with ReLU squared.