Safe By Design AI

GraniteForCausalLM

GraniteForCausalLM at 64 layers and hidden size 4096. 3 published checkpoints share this shape.

The pass (full forward)

The order of operations for one forward. ×N marks a position that fires once per layer.

17 steps across nested levels, recorded from one complete forward of this shape in the author's independent implementation — the structure is what that run emitted, not a reading of the configuration.

forward
├─ embed
├─ layer ×N
│  ├─ rmsnorm_attn
│  ├─ wq
│  ├─ wk
│  ├─ wv
│  ├─ rope
│  ├─ attn
│  │  ├─ scores
│  │  └─ attn_mix
│  ├─ wo
│  ├─ rmsnorm_mlp
│  ├─ w_gate
│  ├─ w_up
│  └─ w_down
└─ head

Recorded separately from the structure: layer fired 64 times. A ×N run says only that it repeated — how long a run is is not part of the structure, so two models differing only in depth have the same pass.

The same thing in canonical form:

0(1 2*N(3 4 5 6 7 8(9 10) 11 12 13 14 15) 16)

Numbers are positions in the pass, not layer indices. Two passes count as the same structure when these strings match.

Implementing it

One forward, written out, per checkpoint whose arithmetic actually differs. A shape groups checkpoints by class, depth, width and layer stack — none of which decides an activation, a rope base or a routing rule — so where the members of this shape disagree there is a block each, and each names the checkpoint it was generated from.

It is not the recorded pass above, which is captured from a real forward; it is what the published configuration says the arithmetic is. Where the configuration does not say, the line says that instead of guessing.

The names are the ones the published checkpoint uses where a name is published, and canonical otherwise. A checkpoint loader may store them differently — fusing a gate/up pair into one matrix, or splitting one published projection in two — and those are that loader's names, not the model's. Everything spelled here is what the download contains.

From granite-4.2-30b

This checkpoint only — its arithmetic differs from the others of this shape.

x = embed[ids] * 1                    # [T, 4096]   <- embedding_multiplier

for i in 0 .. 63:
    h = rmsnorm(x, layers[i].input_layernorm, eps=1e-05)
    q = h @ layers[i].self_attn.q_proj.T       # [T, 32*128]
    k = h @ layers[i].self_attn.k_proj.T       # [T, 8*128]
    v = h @ layers[i].self_attn.v_proj.T       # [T, 8*128]
    q, k = rope(q, k, theta=50000000)
    k, v = repeat_kv(k, v, 4)            # 32 query heads share 8 key/value heads
    a = softmax(q @ k.T * 0.0078125, mask=causal) @ v      # <- attention_multiplier
    a = a @ layers[i].self_attn.o_proj.T
    x = x + a * 1        # <- residual_multiplier

    h = rmsnorm(x, layers[i].post_attention_layernorm)
    g = silu(h @ layers[i].mlp.gate_proj.T)           # [T, 32768]
    u =       h @ layers[i].mlp.up_proj.T
    y = (g * u) @ layers[i].mlp.down_proj.T
    x = x + y * 1

x = rmsnorm(x, model.norm)
logits = (x @ lm_head.T) / 1        # <- logits_scaling

From granite-4.1-30b

Also covers granite-4.1-30b-base.

x = embed[ids] * 12                    # [T, 4096]   <- embedding_multiplier

for i in 0 .. 63:
    h = rmsnorm(x, layers[i].input_layernorm, eps=1e-05)
    q = h @ layers[i].self_attn.q_proj.T       # [T, 32*128]
    k = h @ layers[i].self_attn.k_proj.T       # [T, 8*128]
    v = h @ layers[i].self_attn.v_proj.T       # [T, 8*128]
    q, k = rope(q, k, theta=50000000)
    k, v = repeat_kv(k, v, 4)            # 32 query heads share 8 key/value heads
    a = softmax(q @ k.T * 0.0078125, mask=causal) @ v      # <- attention_multiplier
    a = a @ layers[i].self_attn.o_proj.T
    x = x + a * 0.175        # <- residual_multiplier

    h = rmsnorm(x, layers[i].post_attention_layernorm)
    g = silu(h @ layers[i].mlp.gate_proj.T)           # [T, 32768]
    u =       h @ layers[i].mlp.up_proj.T
    y = (g * u) @ layers[i].mlp.down_proj.T
    x = x + y * 0.175

x = rmsnorm(x, model.norm)
logits = (x @ embed.T) / 16        # tied to the input embedding; <- logits_scaling

Notes that apply to more than one block

Stated once here rather than under each block above.

head_dim is not published; 4096 / 32 = 128 is used.

The Granite multipliers are the part with no Llama analogue: embedding_multiplier, attention_multiplier, residual_multiplier, logits_scaling. They are ordinary floats and a port that ignores them still produces fluent text, which is what makes them worth printing where they act.

Geometry

layers64
hidden size4,096
attention heads32, 8 key/value
feed-forward width32,768
vocabulary100,352
trained context131,072 tokens
largest checkpoint29.3B

Weight structure

The tensors one element of the repeating stack holds, by the names the published checkpoint uses.

repeating stackdepthwhat one element holds
model.layers.#64input_layernorm.weight, mlp.down_proj.weight, mlp.gate_proj.weight, mlp.up_proj.weight, post_attention_layernorm.weight, self_attn.k_proj.weight, self_attn.o_proj.weight, self_attn.q_proj.weight, self_attn.v_proj.weight

Other shapes of GraniteForCausalLM

Identical across all of them: KV heads 8.

Only the columns that differ are shown; a cell with several values means the checkpoints of that shape disagree.

shapelayerswidthheadsFFN widthvocabularycontextcheckpoints
64L x 4,096 (this sheet)644,0963232,768100,352131,0723
40L x 4,096404,0963212,80049,152 / 49,155 / 49,159 / 100,3524,096 / 8,192 / 131,07219
40L x 2,560402,560408,192100,352131,0723
40L x 2,048402,048328,19249,152 / 49,155 / 49,1594,096 / 8,192 / 131,0729
28L x 4,096284,0963212,80049,155131,0722

How this was checked

implemented, evidence grade shape-parity, per the assessment, for each checkpoint of this shape: a converted checkpoint of this shape was compared against a reference recording; whether it holds this checkpoint's weights is not established. The implementation meant here and below is an unpublished independent inference implementation by the author.

What stands behind the block above, beyond the published configuration it is read from:

Where an independent implementation and the published configuration disagree, the configuration is what this page reports and the disagreement is what it says.

Checkpoints with this architecture

modelparameterscontext
granite-4.2-30b29.3B131,072
granite-4.1-30b28.9B131,072
granite-4.1-30b-base28.9B131,072