family gemma4_text
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.
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.
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.
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 + per_layer_output) * layer_scalar == layer_output
The image's path into the text model, then one block of the vision encoder. Hover any part for its nnterp name; click to pin the card.
max_soft_tokens * pooling_kernel_size**2 rows (2520 by default); the processor's image_position_ids is (-1, -1) on the padded rows.patch_embeddings is patch_embedder.input_proj's output; patch_embedder then adds a learned x and a learned y embedding per patch (zero on the padded rows), and every attention rotates queries and keys by the patch's 2D position.vision.tower_output is the encoder's output, padded rows included, and the vision encoder's pooler follows it, outside the blocks.identity vision.layers[i].input + self_attn.attention_output + mlp.mlp_output == layer_output
The image's path into the text model, then one block of the vision encoder. Hover any part for its nnterp name; click to pin the card.
max_soft_tokens * pooling_kernel_size**2 rows (2520 by default); the processor's image_position_ids is (-1, -1) on the padded rows.patch_embeddings is patch_embedder.input_proj's output; patch_embedder then adds a learned x and a learned y embedding per patch (zero on the padded rows), and every attention rotates queries and keys by the patch's 2D position.vision.tower_output is the encoder's output, padded rows included, and the vision encoder's pooler follows it, outside the blocks.identity vision.layers[i].input + self_attn.attention_output + mlp.mlp_output == layer_output
⚠︎ marks a value this checkpoint has only under some load: hover it for the condition.
the vision encoder · Gemma 4 ViT
⚠︎ marks a value this checkpoint has only under some load: hover it for the condition.
the vision encoder · Gemma 4 ViT
⚠︎ marks a value this checkpoint has only under some load: hover it for the condition.
the vision encoder · Gemma 4 ViT
⚠︎ marks a value this checkpoint has only under some load: hover it for the condition.
the vision encoder · Gemma 4 ViT
What print(model) shows on google/gemma-4-E2B: the native modules, standard names and every standard value with its layout.
Gemma4ForConditionalGeneration(
(lm_head): Linear(in_features=1536, out_features=262144, bias=False)
(generator): Generator(
(streamer): Streamer()
)
(embed_tokens): Gemma4TextScaledWordEmbedding(262144, 1536, padding_idx=0)
(layers): ModuleList(
(0-3): 4 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=1536, out_features=256, bias=False)
(v_proj): Linear(in_features=1536, out_features=256, bias=False)
(o_proj): Linear(in_features=2048, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=6144, bias=False)
(up_proj): Linear(in_features=1536, out_features=6144, bias=False)
(down_proj): Linear(in_features=6144, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(4): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=1536, out_features=512, bias=False)
(v_proj): Linear(in_features=1536, out_features=512, bias=False)
(o_proj): Linear(in_features=4096, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=6144, bias=False)
(up_proj): Linear(in_features=1536, out_features=6144, bias=False)
(down_proj): Linear(in_features=6144, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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-8): 4 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=1536, out_features=256, bias=False)
(v_proj): Linear(in_features=1536, out_features=256, bias=False)
(o_proj): Linear(in_features=2048, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=6144, bias=False)
(up_proj): Linear(in_features=1536, out_features=6144, bias=False)
(down_proj): Linear(in_features=6144, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(9): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=1536, out_features=512, bias=False)
(v_proj): Linear(in_features=1536, out_features=512, bias=False)
(o_proj): Linear(in_features=4096, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=6144, bias=False)
(up_proj): Linear(in_features=1536, out_features=6144, bias=False)
(down_proj): Linear(in_features=6144, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(10-13): 4 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=1536, out_features=256, bias=False)
(v_proj): Linear(in_features=1536, out_features=256, bias=False)
(o_proj): Linear(in_features=2048, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=6144, bias=False)
(up_proj): Linear(in_features=1536, out_features=6144, bias=False)
(down_proj): Linear(in_features=6144, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(14): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=1536, out_features=512, bias=False)
(v_proj): Linear(in_features=1536, out_features=512, bias=False)
(o_proj): Linear(in_features=4096, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=6144, bias=False)
(up_proj): Linear(in_features=1536, out_features=6144, bias=False)
(down_proj): Linear(in_features=6144, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(15-18): 4 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=2048, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(19): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=4096, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(20-23): 4 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=2048, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=4096, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(25-28): 4 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=2048, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=4096, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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-33): 4 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=2048, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(34): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=4096, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4RMSNorm()
(vision): Gemma4VisionModel(
(encoder): Gemma4VisionEncoder(
(rotary_emb): Gemma4VisionRotaryEmbedding()
(layers): ModuleList(
(0-15): 16 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=3072, out_features=768, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
)
(pooler): Gemma4VisionPooler()
(patch_embed): Linear(in_features=768, out_features=768, bias=False)
(layers): ModuleList(
(0-15): 16 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=3072, out_features=768, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
(tower_output) -> Patches [images patches vision_hidden_size]: The last block's stream after the tower's final norm, before any pooling or adapter
(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): Gemma4MultimodalEmbedder(
(embedding_projection): Linear(in_features=768, out_features=1536, bias=False)
(embedding_pre_projection_norm): Gemma4RMSNorm()
)
(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-E2B-it: the native modules, standard names and every standard value with its layout.
Gemma4ForConditionalGeneration(
(lm_head): Linear(in_features=1536, out_features=262144, bias=False)
(generator): Generator(
(streamer): Streamer()
)
(embed_tokens): Gemma4TextScaledWordEmbedding(262144, 1536, padding_idx=0)
(layers): ModuleList(
(0-3): 4 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=1536, out_features=256, bias=False)
(v_proj): Linear(in_features=1536, out_features=256, bias=False)
(o_proj): Linear(in_features=2048, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=6144, bias=False)
(up_proj): Linear(in_features=1536, out_features=6144, bias=False)
(down_proj): Linear(in_features=6144, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(4): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=1536, out_features=512, bias=False)
(v_proj): Linear(in_features=1536, out_features=512, bias=False)
(o_proj): Linear(in_features=4096, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=6144, bias=False)
(up_proj): Linear(in_features=1536, out_features=6144, bias=False)
(down_proj): Linear(in_features=6144, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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-8): 4 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=1536, out_features=256, bias=False)
(v_proj): Linear(in_features=1536, out_features=256, bias=False)
(o_proj): Linear(in_features=2048, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=6144, bias=False)
(up_proj): Linear(in_features=1536, out_features=6144, bias=False)
(down_proj): Linear(in_features=6144, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(9): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=1536, out_features=512, bias=False)
(v_proj): Linear(in_features=1536, out_features=512, bias=False)
(o_proj): Linear(in_features=4096, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=6144, bias=False)
(up_proj): Linear(in_features=1536, out_features=6144, bias=False)
(down_proj): Linear(in_features=6144, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(10-13): 4 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=1536, out_features=256, bias=False)
(v_proj): Linear(in_features=1536, out_features=256, bias=False)
(o_proj): Linear(in_features=2048, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=6144, bias=False)
(up_proj): Linear(in_features=1536, out_features=6144, bias=False)
(down_proj): Linear(in_features=6144, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(14): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=1536, out_features=512, bias=False)
(v_proj): Linear(in_features=1536, out_features=512, bias=False)
(o_proj): Linear(in_features=4096, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=6144, bias=False)
(up_proj): Linear(in_features=1536, out_features=6144, bias=False)
(down_proj): Linear(in_features=6144, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(15-18): 4 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=2048, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(19): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=4096, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(20-23): 4 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=2048, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=4096, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(25-28): 4 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=2048, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=4096, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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-33): 4 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=2048, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(34): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=1536, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=4096, out_features=1536, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=1536, out_features=12288, bias=False)
(up_proj): Linear(in_features=1536, out_features=12288, bias=False)
(down_proj): Linear(in_features=12288, out_features=1536, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=1536, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=1536, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4RMSNorm()
(vision): Gemma4VisionModel(
(encoder): Gemma4VisionEncoder(
(rotary_emb): Gemma4VisionRotaryEmbedding()
(layers): ModuleList(
(0-15): 16 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=3072, out_features=768, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
)
(pooler): Gemma4VisionPooler()
(patch_embed): Linear(in_features=768, out_features=768, bias=False)
(layers): ModuleList(
(0-15): 16 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=3072, out_features=768, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
(tower_output) -> Patches [images patches vision_hidden_size]: The last block's stream after the tower's final norm, before any pooling or adapter
(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): Gemma4MultimodalEmbedder(
(embedding_projection): Linear(in_features=768, out_features=1536, bias=False)
(embedding_pre_projection_norm): Gemma4RMSNorm()
)
(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-E4B: the native modules, standard names and every standard value with its layout.
Gemma4ForConditionalGeneration(
(lm_head): Linear(in_features=2560, out_features=262144, bias=False)
(generator): Generator(
(streamer): Streamer()
)
(embed_tokens): Gemma4TextScaledWordEmbedding(262144, 2560, padding_idx=0)
(layers): ModuleList(
(0-4): 5 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=512, bias=False)
(v_proj): Linear(in_features=2560, out_features=512, bias=False)
(o_proj): Linear(in_features=2048, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=1024, bias=False)
(v_proj): Linear(in_features=2560, out_features=1024, bias=False)
(o_proj): Linear(in_features=4096, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=512, bias=False)
(v_proj): Linear(in_features=2560, out_features=512, bias=False)
(o_proj): Linear(in_features=2048, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=1024, bias=False)
(v_proj): Linear(in_features=2560, out_features=1024, bias=False)
(o_proj): Linear(in_features=4096, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=512, bias=False)
(v_proj): Linear(in_features=2560, out_features=512, bias=False)
(o_proj): Linear(in_features=2048, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=1024, bias=False)
(v_proj): Linear(in_features=2560, out_features=1024, bias=False)
(o_proj): Linear(in_features=4096, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=512, bias=False)
(v_proj): Linear(in_features=2560, out_features=512, bias=False)
(o_proj): Linear(in_features=2048, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=1024, bias=False)
(v_proj): Linear(in_features=2560, out_features=1024, bias=False)
(o_proj): Linear(in_features=4096, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=2048, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=4096, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=2048, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=4096, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=2048, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=4096, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4RMSNorm()
(vision): Gemma4VisionModel(
(encoder): Gemma4VisionEncoder(
(rotary_emb): Gemma4VisionRotaryEmbedding()
(layers): ModuleList(
(0-15): 16 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=3072, out_features=768, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
)
(pooler): Gemma4VisionPooler()
(patch_embed): Linear(in_features=768, out_features=768, bias=False)
(layers): ModuleList(
(0-15): 16 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=3072, out_features=768, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
(tower_output) -> Patches [images patches vision_hidden_size]: The last block's stream after the tower's final norm, before any pooling or adapter
(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): Gemma4MultimodalEmbedder(
(embedding_projection): Linear(in_features=768, out_features=2560, bias=False)
(embedding_pre_projection_norm): Gemma4RMSNorm()
)
(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-E4B-it: the native modules, standard names and every standard value with its layout.
Gemma4ForConditionalGeneration(
(lm_head): Linear(in_features=2560, out_features=262144, bias=False)
(generator): Generator(
(streamer): Streamer()
)
(embed_tokens): Gemma4TextScaledWordEmbedding(262144, 2560, padding_idx=0)
(layers): ModuleList(
(0-4): 5 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=512, bias=False)
(v_proj): Linear(in_features=2560, out_features=512, bias=False)
(o_proj): Linear(in_features=2048, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=1024, bias=False)
(v_proj): Linear(in_features=2560, out_features=1024, bias=False)
(o_proj): Linear(in_features=4096, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=512, bias=False)
(v_proj): Linear(in_features=2560, out_features=512, bias=False)
(o_proj): Linear(in_features=2048, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=1024, bias=False)
(v_proj): Linear(in_features=2560, out_features=1024, bias=False)
(o_proj): Linear(in_features=4096, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=512, bias=False)
(v_proj): Linear(in_features=2560, out_features=512, bias=False)
(o_proj): Linear(in_features=2048, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=1024, bias=False)
(v_proj): Linear(in_features=2560, out_features=1024, bias=False)
(o_proj): Linear(in_features=4096, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=512, bias=False)
(v_proj): Linear(in_features=2560, out_features=512, bias=False)
(o_proj): Linear(in_features=2048, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2560, out_features=1024, bias=False)
(v_proj): Linear(in_features=2560, out_features=1024, bias=False)
(o_proj): Linear(in_features=4096, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=2048, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=4096, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=2048, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=4096, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=2048, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=2048, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2560, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(o_proj): Linear(in_features=4096, out_features=2560, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2560, out_features=10240, bias=False)
(up_proj): Linear(in_features=2560, out_features=10240, bias=False)
(down_proj): Linear(in_features=10240, out_features=2560, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(act_fn): GELUTanh()
(per_layer_input_gate): Linear(in_features=2560, out_features=256, bias=False)
(per_layer_projection): Linear(in_features=256, out_features=2560, bias=False)
(post_per_layer_input_norm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4RMSNorm()
(vision): Gemma4VisionModel(
(encoder): Gemma4VisionEncoder(
(rotary_emb): Gemma4VisionRotaryEmbedding()
(layers): ModuleList(
(0-15): 16 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=3072, out_features=768, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
)
(pooler): Gemma4VisionPooler()
(patch_embed): Linear(in_features=768, out_features=768, bias=False)
(layers): ModuleList(
(0-15): 16 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=768, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=768, out_features=3072, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=3072, out_features=768, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
(tower_output) -> Patches [images patches vision_hidden_size]: The last block's stream after the tower's final norm, before any pooling or adapter
(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): Gemma4MultimodalEmbedder(
(embedding_projection): Linear(in_features=768, out_features=2560, bias=False)
(embedding_pre_projection_norm): Gemma4RMSNorm()
)
(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-26B-A4B: the native modules, standard names and every standard value with its layout.
Gemma4ForConditionalGeneration(
(lm_head): Linear(in_features=2816, out_features=262144, bias=False)
(generator): Generator(
(streamer): Streamer()
)
(embed_tokens): Gemma4TextScaledWordEmbedding(262144, 2816, padding_idx=0)
(layers): ModuleList(
(0-4): 5 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=2048, bias=False)
(v_proj): Linear(in_features=2816, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=1024, bias=False)
(o_proj): Linear(in_features=8192, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=2048, bias=False)
(v_proj): Linear(in_features=2816, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=1024, bias=False)
(o_proj): Linear(in_features=8192, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=2048, bias=False)
(v_proj): Linear(in_features=2816, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=1024, bias=False)
(o_proj): Linear(in_features=8192, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=2048, bias=False)
(v_proj): Linear(in_features=2816, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=1024, bias=False)
(o_proj): Linear(in_features=8192, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=2048, bias=False)
(v_proj): Linear(in_features=2816, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=1024, bias=False)
(o_proj): Linear(in_features=8192, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4RMSNorm()
(vision): Gemma4VisionModel(
(encoder): Gemma4VisionEncoder(
(rotary_emb): Gemma4VisionRotaryEmbedding()
(layers): ModuleList(
(0-26): 27 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=4304, out_features=1152, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
)
(pooler): Gemma4VisionPooler()
(patch_embed): Linear(in_features=768, out_features=1152, bias=False)
(layers): ModuleList(
(0-26): 27 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=4304, out_features=1152, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
(tower_output) -> Patches [images patches vision_hidden_size]: The last block's stream after the tower's final norm, before any pooling or adapter
(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): Gemma4MultimodalEmbedder(
(embedding_projection): Linear(in_features=1152, out_features=2816, bias=False)
(embedding_pre_projection_norm): Gemma4RMSNorm()
)
(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-26B-A4B-it: the native modules, standard names and every standard value with its layout.
Gemma4ForConditionalGeneration(
(lm_head): Linear(in_features=2816, out_features=262144, bias=False)
(generator): Generator(
(streamer): Streamer()
)
(embed_tokens): Gemma4TextScaledWordEmbedding(262144, 2816, padding_idx=0)
(layers): ModuleList(
(0-4): 5 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=2048, bias=False)
(v_proj): Linear(in_features=2816, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=1024, bias=False)
(o_proj): Linear(in_features=8192, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=2048, bias=False)
(v_proj): Linear(in_features=2816, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=1024, bias=False)
(o_proj): Linear(in_features=8192, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=2048, bias=False)
(v_proj): Linear(in_features=2816, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=1024, bias=False)
(o_proj): Linear(in_features=8192, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=2048, bias=False)
(v_proj): Linear(in_features=2816, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=1024, bias=False)
(o_proj): Linear(in_features=8192, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=4096, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=2048, bias=False)
(v_proj): Linear(in_features=2816, out_features=2048, bias=False)
(o_proj): Linear(in_features=4096, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=2816, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=2816, out_features=1024, bias=False)
(o_proj): Linear(in_features=8192, out_features=2816, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=2816, out_features=2112, bias=False)
(up_proj): Linear(in_features=2816, out_features=2112, bias=False)
(down_proj): Linear(in_features=2112, out_features=2816, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(router): Gemma4TextRouter(
(norm): Gemma4RMSNorm()
(proj): Linear(in_features=2816, out_features=128, bias=False)
)
(experts): Gemma4TextExperts(
(act_fn): GELUTanh()
)
(post_feedforward_layernorm_1): Gemma4RMSNorm()
(post_feedforward_layernorm_2): Gemma4RMSNorm()
(pre_feedforward_layernorm_2): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4RMSNorm()
(vision): Gemma4VisionModel(
(encoder): Gemma4VisionEncoder(
(rotary_emb): Gemma4VisionRotaryEmbedding()
(layers): ModuleList(
(0-26): 27 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=4304, out_features=1152, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
)
(pooler): Gemma4VisionPooler()
(patch_embed): Linear(in_features=768, out_features=1152, bias=False)
(layers): ModuleList(
(0-26): 27 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=4304, out_features=1152, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
(tower_output) -> Patches [images patches vision_hidden_size]: The last block's stream after the tower's final norm, before any pooling or adapter
(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): Gemma4MultimodalEmbedder(
(embedding_projection): Linear(in_features=1152, out_features=2816, bias=False)
(embedding_pre_projection_norm): Gemma4RMSNorm()
)
(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-31B: the native modules, standard names and every standard value with its layout.
Gemma4ForConditionalGeneration(
(lm_head): Linear(in_features=5376, out_features=262144, bias=False)
(generator): Generator(
(streamer): Streamer()
)
(embed_tokens): Gemma4TextScaledWordEmbedding(262144, 5376, padding_idx=0)
(layers): ModuleList(
(0-4): 5 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(48-52): 5 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(53): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(54-58): 5 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(59): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4RMSNorm()
(vision): Gemma4VisionModel(
(encoder): Gemma4VisionEncoder(
(rotary_emb): Gemma4VisionRotaryEmbedding()
(layers): ModuleList(
(0-26): 27 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=4304, out_features=1152, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
)
(pooler): Gemma4VisionPooler()
(patch_embed): Linear(in_features=768, out_features=1152, bias=False)
(layers): ModuleList(
(0-26): 27 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=4304, out_features=1152, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
(tower_output) -> Patches [images patches vision_hidden_size]: The last block's stream after the tower's final norm, before any pooling or adapter
(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): Gemma4MultimodalEmbedder(
(embedding_projection): Linear(in_features=1152, out_features=5376, bias=False)
(embedding_pre_projection_norm): Gemma4RMSNorm()
)
(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-31B-it: the native modules, standard names and every standard value with its layout.
Gemma4ForConditionalGeneration(
(lm_head): Linear(in_features=5376, out_features=262144, bias=False)
(generator): Generator(
(streamer): Streamer()
)
(embed_tokens): Gemma4TextScaledWordEmbedding(262144, 5376, padding_idx=0)
(layers): ModuleList(
(0-4): 5 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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 Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(48-52): 5 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(53): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(54-58): 5 x Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=8192, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=4096, bias=False)
(v_proj): Linear(in_features=5376, out_features=4096, bias=False)
(o_proj): Linear(in_features=8192, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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
)
(59): Gemma4TextDecoderLayer(
(self_attn): Gemma4TextAttention(
(q_proj): Linear(in_features=5376, out_features=16384, bias=False)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(k_proj): Linear(in_features=5376, out_features=2048, bias=False)
(o_proj): Linear(in_features=16384, out_features=5376, 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): Gemma4TextMLP(
(gate_proj): Linear(in_features=5376, out_features=21504, bias=False)
(up_proj): Linear(in_features=5376, out_features=21504, bias=False)
(down_proj): Linear(in_features=21504, out_features=5376, bias=False)
(act_fn): GELUTanh()
(mlp_output) -> Residual [batch seq hidden_size]: What the MLP (and, on a mixture block, the experts) adds to the residual stream: the post-feedforward norm's output
(router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
(shared_expert_output) -> Residual [batch seq hidden_size]: The dense MLP's output, before its post-norm: the shared expert beside the mixture
(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
(expert_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
(expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
(expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
(routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(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
(per_layer_output) -> Residual [batch seq hidden_size]: What the per-layer-embedding branch adds to the residual stream: the post-per-layer-input norm's output
(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): Gemma4RMSNorm()
(vision): Gemma4VisionModel(
(encoder): Gemma4VisionEncoder(
(rotary_emb): Gemma4VisionRotaryEmbedding()
(layers): ModuleList(
(0-26): 27 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=4304, out_features=1152, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
)
(pooler): Gemma4VisionPooler()
(patch_embed): Linear(in_features=768, out_features=1152, bias=False)
(layers): ModuleList(
(0-26): 27 x Gemma4VisionEncoderLayer(
(self_attn): Gemma4VisionAttention(
(q_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(k_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(v_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(o_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=1152, bias=False)
)
(q_norm): Gemma4RMSNorm()
(k_norm): Gemma4RMSNorm()
(v_norm): Gemma4RMSNorm()
(attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream: the post-attention norm's output
(attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
(attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
(attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
(attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
(attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
(attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
(attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
(attention_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): Gemma4VisionMLP(
(gate_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(up_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=1152, out_features=4304, bias=False)
)
(down_proj): Gemma4ClippableLinear(
(linear): Linear(in_features=4304, out_features=1152, bias=False)
)
(act_fn): GELUTanh()
(mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's 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
)
(input_layernorm): Gemma4RMSNorm()
(post_attention_layernorm): Gemma4RMSNorm()
(pre_feedforward_layernorm): Gemma4RMSNorm()
(post_feedforward_layernorm): Gemma4RMSNorm()
(layer_mid) -> Patches [images patches vision_hidden_size]: The tower's stream after the attention add
(mlp_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the MLP
(layer_input) -> Patches [images patches vision_hidden_size]: The tower's stream entering the block
(attention_norm_output) -> Patches [images patches vision_hidden_size]: The normed stream entering the attention
(mlp_input) -> Patches [images patches vision_hidden_size]: What the MLP is called with
(layer_output) -> Patches [images patches vision_hidden_size]: The tower's stream leaving the block
)
)
(tower_output) -> Patches [images patches vision_hidden_size]: The last block's stream after the tower's final norm, before any pooling or adapter
(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): Gemma4MultimodalEmbedder(
(embedding_projection): Linear(in_features=1152, out_features=5376, bias=False)
(embedding_pre_projection_norm): Gemma4RMSNorm()
)
(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)))
h = h + per_layer_output # E2B and E4B
out = h * layer_scalar
attention_output, mlp_output and per_layer_output are the post-norms' outputs, before the
scalar, and on E2B every scalar is below one. 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.
token_embeddings does not swap the token on E2B and E4BEach block's per-layer input is a table lookup by token id plus a projection of token_embeddings,
so writing another token's embedding into token_embeddings changes only the projected half. To swap
a token, also patch model.model.language_model.embed_tokens_per_layer.output at that position.
On E2B and E4B the last blocks attend with an earlier block's keys and values, served to each
borrowing block as its own copy. An edit to the source block's attention_keys or attention_values
reaches only that block; an edit to its k_proj output reaches every block that borrows from it.
mlp.output is the dense MLP's, served as shared_expert_output, and mlp_output norms it together
with routed_output. expert_weights are the top-8 softmax entries renormalized to sum to one, then
multiplied by the learned per_expert_scale.
h = x + post_attention_layernorm(self_attn(input_layernorm(x)))
out = h + post_feedforward_layernorm(mlp(pre_feedforward_layernorm(h)))
Four RMSNorms per block, no per-layer branch and no scalar.
attention_output and mlp_output are the post-norms' outputs, so
vision.layers[i].input + attention_output + mlp_output == layer_output holds exactly in float32,
and an ablation or a steering vector on a sublayer goes on attention_output or mlp_output.
The attention norms each head's queries and keys (q_norm, k_norm) and its values (v_norm,
without gain), rotates queries and keys by the patch's x and y position, and computes the scores
with scaling 1.0. model.vision.head_dim is the config's head_dim: 64 on E2B and E4B, with 12
heads over a 768-wide stream.
The processor resizes an image within a budget of max_soft_tokens * pooling_kernel_size**2
patches of 16 pixels and pads the row to that length: a square image is 48 × 48 = 2304 patches
and 216 padded rows of 2520. The padded rows are masked as keys, so no patch reads them, but they
are rows of every block's layer_output and of tower_output, with values. Select the image's
patches with the processor's positions:
encoding = model.processor(text=prompt, images=[image], return_tensors="pt")
padded = (encoding["image_position_ids"] == -1).all(-1) # [images, 2520]
with model.trace(dict(encoding)):
stream = model.vision.layers[0].layer_output.save()
stream[~padded] # the 2304 patches
After the last block the vision encoder's pooler zeroes the padded rows, averages each 3 × 3
block of patches by position (pooling_kernel_size), multiplies by √vision_hidden_size and drops
the padding: 2304 patches become 256 soft tokens, [soft_tokens, vision_hidden_size] flat over the
images. These soft tokens are model.projector.input. A write to tower_output at the padded rows changes
nothing downstream; at the patches it reaches the text model. On 26B-A4B and 31B
(standardize) the pooled tokens are then shifted by std_bias and scaled by std_scale, inside
the vision encoder.
embed_vision reads the soft tokens the vision encoder's pooler averages from tower_output, not
tower_output itself.
On a sliding block an image's tokens attend to every token of the same image within the window, later ones included; the full blocks stay causal. E2B and E4B are causal throughout.
Gemma 4, text (Gemma4ForCausalLM, model_type gemma4_text): E2B, E4B, 26B-A4B and 31B.
model.{embed_tokens, layers[i].{input_layernorm, self_attn, post_attention_layernorm, pre_feedforward_layernorm, mlp, post_feedforward_layernorm}, norm} and lm_head:
Gemma-3's sandwich tree. A gemma4 checkpoint (Gemma4ForConditionalGeneration,
the published repos) nests its config's text_config, of this type; the
text-generation task builds the wrapper, whose text stack sits at
model.language_model.{embed_tokens, layers, norm} with lm_head at the root, so
RENAME carries both spellings and whichever the tree has binds.
The block, in order::
x1 = x + post_attention_layernorm(self_attn(input_layernorm(x)))
x2 = x1 + post_feedforward_layernorm(mlp(pre_feedforward_layernorm(x1)) [+ experts])
p = gelu(per_layer_input_gate(x2)) * per_layer_input
x3 = x2 + post_per_layer_input_norm(per_layer_projection(p))
out = x3 * layer_scalar # in place, on x3
enable_moe_block) the block
also runs router and experts, direct children of the block, not of
mlp: post_feedforward_layernorm_1(mlp(...)) + post_feedforward_layernorm_2(experts(pre_feedforward_layernorm_2(x1))), and
post_feedforward_layernorm norms that sum, so mlp_output is the dense
MLP and the experts together, what the block adds. The mixture has no module
of its own, so mlp (a Moe) hosts its values, reading the block's
router and experts through its parent. The router
runs on x1, the stream after the attention's add (the block's residual
at that point, not its input), with its own norm, and returns
probabilities; router_logits are its projection's output
(router.proj). shared_expert_output is the dense MLP's output, before
its post-norm: mlp_output == post_feedforward_layernorm( post_feedforward_layernorm_1(shared_expert_output) + post_feedforward_layernorm_2(routed_output)). On a dense checkpoint every
mixture value is unavailable.hidden_size_per_layer_input): a third
add, served as layers[i].per_layer_output (the post-per-layer-input norm's
output). per_layer_input is the block's second argument, one slice of the
model's per-layer embedding table mixed with a projection of the token
embeddings. On a checkpoint without them the value is unavailable.layer_scalar, a per-block buffer, multiplies the sum in place. The
contributions are served unscaled, so the identity is
(input + attention_output + mlp_output [+ per_layer_output]) * layer_scalar == layer_output.num_kv_shared_layers blocks have no k_proj/v_proj: each borrows
the keys and values of the last earlier block of the same kind (sliding or
full) before the sharing starts. On a checkpoint with attention_k_eq_v
(26B-A4B, 31B) the full-attention blocks have no v_proj: their values are
v_norm(k_proj(x)), the keys' projection before k_norm and the rotary
embedding. attention_keys and attention_values are what the attention
receives on every block, borrowed or not, served as copies private to the
block: an edit, in place or by assignment, changes what that block attends
with and nothing else, and the blocks that borrow a source block's tensors
keep the originals.head_dim (and on
26B-A4B/31B in num_key_value_heads), and on E2B (use_double_wide_mlp)
the KV-sharing blocks' MLP is twice intermediate_size wide; the config
marks the attention sizes per-layer and refuses a plain config.head_dim.
The root's head_dim and num_kv_heads report the config's top-level
values (the sliding blocks'); each block's own are on layers[i].self_attn
and layers[i].mlp, read off the module.final_logit_softcapping is in the text config; the root's project_on_vocab
reads it there.
On the wrapper the vision tower model.vision_tower is vision (a Vision)
and model.embed_vision, the last module before the scatter, is
projector. The tower is a ViT over each image's patches: the patch embedder's
linear over the processor's flattened patches (patch_embedder.input_proj) is
vision.patch_embed, so vision.patch_embeddings is before the 2D position
embedding patch_embedder adds, and the blocks (encoder.layers) are
vision.layers. Each block is the text block's
sandwich, so its contributions are the post-norms' outputs too
(VisionAttention, VisionMlp). The processor pads every image's patches to
max_soft_tokens * pooling_kernel_size**2 rows with zero pixels at position
(-1, -1); the padded rows run through every block (masked as keys only), so
they are present in vision.layers[i].layer_output. There is no final norm:
the tower's pooler zeroes the padded rows, average-pools the patches
pooling_kernel_size by pooling_kernel_size and multiplies by
sqrt(vision_hidden_size) (in float32); the tower then strips the padding and,
where the vision config sets standardize (26B-A4B, 31B), subtracts std_bias
and multiplies by std_scale. So vision.tower_output is the encoder's output
(the last block's stream, padded) and projector.input is the pooled, scaled
(and standardized) soft tokens, flat over the images. The audio tower (model.audio_tower, a Conformer) and its embedder
model.embed_audio keep their native names.