Gemma · Google

Gemma 3 27B

Gemma 3 27B from Google has 27,009,346,304 parameters in its language model. Its weights take 54.0 GB in BF16 and about 13.5 GB at 4-bit, and each token of context adds 507.9 KB of KV cache (16.6 GB at 32K tokens). The checkpoint also carries a 423M-parameter vision encoder.

27Bparameters
54.0 GBBF16 weights
13.5 GB4-bit weights
507.9 KBKV per token

Part of the Gemma 3 family: 268M · 1B · 3.88B · 11.8B · 27B

Architecture · VRAM · KV cache · Tensor shapes · Parameter count · FLOPs

Architecture

ArchitectureGemma3ForConditionalGeneration
Layers (L)62
Hidden size (d)5,376
AttentionGQA (2 query heads share each KV head)
Heads32 query, 16 key/value, 128 each
Feed-forwardGeGLU, hidden size 21,504
Vocabulary (V)262,208
Tied embeddingsyes: the output head reuses the embedding
Biasesnone
Extra normsRMSNorm on q and k (per head); norms before and after attention and FFN
Max context131,072 tokens; 52 of 62 layers use a 1,024-token sliding window
Vision encoderSigLIP, 27 layers, 1,152 wide: 423M parameters with the projector (in the checkpoint, used only for images)
Weights in the releasebfloat16

How much memory the weights need

Each parameter takes 4 bytes in FP32, 2 in BF16, 1 at 8 bits and half a byte at 4 bits, so the weights of the language model alone need:

PrecisionBytes per parameterWeights
FP324108 GB100.62 GiB
BF16 / FP16254.0 GB50.31 GiB
INT8 / FP8127.0 GB25.15 GiB
INT40.513.5 GB12.58 GiB

GB here is 109 bytes; GiB (230) is what tools like nvidia-smi show. Real 4-bit files are a little larger: they also store scales, and some layers are often kept at higher precision. The vision encoder adds 846 MB in BF16 when images are used. A running model also needs its KV cache, activations and the runtime's own buffers.

Memory calculator

On common GPUs

Whether the weights plus a 8K-token KV cache fit in 90% of the card (how this is worked out):

GPU memoryBF168-bit4-bit
8 GB–––
12 GB–––
16 GB–––
24 GB––✓
48 GB–✓✓
80 GB✓✓✓

KV cache

Every layer keeps a key and a value vector for each of its 16 KV heads, for every token in the context:

2 × L × K × h × 2 bytes = 2 × 62 × 16 × 128 × 2 = 507,904 bytes per token

Grouped-query attention is why this is small: with a KV head for each of the 32 query heads it would be 2 times larger.

ContextKV cache, BF168-bit KVWith the sliding windowWeights + KV, BF16
4K2.1 GB1.0 GB772 MB56.1 GB
32K16.6 GB8.3 GB3.1 GB70.7 GB
128K (max)66.6 GB33.3 GB11.2 GB121 GB

In the config, 52 of 62 layers use a 1,024-token sliding window. Runtimes that honour it never cache more than 1,024 tokens for those layers; the column shows what that saves.

For one sequence. Batching multiplies the KV cache by the number of sequences, not the weights.

Every tensor shape

