One block of the stack. Hover any part for its nnterp name; click to pin the card. The slider picks a block; this family's blocks differ by layer_types.
identity (layers[i].input + self_attn.attention_output + mlp.mlp_output) * layer_scalar == layer_output
The image's path into the text model. Hover any part for its nnterp name; click to pin the card.
max_soft_tokens rows (280); the processor's image_position_ids is (-1, -1) on the padded rows.patch_embeddings is patch_dense's output, before patch_ln2; a factorized 2D position embedding (a learned x and a learned y row per patch, zero on the padded rows) is added after patch_ln2, and pos_norm norms the sum.pos_norm, a LayerNorm, ends the embedder's states, so vision.tower_output is its output; it is not vision.norm.⚠︎ marks a value this checkpoint has only under some load: hover it for the condition.
the vision encoder · Gemma 4 unified embedder
What print(model) shows on google/gemma-4-12B: the native modules, standard names and every standard value with its layout.
Gemma4UnifiedForConditionalGeneration(
(lm_head): Linear(in_features=3840, out_features=262144, bias=False)
(generator): Generator(
(streamer): Streamer()
)
(embed_tokens): Gemma4UnifiedTextScaledWordEmbedding(262144, 3840, padding_idx=0)
(layers): ModuleList(
(0-4): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(5): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(6-10): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(11): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(12-16): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(17): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(18-22): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(23): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(24-28): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(29): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(30-34): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(35): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(36-40): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(41): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(42-46): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(47): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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): Gemma4UnifiedRMSNorm()
(vision): Gemma4UnifiedVisionEmbedder(
(patch_ln1): LayerNorm((6912,), eps=1e-05, elementwise_affine=True, bias=True)
(patch_embed/patch_dense): Linear(in_features=6912, out_features=3840, bias=True)
(patch_ln2): LayerNorm((3840,), eps=1e-05, elementwise_affine=True, bias=True)
(pos_norm): LayerNorm((3840,), eps=1e-05, elementwise_affine=True, bias=True)
(multimodal_embedder): Gemma4UnifiedMultimodalEmbedder(
(embedding_projection): Linear(in_features=3840, out_features=3840, bias=False)
(embedding_pre_projection_norm): Gemma4UnifiedRMSNorm()
)
(tower_output) -> Patches [images patches vision_hidden_size]: The embedder's states over the patches before the projection
(image_token_mask) -> ImageTokenMask [batch seq]: Which positions hold image tokens: input_ids == the config's image_token_id; read-only
(patch_embeddings) -> Patches [images patches vision_hidden_size]: The patch embedding's output, one row per patch
(image_features) -> ImageFeatures [image_tokens hidden_size]: The image features the text model receives at the image tokens, flat over them
)
(projector): Gemma4UnifiedMultimodalEmbedder(
(embedding_projection): Linear(in_features=3840, out_features=3840, bias=False)
(embedding_pre_projection_norm): Gemma4UnifiedRMSNorm()
)
(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
)What print(model) shows on google/gemma-4-12B-it: the native modules, standard names and every standard value with its layout.
Gemma4UnifiedForConditionalGeneration(
(lm_head): Linear(in_features=3840, out_features=262144, bias=False)
(generator): Generator(
(streamer): Streamer()
)
(embed_tokens): Gemma4UnifiedTextScaledWordEmbedding(262144, 3840, padding_idx=0)
(layers): ModuleList(
(0-4): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(5): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(6-10): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(11): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(12-16): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(17): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(18-22): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(23): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(24-28): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(29): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(30-34): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(35): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(36-40): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(41): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(42-46): 5 x Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=4096, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=2048, bias=False)
(v_proj): Linear(in_features=3840, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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
)
(47): Gemma4UnifiedTextDecoderLayer(
(self_attn): Gemma4UnifiedTextAttention(
(q_proj): Linear(in_features=3840, out_features=8192, bias=False)
(q_norm): Gemma4UnifiedRMSNorm()
(k_norm): Gemma4UnifiedRMSNorm()
(v_norm): Gemma4UnifiedRMSNorm()
(k_proj): Linear(in_features=3840, out_features=512, bias=False)
(o_proj): Linear(in_features=8192, out_features=3840, bias=False)
(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_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_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: the post-attention norm's output
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries 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
)
(mlp): Gemma4UnifiedTextMLP(
(gate_proj): Linear(in_features=3840, out_features=15360, bias=False)
(up_proj): Linear(in_features=3840, out_features=15360, bias=False)
(down_proj): Linear(in_features=15360, out_features=3840, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the post-feedforward norm's output
(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
)
(input_layernorm): Gemma4UnifiedRMSNorm()
(post_attention_layernorm): Gemma4UnifiedRMSNorm()
(pre_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(post_feedforward_layernorm): Gemma4UnifiedRMSNorm()
(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
(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
(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): Gemma4UnifiedRMSNorm()
(vision): Gemma4UnifiedVisionEmbedder(
(patch_ln1): LayerNorm((6912,), eps=1e-05, elementwise_affine=True, bias=True)
(patch_embed/patch_dense): Linear(in_features=6912, out_features=3840, bias=True)
(patch_ln2): LayerNorm((3840,), eps=1e-05, elementwise_affine=True, bias=True)
(pos_norm): LayerNorm((3840,), eps=1e-05, elementwise_affine=True, bias=True)
(multimodal_embedder): Gemma4UnifiedMultimodalEmbedder(
(embedding_projection): Linear(in_features=3840, out_features=3840, bias=False)
(embedding_pre_projection_norm): Gemma4UnifiedRMSNorm()
)
(tower_output) -> Patches [images patches vision_hidden_size]: The embedder's states over the patches before the projection
(image_token_mask) -> ImageTokenMask [batch seq]: Which positions hold image tokens: input_ids == the config's image_token_id; read-only
(patch_embeddings) -> Patches [images patches vision_hidden_size]: The patch embedding's output, one row per patch
(image_features) -> ImageFeatures [image_tokens hidden_size]: The image features the text model receives at the image tokens, flat over them
)
(projector): Gemma4UnifiedMultimodalEmbedder(
(embedding_projection): Linear(in_features=3840, out_features=3840, bias=False)
(embedding_pre_projection_norm): Gemma4UnifiedRMSNorm()
)
(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
)layer_scalarh = x + post_attention_layernorm(self_attn(input_layernorm(x)))
h = h + post_feedforward_layernorm(mlp(pre_feedforward_layernorm(h)))
out = h * layer_scalar
attention_output and mlp_output are the post-norms' outputs, before the scalar, and the scalars
are far from one on 12B. A term's weight in the last stream is the product of its own block's scalar
and every later one, so direct logit attribution multiplies each term by that product first, and a
vector added to mlp_output reaches layer_output scaled by the block's scalar.
h = patch_dense(patch_ln1(pixels)) # patch_embeddings
h = pos_norm(patch_ln2(h) + pos_x + pos_y)
out = multimodal_embedder(h) # projector: RMS norm, linear
model.vision is model.model.embed_vision, a Vision with no layers: vision.num_layers is
0 and vision.num_heads, head_dim and intermediate_size raise Unavailable. Each row of
pixel_values is one merged patch of 48 × 48 pixels, 6912 values, and patch_dense maps it
straight to vision.vision_hidden_size (mm_embed_dim, 3840 on 12B). patch_embeddings and
tower_output are the embedder's only values.
The processor fits each image into at most max_soft_tokens merged patches (280) and pads the
row to that length. The padded rows are rows of patch_embeddings, tower_output and
projector.output; the wrapper drops them before the scatter. Select the image's rows with the
processor's positions:
encoding = model.processor(text=prompt, images=[image], return_tensors="pt")
valid = (encoding["image_position_ids"] != -1).all(-1) # [images, 280]
with model.trace(dict(encoding)):
states = model.vision.tower_output.save()
states[valid] # the image's merged patches
vision.tower_output, padded rows includedThe wrapper scatters only the image's rows of the projector's output, so a write to tower_output
at an image's rows reaches the text model and at the padded rows reaches nothing.
An image's tokens attend to every token of the same image, later ones included, on the full blocks and within the window on the sliding ones.
Gemma 4 unified, text (Gemma4UnifiedForCausalLM, model_type gemma4_unified_text): Gemma-4-12B.
Gemma-4's tree and block without per-layer embeddings or a mixture of experts:
the sandwich, then out = (x + post_attention_layernorm(...) + post_feedforward_layernorm(...)) * layer_scalar, in place. The contributions are the
post-norms' outputs, served unscaled, so the identity is
(input + attention_output + mlp_output) * layer_scalar == layer_output. KV
sharing, attention_k_eq_v and the per-layer head_dim are Gemma-4's
(gemma4_text), and so is the attention envoy (keys and values served as
copies private to the block), and so are the root's head_dim and
num_kv_heads: the config's top-level values. A gemma4_unified checkpoint
(Gemma4UnifiedForConditionalGeneration) keeps the text stack at
model.language_model, so RENAME carries both spellings.
The wrapper is encoder-free: no vision tower, no blocks. model.embed_vision
embeds the processor's merged patches (model_patch_size pixels square)
directly: patch_ln1, patch_dense, patch_ln2, a factorized 2D position
embedding, pos_norm, then multimodal_embedder (an RMS norm and a linear
onto the text width, the same projection Gemma-4's embed_vision is). So
vision is the embedder (a Vision with no layers), vision.patch_embed
its patch_dense, and projector its multimodal_embedder, the module
mapping onto the text width as on every other wrapper. The processor pads each
image's patches to max_soft_tokens rows at position (-1, -1), and the
embedder runs on every row; the wrapper strips the padded rows of the
projector's output before scattering, so vision.image_features is read at
the scatter (the first inputs_embeds.masked_scatter of
Gemma4UnifiedModel.forward, an ImageScatter). Audio is embedded the same
way, without blocks: model.embed_audio keeps its native name, and there is no
audio_tower.