nnterp · encyclopedia falcon_h1 · nnterp.families.falcon_h1

family falcon_h1

Falcon-H1

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
→
logitsscaled
i = 0

identity layers[i].input + (linear_attn.attention_output + 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 FalconH1ForCausalLMlayoutwhat 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] FalconH1DecoderLayerlayoutwhat 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].mlp FalconH1MLPlayoutwhat 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

model.layers[i].linear_attn FalconH1Mixerlayoutwhat it isread at
attention_output Residual [batch seq hidden_size] What the Mamba-2 mixer adds to the residual stream: its output times ssm_out_multiplier

the sibling module source.mamba_hidden_states_1's output

⚠︎state scalar Unavailable: the chunk scan computes every token's state in one tensor per call, not one occurrence per token to walk with tracer.iter; read states, or state_after(t), after nnterp.chunk_per_token(model)

nowhere: the family does not serve it

⚠︎states States [batch seq heads key_dim value_dim] The state after every token of this call; needs nnterp.chunk_per_token(model)

computed from other values read in the same call

⚠︎attention_queries SSDQueries [batch seq groups state_dim] C, the queries reading the state

inside the forward: the arguments of the kernel this call runs (a prompt's chunked one or a decode step's recurrent one), argument C

⚠︎attention_keys SSDKeys [batch seq groups state_dim] B, the keys writing into the state

inside the forward: the arguments of the kernel this call runs (a prompt's chunked one or a decode step's recurrent one), argument B

⚠︎attention_values SSDValues [batch seq heads head_dim] x, the values written into the state

inside the forward: the arguments of the kernel this call runs (a prompt's chunked one or a decode step's recurrent one), argument hidden_states

⚠︎betas Gates [batch seq heads] dt, the per-token write strength into the state

inside the forward: the arguments of the kernel this call runs (a prompt's chunked one or a decode step's recurrent one), argument dt

⚠︎decays Gates [batch seq heads] A * dt, the per-token log decay of the state

inside the forward: the arguments of the kernel this call runs (a prompt's chunked one or a decode step's recurrent one), argument dt

