nnterp · encyclopedia granitemoehybrid · nnterp.families.granitemoehybrid

family granitemoehybrid

Granite 4.0

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, each tick's color gives its block's shape, and the diagram redraws for the block picked.

embed_tokenstoken_embeddings
→
layers× 40
→
normfinal_norm_output
→
lm_headlm_head_output
→
logitsscaled
i = 0

identity layers[i].input + linear_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 GraniteMoeHybridForCausalLMlayoutwhat 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] GraniteMoeHybridDecoderLayerlayoutwhat 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 feed-forward is called with: the input of each of its modules

the child module post_attention_layernorm's output

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

the module's own output

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

nowhere: routed experts; read per-expert via the Moe component

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

nowhere: routed experts; read per-expert via the Moe component

mlp_output Residual [batch seq hidden_size] What the MLP adds to the residual stream: the routed experts plus the shared expert, times residual_multiplier

the sibling module source.hidden_states_4'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 F_linear_0

expert_weights ExpertWeights [batch seq top_k] The weight each selected expert's output is scaled by

the child module experts's inputs, element 2

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

the child module experts's inputs, element 1

expert_outputs ExpertOutputs [batch seq top_k hidden_size] Each routing slot's weighted expert output

inside experts's forward: the output of weighted_out_view_0 inside experts_forward_1

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

the child module experts's output

shared_expert_output Residual [batch seq hidden_size] The shared expert's output, unscaled

the module's own output

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

the module's own output

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

nowhere: the family does not serve it

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

computed from other values read in the same call

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

nowhere: the family does not serve it

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

nowhere: no rotary embedding: this checkpoint's position_embedding_type is 'nope', so its attention uses no position encoding (NoPE)

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

nowhere: no rotary embedding: this checkpoint's position_embedding_type is 'nope', so its attention uses no position encoding (NoPE)

⚠︎attention_queries Queries [batch num_heads seq qk_head_dim] The queries entering attention

inside the forward: the arguments of attention_interface_1, element 1

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

inside the forward: the arguments of attention_interface_1, element 2

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

inside the forward: the arguments of attention_interface_1, element 3

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

inside the forward: the input of nn_functional_softmax_0 inside attention_interface_1

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

the child module o_proj's input

attention_output Residual [batch seq hidden_size] What the attention adds to the residual stream: its output times residual_multiplier

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

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

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

Printout

What print(model) shows on ibm-granite/granite-4.0-h-tiny-base: the native modules, standard names and every standard value with its layout.

