TL;DR

Gemma 4 12B (Apache 2.0, Google DeepMind) now has community GGUF builds, and for an edge builder the interesting number is not the file size. The Q4_K_M file is 6.87 GiB and Q8_0 is 11.8 GiB, but the config shows 48 layers of which only 8 use full attention, and those 8 have a single global KV head. Done window-aware, the whole KV cache at fp16 is about 0.8 GiB at 32K tokens, 2.3 GiB at 128K and 4.3 GiB at the full 256K. A runtime that ignores the sliding window would ask for 10.5, 42 and 84 GiB. The result: a 16 GB machine runs Q6_K with 128K of context, and a 12 GB card fits Q4_K_M with a long prompt, provided the runtime handles the window.

Gemma 4 12B GGUF file size by quant

Sources: the community GGUF repository for file sizes and the base model card and config from Google. Cache figures are our arithmetic from config.json, with the formula printed below so you can redo it.

What is Gemma 4 12B, in terms an edge builder cares about?

The model card describes a "Unified" 12B model that takes text, image, video and audio input and produces text, without separate vision or audio encoders. For deployment that matters in two ways: there is one weight file to size, and the multimodal projector in the GGUF repo is tiny (mmproj-gemma-4-12b-F16.gguf is 0.11 GiB). The facts from config.json that drive the memory math:

  • 48 layers, hidden size 3840, 16 attention heads.
  • 40 sliding-attention layers with a window of 1,024 tokens, 8 KV heads, head dimension 256.
  • 8 full-attention layers (every sixth layer: 6, 12, 18, 24, 30, 36, 42, 48), with 1 global KV head and global head dimension 512.
  • attention_k_eq_v: true, meaning keys and values are tied in the global layers.
  • max_position_embeddings 262,144, so a 256K window.
  • Tied input and output embeddings.

The pattern is five sliding layers for every full layer. That is the whole story of why a 12B model can talk about 256K tokens on a consumer machine.

Which Gemma 4 12B GGUF file fits my device?

The community repo lists these files (sizes from the repository listing, in GiB):

File Size (GiB)
gemma-4-12b-Q4_K_M.gguf 6.87
gemma-4-12b-Q5_K_M.gguf 7.96
gemma-4-12b-Q6_K.gguf 9.11
gemma-4-12b-Q8_0.gguf 11.8
gemma-4-12b-F16.gguf / BF16.gguf 22.2

The quant ladder is gentle. Going from Q4_K_M to Q8_0 costs 4.9 GiB, and the half-precision file is 22.2 GiB, which is why almost nobody ships it to a device. The practical choice for a 12 GB card is Q4_K_M or Q5_K_M. For a 16 GB laptop or phone-class unified memory, Q6_K leaves headroom. For 24 GB or more, Q8_0 is the quant to pick if you want the closest behavior to the original weights.

How big is the KV cache, really?

Per token and per layer the cache stores keys and values. At fp16 (2 bytes per value):

def kv_bytes_per_token(kv_heads, head_dim, k_eq_v=False, dtype_bytes=2): streams = 1 if k_eq_v else 2 # K and V, or one shared stream return streams * kv_heads * head_dim * dtype_bytes sliding = kv_bytes_per_token(8, 256) # 8192 B per token per layer glob = kv_bytes_per_token(1, 512) # 2048 B per token per layer (K and V stored apart) WINDOW, N_SLIDING, N_GLOBAL = 1024, 40, 8 def window_aware_gib(ctx): fixed = N_SLIDING * WINDOW * sliding # capped at the window growing = N_GLOBAL * ctx * glob # grows with context return (fixed + growing) / 2**30 def naive_gib(ctx): return ctx * (N_SLIDING * sliding + N_GLOBAL * glob) / 2**30 

The sliding layers cost 40 x 1,024 x 8,192 B = 320 MiB no matter how long the prompt is. The global layers cost 16,384 B per token across all 8 of them. That gives:

Context Global layers only Window-aware total Naive (full cache every layer)
8K 0.12 GiB 0.44 GiB 2.6 GiB
32K 0.50 GiB 0.81 GiB 10.5 GiB
128K 2.0 GiB 2.31 GiB 42 GiB
256K 4.0 GiB 4.31 GiB 84 GiB

Global-layer KV cache by context

Total KV cache, window-aware versus naive

The gap between the last two columns is the reason to check how your runtime allocates the cache. A runtime that allocates a full-length cache for sliding layers needs 10.5 GiB at 32K, which would push even Q4_K_M off a 12 GB card. A runtime that respects the window needs 0.81 GiB. Same model, same file, a 13x difference in cache memory.

