Safe By Design AI

GPTBigCodeForCausalLM

GPTBigCodeForCausalLM at 52 layers and hidden size 6144. 5 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.

16 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_up
│  └─ w_down
└─ head

Recorded separately from the structure: layer fired 52 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 step names in the recorded pass are the implementation's generic decoder labels, not this class's: the block below has LayerNorm where the labels say rmsnorm, one fused c_attn where they say wq/wk/wv, and no rotary step where they say rope. The order is what the recording shows.

The same thing in canonical form:

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

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-20b-code-base-8k

Also covers granite-20b-code-base-r1.1, granite-20b-code-instruct-8k, granite-20b-code-instruct-r1.1.

x = wte[ids] + wpe[0..T]                 # [T, 6144], learned absolute positions

for i in 0 .. 51:
    h = layernorm(x, layers[i].ln_1, eps=1e-05)
    qkv = h @ layers[i].attn.c_attn.T + layers[i].attn.c_attn.bias
    q, k, v = split(qkv, [48*128, 128, 128])
    # Multi-query: 48 query heads, one key/value head — and one
    # fused projection. The configuration says so with
    # `multi_query: true` and publishes no `num_key_value_heads`.
    a = softmax(q @ k.T / sqrt(128), mask=causal) @ v
    x = x + a @ layers[i].attn.c_proj.T + layers[i].attn.c_proj.bias

    h = layernorm(x, layers[i].ln_2)
    y = gelu(h @ layers[i].mlp.c_fc.T + layers[i].mlp.c_fc.bias)   # [T, 24576]
    x = x + y @ layers[i].mlp.c_proj.T + layers[i].mlp.c_proj.bias

x = layernorm(x, ln_f)
logits = x @ wte.T                        # tied to the input embedding

From granite-20b-functioncalling

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

x = wte[ids] + wpe[0..T]                 # [T, 6144], learned absolute positions

for i in 0 .. 51:
    h = layernorm(x, layers[i].ln_1, eps=1e-05)
    qkv = h @ layers[i].attn.c_attn.T + layers[i].attn.c_attn.bias
    q, k, v = split(qkv, [48*128, 128, 128])
    # Multi-query: 48 query heads, one key/value head — and one
    # fused projection. The configuration says so with
    # `multi_query: true` and publishes no `num_key_value_heads`.
    a = softmax(q @ k.T / sqrt(128), mask=causal) @ v
    x = x + a @ layers[i].attn.c_proj.T + layers[i].attn.c_proj.bias

    h = layernorm(x, layers[i].ln_2)
    y = gelu_pytorch_tanh(h @ layers[i].mlp.c_fc.T + layers[i].mlp.c_fc.bias)   # [T, 24576]
    x = x + y @ layers[i].mlp.c_proj.T + layers[i].mlp.c_proj.bias

x = layernorm(x, ln_f)
logits = x @ wte.T                        # tied to the input embedding

Notes that apply to more than one block

Stated once here rather than under each block above.

This is the older code lineage and it differs from the Granite classes at every point a reader might carry an assumption across: LayerNorm, not RMSNorm; learned absolute positions, not rotary; a GELU MLP with no gate, not SwiGLU; one fused c_attn rather than three projections; and a bias on every projection, where the Granite classes carry none.

The biases are the one of those five a reader is most likely to drop.

wpe has 8,192 rows, which is the hard context bound: there is no rotary base to extend.

Geometry

layers52
hidden size6,144
attention heads48, 1 key/value
feed-forward width24,576
vocabulary49,152
trained context8,192 tokens
largest checkpoint20.1B

Weight structure

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

repeating stackdepthwhat one element holds
transformer.h.#52attn.c_attn.bias, attn.c_attn.weight, attn.c_proj.bias, attn.c_proj.weight, ln_1.bias, ln_1.weight, ln_2.bias, ln_2.weight, mlp.c_fc.bias, mlp.c_fc.weight, mlp.c_proj.bias, mlp.c_proj.weight

Outside the stack: transformer.wte.weight (the token embedding, which the output also reads), transformer.wpe.weight (the learned position table), and the final norm transformer.ln_f.weight, transformer.ln_f.bias.

Other shapes of GPTBigCodeForCausalLM

Identical across all of them: width 6,144, heads 48, KV heads 1, FFN width 24,576, vocabulary 49,152, context 8,192.

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

shapelayerscheckpoints
88L x 6,144882
52L x 6,144 (this sheet)525

How this was checked

The checkpoints of this shape do not all carry the same grade in the assessment. 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-20b-code-base-8k20.1B8,192
granite-20b-code-base-r1.120.1B8,192
granite-20b-code-instruct-8k20.1B8,192
granite-20b-code-instruct-r1.120.1B8,192
granite-20b-functioncalling20.1B8,192