GraniteMoeHybridForCausalLM(
  (lm_head): Linear(in_features=1536, out_features=100352, bias=False)
  (generator): Generator(
    (streamer): Streamer()
  )
  (embed_tokens): Embedding(100352, 1536, padding_idx=100256)
  (layers): ModuleList(
    (0-4): 5 x GraniteMoeHybridDecoderLayer(
      (input_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (post_attention_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (block_sparse_moe): GraniteMoeHybridMoE(
        (router): GraniteMoeHybridTopKRouter()
        (experts): GraniteMoeHybridExperts(
          (act_fn): SiLUActivation()
        )
      )
      (mlp/shared_mlp): GraniteMoeHybridMLP(
        (act_fn/activation): SiLUActivation()
        (input_linear): Linear(in_features=1536, out_features=2048, bias=False)
        (down_proj/output_linear): Linear(in_features=1024, out_features=1536, bias=False)
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output, unscaled
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the routed experts plus the shared expert, times residual_multiplier
        (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_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
      )
      (linear_attn/mamba): GraniteMoeHybridMambaLayer(
        (act): SiLUActivation()
        (conv1d): Conv1d(3328, 3328, kernel_size=(4,), stride=(1,), padding=(3,), groups=3328)
        (in_proj): Linear(in_features=1536, out_features=6448, bias=False)
        (norm): GraniteMoeHybridRMSNormGated()
        (out_proj): Linear(in_features=3072, out_features=1536, bias=False)
        (attention_output) -> Residual [batch seq hidden_size]: What the Mamba-2 mixer adds to the residual stream: its output times residual_multiplier
        (attention_queries) -> SSDQueries [batch seq groups state_dim]: C, the queries reading the state
        (attention_keys) -> SSDKeys [batch seq groups state_dim]: B, the keys writing into the state
        (attention_values) -> SSDValues [batch seq heads head_dim]: x, the values written into the state
        (betas) -> Gates [batch seq heads]: dt, the per-token write strength into the state
        (decays) -> Gates [batch seq heads]: A * dt, the per-token log decay of the state
        (state_input) -> State | None [batch heads key_dim value_dim]: The state entering the layer, or None at the start of a prompt (a copy of the cache's buffer)
        (attention_head_outputs) -> SSDHeadOutputs [batch seq heads head_dim]: y, the per-head outputs before the gated norm and the output projection
        (state_output) -> State [batch heads key_dim value_dim]: The state leaving the layer
        (states) -> States [batch seq heads key_dim value_dim]: The state after every token of this call; needs nnterp.chunk_per_token(model)
        (state): Unavailable: the chunk scan computes every token's state in one tensor per call, not one occurrence per token to walk with tracer.iter; read states, or state_after(t), after nnterp.chunk_per_token(model)
        (set_state_after): Unavailable: the chunk scan computes every boundary state in one cumulative step from the initial state, so a state written at token t does not flow into later tokens' states; assign state_input to change where a call starts
      )
      (mlp_input) -> Residual [batch seq hidden_size]: What the feed-forward is called with: the input of each of its modules
      (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
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (5): GraniteMoeHybridDecoderLayer(
      (input_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (post_attention_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (block_sparse_moe): GraniteMoeHybridMoE(
        (router): GraniteMoeHybridTopKRouter()
        (experts): GraniteMoeHybridExperts(
          (act_fn): SiLUActivation()
        )
      )
      (mlp/shared_mlp): GraniteMoeHybridMLP(
        (act_fn/activation): SiLUActivation()
        (input_linear): Linear(in_features=1536, out_features=2048, bias=False)
        (down_proj/output_linear): Linear(in_features=1024, out_features=1536, bias=False)
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output, unscaled
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the routed experts plus the shared expert, times residual_multiplier
        (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_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
      )
      (self_attn): GraniteMoeHybridAttention(
        (q_proj): Linear(in_features=1536, out_features=1536, bias=False)
        (k_proj): Linear(in_features=1536, out_features=512, bias=False)
        (v_proj): Linear(in_features=1536, out_features=512, bias=False)
        (o_proj): Linear(in_features=1536, out_features=1536, bias=False)
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: its output times residual_multiplier
        (attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
        (attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
        (interface): The attention function this call ran, as f(queries, keys, values) -> (head outputs, pattern), with the rest of the call's arguments
      )
      (mlp_input) -> Residual [batch seq hidden_size]: What the feed-forward is called with: the input of each of its modules
      (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
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (6-14): 9 x GraniteMoeHybridDecoderLayer(
      (input_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (post_attention_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (block_sparse_moe): GraniteMoeHybridMoE(
        (router): GraniteMoeHybridTopKRouter()
        (experts): GraniteMoeHybridExperts(
          (act_fn): SiLUActivation()
        )
      )
      (mlp/shared_mlp): GraniteMoeHybridMLP(
        (act_fn/activation): SiLUActivation()
        (input_linear): Linear(in_features=1536, out_features=2048, bias=False)
        (down_proj/output_linear): Linear(in_features=1024, out_features=1536, bias=False)
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output, unscaled
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the routed experts plus the shared expert, times residual_multiplier
        (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_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
      )
      (linear_attn/mamba): GraniteMoeHybridMambaLayer(
        (act): SiLUActivation()
        (conv1d): Conv1d(3328, 3328, kernel_size=(4,), stride=(1,), padding=(3,), groups=3328)
        (in_proj): Linear(in_features=1536, out_features=6448, bias=False)
        (norm): GraniteMoeHybridRMSNormGated()
        (out_proj): Linear(in_features=3072, out_features=1536, bias=False)
        (attention_output) -> Residual [batch seq hidden_size]: What the Mamba-2 mixer adds to the residual stream: its output times residual_multiplier
        (attention_queries) -> SSDQueries [batch seq groups state_dim]: C, the queries reading the state
        (attention_keys) -> SSDKeys [batch seq groups state_dim]: B, the keys writing into the state
        (attention_values) -> SSDValues [batch seq heads head_dim]: x, the values written into the state
        (betas) -> Gates [batch seq heads]: dt, the per-token write strength into the state
        (decays) -> Gates [batch seq heads]: A * dt, the per-token log decay of the state
        (state_input) -> State | None [batch heads key_dim value_dim]: The state entering the layer, or None at the start of a prompt (a copy of the cache's buffer)
        (attention_head_outputs) -> SSDHeadOutputs [batch seq heads head_dim]: y, the per-head outputs before the gated norm and the output projection
        (state_output) -> State [batch heads key_dim value_dim]: The state leaving the layer
        (states) -> States [batch seq heads key_dim value_dim]: The state after every token of this call; needs nnterp.chunk_per_token(model)
        (state): Unavailable: the chunk scan computes every token's state in one tensor per call, not one occurrence per token to walk with tracer.iter; read states, or state_after(t), after nnterp.chunk_per_token(model)
        (set_state_after): Unavailable: the chunk scan computes every boundary state in one cumulative step from the initial state, so a state written at token t does not flow into later tokens' states; assign state_input to change where a call starts
      )
      (mlp_input) -> Residual [batch seq hidden_size]: What the feed-forward is called with: the input of each of its modules
      (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
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (15): GraniteMoeHybridDecoderLayer(
      (input_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (post_attention_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (block_sparse_moe): GraniteMoeHybridMoE(
        (router): GraniteMoeHybridTopKRouter()
        (experts): GraniteMoeHybridExperts(
          (act_fn): SiLUActivation()
        )
      )
      (mlp/shared_mlp): GraniteMoeHybridMLP(
        (act_fn/activation): SiLUActivation()
        (input_linear): Linear(in_features=1536, out_features=2048, bias=False)
        (down_proj/output_linear): Linear(in_features=1024, out_features=1536, bias=False)
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output, unscaled
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the routed experts plus the shared expert, times residual_multiplier
        (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_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
      )
      (self_attn): GraniteMoeHybridAttention(
        (q_proj): Linear(in_features=1536, out_features=1536, bias=False)
        (k_proj): Linear(in_features=1536, out_features=512, bias=False)
        (v_proj): Linear(in_features=1536, out_features=512, bias=False)
        (o_proj): Linear(in_features=1536, out_features=1536, bias=False)
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: its output times residual_multiplier
        (attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
        (attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
        (interface): The attention function this call ran, as f(queries, keys, values) -> (head outputs, pattern), with the rest of the call's arguments
      )
      (mlp_input) -> Residual [batch seq hidden_size]: What the feed-forward is called with: the input of each of its modules
      (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
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (16-24): 9 x GraniteMoeHybridDecoderLayer(
      (input_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (post_attention_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (block_sparse_moe): GraniteMoeHybridMoE(
        (router): GraniteMoeHybridTopKRouter()
        (experts): GraniteMoeHybridExperts(
          (act_fn): SiLUActivation()
        )
      )
      (mlp/shared_mlp): GraniteMoeHybridMLP(
        (act_fn/activation): SiLUActivation()
        (input_linear): Linear(in_features=1536, out_features=2048, bias=False)
        (down_proj/output_linear): Linear(in_features=1024, out_features=1536, bias=False)
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output, unscaled
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the routed experts plus the shared expert, times residual_multiplier
        (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_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
      )
      (linear_attn/mamba): GraniteMoeHybridMambaLayer(
        (act): SiLUActivation()
        (conv1d): Conv1d(3328, 3328, kernel_size=(4,), stride=(1,), padding=(3,), groups=3328)
        (in_proj): Linear(in_features=1536, out_features=6448, bias=False)
        (norm): GraniteMoeHybridRMSNormGated()
        (out_proj): Linear(in_features=3072, out_features=1536, bias=False)
        (attention_output) -> Residual [batch seq hidden_size]: What the Mamba-2 mixer adds to the residual stream: its output times residual_multiplier
        (attention_queries) -> SSDQueries [batch seq groups state_dim]: C, the queries reading the state
        (attention_keys) -> SSDKeys [batch seq groups state_dim]: B, the keys writing into the state
        (attention_values) -> SSDValues [batch seq heads head_dim]: x, the values written into the state
        (betas) -> Gates [batch seq heads]: dt, the per-token write strength into the state
        (decays) -> Gates [batch seq heads]: A * dt, the per-token log decay of the state
        (state_input) -> State | None [batch heads key_dim value_dim]: The state entering the layer, or None at the start of a prompt (a copy of the cache's buffer)
        (attention_head_outputs) -> SSDHeadOutputs [batch seq heads head_dim]: y, the per-head outputs before the gated norm and the output projection
        (state_output) -> State [batch heads key_dim value_dim]: The state leaving the layer
        (states) -> States [batch seq heads key_dim value_dim]: The state after every token of this call; needs nnterp.chunk_per_token(model)
        (state): Unavailable: the chunk scan computes every token's state in one tensor per call, not one occurrence per token to walk with tracer.iter; read states, or state_after(t), after nnterp.chunk_per_token(model)
        (set_state_after): Unavailable: the chunk scan computes every boundary state in one cumulative step from the initial state, so a state written at token t does not flow into later tokens' states; assign state_input to change where a call starts
      )
      (mlp_input) -> Residual [batch seq hidden_size]: What the feed-forward is called with: the input of each of its modules
      (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
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (25): GraniteMoeHybridDecoderLayer(
      (input_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (post_attention_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (block_sparse_moe): GraniteMoeHybridMoE(
        (router): GraniteMoeHybridTopKRouter()
        (experts): GraniteMoeHybridExperts(
          (act_fn): SiLUActivation()
        )
      )
      (mlp/shared_mlp): GraniteMoeHybridMLP(
        (act_fn/activation): SiLUActivation()
        (input_linear): Linear(in_features=1536, out_features=2048, bias=False)
        (down_proj/output_linear): Linear(in_features=1024, out_features=1536, bias=False)
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output, unscaled
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the routed experts plus the shared expert, times residual_multiplier
        (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_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
      )
      (self_attn): GraniteMoeHybridAttention(
        (q_proj): Linear(in_features=1536, out_features=1536, bias=False)
        (k_proj): Linear(in_features=1536, out_features=512, bias=False)
        (v_proj): Linear(in_features=1536, out_features=512, bias=False)
        (o_proj): Linear(in_features=1536, out_features=1536, bias=False)
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: its output times residual_multiplier
        (attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
        (attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
        (interface): The attention function this call ran, as f(queries, keys, values) -> (head outputs, pattern), with the rest of the call's arguments
      )
      (mlp_input) -> Residual [batch seq hidden_size]: What the feed-forward is called with: the input of each of its modules
      (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
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (26-34): 9 x GraniteMoeHybridDecoderLayer(
      (input_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (post_attention_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (block_sparse_moe): GraniteMoeHybridMoE(
        (router): GraniteMoeHybridTopKRouter()
        (experts): GraniteMoeHybridExperts(
          (act_fn): SiLUActivation()
        )
      )
      (mlp/shared_mlp): GraniteMoeHybridMLP(
        (act_fn/activation): SiLUActivation()
        (input_linear): Linear(in_features=1536, out_features=2048, bias=False)
        (down_proj/output_linear): Linear(in_features=1024, out_features=1536, bias=False)
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output, unscaled
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the routed experts plus the shared expert, times residual_multiplier
        (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_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
      )
      (linear_attn/mamba): GraniteMoeHybridMambaLayer(
        (act): SiLUActivation()
        (conv1d): Conv1d(3328, 3328, kernel_size=(4,), stride=(1,), padding=(3,), groups=3328)
        (in_proj): Linear(in_features=1536, out_features=6448, bias=False)
        (norm): GraniteMoeHybridRMSNormGated()
        (out_proj): Linear(in_features=3072, out_features=1536, bias=False)
        (attention_output) -> Residual [batch seq hidden_size]: What the Mamba-2 mixer adds to the residual stream: its output times residual_multiplier
        (attention_queries) -> SSDQueries [batch seq groups state_dim]: C, the queries reading the state
        (attention_keys) -> SSDKeys [batch seq groups state_dim]: B, the keys writing into the state
        (attention_values) -> SSDValues [batch seq heads head_dim]: x, the values written into the state
        (betas) -> Gates [batch seq heads]: dt, the per-token write strength into the state
        (decays) -> Gates [batch seq heads]: A * dt, the per-token log decay of the state
        (state_input) -> State | None [batch heads key_dim value_dim]: The state entering the layer, or None at the start of a prompt (a copy of the cache's buffer)
        (attention_head_outputs) -> SSDHeadOutputs [batch seq heads head_dim]: y, the per-head outputs before the gated norm and the output projection
        (state_output) -> State [batch heads key_dim value_dim]: The state leaving the layer
        (states) -> States [batch seq heads key_dim value_dim]: The state after every token of this call; needs nnterp.chunk_per_token(model)
        (state): Unavailable: the chunk scan computes every token's state in one tensor per call, not one occurrence per token to walk with tracer.iter; read states, or state_after(t), after nnterp.chunk_per_token(model)
        (set_state_after): Unavailable: the chunk scan computes every boundary state in one cumulative step from the initial state, so a state written at token t does not flow into later tokens' states; assign state_input to change where a call starts
      )
      (mlp_input) -> Residual [batch seq hidden_size]: What the feed-forward is called with: the input of each of its modules
      (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
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (35): GraniteMoeHybridDecoderLayer(
      (input_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (post_attention_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (block_sparse_moe): GraniteMoeHybridMoE(
        (router): GraniteMoeHybridTopKRouter()
        (experts): GraniteMoeHybridExperts(
          (act_fn): SiLUActivation()
        )
      )
      (mlp/shared_mlp): GraniteMoeHybridMLP(
        (act_fn/activation): SiLUActivation()
        (input_linear): Linear(in_features=1536, out_features=2048, bias=False)
        (down_proj/output_linear): Linear(in_features=1024, out_features=1536, bias=False)
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output, unscaled
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the routed experts plus the shared expert, times residual_multiplier
        (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_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
      )
      (self_attn): GraniteMoeHybridAttention(
        (q_proj): Linear(in_features=1536, out_features=1536, bias=False)
        (k_proj): Linear(in_features=1536, out_features=512, bias=False)
        (v_proj): Linear(in_features=1536, out_features=512, bias=False)
        (o_proj): Linear(in_features=1536, out_features=1536, bias=False)
        (attention_output) -> Residual [batch seq hidden_size]: What the attention adds to the residual stream: its output times residual_multiplier
        (attention_queries_prerope) -> Queries [batch num_heads seq qk_head_dim]: The queries entering the rotary embedding
        (attention_keys_prerope) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering the rotary embedding
        (attention_queries) -> Queries [batch num_heads seq qk_head_dim]: The queries entering attention
        (attention_keys) -> Keys [batch num_kv_heads seq qk_head_dim]: The keys entering attention
        (attention_values) -> Values [batch num_kv_heads seq head_dim]: The values entering attention
        (attention_scores) -> Pattern [batch num_heads query key]: The attention scores entering the softmax, masked
        (attention_premix) -> HeadOutputs [batch seq num_heads head_dim]: Every head's output side by side, as the output projection takes it
        (attention_probabilities) -> Pattern [batch num_heads query key]: The attention pattern the values are mixed with
        (attention_head_outputs) -> HeadOutputs [batch seq num_heads head_dim]: The per-head outputs before the output projection
        (interface): The attention function this call ran, as f(queries, keys, values) -> (head outputs, pattern), with the rest of the call's arguments
      )
      (mlp_input) -> Residual [batch seq hidden_size]: What the feed-forward is called with: the input of each of its modules
      (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
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
    (36-39): 4 x GraniteMoeHybridDecoderLayer(
      (input_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (post_attention_layernorm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
      (block_sparse_moe): GraniteMoeHybridMoE(
        (router): GraniteMoeHybridTopKRouter()
        (experts): GraniteMoeHybridExperts(
          (act_fn): SiLUActivation()
        )
      )
      (mlp/shared_mlp): GraniteMoeHybridMLP(
        (act_fn/activation): SiLUActivation()
        (input_linear): Linear(in_features=1536, out_features=2048, bias=False)
        (down_proj/output_linear): Linear(in_features=1024, out_features=1536, bias=False)
        (shared_expert_output) -> Residual [batch seq hidden_size]: The shared expert's output, unscaled
        (mlp_output) -> Residual [batch seq hidden_size]: What the MLP adds to the residual stream: the routed experts plus the shared expert, times residual_multiplier
        (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_weights) -> ExpertWeights [batch seq top_k]: The weight each selected expert's output is scaled by
        (expert_indices) -> ExpertIndices [batch seq top_k]: The expert each routing slot sends the token to
        (expert_outputs) -> ExpertOutputs [batch seq top_k hidden_size]: Each routing slot's weighted expert output
        (routed_output) -> Residual [batch seq hidden_size]: The routed experts' combined output
      )
      (linear_attn/mamba): GraniteMoeHybridMambaLayer(
        (act): SiLUActivation()
        (conv1d): Conv1d(3328, 3328, kernel_size=(4,), stride=(1,), padding=(3,), groups=3328)
        (in_proj): Linear(in_features=1536, out_features=6448, bias=False)
        (norm): GraniteMoeHybridRMSNormGated()
        (out_proj): Linear(in_features=3072, out_features=1536, bias=False)
        (attention_output) -> Residual [batch seq hidden_size]: What the Mamba-2 mixer adds to the residual stream: its output times residual_multiplier
        (attention_queries) -> SSDQueries [batch seq groups state_dim]: C, the queries reading the state
        (attention_keys) -> SSDKeys [batch seq groups state_dim]: B, the keys writing into the state
        (attention_values) -> SSDValues [batch seq heads head_dim]: x, the values written into the state
        (betas) -> Gates [batch seq heads]: dt, the per-token write strength into the state
        (decays) -> Gates [batch seq heads]: A * dt, the per-token log decay of the state
        (state_input) -> State | None [batch heads key_dim value_dim]: The state entering the layer, or None at the start of a prompt (a copy of the cache's buffer)
        (attention_head_outputs) -> SSDHeadOutputs [batch seq heads head_dim]: y, the per-head outputs before the gated norm and the output projection
        (state_output) -> State [batch heads key_dim value_dim]: The state leaving the layer
        (states) -> States [batch seq heads key_dim value_dim]: The state after every token of this call; needs nnterp.chunk_per_token(model)
        (state): Unavailable: the chunk scan computes every token's state in one tensor per call, not one occurrence per token to walk with tracer.iter; read states, or state_after(t), after nnterp.chunk_per_token(model)
        (set_state_after): Unavailable: the chunk scan computes every boundary state in one cumulative step from the initial state, so a state written at token t does not flow into later tokens' states; assign state_input to change where a call starts
      )
      (mlp_input) -> Residual [batch seq hidden_size]: What the feed-forward is called with: the input of each of its modules
      (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
      (layer_output) -> Residual [batch seq hidden_size]: The residual stream leaving the block, a tensor even when the block returns a tuple
    )
  )
  (norm): GraniteMoeHybridRMSNorm((1536,), eps=1e-05)
  (logits) -> Logits [batch seq vocab_size]: The logits the model returns, after anything it does past lm_head (a softcap, a scale)
  (token_embeddings) -> Residual [batch seq hidden_size]: The embedding module's output; layers[0].input is what enters the first block
  (final_norm_output) -> Residual [batch seq hidden_size]: The residual stream after the final norm, what lm_head reads
  (lm_head_output) -> Logits [batch seq vocab_size]: The head's logits before anything the model does past lm_head (a softcap, a scale)
  (next_token_probs) -> NextTokenProbs [batch vocab_size]: The next-token distribution at the last position; derived, read-only
  (input_ids) -> Tokens [batch seq]: The token ids the model was called with
  (attention_mask) -> Tokens [batch seq]: The attention mask the model was called with; zeros are padding
  (input_size): [batch, seq] of the current call; read-only
)

Config

model.num_layers40
model.hidden_size1536
model.num_heads12
model.num_kv_heads4
model.head_dim128
model.qk_head_dim128
model.vocab_size100352
model.intermediate_size1024
architecturesGraniteMoeHybridForCausalLM
num_hidden_layers40
hidden_size1536
intermediate_size512
num_attention_heads12
num_key_value_heads4
vocab_size100352
max_position_embeddings131072
hidden_actsilu
rms_norm_eps1e-05
tie_word_embeddingsTrue
dtypebfloat16
embedding_multiplier12
residual_multiplier0.22
attention_multiplier0.0078125
logits_scaling6
num_experts_per_tok6
num_local_experts64
mamba_n_heads48
mamba_d_head64
mamba_d_state128
mamba_expand2
mamba_chunk_size256
mamba_n_groups1
attention_biasFalse

The Notes

03 · what to know before you run

The contributions are scaled, and mlp is the shared MLP

h   = x + mixer(input_layernorm(x)) * residual_multiplier       # linear_attn or self_attn
n   = post_attention_layernorm(h)
out = h + (block_sparse_moe(n) + mlp(n)) * residual_multiplier

attention_output, on either mixer, and mlp_output are the tensors the block adds, outputs times residual_multiplier. mlp is the shared MLP every block has, so mlp.output is its output alone; on the mixture checkpoints (H-Tiny, H-Small, the Tiny previews) mlp_output also holds the routed experts' term, layers[i].block_sparse_moe.output, and a write to it replaces both. In bfloat16 a write to either contribution moves the other positions by rounding; load in float32 for small edits.

The prompt's first token is an attention sink

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

The logits are divided by logits_scaling, and the embeddings multiplied

model.logits is lm_head.output / logits_scaling and project_on_vocab divides too, so a softmax over lm_head.output is sharper than the model's own distribution. layers[0].input is token_embeddings times embedding_multiplier, and embeddings passed as inputs_embeds are multiplied too, so to set what block 0 reads, edit layers[0].input.

From the family module

04 · nnterp/families/granitemoehybrid.py

GraniteMoE-Hybrid (GraniteMoeHybridForCausalLM, IBM Granite 4.0 and 4.0-H).

Llama's containers over one block class that holds either a Mamba-2 mixer or attention, by config.layers_block_type, and then a feed-forward::

model.layers[i]          GraniteMoeHybridDecoderLayer
    .input_layernorm
    .mamba               GraniteMoeHybridMambaLayer, an SSD mixer   (or .self_attn)
    .post_attention_layernorm
    .block_sparse_moe    GraniteMoeHybridMoE (only when num_local_experts > 0)
    .shared_mlp          GraniteMoeHybridMLP (on every block)

h = x + mixer(input_layernorm(x)) * residual_multiplier
out = h + (block_sparse_moe(n) + shared_mlp(n)) * residual_multiplier     with n = post_attention_layernorm(h)

(shared_mlp(n) alone on a dense checkpoint, Granite-4.0-H-Micro's.) mamba is linear_attn (nnterp.StateSpace) and shared_mlp, the one feed-forward every block has, is mlp; each block has self_attn or linear_attn, never both. As on Granite (granite.py) the block adds each sublayer's output times residual_multiplier: both mixers' attention_output are the module's output times it, computed copies divided on assignment and carried back by a transform. No module returns the feed-forward's sum, so mlp_output is the block's binding of it (hidden_states_4 with experts, hidden_states_5 without) times the multiplier, and the family's Layer sets sourced for it; the mixer and the shared expert, whose modules keep no config, read the multiplier (and the Mlp whether routed experts run) off their parent block. A write lands on the sum, replacing both experts' contribution. mlp.output is the shared expert's output alone and layers[i].block_sparse_moe.output the routed experts'; mlp_input is the pre-MLP norm's output, which both are called with, not mlp.input, the shared expert's argument alone, so a write to it reaches both. The mixture's values live on mlp (a Moe), which reads block_sparse_moe's router and experts through its parent: shared_expert_output is mlp.output and routed_output + shared_expert_output == mlp_output / residual_multiplier. mlp.intermediate_size and the root's intermediate_size are the shared expert's width, shared_intermediate_size; the routed experts are intermediate_size wide. The attention runs the shared attention interface with attention_multiplier as its scale and no rotary under position_embedding_type nope (Granite-4.0-H); embedding_multiplier and logits_scaling are as on Granite.