The names are those in the Hugging Face checkpoint (the language model's sit under language_model.); shapes are [out, in] for weight matrices, as PyTorch stores them. One block is shown: the model repeats it 62 times.

TensorShapeParameters
Embedding
model.embed_tokens.weightalso used as the output head (tied)[262,208, 5,376]1,409,630,208
Every block: model.layers.N.…
self_attn.q_proj.weight[4,096, 5,376]22,020,096
self_attn.k_proj.weight[2,048, 5,376]11,010,048
self_attn.v_proj.weight[2,048, 5,376]11,010,048
self_attn.o_proj.weight[5,376, 4,096]22,020,096
self_attn.q_norm.weightshared by every head[128]128
self_attn.k_norm.weight[128]128
mlp.gate_proj.weight[21,504, 5,376]115,605,504
mlp.up_proj.weight[21,504, 5,376]115,605,504
mlp.down_proj.weight[5,376, 21,504]115,605,504
input_layernorm.weight[5,376]5,376
post_attention_layernorm.weight[5,376]5,376
pre_feedforward_layernorm.weight[5,376]5,376
post_feedforward_layernorm.weight[5,376]5,376
After the last block
model.norm.weightfinal norm[5,376]5,376
Vision encoder: patches and positions
vision_tower.vision_model.embeddings.patch_embedding.weighta 14×14 convolution over the image[1,152, 3, 14, 14]677,376
vision_tower.vision_model.embeddings.patch_embedding.bias[1,152]1,152
vision_tower.vision_model.embeddings.position_embedding.weightone per patch of a 896×896 image[4,096, 1,152]4,718,592
Vision encoder: one layer (×27): …layers.N.…
self_attn.q_proj.weight[1,152, 1,152]1,327,104
self_attn.q_proj.bias[1,152]1,152
self_attn.k_proj.weight[1,152, 1,152]1,327,104
self_attn.k_proj.bias[1,152]1,152
self_attn.v_proj.weight[1,152, 1,152]1,327,104
self_attn.v_proj.bias[1,152]1,152
self_attn.out_proj.weight[1,152, 1,152]1,327,104
self_attn.out_proj.bias[1,152]1,152
mlp.fc1.weight[4,304, 1,152]4,958,208
mlp.fc1.bias[4,304]4,304
mlp.fc2.weight[1,152, 4,304]4,958,208
mlp.fc2.bias[1,152]1,152
layer_norm1.weight[1,152]1,152
layer_norm1.bias[1,152]1,152
layer_norm2.weight[1,152]1,152
layer_norm2.bias[1,152]1,152
Vision encoder: final norm and projector
vision_tower.vision_model.post_layernorm.weight[1,152]1,152
vision_tower.vision_model.post_layernorm.bias[1,152]1,152
multi_modal_projector.mm_input_projection_weightimage features to the language model's width[1,152, 5,376]6,193,152
multi_modal_projector.mm_soft_emb_norm.weight[1,152]1,152

The parameter count, step by step

Each line gives the formula, the numbers from config.json, and the subtotal. The symbols:

V
vocabulary 262,208
d
hidden size 5,376
L
layers 62
H
query heads 32
K
key/value heads 16
h
head size 128
f
FFN hidden size 21,504

1. Embedding

One row of d numbers for each of the V tokens in the vocabulary.

Embedding
V × d
262,208 × 5,376
= 1,409,630,208

2. Every block, ×62

Attention
H·h × d + 2 × (K·h × d) + d × H·h + 2 × h
4,096 × 5,376 + 2 × (2,048 × 5,376) + 5,376 × 4,096 + 2 × 128
= 66,060,544
Feed-forward (GeGLU)
2 × (f × d) + d × f
2 × (21,504 × 5,376) + 5,376 × 21,504
= 346,816,512
Norms
4 × d
4 × 5,376
= 21,504
One block
attention + feed-forward + norms
66,060,544 + 346,816,512 + 21,504
= 412,898,560
62 blocks
L × block
62 × 412,898,560
= 25,599,710,720

3. Final norm and output head

Final norm (the head is the embedding, tied: 0 more)
d
5,376
= 5,376

4. Total

Language model
embedding + blocks + final
1,409,630,208 + 25,599,710,720 + 5,376
= 27,009,346,304

5. Vision encoder

The checkpoint also holds an image encoder (SigLIP, 27 layers of width d_v = 1,152, MLP f_v = 4,304) and a projector into the language model. It runs only when the prompt has an image, so it is listed apart from the language model.

patches and positions

Patch embedding
d_v × C × p × p + d_v + (img/p)² × d_v
1,152 × 3 × 14 × 14 + 1,152 + 4,096 × 1,152
= 5,397,120

one layer, ×27

Attention
4 × (d_v × d_v) + 4 × d_v
4 × (1,152 × 1,152) + 4 × 1,152
= 5,313,024
MLP
f_v × d_v + f_v + d_v × f_v + d_v
4,304 × 1,152 + 4,304 + 1,152 × 4,304 + 1,152
= 9,921,872
LayerNorms
4 × d_v
4 × 1,152
= 4,608
One block
attention + mlp + layernorms
5,313,024 + 9,921,872 + 4,608
= 15,239,504
27 blocks
27 × block
27 × 15,239,504
= 411,466,608

final norm and projector

Into the language model
3 × d_v + d_v × d
3 × 1,152 + 1,152 × 5,376
= 6,196,608
Vision encoder
the parts above
5,397,120 + 411,466,608 + 6,196,608
= 423,060,336
In the checkpoint
language model + vision
27,009,346,304 + 423,060,336
= 27,432,406,640

Hugging Face counts 27,432,406,640 parameters in the unsloth/gemma-3-27b-pt safetensors files. The arithmetic above matches exactly.

FLOPs per token

A forward pass costs about two floating-point operations (a multiply and an add) for every weight a token passes through: 2 × N, with N the weights used in matrix multiplies (the embedding lookup is a read, not a multiply; the output head is a multiply, even though it is tied to the embedding). Here that is 2 × 27,009,346,304 = 54.0 GFLOPs per token.

Attention adds the work of comparing the token with every earlier one: 2 × L × T × H × (hqk + hv) for T tokens of context, which grows with the context while 2N does not. Layers with a window see at most 1,024 tokens, which the table allows for.

That is for one new token at position T, as when generating. Averaged over a whole training sequence of length T, each token sees T/2 earlier ones on average, which halves it.

Context T2NAttentionTotal per token
4K54.0 GFLOPs1.5 GFLOPs55.6 GFLOPs
32K54.0 GFLOPs6.2 GFLOPs60.3 GFLOPs
128K54.0 GFLOPs22.3 GFLOPs76.4 GFLOPs

Training costs about three times the forward pass per token (6N): the backward pass does roughly twice the forward work.

Compare

Gemma 3 27B vs Qwen3 32B · Gemma 3 27B vs Mistral Small 3 (24B) · Compare with any model →

Close in size: Gemma 2 27B 27.2B · Qwen3 30B-A3B 30.5B · Mistral Small 3 (24B) 23.6B · OLMo 2 32B 32.2B · Qwen3 32B 32.8B

Source

Read from unsloth/gemma-3-27b-pt, an ungated copy of google/gemma-3-27b-pt (which needs a sign-in to download), fetched 2026-12-02.