google · text

gemma-2-9b

google/gemma-2-9b

gemma-2-9b at Q4_K_M is exactly 5,761,057,664 bytes (5.37 GiB / 5.76 GB) — an effective 4.987 bits per weight, not the nominal 4. Its KV cache at 32K is 5.99 GiB, not the 10.50 GiB a flat formula predicts.

From the file· summed from 1 file(s)From the file· KV from mirror (mirror:unsloth/gemma-2-9b)
Parameters
9.2B
Architecture
gemma2
42 layers
Context
8,192
native (config.json)
License
gemma

Shipped quantizations

exact bytes, summed from published files
QuantSizeExact bytesEffective bpwTensorsPublisher
Q2_K3.54 GiB3,805,397,8883.294QuantFactory
Q3_K_S4.04 GiB4,337,664,8963.755QuantFactory
Q3_K_M4.43 GiB4,761,781,1204.122QuantFactory
Q3_K_L4.78 GiB5,132,452,7364.443QuantFactory
Q4_05.07 GiB5,443,142,5284.712QuantFactory
Q4_K_S5.10 GiB5,478,925,1844.743QuantFactory
Q4_K_S5.10 GiB5,478,925,7284.743INSAIT-Institute
Q4_K_M5.37 GiB5,761,057,6644.987QuantFactory
Q4_K_M5.37 GiB5,761,058,2084.987INSAIT-Institute
Q4_15.55 GiB5,963,367,2965.162QuantFactory
Q5_K_S6.04 GiB6,483,592,0645.612QuantFactory
Q5_06.04 GiB6,483,592,0645.612QuantFactory
Q5_K_S6.04 GiB6,483,592,6085.612INSAIT-Institute
Q5_K_M6.19 GiB6,647,366,5285.754QuantFactory
Q5_16.52 GiB7,003,816,8326.063QuantFactory
Q6_K7.07 GiB7,589,069,6966.569QuantFactory
Q8_09.15 GiB9,827,148,6728.507QuantFactory
Q8_09.15 GiB9,827,149,2168.507INSAIT-Institute

KV cache by context

computed per layer — this model uses sliding-window attention
ContextKV cache (f16)Flat formulaOverstated byFull / windowed / recurrent
4,0961.31 GiB1.31 GiB21 / 21 / 0
8,1922.05 GiB2.63 GiB1.28×21 / 21 / 0
16,3843.36 GiB5.25 GiB1.56×21 / 21 / 0
32,7685.99 GiB10.50 GiB1.75×21 / 21 / 0
65,53611.24 GiB21.00 GiB1.87×21 / 21 / 0
131,07221.74 GiB42.00 GiB1.93×21 / 21 / 0

21 of 42 layers cache only a 4,096-token window rather than the full context, on a period of 2. Figures assume the default configuration; --swa-full disables the saving entirely.

Compare with

same modality, comparable size

Will it run on your card?

full quant x context sweep

Why other calculators give a different number

A parameters × bits ÷ 8 estimate puts Q4_K_M at roughly 4.84 GiB. The real file is 5.37 GiB, because a quantization is a mixture and some tensors are always kept at higher precision. The larger discrepancy is the cache: a flat formula gives 10.50 GiB at 32K context where the real figure is 5.99 GiB, because most of this model's layers cache a fixed window rather than the whole context.

Architecture

from mirror:unsloth/gemma-2-9b
Layers
42
Attention heads
16
KV heads
8
Head dim
256
Hidden size
3584
Vocab
256,000
Sliding window
4096
SWA period
2
MLA
no
Experts
Experts per token
use_sliding_window

Questions people ask

How much VRAM does gemma-2-9b need?
Q4_K_M is exactly 5,761,057,664 bytes (5.37 GiB) in weights. Add the KV cache, which depends on your context length, plus roughly half a gigabyte of runtime overhead.
How large is gemma-2-9b's KV cache?
5.99 GiB at 32K context with an f16 cache, computed per layer. Quantizing the cache to q8_0 roughly halves it, which is often the difference between a context length fitting and not.
Which quantization of gemma-2-9b should I use?
Q4_K_M is the usual default. Pick the largest quantization that fits your card at the context you actually need — the table above gives exact sizes for every one published.