Safe By Design AI

GPTBigCodeForCausalLM

GPTBigCodeForCausalLM at 52 layers and hidden size 6144. 5 published checkpoints share this shape.

Implementing it

How to read this sheet: method.

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

Differs from the block above

The same arithmetic with this value changed. Everything not listed is as above.

checkpointactivation_function
granite-20b-functioncallinggelu_pytorch_tanh (the tanh approximation; the block above is exact gelu)

Notes

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. Each is in modeling_gpt_bigcode.py at transformers v4.57.1: LayerNorm, position table, fused c_attn, its q/k/v split, tied head.

wpe has 8,192 rows (n_positions), 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

Status and evidence grade in the assessment (see what the grades mean):

Parts of the author's unpublished implementation that exist for this shape:

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

Recorded pass: passes.