AI Engineering

Understand AI model quantization, ideal 16/8/4/2/1-bit storage, GLM-5.3 and Qwen3.8 sizing, and local versus data-center inference.

~10 min reading~6 min practice estimate
Suggest content

AI Model Quantization Explained: Bits, Memory, and Running Large Models

A model can be available for download and still be too large for a laptop. Quantization makes its weights smaller, but the download size, memory needed to answer a question, and hardware needed to serve many users are different measurements. This lesson explains the bits behind those numbers and how an app actually reaches a model.

🧠 Mental model: A parameter is a stored numerical value in the model. A weight is a parameter used to transform signals as the model computes an answer. Quantization stores many weights with fewer bits, somewhat like rounding a long decimal to a shorter one. The values become less precise; the number of parameters usually stays the same.

Weights, bits, and a simple rounding analogy

Imagine a tiny list of weights: 0.137, −0.822, and 1.041. Rounding them to 0.1, −0.8, and 1.0 uses fewer distinct values. Real quantizers do more than decimal rounding: they map groups of values to compact integer codes and keep scales or other data needed to reconstruct useful approximations. The analogy explains the tradeoff, not the implementation.

🟪 A bit has two possible values. More bits can represent more distinct codes. In a simple fixed-width calculation, 16 bits is two bytes per weight; 8 bits is one byte; 4 bits is half a byte when many weights are packed together. Quantization changes the representation of those weights. It does not turn a 10-billion-parameter model into a 2.5-billion-parameter model.

Nominal weight precisionIdeal bytes per weightIdeal raw weight storage vs 16-bitIllustrative 10B-weight floor
16-bit2100%20 GB
8-bit150%10 GB
4-bit0.525%5 GB
2-bit0.2512.5%2.5 GB
1-bit0.1256.25%1.25 GB

The arithmetic is parameter count × bits per weight ÷ 8, using decimal GB for this illustration. It is an ideal raw weight floor, not a download-size or device-memory promise. A real checkpoint also contains scale values, metadata, tensors kept at other precisions, and sometimes multiple files. Labels such as “2-bit” describe a quantization family; a format can use more than two effective bits per weight. The ggml quantization structures show block scales and an example described as 2-bit but averaging 2.625 bits per weight.

Storage and execution memory

ResourceWhat it holdsWhy it matters
Disk storageDownloaded model filesA file can fit on disk even if it cannot run in available memory.
System RAMCPU-side model data, runtime buffers, and other applicationsCPU inference or GPU offload may use it; the operating system also needs headroom.
GPU VRAMWeights or layers placed on the GPU, key-value cache, and computation buffersToo little VRAM may force slower CPU offload or prevent a particular configuration.
Unified memoryShared CPU/GPU memory on supported machinesIt still has a finite usable budget; “shared” does not mean all installed memory is free.

🟨 The key-value cache (KV cache) grows with the context and concurrent requests. The runtime also needs space for buffers and bookkeeping. Long context windows, more simultaneous users, and larger batches can raise peak memory beyond the model file size. RAM and VRAM are not interchangeable on every runtime: adding their advertised capacities is only useful when the chosen software can place the needed parts across them. CPU offload may make a model fit while reducing speed. The llama.cpp project documents CPU/GPU hybrid inference and quantized model support.

To decide whether a model fits, record the exact checkpoint and quantization, its file size, supported runtime, available RAM/VRAM or unified memory, planned context length, concurrency, and a measured peak-memory result. Leave headroom for the operating system and other processes.

Worked example: GLM-5.3, not GLM-5.3-Flash

As checked 5 November 2026, Unsloth’s GLM-5.3 guide describes GLM-5.3 as a 744B-total-parameter, 40B-active-parameter model. Its separate GLM-5.3-Flash guide covers a different checkpoint. Do not transfer a file size or hardware claim from one to the other.

Unsloth GLM-5.3 quantization labelGuide’s estimated total memory for inference
1-bit223 GB
2-bit245 GB
4-bit372–475 GB
8-bit810 GB

These are the guide’s RAM + VRAM or unified-memory estimates, not the ideal percentages in the previous table and not measured results for every machine. The guide says its 2-bit UD-IQ2_M file uses about 239 GB of disk and discusses 256 GB RAM devices, while recommending comfortable memory headroom beyond the file size. A 239 GB download does not imply that 239 GB of free disk alone can answer a prompt, nor does it guarantee useful speed or the full advertised context on a given device. Source: Unsloth GLM-5.3 hardware table.

🧠 In a mixture-of-experts (MoE) model, active parameters describe the portion used for a particular token’s computation. Other experts must still be available to the serving system because later tokens may route to them. “40B active” therefore does not mean the complete GLM-5.3 checkpoint stores only 40B weights. The smaller active count can reduce work per token, while total weights still dominate storage and distribution decisions.

Worked example: Qwen3.8, from 27B to 2.4T-A95B

As checked 5 November 2026, Qwen’s official model card lists 2.4 trillion total parameters and 95 billion active parameters for Qwen3.8-2.4T-A95B. The 95B figure describes routed computation, not the amount of weights to store. Qwen3.8-27B is a separate, much smaller model, not a quantized copy of the 2.4T checkpoint. Unsloth’s Qwen3.8 guide discusses both.

For the 2.4T-A95B checkpoint, Unsloth publishes these approximate storage sizes for its listed versions:

Qwen3.8-2.4T-A95B versionPublished size
Dynamic 1-bit XXXS397 GB
Dynamic 1-bit Standard508 GB
Dynamic 2-bit657 GB
Q8_02.6 TB
BF164.9 TB

