nnterp · encyclopedia llama4_text · nnterp.families.llama4_text

family llama4_text

Llama 4

Llama's pre-norm block with a mixture of experts and a shared expert as the MLP (every block on Scout, every other block on Maverick), routed by a sigmoid of the top-1 logit; every fourth block attends over the whole context without rotary, and the others attend within fixed chunks.

The block

01 · the residual stream

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.

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

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

The vision encoder

· Llama 4 ViT · Llama4VisionModel

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.

imagepixel_values
→
patch_embedpatch_embeddings
→
layers× 34
→
normtower_output
→
projectorinput: the pixel-shuffle adapter's output over vision.tower_output, flattened over the tiles
→
image_featuresat the scatter
→
layers[0].inputat image_token_mask
rows
One row per image tile: the processor fits an image onto a grid of up to max_patches (16) tiles of 336 pixels and adds a global tile, the whole image resized, when there is more than one. A row is the tile's 576 patches, then the CLS token last: patches + 1 rows.
positions
patch_embeddings is the unfold-and-linear output, before the CLS token is appended. A learned embedding per row (positional_embedding_vlm, the CLS's last) is added and layernorm_pre norms the rows; every attention rotates queries and keys by the patch's 2D position, and leaves the CLS row unrotated.
masking
No mask: each row attends to every patch of its own tile and to its CLS token; tiles do not see one another.
final norm
layernorm_post is vision.norm, a LayerNorm over every row, CLS included; vision.tower_output is its output. The tower then drops the CLS row and runs vision.vision_adapter.

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

The API

02 · support()

Values, by host

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

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

the module's own output

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

the child module embed_tokens's output

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

the child module norm's output

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

the child module lm_head's output

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

the module's own output

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

the module's own input

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

the module's own input

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

the module's own input

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

the module's own input

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

the child module input_layernorm's output

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

the child module post_attention_layernorm's input

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

the child module post_attention_layernorm's output

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

the child module mlp's input

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

the module's own output

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

inside the forward: the arguments of attention_interface_1, element 1

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

inside the forward: the arguments of attention_interface_1, element 2

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

inside the forward: the arguments of attention_interface_1, element 3

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

inside the forward: the input of nn_functional_softmax_0 inside attention_interface_1

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

the child module o_proj's input

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

the module's own output

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

inside the forward: the output of nn_functional_dropout_0 inside attention_interface_1

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

inside the forward: the output of attention_interface_1, element 0

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

the child module act_fn's output

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

the child module down_proj's input

mlp_output Residual [batch seq hidden_size] What the MLP adds to the residual stream: its output viewed in the residual's shape

the sibling module source.hidden_states_view_0's output

router_logits RouterLogits [batch seq num_experts] The router's logits, one per expert, before the scoring

inside router's forward: the output of forward_0

⚠︎expert_weights scalar Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet

nowhere: the family does not serve it

expert_indices ExpertIndices [batch seq top_k] The expert each routing slot sends the token to

inside router's forward: the output of torch_topk_0, element 1

⚠︎expert_outputs scalar Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet

nowhere: the family does not serve it

routed_output Residual [batch seq hidden_size] The routed experts' combined output

inside the forward: the output of sum_0

shared_expert_output Residual [batch seq hidden_size] The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)

the child module shared_experts's output

the vision encoder · Llama 4 ViT

model.vision Llama4VisionModellayoutwhat it isread at
image_token_mask ImageTokenMask [batch seq] Which positions hold image tokens: input_ids == the config's image_token_id; read-only

the model's own inputs, at the root

patch_embeddings Patches [images patches vision_hidden_size] The patch embedding's output, one row per patch

the child module patch_embed's output

tower_output Patches [images patches vision_hidden_size] The last block's stream after the tower's final norm, before any pooling or adapter

the child module norm's output

image_features ImageFeatures [image_tokens hidden_size] The image features the text model receives at the image tokens, flat over them

inside the forward: the arguments of inputs_embeds_masked_scatter_0, element 1

model.vision.layers[i] Llama4VisionEncoderLayerlayoutwhat it isread at
layer_input Patches [images patches vision_hidden_size] The tower's stream entering the block

the module's own input

attention_norm_output Patches [images patches vision_hidden_size] The normed stream entering the attention

the child module input_layernorm's output

layer_mid Patches [images patches vision_hidden_size] The tower's stream after the attention add

the child module post_attention_layernorm's input

mlp_norm_output Patches [images patches vision_hidden_size] The normed stream entering the MLP

