LW IT Solutions logo LW IT Solutions logo LW IT Solutions
« Blog Overview /Cloud & AI / Q4, Q8, FP16 and Long Context: Why...
Read this article in other languages:

Q4, Q8, FP16 and Long Context: Why a Local LLM Can Fail Despite Fitting on Disk

Q4, Q8, FP16 and Long Context: Why a Local LLM Can Fail Despite Fitting on Disk

Management Summary

A local language model is an AI system for text and answers running on a personal computer. It needs room for its files and free memory for the work in progress. A short chat can therefore work while a long document overwhelms the same device. The article explains this difference and the trade-offs of more compact model versions. This helps match software to a computer: reduced memory requirements can come with changes in answer quality or longer waiting times.

Jump to the interactive example ↓

Contents
  1. Q4, Q8 and FP16 imply different budgets
  2. Context consumes runtime memory
  3. Hybrid architectures need their own profiles
  4. Offloading changes the workload
  5. Quality and memory together
  6. Related tools
  7. Questions and answers
  8. Sources

A 20 GB model file does not automatically fit into a graphics card with 24 GB of memory. The file mainly contains weights: numbers learned during training. While answering, the software also needs room for earlier text and intermediate calculations. Other programs may occupy graphics memory too. File size and memory used during execution are therefore different quantities.

Quantisation stores model numbers with fewer bits. This usually reduces storage, but may also affect quality. Context means the input and generated response considered by the model. Long documents and simultaneous requests can require extra memory. The calculations below are examples, not measurements of a particular model.

Memory needs: model weights, KV cache and other allocations; practical test with long input and simultaneous requests.
1 GiB cache in the assumed example; not a universal model formula.

Q4, Q8 and FP16 imply different budgets

Idealised example Calculation for 30 billion weights Weights only
4 bit 30 billion × 0.5 byte 15 GB
8 bit 30 billion × 1 byte 30 GB
16 bit 30 billion × 2 bytes 60 GB

Q4 and Q8 here refer to quantisation methods using roughly four and eight bits per weight. FP16 stores numbers in a 16-bit floating-point format. The table covers only idealised weights. Extra scale values, parts stored differently and metadata change real file sizes. A GB is one billion bytes, whereas a GiB is 1,073,741,824 bytes. The table’s 15 GB therefore equal about 13.97 GiB.

Context consumes runtime memory

The KV cache keeps calculated keys and values from earlier text. This avoids repeating all that work for each new text piece. A token is such a piece, for example part of a word. For a simple cache with equally sized key and value vectors, the calculation is: 2 × layers × KV heads × head dimension × stored tokens × bytes per value × independent sequences. Layers are processing stages; heads and their dimension describe the number and length of stored number arrays. These settings come from the model configuration.

Example: 2 × 32 layers × 8 KV heads × 128 values × 8,192 tokens × 2 bytes × 1 sequence equals 1,073,741,824 bytes, or 1 GiB. Four independent, equally full sequences need 4 GiB of cache in this calculation. This does not necessarily load the weights four times. The calculation covers cache payload only, excluding bookkeeping and calculation buffers. Some programs reserve the configured maximum at startup; others grow the cache as needed. Shared prefixes, smaller number formats and limited attention windows change memory needs.

Hybrid architectures need their own profiles

Not every model stores every processing stage this way. Qwen3.5-9B, for example, combines 24 linear-attention layers with eight full-attention layers. The linear layers maintain a different running state. The simple KV formula therefore must not be applied to all 32 layers. Image processing also requires its own weights and work areas. The specific configuration and execution software determine the actual requirements.

MoE means Mixture of Experts: each calculation step uses only some of several expert groups. The weights of all groups may nevertheless need to remain in memory. An active-parameter count therefore does not automatically describe storage for all weights. This is another architecture case; Qwen3.5-9B is not an MoE model.

Offloading changes the workload

llama.cpp can split a model between the CPU and graphics card. Parts then stay in system RAM instead of everything occupying graphics memory. This can allow a model to start despite exceeding the graphics card’s capacity. The trade-off may be longer waits because CPU calculations and data transfers become part of execution. Available splits also depend on supported hardware and software versions.

A practical test therefore records graphics-memory use, system RAM, time until the first output token and subsequent tokens generated per second. The test includes the intended long input, room for the response and the expected number of simultaneous requests. A successful short chat does not establish that this larger load fits.

Quality and memory together

A larger Q4 model is not automatically better than a smaller Q8 model. Training and task also affect answers. A small test set could contain three questions about a document and the expected supporting passages. The comparison counts incorrect claims, omissions and unusable output formats. Previously unused cases help show whether the result extends beyond the initial test.

The linked memory calculator can support an initial shortlist. A reproducible plan records the model revision, number format, execution software, planned context, simultaneous requests and available memory. Without suitable architecture data, the result remains a rough estimate. Actual memory measurements under the intended load and a quality test are needed to confirm a useful configuration.

Memory planning for model selection: LLM VRAM estimator.

Questions and answers

Why does a 20 GB model file not always fit on a 24 GB GPU?

The file mainly contains weights. Answering also needs memory for text state and intermediate results. Long input or simultaneous requests may therefore exhaust the remaining capacity.

Is a larger Q4 model always better than a smaller Q8 model?

No. Fewer bits save space but do not establish answer accuracy. The same documents and questions can reveal which model makes fewer errors. Wait time and actual memory use also belong in the comparison.

Sources

  1. llama.cpp: project and hardware support
  2. Qwen: Qwen3.5-9B official model card
  3. Mistral: Ministral 3 14B Instruct official model card
  4. vLLM: GPU installation
  5. Hugging Face Transformers: How caching works
  6. Hugging Face Transformers: Cache strategies
  7. Qwen3.5-9B: config.json

Sources checked again: 25 October 2026. Calculated examples, not original hardware measurements.

Learn by trying

The model fits. What about the context?

A hypothetical 7B model: change precision and context length. Watch the KV cache consume memory.

Weights
KV cache
Runtime allowance

Illustration, not a hardware guarantee: 7 billion weights; 32 layers, 8 KV heads, head dimension 128, FP16 KV, batch 1, full context; 1 GiB runtime allowance. Metadata, architecture and backend change the requirement.

This module runs in your browser and does not send or store your input.

Continue in the matching tool →

Reference ↗

Terms you can try

Explore

Terms you can try

A short explanation and a small experiment make each term easier to understand.

Quantization

Model weights are represented with fewer bits. This reduces memory for weights; accuracy and other memory use need separate consideration.

Read the related article →

Quick explanation

Read the related article →

These exercises calculate in your browser. The learning module does not send your answers.

Explore more experiments →

Lukas Wojcik

Lukas Wojcik

Systems architect and technology enthusiast specializing in scalable tracking solutions, GMP Stack (GA4 & GTM), and robust backend architectures. Advocate for clean code and privacy-first design.

Get in touch

A question or an idea for a web project? Tell me a little about it. This form uses reCAPTCHA to protect against spam.

Write a comment

Experience with other models or providers and questions about the implementation are welcome here.

The email address is not published. Required fields are marked with an asterisk.