⚠︎state_input State | None [batch heads key_dim value_dim] The state entering the layer, or None at the start of a prompt (a copy of the cache's buffer)

inside the forward: the arguments of the kernel this call runs (a prompt's chunked one or a decode step's recurrent one), argument state

⚠︎attention_head_outputs SSDHeadOutputs [batch seq heads head_dim] y, the per-head outputs before the gated norm and the output projection

inside the forward: the output of the kernel this call runs (a prompt's chunked one or a decode step's recurrent one), the element that call returns it in

⚠︎state_output State [batch heads key_dim value_dim] The state leaving the layer

inside the forward: at or inside the kernel this call runs (a prompt's chunked one or a decode step's recurrent one), the element that call returns it in

set_state_after scalar Unavailable: the chunk scan computes every boundary state in one cumulative step from the initial state, so a state written at token t does not flow into later tokens' states; assign state_input to change where a call starts

nowhere: the family does not serve it

model.layers[i].self_attn FalconH1Attentionlayoutwhat it isread at
attention_queries_prerope Queries [batch num_heads seq qk_head_dim] The queries entering the rotary embedding

inside the forward: the arguments of apply_rotary_pos_emb_0, element 0

attention_keys_prerope Keys [batch num_kv_heads seq qk_head_dim] The keys entering the rotary embedding

inside the forward: the arguments of apply_rotary_pos_emb_0, element 1

⚠︎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: its output times attention_out_multiplier

the sibling module source.attention_hidden_states_0's 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

⚠︎interface method (Queries, Keys, Values) -> (HeadOutputs, Pattern) The attention function this call ran, as f(queries, keys, values) -> (head outputs, pattern), with the rest of the call's arguments

read at the arguments of attention_interface_1, with the queries, keys and values; called, the function that call ran, on the tensors given and the call's other arguments

Printout

What print(model) shows on tiiuae/Falcon-H1-0.5B-Base: the native modules, standard names and every standard value with its layout.

FalconH1ForCausalLM(
  (lm_head): Linear(in_features=1024, out_features=32784, bias=False)
  (generator): Generator(
    (streamer): Streamer()
  )
  (embed_tokens): Embedding(32784, 1024, padding_idx=0)
  (layers): ModuleList(
    (0-35): 36 x FalconH1DecoderLayer(
      (mlp/feed_forward): FalconH1MLP(
        (gate_proj): Linear(in_features=1024, out_features=2048, bias=False)
        (up_proj): Linear(in_features=1024, out_features=2048, bias=False)
        (down_proj): Linear(in_features=2048, out_features=1024, bias=False)
        (act_fn): SiLUActivation()
        (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
      )
      (linear_attn/mamba): FalconH1Mixer(
        (act): SiLUActivation()
        (conv1d): Conv1d(1792, 1792, kernel_size=(4,), stride=(1,), padding=(3,), groups=1792)
        (in_proj): Linear(in_features=1024, out_features=3352, bias=False)
        (norm): Identity()
        (out_proj): Linear(in_features=1536, out_features=1024, bias=False)
        (attention_output) -> Residual [batch seq hidden_size]: What the Mamba-2 mixer adds to the residual stream: its output times ssm_out_multiplier
        (attention_queries) -> SSDQueries [batch seq groups state_dim]: C, the queries reading the state
        (attention_keys) -> SSDKeys [batch seq groups state_dim]: B, the keys writing into the state
        (attention_values) -> SSDValues [batch seq heads head_dim]: x, the values written into the state
        (betas) -> Gates [batch seq heads]: dt, the per-token write strength into the state
        (decays) -> Gates [batch seq heads]: A * dt, the per-token log decay of the state
        (state_input) -> State | None [batch heads key_dim value_dim]: The state entering the layer, or None at the start of a prompt (a copy of the cache's buffer)
        (attention_head_outputs) -> SSDHeadOutputs [batch seq heads head_dim]: y, the per-head outputs before the gated norm and the output projection
        (state_output) -> State [batch heads key_dim value_dim]: The state leaving the layer
        (states) -> States [batch seq heads key_dim value_dim]: The state after every token of this call; needs nnterp.chunk_per_token(model)
        (state): Unavailable: the chunk scan computes every token's state in one tensor per call, not one occurrence per token to walk with tracer.iter; read states, or state_after(t), after nnterp.chunk_per_token(model)
        (set_state_after): Unavailable: the chunk scan computes every boundary state in one cumulative step from the initial state, so a state written at token t does not flow into later tokens' states; assign state_input to change where a call starts
      )
      (self_attn): FalconH1Attention(
        (q_proj): Linear(in_features=1024, out_features=512, bias=False)
        (k_proj): Linear(in_features=1024, out_features=128, bias=False)
        (v_proj): Linear(in_features=1024, out_features=128, bias=False)
        (o_proj): Linear(in_features=512, out_features=1024, bias=False)
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: its output times attention_out_multiplier
        (attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
        (attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
        (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_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
        (interface): The attention function this call ran, as f(queries, keys, values) -> (head outputs, pattern), with the rest of the call's arguments
      )
      (input_layernorm): FalconH1RMSNorm((1024,), eps=1e-05)
      (post_attention_layernorm/pre_ff_layernorm): FalconH1RMSNorm((1024,), 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): FalconH1RMSNorm((1024,), 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_size1024
model.num_heads8
model.num_kv_heads2
model.head_dim64
model.qk_head_dim64
model.vocab_size32784
model.intermediate_size2048
architecturesFalconH1ForCausalLM
num_hidden_layers36
hidden_size1024
intermediate_size2048
num_attention_heads8
num_key_value_heads2
head_dim64
vocab_size32784
max_position_embeddings16384
hidden_actsilu
rms_norm_eps1e-05
tie_word_embeddingsFalse
dtypebfloat16
embedding_multiplier5.656854249492381
mamba_n_heads24
mamba_d_head64
mamba_d_state128
mamba_expand2
mamba_chunk_size128
mamba_n_groups1
mamba_rms_normFalse
ssm_in_multiplier1.25
ssm_out_multiplier0.23570226039551587
attention_in_multiplier1.0
attention_out_multiplier0.9375
key_multiplier0.39062499999999994
lm_head_multiplier0.0390625
attention_biasFalse

The Notes

03 · what to know before you run

Each mixer's contribution is its output times a multiplier

n   = input_layernorm(x)
h   = x + mamba(n) * ssm_out_multiplier + self_attn(n) * attention_out_multiplier
out = h + mlp(post_attention_layernorm(h))

Each mixer's attention_output is the module's output times its multiplier, the tensor the block adds; linear_attn.output and self_attn.output[0] are unscaled. Patch, ablate and decompose through the two attention_output values.

The prompt's first token is an attention sink

The tokenizer adds no beginning-of-sequence token, so the prompt's first token takes much of the attention and, in the middle blocks, its stream has a norm many times the other positions'. Leave position 0 out of activation statistics and steering-vector norms.

From the family module

04 · nnterp/families/falcon_h1.py

Falcon-H1 (FalconH1ForCausalLM).

Llama's containers over a parallel hybrid block: every block runs a Mamba-2 mixer and attention side by side on the same normed input, then an MLP::

model.layers[i]          FalconH1DecoderLayer
    .input_layernorm
    .mamba               FalconH1Mixer, an SSD mixer
    .self_attn           FalconH1Attention
    .pre_ff_layernorm
    .feed_forward        FalconH1MLP

h = x + mamba(n) * ssm_out_multiplier + self_attn(n * attention_in_multiplier) * attention_out_multiplier
out = h + feed_forward(pre_ff_layernorm(h))          with n = input_layernorm(x)

mamba is linear_attn (nnterp.StateSpace), feed_forward is mlp and pre_ff_layernorm is post_attention_layernorm. Every block has both mixers, so the contribution identity has four terms, input + self_attn.attention_output + linear_attn.attention_output + mlp_output == layer_output.

The config's µP multipliers, and where each is handled:

  • ssm_out_multiplier / attention_out_multiplier: the block scales each mixer's output before adding it, so attention_output on each is that product, the block's own binding of it (mamba_hidden_states_1, attention_hidden_states_0): the tensor the block adds, so reads, writes and in-place edits need no arithmetic.
  • lm_head_multiplier: the model multiplies the head's output by it, so the family defines project_on_vocab with that step.
  • embedding_multiplier: the model multiplies the embedding module's output by it before the first block, so token_embeddings (the module's output) times the multiplier is layers[0].input.
  • attention_in_multiplier: the attention's input is the normed stream times it (1.0 on the released checkpoints), so self_attn.input is the norm's output only then.
  • mlp_multipliers, key_multiplier, ssm_in_multiplier, ssm_multipliers: applied inside the MLP, the attention and the mixer; the values read where the forward already applied them.

With mamba_rms_norm false the decode step passes the gate into the update kernel, so a decode step's attention_head_outputs is gated by silu(z) where a prompt's is not; with it true (Falcon-H1 1.5B and up, H1R-7B) both are ungated. Falcon-H1-0.5B and the Falcon-H1-Tiny checkpoints set it false, and their linear_attn.norm is an identity. The block returns a one-element tuple.