# Gemma 3 4B Instruct on an L40S

Yes — the unquantized weights fit with room for 128k tokens of context.

Canonical page: https://makerportal.ai/lab/llm-vram/gemma-3-4b-it/l40s
Page title: Gemma 3 4B Instruct VRAM on L40S — fits at BF16

This markdown document and the HTML page above are rendered from the same solved values at build time, by the same functions. Nothing here is written by a language model and nothing is fetched at request time.

## Key figures

- **Verdict:** Fits at FP16 — 44.2 GiB usable of 48 GB
- **Usable memory:** 44.2 GiB — 92% of the card's 48 GB — an assumption for a dedicated card, not a single fraction applied to every device
- **Weights at FP16:** 8.0 GiB — 4.3B parameters
- **Weights (Q4_K_M):** 2.4 GiB — 8.0 GiB at FP16 · 4.3B params · 1 of 6 quant rows are measured files
- **KV cache:** 136.0 KiB per token at FP16 — 34 layers × 4 KV heads × 256 dimensions
- **Speed ceiling:** 97 tok/s — 864 GB/s ÷ bytes read per token
- **Largest context that fits:** 131,072 tokens at FP16 / BF16
- **Trained context:** 131,072 — the cap the KV-cache figures are held to
- **Card bandwidth:** 864 GB/s — 48 GB GDDR6 ECC

## Every quant, against this card

Every quantization of Gemma 3 4B Instruct against the 44.2 GiB usable on an L40S. "Measured" rows are the byte size of a real published file; "nominal" rows are the parameter count times the published bits-per-weight.

| Precision | Bits/weight | Weights | Source | Fits | Max context | Ceiling |
|---|---|---|---|---|---|---|
| FP16 / BF16 | 16.00 | 8.0 GiB | measured file | yes | 131,072 (model cap) | 97 tok/s |
| Q8_0 | 8.50 | 4.3 GiB | nominal | yes | 131,072 (model cap) | 178 tok/s |
| Q6_K | 6.56 | 3.3 GiB | nominal | yes | 131,072 (model cap) | 226 tok/s |
| Q5_K_M | 5.67 | 2.8 GiB | nominal | yes | 131,072 (model cap) | 259 tok/s |
| Q4_K_M | 4.83 | 2.4 GiB | nominal | yes | 131,072 (model cap) | 299 tok/s |
| Q3_K_M | 3.91 | 2.0 GiB | nominal | yes | 131,072 (model cap) | 361 tok/s |

## Questions this page answers

### How much VRAM does Gemma 3 4B Instruct need?

8.0 GiB for the weights at FP16 — 4.3B parameters at two bytes each — and 2.4 GiB at Q4_K_M. The KV cache is on top of that and is not a fixed number: this model spends 136.0 KiB per token of context on its full-attention layers, so 8,192 tokens costs a further 276 MiB. An L40S makes 44.2 GiB of its 48 GB available on the assumption below.

### Can an L40S run Gemma 3 4B Instruct?

Yes — the unquantized weights fit with room for 128k tokens of context. That is the weights and the KV cache together, against 44.2 GiB of usable memory.

### How fast will Gemma 3 4B Instruct run on an L40S?

No faster than 97 tokens/second at FP16 / BF16, and in practice below it. Decoding is memory-bound: every token reads all 8.0 GiB of weights plus the cache, and this card moves 864 GB/s. That division is the ceiling — no kernel, runtime or driver beats it, and a real runtime typically reaches 60–80% of it.

### Why does the context length change how much memory Gemma 3 4B Instruct needs?

Because the KV cache holds one key and one value vector per token, per layer, for the whole conversation, and it is allocated separately from the weights. This model has 34 layers and 4 key/value heads of 256 dimensions, shared across 8 query heads — grouped-query attention, which divides the cache by 2. That works out at 136.0 KiB per token, except that 29 of the 34 layers use a 1024-token sliding window and stop growing there. Parameter count tells you nothing about this number.

## Method and limits

Weight bytes are the byte size of the real published file wherever one exists, and the model's exact parameter count times the published llama.cpp bits-per-weight where it does not. That distinction is on every row above and it matters at both ends: a sub-1B model's Q4_K_M file runs a third larger than the nominal figure because k-quants keep its embedding tables at higher precision, and an already-4-bit release cannot be quantized upward at all. The KV cache is 2 · layers · kv_heads · head_dim · bytes per token, summed over layers with each sliding-window layer capped at its window. The speed figure is a roofline bound, not a benchmark: bandwidth divided by bytes read per token, which no runtime exceeds and every runtime falls short of. The usable fraction of card memory is an assumption: 92% here, which is what this lane assumes for a dedicated card — the other class assumes 75%, so it is not one number applied to every device. That is the only assumed input on this page; every other figure is computed from the model config and the card's published specification. Nothing on this page is written by a language model.

## Related tool

[LLM VRAM & KV-Cache Footprint Calculator](https://makerportal.ai/lab/llm-vram-kvcache-calculator) — Interactive VRAM planner — change the model geometry, quantization, context length and card capacity and read the weight bytes, KV-cache bytes and the bandwidth ceiling on decode speed.

---

Source: MakerPortal — https://makerportal.ai/lab/llm-vram/gemma-3-4b-it/l40s. Free to quote and cite with attribution and a link to the canonical page.