the child module post_attention_layernorm's output

mlp_input Patches [images patches vision_hidden_size] What the MLP is called with

the child module mlp's input

layer_output Patches [images patches vision_hidden_size] The tower's stream leaving the block

the module's own output

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

inside the forward: the arguments of attention_interface_1, element 1

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

inside the forward: the arguments of attention_interface_1, element 2

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

inside the forward: the arguments of attention_interface_1, element 3

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

inside the forward: the input of nn_functional_softmax_0 inside attention_interface_1

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

the child module o_proj's input

attention_output Patches [images patches vision_hidden_size] What the attention adds to the tower's stream

the module's own output

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

inside the forward: the output of nn_functional_dropout_0 inside attention_interface_1

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

inside the forward: the output of attention_interface_1, element 0

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

the child module act_fn's output

mlp_neurons Neurons [batch seq intermediate_size] What the down projection receives

the child module down_proj's input

mlp_output Patches [images patches vision_hidden_size] What the MLP adds to the tower's stream

the module's own output

Printout

What print(model) shows on meta-llama/Llama-4-Scout-17B-16E: the native modules, standard names and every standard value with its layout.

Llama4ForConditionalGeneration(
  (vision/vision_model): Llama4VisionModel(
    (patch_embed/patch_embedding): Llama4UnfoldConvolution(
      (unfold): Unfold(kernel_size=(14, 14), dilation=1, padding=0, stride=14)
      (linear): Linear(in_features=588, out_features=1408, bias=False)
    )
    (rotary_embedding): Llama4VisionRotaryEmbedding()
    (layernorm_pre): LayerNorm((1408,), eps=1e-05, elementwise_affine=True, bias=True)
    (norm/layernorm_post): LayerNorm((1408,), eps=1e-05, elementwise_affine=True, bias=True)
    (vision_adapter): Llama4VisionPixelShuffleMLP(
      (mlp): Llama4VisionMLP2(
        (fc1): Linear(in_features=5632, out_features=4096, bias=False)
        (down_proj/fc2): Linear(in_features=4096, out_features=4096, bias=False)
        (act_fn/activation_fn): GELU(approximate='none')
      )
    )
    (layers): ModuleList(
      (0-33): 34 x Llama4VisionEncoderLayer(
        (self_attn): Llama4VisionAttention(
          (q_proj): Linear(in_features=1408, out_features=1408, bias=True)
          (k_proj): Linear(in_features=1408, out_features=1408, bias=True)
          (v_proj): Linear(in_features=1408, out_features=1408, bias=True)
          (o_proj): Linear(in_features=1408, out_features=1408, bias=True)
          (attention_output) -> Patches [images patches vision_hidden_size]: What the attention adds to the tower's stream
          (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
          (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
        )
        (mlp): Llama4VisionMLP(
          (act_fn/activation_fn): GELU(approximate='none')
          (fc1): Linear(in_features=1408, out_features=5632, bias=True)
          (down_proj/fc2): Linear(in_features=5632, out_features=1408, bias=True)
          (mlp_output) -> Patches [images patches vision_hidden_size]: What the MLP adds to the tower's stream
          (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): LayerNorm((1408,), eps=1e-05, elementwise_affine=True, bias=True)
        (post_attention_layernorm): LayerNorm((1408,), eps=1e-05, elementwise_affine=True, bias=True)
        (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
        (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
        (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/multi_modal_projector): Llama4MultiModalProjector(
    (linear_1): Linear(in_features=4096, out_features=5120, bias=False)
  )
  (generator): Generator(
    (streamer): Streamer()
  )
  (embed_tokens): Embedding(202048, 5120, padding_idx=200018)
  (layers): ModuleList(
    (0-2): 3 x Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (qk_norm): Llama4TextL2Norm(eps=1e-05)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (3): Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (4-6): 3 x Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (qk_norm): Llama4TextL2Norm(eps=1e-05)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (7): Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (8-10): 3 x Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (qk_norm): Llama4TextL2Norm(eps=1e-05)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (11): Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (12-14): 3 x Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (qk_norm): Llama4TextL2Norm(eps=1e-05)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (15): Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (16-18): 3 x Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (qk_norm): Llama4TextL2Norm(eps=1e-05)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (19): Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (20-22): 3 x Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (qk_norm): Llama4TextL2Norm(eps=1e-05)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (23): Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (24-26): 3 x Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (qk_norm): Llama4TextL2Norm(eps=1e-05)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (27): Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (28-30): 3 x Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (qk_norm): Llama4TextL2Norm(eps=1e-05)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (31): Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (32-34): 3 x Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (qk_norm): Llama4TextL2Norm(eps=1e-05)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (35): Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (36-38): 3 x Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (qk_norm): Llama4TextL2Norm(eps=1e-05)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (39): Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (40-42): 3 x Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (qk_norm): Llama4TextL2Norm(eps=1e-05)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (43): Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (44-46): 3 x Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (qk_norm): Llama4TextL2Norm(eps=1e-05)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (47): Llama4TextDecoderLayer(
      (self_attn): Llama4TextAttention(
        (q_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (k_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (v_proj): Linear(in_features=5120, out_features=1024, bias=False)
        (o_proj): Linear(in_features=5120, out_features=5120, bias=False)
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
      )
      (mlp/feed_forward): Llama4TextMoe(
        (experts): Llama4TextExperts(
          (act_fn): SiLUActivation()
        )
        (router): Llama4Router(in_features=5120, out_features=16, bias=False)
        (shared_experts/shared_expert): Llama4TextMLP(
          (gate_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (up_proj): Linear(in_features=5120, out_features=8192, bias=False)
          (down_proj): Linear(in_features=8192, out_features=5120, bias=False)
          (act_fn/activation_fn): SiLUActivation()
          (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
          (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
        )
        (router_logits) -> RouterLogits [batch seq num_experts]: The router's logits, one per expert, before the scoring
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_weights): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (expert_outputs): Unavailable: Llama 4's router scales each expert's input by a dense score over every expert; not mapped yet
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output (a copy, since the mixture adds the routed sum into the live tensor in place)
        (mlp_activation) -> Neurons [batch seq intermediate_size]: The activation function's output
        (mlp_neurons) -> Neurons [batch seq intermediate_size]: What the down projection receives: act(gate)·up on a gated MLP, the activation itself otherwise
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: its output viewed in the residual's shape
      )
      (input_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (post_attention_layernorm): Llama4TextRMSNorm((5120,), eps=1e-05)
      (layer_input) -> Residual [batch seq hidden_size]: The residual stream entering the block
      (attention_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the attention
      (layer_mid) -> Residual [batch seq hidden_size]: The residual stream after the attention add
      (mlp_norm_output) -> Residual [batch seq hidden_size]: The normed stream entering the MLP
      (mlp_input) -> Residual [batch seq hidden_size]: What the MLP is called with
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
  )
  (norm): Llama4TextRMSNorm((5120,), eps=1e-05)
  (lm_head): Linear(in_features=5120, out_features=202048, bias=False)
  (logits) -> Logits [batch seq vocab_size]: The logits the model returns, after anything it does past lm_head (a softcap, a scale)
  (token_embeddings) -> Residual [batch seq hidden_size]: The embedding module's output; layers[0].input is what enters the first block
  (final_norm_output) -> Residual [batch seq hidden_size]: The residual stream after the final norm, what lm_head reads
  (lm_head_output) -> Logits [batch seq vocab_size]: The head's logits before anything the model does past lm_head (a softcap, a scale)
  (next_token_probs) -> NextTokenProbs [batch vocab_size]: The next-token distribution at the last position; derived, read-only
  (input_ids) -> Tokens [batch seq]: The token ids the model was called with
  (attention_mask) -> Tokens [batch seq]: The attention mask the model was called with; zeros are padding
  (input_size): [batch, seq] of the current call; read-only
)

Config

model.num_layers48
model.hidden_size5120
model.num_heads40
model.num_kv_heads8
model.head_dim128
model.qk_head_dim128
model.vocab_size202048
model.intermediate_size16384
architecturesLlama4ForConditionalGeneration
num_hidden_layers48
hidden_size5120
intermediate_size8192
num_attention_heads40
num_key_value_heads8
head_dim128
vocab_size202048
max_position_embeddings262144
hidden_actsilu
rms_norm_eps1e-05
tie_word_embeddingsFalse
num_experts_per_tok1
num_local_experts16
attention_biasFalse
use_qk_normTrue
interleave_moe_layer_step1
intermediate_size_mlp16384
no_rope_layer_interval4
attention_chunk_size8192
attn_temperature_tuningTrue
attn_scale0.1
floor_scale8192
Vision Config

Vision Config

model.vision.num_layers34
model.vision.vision_hidden_size1408
model.vision.num_heads16
model.vision.head_dim88
model.vision.intermediate_size5632
model.vision.patch_size14
model.vision.image_size336

The Notes

03 · what to know before you run

The block, in order

h   = x + self_attn(input_layernorm(x))               # rotary + L2 qk-norm, or NoPE
f   = feed_forward(post_attention_layernorm(h))       # dense, or (out, router_logits)
out = h + f.view(h.shape)

Llama's pre-norm block with the feed-forward named feed_forward, which nnterp calls mlp; post_attention_layernorm is the MLP's input norm. Nothing norms a sublayer's output, and the identity is the plain sum on dense and mixture blocks alike, exact on the pinned tiny checkpoint:

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

torch.equal(x + attn + mlp, out)    # True

mlp_output is the block's view, not the module's output

A mixture returns (out, router_logits) with out flattened to [batch * seq, hidden_size], and the block views it back into the residual's shape before the add. mlp_output is read at that view, [batch, seq, hidden_size] on every block, and an in-place edit of it lands on the mixture's own output tensor; layers[i].mlp.output[0] is the flat tensor. The view is an operation of the block's forward, read after the attention has returned, so nnterp builds the block's .source when it loads the model.

Dense and mixture blocks interleave

interleave_moe_layer_step places the mixtures (config.moe_layers): 1 on Scout, so all 48 blocks are a Moe, and 2 on Maverick, so blocks 1, 3, ..., 47 are a Moe and the even blocks a dense Mlp. The widths are spelled the other way round from most families: the config's intermediate_size (8192) is each expert's and the shared expert's, and intermediate_size_mlp (16384) is the dense MLP's, which model.intermediate_size reports. On Scout no block uses that width. On a dense block every mixture value is missing, with the reason saying so.

The router takes a sigmoid over the top-1 logit

num_experts_per_tok is 1 on both: Scout routes over 16 experts, Maverick over 128, and every mixture also runs its shared expert on every token. The router keeps the largest logit, sets the others to -inf and takes a sigmoid (SCORING "sigmoid"), so a token's score is between 0 and 1 for its expert and 0 for the rest. Each expert's input is multiplied by its score, every expert runs on every token, and the routed sum is added in place to the shared expert's output. nnterp serves router_logits (the router's projection, [batch, seq, num_experts]), expert_indices (its top 1), routed_output (the sum over experts) and shared_expert_output (a copy, whose edits are carried back). expert_weights and expert_outputs are unavailable, because the mixture has no per-slot weight or per-slot output to read.

moe = model.layers[1].mlp
with model.trace(prompt):
    logits = moe.router_logits.save()
    idx = moe.expert_indices.save()             # [batch, seq, 1]
    shared = moe.shared_expert_output.save()
    routed = moe.routed_output.save()
    contribution = moe.mlp_output.save()

torch.equal(logits.topk(moe.top_k, dim=-1).indices, idx)   # True
torch.testing.assert_close(shared + routed, contribution)

Steer the routing at router_logits

expert_indices and the scores are both computed from router_logits, so a write there moves both. Setting expert e's logit to -inf sends the tokens that chose it to their second choice, and mlp_output changes on exactly those tokens; setting it high sends every token to e. moe.routed_output[:] = 0 leaves the shared expert's output as the block's whole mlp_output, and moe.shared_expert_output[:] = 0 leaves the routed sum.

with model.trace(prompt):
    moe.router_logits[..., e] = float("-inf")   # e's tokens go to their next expert
    rerouted = moe.mlp_output.save()

Every fourth block has no rotary and tunes its queries

no_rope_layers (built from no_rope_layer_interval 4) makes blocks 3, 7, ..., 47 NoPE blocks: no rotary embedding and no query/key norm, and full causal attention (layer_types full_attention). On them attn_temperature_tuning multiplies the queries by 1 + attn_scale · log(1 + floor((position + 1) / floor_scale)), with attn_scale 0.1 and floor_scale 8192 on both, so the factor is exactly 1 for the first 8191 positions and steps up by 0.069 at 8191. The other blocks (chunked_attention) rotate queries and keys and attend only within their chunk of attention_chunk_size 8192 tokens, so their pattern is zero across chunk boundaries. attention_queries and attention_keys are read after the rotary, the norm and the temperature: on a NoPE block of a prompt of at most 8191 tokens, attention_queries is q_proj's output split into heads.

Scout norms each query and key head to RMS 1

Where use_qk_norm is true, a rotary block divides each query and key head by its RMS after the rotary (qk_norm, a Llama4TextL2Norm: an RMS norm with no weight, not a unit-length L2 norm), so every head of attention_queries and attention_keys has RMS 1. One module serves both, and NoPE blocks have none. Scout sets use_qk_norm; Maverick does not, and its blocks have no qk_norm. The scores are scaled by 1/√head_dim on every block. Both have 40 query heads over 8 key/value heads of 128, so an edit to one head of attention_keys or attention_values reaches 5 query heads.

Rotary and context

Scout rotates with rope_theta 500,000 under llama3 scaling (factor 16 over an original 8192 positions); Maverick with the same base, unscaled. max_position_embeddings is 262,144 on both base checkpoints, 10,485,760 on Scout-Instruct and 1,048,576 on Maverick-Instruct. NoPE blocks carry no position: only the causal mask orders the tokens there.

The readout

logits is lm_head.output, with no cap or scale, and lm_head is its own weight on both checkpoints (tie_word_embeddings false). The vocabulary is 202,048 tokens. The final norm is an RMSNorm whose gain is norm.weight itself; project_on_vocab applies it and lm_head.

Every checkpoint is a multimodal wrapper

The published repos are llama4 checkpoints with a llama4_text text_config. The text-generation task builds Llama4ForCausalLM from the text config, reading its weights out of the wrapper checkpoint and leaving the vision encoder's unused; task="image-text-to-text" builds Llama4ForConditionalGeneration with its processor, the text model under language_model. The standard names are the same under both loads.

Vision notes

· Llama 4 ViT · Llama 4

The Llama 4 ViT vision encoder

The block is LayerNorm pre-norm, with biases

h   = x + self_attn(input_layernorm(x))             # 2D rotary on q and k
out = h + mlp(post_attention_layernorm(h))          # fc1, GELU, fc2

Both norms are LayerNorms, and the projections and both MLP linears carry biases. Nothing norms a sublayer's output, so vision.layers[i].input + attention_output + mlp_output == layer_output. On Scout and Maverick the vision encoder is 34 blocks of 1408 wide, 16 heads of 88.

The CLS token is the last row

The tower appends its class_embedding after the 576 patches, so every vision.layers[i] value is [tiles, 577, vision_hidden_size] with the CLS at index -1, and patch_embeddings is the 576 patches alone. layernorm_post norms all 577 rows; the tower then drops the CLS, so vision.tower_output[:, -1] reaches nothing: on the pinned tiny checkpoint a write to it leaves the logits bit-identical, and a write to vision.tower_output[:, :-1] changes them. Select the patches with [:, :-1], not CLIP's [:, 1:].

The pixel-shuffle adapter is inside the vision encoder

vision.vision_adapter takes vision.tower_output[:, :-1], merges each 2 × 2 block of patches into one row (pixel_shuffle_ratio 0.5) and runs a two-layer MLP with a GELU after each linear: 576 patches become 144 rows of projector_output_dim (4096). Its output is the tower's own last_hidden_state.

with model.trace(prompt, images=[image]):
    out = model.vision.tower_output.save()              # [tiles, 577, vision_hidden_size]
    read = model.vision.vision_adapter.input.save()
    shuffled = model.vision.vision_adapter.output.save()

torch.equal(read, out[:, :-1])     # True: the patches, the CLS dropped
shuffled.shape[1]                  # 144 on Scout: 576 / 4

Llama 4

The projector reads the adapter's output, flattened over the tiles

model.multi_modal_projector (the projector) is one linear, 4096 to the text model's 5120, without a bias. Its input is vision.vision_adapter's output flattened over the tiles, [tiles × 144, 4096], so projector.input has a quarter as many rows per tile as the tile has patches. vision.image_features is model.projector.output, and layers[0].input[vision.image_token_mask] == vision.image_features holds exactly. On the pinned tiny checkpoint:

with model.trace(prompt, images=[image]):
    mask = model.vision.image_token_mask.save()
    shuffled = model.vision.vision_adapter.output.save()
    fed = model.projector.input.save()
    features = model.vision.image_features.save()
    first = model.layers[0].input.save()

torch.equal(fed, shuffled.flatten(0, 1))     # True: the adapter's rows, tile after tile
torch.equal(first[mask], features)           # True: the scatter

A write to vision.tower_output at the patch rows reaches the adapter and the text model.

144 image tokens per tile

config.image_token_index is <|patch|>: the processor writes 144 of them per tile, with <|tile_x_separator|> and <|tile_y_separator|> between tiles and the global tile's 144 last, and vision.image_token_mask marks the <|patch|> positions only. A 64 × 64 image is one tile and 144 image tokens; a 900 × 500 image is a 2 × 3 grid plus the global tile, 7 rows of the vision encoder's batch and 1008 image tokens. The count depends on the image's shape: assign one image's features into another's run only when the two give the same count.

The wrapper's own forward scatters

Llama4ForConditionalGeneration has no inner model: its own forward runs the vision encoder, the projector and inputs_embeds.masked_scatter, and vision.image_features is read at that scatter on the root. The text model is model.language_model, with lm_head under it.

Load in bfloat16

The image processor returns bfloat16 pixels, and a float32 vision encoder refuses them (expected m1 and m2 to have the same dtype). Load with dtype=torch.bfloat16, or build the encoding with model.processor and cast pixel_values to the model's dtype before the trace.

From the family module

04 · nnterp/families/llama4_text.py

Llama 4, text (Llama4ForCausalLM, model_type llama4_text): Scout and Maverick's language model.

model.{embed_tokens, layers[i].{input_layernorm, self_attn, post_attention_layernorm, feed_forward}, norm} and lm_head: Llama's tree with the feed-forward called feed_forward, renamed to mlp. A llama4 checkpoint (Llama4ForConditionalGeneration, the published Scout and Maverick repos) nests its config's text_config, of this type; the text-generation task builds Llama4ForCausalLM from it, and a wrapper module passed in already loaded keeps the text model at language_model.{model.*, lm_head}, so RENAME carries both spellings and whichever the tree has binds.

The block adds both residuals itself, attention through the shared eager forward (Llama 4's own copy, which keeps the softmax in the model dtype). What differs from Llama, inside the attention and the feed-forward:

  • iRoPE. no_rope_layers[i] == 0 marks a NoPE block: no rotary embedding, no qk-norm, full causal attention, and attention temperature tuning (attn_temperature_tuning) scales its queries by a factor that grows with the position. The other blocks apply the rotary embedding, then a weightless RMS qk-norm (Llama4TextL2Norm, use_qk_norm), and attend within chunks of attention_chunk_size tokens (config.layer_types). The queries and keys served are what the interface receives, after all of that; a chunked block's pattern is zero across chunk boundaries.
  • Interleaved mixture of experts. Blocks in moe_layers carry a Llama4TextMoe (a shared expert plus routed experts) returning (out, router_logits) with out flattened to [batch * seq, hidden_size]; the others a dense Llama4TextMLP. The block views either back into the residual's shape before adding it, so mlp_output is read at that view in the block's forward: [batch, seq, hidden_size] on both kinds, and edits to it reach the feed-forward's own output tensor. The shared expert is a Llama4TextMLP too, so it is an Mlp; its mlp_output is unavailable, since the block adds the mixture's sum. The mixture is a Moe whose router returns dense scores [tokens, num_experts] (the sigmoid of the top-k logits, zero elsewhere): the experts run on every token, each scaled on its input by its score, and the routed sum is added into the shared expert's output tensor in place. So router_logits (the router's projection) and expert_indices (its top-k) are the router's own; routed_output is the mixture's sum over the experts; shared_expert_output is a copy taken as the shared expert returns, whose edits are carried back; and expert_weights / expert_outputs are unavailable.
  • Sizes. intermediate_size in this config is the experts' width (and the shared expert's); the dense MLP's is intermediate_size_mlp, which the root's intermediate_size reports. Scout has a mixture on every block, so there it names a width the model never uses, as on Qwen3-MoE; Maverick alternates dense and mixture blocks.

On the wrapper the vision tower vision_model is vision (a Vision) and multi_modal_projector, the last module before the scatter, is projector. The tower is a ViT over each image tile: the patch embedding (patch_embedding, an unfold and a linear) is vision.patch_embed, the blocks (model.layers, pre-norm, on the shared attention interface with a 2D rotary embedding) are vision.layers, and layernorm_post is vision.norm. A CLS token is appended after the patches, so the tower's stream is [tiles, patches + 1, vision_hidden_size] with the CLS last (CLIP's is first); the tower drops it after layernorm_post, then pixel-shuffles and projects the patches in vision.vision_adapter, so vision.tower_output is layernorm_post's output, CLS included, and projector.input is the adapter's output, flattened over the tiles. Loaded with task="image-text-to-text" (the processor), the tower serves vision.image_token_mask and vision.image_features. The text-generation task builds Llama4ForCausalLM, which has no tower.