These are figures from the Unsloth Qwen3.8 guide, not tested peak-memory or speed results. The ideal one-bit raw-weight floor for 2.4T parameters is 300 GB; the published one-bit versions are larger and even differ from each other. That gap is why a bit label alone is insufficient for a hardware decision. Loading a 397 GB file still needs usable memory, runtime and cache overhead, and a supported offload layout. A 95B-active MoE model is not equivalent to a 95B-total dense model.

For the 27B checkpoint, the same guide gives estimated total inference memory in RAM + VRAM, or unified memory:

Qwen3.8-27B quantization labelGuide’s estimated total memory
1-bit7–8 GB
2-bit9–11 GB
4-bit16–19 GB
8-bit31 GB
BF1656 GB

The 27B model is a more plausible local candidate, but these estimates still need a runtime, context length, available-memory check, and measured quality and speed on the actual machine. The Qwen guide notes that its 27B checkpoint supports vision; do not assume that capability or its memory table applies to the 2.4T-A95B checkpoint. Check the exact model card and license before deployment.

Smaller weights, quality, and speed

Lower precision can change answers. The effect depends on the model, quantizer, task, and chosen format. A 2-bit version may be adequate for one workload and lose important accuracy on another. Compare it with a higher-precision baseline on representative questions, code tasks, long prompts, and tool calls instead of judging by file size alone.

Smaller files can reduce memory traffic and make more weights fit on faster hardware. They do not guarantee faster responses: the runtime needs compatible kernels, and dequantization or CPU offload can erase the gain. Measure time to first token, output tokens per second, peak memory, and answer quality on the actual machine. For a model-choice framework, see AI Model Selection and Benchmark Scores.

Inference is different from training

Inference uses learned weights to answer a request. Training changes weights and typically needs gradients, activations, optimizer state, and often additional copies of model data. A checkpoint that fits for inference can be far too large to train on the same hardware. Hugging Face’s GPU memory anatomy breaks down these separate training allocations.

Fine-tuning methods can reduce what must be updated, but they do not make the base model’s loading, context, and runtime costs disappear. Always label a hardware number as training, fine-tuning, or inference.

The app-to-model request path

App → authenticated app backend → model server → local machine or rented hardware → streamed answer → app.

The app sends a request to a backend that enforces authentication, input limits, and the permitted data route. A model server loads the selected checkpoint into suitable memory, processes the prompt, and streams generated tokens back. For a private local setup, the backend and model server can run on the same machine or trusted local network; for a hosted setup, they run on rented infrastructure. An OpenAI-compatible endpoint is an interface shape, not proof that the backing model is an OpenAI service. The llama.cpp server is one example of a local model endpoint.

🟩 Keep sensitive data out of external routes unless the user or organization has authorized that route. A “local” app can still call a remote model or plugin, so verify the actual network destination, tool permissions, and logs. See Build a Private Local AI Assistant for a fuller privacy design.

Data-center serving for large models and many users

One big model may be sharded across GPUs so each device holds part of the weights. A serving system can also make replicas of a model to handle more requests. Batching groups work from multiple requests to use hardware efficiently; it is a throughput choice that must be checked against per-user latency. vLLM’s parallelism guide describes tensor, data, and expert parallelism for these cases.

Serving has two useful phases: prefill processes the prompt and builds the initial cache; decode produces subsequent tokens. Long prompts and long answers stress different parts of the system. Some deployments separate those phases or schedule them differently to control time to first token and sustained generation. vLLM’s optimization guide describes chunked prefill and its batching tradeoff. MoE adds expert routing across the serving hardware; the active expert count describes computation for a token, not the total model inventory.

A practical selection checklist

  1. Choose the exact model, license, quantized file, and runtime; verify that the runtime supports that model architecture.
  2. Compare file size with available, not installed, memory. Add KV cache, context, concurrency, runtime buffers, and operating-system headroom.
  3. Test a real prompt and measure peak memory, time to first token, output speed, and answer quality.
  4. For an app, verify the end-to-end route and whether any data, tool calls, or logs leave the intended trust boundary.
  5. If serving many users, measure throughput and latency under realistic batching and concurrency; plan GPU shards and replicas from those measurements.

Practice: diagnose a misleading “fits” claim

Prompt: A model page says “2-bit, 239 GB download.” A computer has 256 GB installed memory and 300 GB free disk. A teammate says it will run quickly at the maximum context length for several users. Which parts of that claim are unsupported?

Answer

The download fits on disk, but installed memory is not the same as available memory. The model server needs extra memory for runtime buffers and KV cache, which grows with context and users. The exact checkpoint, runtime, offload layout, and available RAM/VRAM must be checked. The quoted file size does not establish speed, maximum-context usability, or concurrency. Run a measured single-user test first, then load-test the intended number of users. If this is the Unsloth example, also confirm the model is GLM-5.3 rather than GLM-5.3-Flash.

Quick Recap

  • Quantization stores model weights with fewer nominal bits; it usually leaves the parameter count unchanged.
  • The 16/8/4/2/1-bit percentages are ideal raw-weight arithmetic, not GGUF file sizes or memory guarantees.
  • Disk, RAM, VRAM, unified memory, KV cache, context, and concurrent users answer different sizing questions.
  • MoE active parameters describe work per token; the serving system still needs access to the complete set of experts.
  • Qwen3.8-27B and Qwen3.8-2.4T-A95B are different checkpoints; compare their exact quantization files and sizing claims separately.
  • Inference hardware claims cannot be reused as training claims.

Key Takeaways

Choose a quantization by measured quality, memory, and latency on the exact workload. For a local assistant, verify the full app-to-model data path. For a data center, size the whole serving system, including sharding, batching, replicas, and prompt versus generation demand.