Two notes on the arithmetic. First, attention_k_eq_v is true, so a runtime that stores one tied stream in the global layers would halve the global column. The table above stores K and V separately, which is the upper bound. Second, real runtimes add compute buffers and a small slack beyond the window, so budget a few hundred MiB on top.

What fits where? A budget per device class

Add the file, the cache and about 1 GiB for compute buffers and the multimodal projector. These totals use the window-aware cache.

Device memory Quant Context File Cache Total with 1 GiB overhead
12 GB GPU Q4_K_M 32K 6.87 0.81 8.7 GiB
12 GB GPU Q5_K_M 128K 7.96 2.31 11.3 GiB
16 GB laptop Q6_K 128K 9.11 2.31 12.4 GiB
16 GB laptop Q8_0 32K 11.8 0.81 13.6 GiB
24 GB Q8_0 256K 11.8 4.31 17.1 GiB

On a 16 GB unified-memory machine the operating system and apps also need room, so the Q6_K row at 128K is the comfortable choice and Q8_0 at 32K is the ceiling. On a 12 GB discrete GPU, Q5_K_M at 128K is the high-quality option that still fits.

How should I run it and check the memory myself?

A minimal llama.cpp invocation, assuming a build that supports the gemma4 architecture (the GGUF metadata in the repo reports gemma4 with a 262,144-token context):

huggingface-cli download moonbox-dev/gemma-4-12B-it-GGUF \ gemma-4-12b-Q6_K.gguf mmproj-gemma-4-12b-F16.gguf --local-dir ./gemma4-12b llama-server -m ./gemma4-12b/gemma-4-12b-Q6_K.gguf \ --mmproj ./gemma4-12b/mmproj-gemma-4-12b-F16.gguf \ -c 131072 -ngl 99 --port 8080 

Then compare what the runtime reports at startup for the KV buffers against the table. If the figure for the sliding layers is close to the naive column, the runtime is allocating full-length caches for them, and you should either shorten -c or move to a build that caps sliding layers at the window. The check takes one minute and saves an out-of-memory crash at the worst possible time, when a user pastes a long document.

Quantizing the cache is the next lever. Setting the cache type to 8-bit halves every number in the cache columns, so the 128K total drops from 2.3 GiB to roughly 1.2 GiB. For a device-resident assistant that handles long documents, that is usually a better trade than dropping the weights from Q6_K to Q4_K_M.

Why does on-device multimodal change the sizing?

With a separate vision encoder you size two models. Here the projector file is 0.11 GiB and audio is handled inside the same network, so one download covers text, image and audio input. The memory that grows with use is the image and audio tokens, which land in the same cache as text. A 32K cache holds a long chat plus a handful of images, and a 128K cache is the right size if you plan to feed several pages of scanned documents or minutes of audio. Because the 8 global layers carry the long-range part, image-heavy sessions grow the cache at 16 KiB per token once past the window.

What does this mean for offline and private deployments?

A single 6 to 12 GiB file that handles text, images and audio with a 256K window is a good match for the offline cases our team cares about: field tablets without connectivity, kiosks that must not send data out, and assistants in places where a cloud call is not allowed. The sizing above is what turns that from a demo into a plan: pick the quant for the device, pick the context for the job, and confirm the cache allocation before you ship.

FAQ

How much RAM does Gemma 4 12B need?
With the Q4_K_M file at 6.87 GiB plus about 0.8 GiB of cache at 32K and 1 GiB of overhead, plan for roughly 9 GiB. Q8_0 at 32K needs about 13.6 GiB.

Does Gemma 4 12B support 256K context on a laptop?
The config sets 262,144 positions. With a window-aware cache the fp16 cache at 256K is about 4.3 GiB, so Q6_K at 256K totals roughly 14.4 GiB with overhead. That fits a 16 GB machine when little else is running.

Why is the KV cache so small for this model?
Only 8 of 48 layers attend to the full context, and they share a single KV head. The other 40 layers look back 1,024 tokens, which is a fixed 320 MiB at fp16.

Which quant should I choose?
Q4_K_M for 12 GB devices, Q6_K for 16 GB, Q8_0 when you have 24 GB or more. The step between neighbors is about 1 to 3 GiB, so size the context first, then pick the largest file that leaves room.

Is the model open for commercial use?
The model card lists Apache 2.0, with a link to the Gemma license page. Read both before shipping.

Where do the numbers come from?
File sizes from the GGUF repository listing, architecture values from the base model config.json. The cache figures are arithmetic, so confirm them against your runtime's startup log.

Further reading