Skip to content
← All posts

Research 15 min read

Ultra-Low-Bit Quantization and QAT: AI on Entry-Level Chips

How does a Raspberry Pi 5 run a 3B-parameter model? It takes ultra-low-bit quantization, quantization-aware training and CPU kernels built for low-bit math.

ByZihao Wang Updated

On this page
low-bit quantization like ridges

To get a sense of three billion parameters, imagine inspecting one every second. Even around the clock, it would take about 95 years.

These numbers are the weights a model learns during training. They take part in repeated computations as it generates text. Yet the processor running them can be far less powerful than the one in a flagship phone: for a familiar comparison, the Raspberry Pi 5 scores roughly one-eighth as high as the iPhone 18 Pro in a multicore CPU benchmark.

The T-MAC research demonstrated a roughly three-billion-parameter BitNet model generating about 11 tokens per second on that device. A token is a piece of text the model generates at each step; it does not necessarily correspond to a whole word or character. T-MAC, Section 5

That result rests on three things: a more compact numerical representation, training that accommodates low precision, and computation designed for that representation. Together, they explain the value of ultra-low-bit quantization and quantization-aware training.

Here, “entry-level chips” primarily means application processors in everyday mobile devices and single-board computers, especially CPUs with vector instructions but limited memory and bandwidth. “Running AI” means completing a useful task within the device’s resource budget. The application determines the required quality and response time. Training happens during development; the device runs inference.

1. Compute is only part of the problem

A model must read weights, produce intermediate results, and pass those results to subsequent operations. Text generation repeats this process. A device therefore has to clear at least three hurdles:

  • Fit the model in memory. Weights, runtime caches, and workspaces must stay within the memory available to the application.

  • Keep the compute units fed. Data must arrive fast enough. Even high peak compute throughput is of little use when the processor is waiting for memory.

  • Execute the representation efficiently. The numerical formats, data layouts, and operations need suitable implementations on the target hardware.

Start with the simplest calculation. Suppose one billion weights are all stored at the same bit width:

Weight-code payload in bytes = number of weights × bits per weight ÷ 8

Using decimal units, 16-bit weights require 2,000 MB, 4-bit weights 500 MB, and 2-bit weights 250 MB. If each weight stores just one binary state, the codes alone take 125 MB. Here, a “code” means the bits that identify a quantized state.

Ideal weight payload at different bit widths, with separate scale overhead

Figure 1. Theoretical storage for one billion weights at a uniform bit width. The left panel counts weight codes only; the right panel separately shows the overhead of one 16-bit scale per group. Neither represents the complete model or peak runtime memory.

A deployed representation also needs scale factors, or simply scales, to specify what numerical value an integer code such as 3 represents. If every 32 weights share a 16-bit scale, that adds 16/32 = 0.5 bits per weight. Some layers may remain at higher precision, and the format may also require zero points or codebooks.

This is why model file size, loaded weight memory, and peak runtime memory are different quantities. A runtime may reorder or convert weights. Inference also needs activations, attention caches, and temporary workspaces. Compression makes room for these costs; a complete memory budget still has to account for them.

2. Why can a model still work with coarser numbers?

Think of quantization as switching to a ruler with fewer tick marks. A weight of 0.37 might be reconstructed as 0.4. That introduces an error in the individual value, but what matters is whether those errors change the task outcome after propagating through the model.

A common form of uniform quantization is:

Quantized code q = clip(round(w / s) + z, qmin, qmax)
Reconstructed value ŵ = s × (q − z)

Here, s is a positive scale and z is an integer zero point. Rounding selects a level; clipping bounds the range. Fewer bits mean fewer available levels. A handful of large outliers can stretch the range so far that most values are squeezed onto a few coarse levels. Giving each group its own scale improves local precision at the cost of additional metadata. Quantization fundamentals: Jacob et al.

Figure 2. Animated quantization mapping. Values move onto a finite grid. Grouping gives the first four values a finer grid, but requires additional scales. This example uses seven codes, −3 through +3, within a 3-bit representation. Movement shows the mapping, not a training trajectory.

The input matters, too. For a linear layer y = Wx, quantizing only the weights gives:

Output error Δy = (Ŵ − W)x

Weight errors of the same magnitude can have different effects. Errors along directions that the input frequently activates strongly can cause larger output shifts. That is why quantization methods examine representative inputs as well as the weight distribution.

Several post-training quantization (PTQ) methods exploit this insight. GPTQ uses calibration inputs and approximate second-order information to compensate for reconstruction error. AWQ identifies important channels from activations and uses rescaling to make weights easier to quantize. PTQ can involve calibration and optimization without full model retraining.

It also matters what is quantized. W4A16 generally means 4-bit weights and 16-bit activations for the relevant operations; W4A8 also quantizes activations to 8 bits. Accumulation, normalization, and other operations may use higher precision. The attention KV cache, which holds keys and values for reuse during generation, has its own precision and capacity budget. A “2-bit model” rarely means that every operation uses 2-bit arithmetic.

3. QAT: training for the coarser grid

As the number of available states shrinks, approximating the original weights may no longer preserve enough quality. Quantization-aware training (QAT) introduces quantization error during training so that the model can adapt to the constraint.

A typical approach maintains high-precision master weights W. The forward pass quantizes and reconstructs them to obtain Ŵ, which is used to compute the output and loss. Backpropagation then updates the master weights. This is fake quantization: tensors can remain in floating-point storage during training while their values are constrained to the target quantizer’s grid.

Figure 3. Animated QAT workflow. A fixed-scale example distinguishes gradual changes in the master weight from discrete changes in its quantized value. The update sequence is illustrative, not a recorded training run. QAT optimizes task loss; some methods also learn the scales.

The difficulty is that rounding has a derivative of zero almost everywhere and is not differentiable at its jumps. A common straight-through estimator (STE) supplies a surrogate gradient—for example, treating the derivative as 1 within the clipping range. Small updates can then accumulate in a master weight until it crosses a quantization boundary and changes the code used in the forward pass. This surrogate is an optimization device, not the true derivative of rounding. Early work on STEs

Knowledge distillation can provide another source of guidance. A low-bit student learns from the teacher’s probabilities over candidate outputs rather than a single label alone. BitDistiller combines self-distillation with low-bit QAT. In translation, these probabilities can provide signals about alternative valid translations. Teacher errors, student capacity, and data coverage still limit how much quality can be recovered.

QAT’s resource costs arise primarily during development. High-precision weights, gradients, optimizer state, and training activations still consume memory, and a teacher adds computation. The potential payoff is a compact representation at deployment. The grouping, scale precision, rounding, and clipping rules simulated during training must match the final artifact.

Same size, different quality

In an official PyTorch comparison using Llama3-8B, the PTQ and QAT artifacts were both 3.881 GB, while WikiText word-level perplexity fell from 23.316 to 19.403. This illustrates a useful point: even at the same deployment size, how the model adapts to its representation can affect quality. Original Table 1

Published PTQ and QAT quality results at the same model size

Figure 4. Redrawn from a published experiment; we did not reproduce it. Linear layers use INT4 weights and dynamic INT8 activations; embeddings are separately quantized to INT4. QAT is applied only to the linear layers. Quality was evaluated on a server CPU using 5 samples with a maximum length of 127 tokens. The original article used a Galaxy S22 for speed measurements; speed is not shown here.

The relative reduction in perplexity is about 16.8%. That does not mean “16.8% better language ability.” Given the small evaluation, the result illustrates the mechanism; translation quality requires separate validation. A comparison of your own should also control for additional data and training steps to distinguish the benefit of quantization awareness from that of continued training itself.

A practical starting point is a reliable PTQ baseline, followed by an assessment of whether QAT justifies its cost. Other compression approaches also operate at ultra-low bit widths. Bit width alone does not determine the training method.

4. How can an ordinary CPU accelerate low-bit inference?

In small-batch, token-by-token generation, many weights are read repeatedly. When compute units spend substantial time waiting for memory, storing the same weights in fewer bytes can reduce that wait.

Suppose a step really does need to read one billion weights from memory, at an effective bandwidth of 10 GB/s. Counting only weight-code transfers, the lower bounds are about 200 ms at 16 bits, 50 ms at 4 bits, and 25 ms at 2 bits.

Lower bounds on weight-transfer time and limits to overall speedup

Figure 5. Hypothetical calculations. The left panel excludes metadata, cache reuse, computation, and unpacking; 10 GB/s is an assumption, not a device measurement. Independently, the right panel applies Amdahl’s law with 80% of the original runtime accelerated and 20% unchanged.

This shows both the opportunity and its limits. A fourfold reduction in weight bytes does not necessarily make an entire translation four times faster. If the part accounting for 80% of runtime becomes four times faster and the rest is unchanged, the overall speedup is only 1/(0.2+0.8/4)=2.5 times. Unpacking, operator dispatch, or attention computation may become the next bottleneck.

Three common kernel design choices help turn compression into speed.

Dequantize a tile, then use it immediately. After loading compact weights, the kernel reconstructs values in a hardware-supported format in registers or a local buffer, then computes with them. This can still reduce main-memory traffic. Expanding the entire model into a resident high-precision copy would give back some of the memory savings.

Reuse computation across a small set of states. For two inputs x₁, x₂ and two ±1 weights, the dot product has only four possible results: x₁+x₂, x₁−x₂, −x₁+x₂, and −x₁−x₂. A kernel can precompute these in a lookup table, then use weight signs to select entries for output channels sharing those inputs. Larger groups create larger tables, so table construction, reuse, and fast-memory capacity must be balanced.

Arrange data for vector instructions. SIMD processes multiple values with one instruction. Packing, tiling, and access order determine how effectively those instructions are used. A denser encoding can even be slower if addressing and unpacking become too expensive.

T-MAC’s lookup-table approach and bitnet.cpp’s optimizations for ternary models both demonstrate the value of designing numerical representations and CPU kernels together. Low-bit efficiency depends on the full execution path; scaling, accumulation, and other operations still have to run.

For NPUs and mobile GPUs, the supported data types, operators, and tensor shapes also matter. The ONNX Runtime documentation discusses how quantization overhead interacts with hardware support. Successful export or loading is only one part of deployment.

5. Approaching 1 bit (BitNet b1.58): less precision, or fewer independent parameters?

Moving from 4 bits to 2 bits reduces the number of levels available to each weight. Near 1 bit, two further questions become essential: Does each weight still have its own code? Where is its magnitude stored? These questions explain how compression works more clearly than a method’s name alone.

Ternary weights retain three states: negative, zero, and positive. The “1.58” in BitNet b1.58 comes from the entropy of three equally likely states, log₂3≈1.585; an actual implementation still needs to pack them. A binary representation retains only the sign, removing the choice of whether a weight is zero. That imposes a stronger constraint, with shared parameters and training helping to compensate.

Keep the signs; share the magnitudes

Consider four weights: 0.12, 0.18, −0.10, −0.20. Store their signs with a shared magnitude s=0.15, and the reconstructed values become 0.15, 0.15, −0.15, −0.15. Each position still has an independent sign, but the different magnitudes within the group have been merged. Training can adjust the signs and shared magnitude; it cannot give this representation four independent magnitudes.

Bonsai Q1_0 implements this idea as a concrete format: 128 sign bits for 128 weights, plus one shared 16-bit scale, for 144/128=1.125 bits per weight. Smaller groups generally allow finer control over magnitudes while increasing scale overhead.

OneBit pairs a binary weight matrix with high-precision input and output scaling vectors. A weight’s magnitude depends on the scales for its row and column, with the representation adapted through quantization-aware distillation. The shared principle is to store an inexpensive sign at every position and share the more expensive magnitude parameters. Both retain a full-size sign matrix without forcing it through a low-dimensional bottleneck.

Figure 6. Animated mechanisms with theoretical bit counts. Shared magnitudes and the Q1_0 group format are followed by a separate low-rank example: two binary factors represent a 1024×1024 matrix with an inner dimension of 256. The 0.5-bit figure counts factor codes only; scales add overhead. The diagrams show matrix shapes, not actual model weights or measured quality.

Below 1 bit, store fewer independent states

If every position can independently be positive or negative, N signs have 2ᴺ possible combinations. A fixed-length, lossless code that represents all of them needs at least N bits. The low-rank binary approach therefore changes the structure of the representation: two smaller binary matrices, A and B, plus scaling parameters approximate the original matrix, instead of storing a separate sign for every original position.

For a code-only example, a full 1024×1024 binary matrix needs 1,048,576 bits. Replacing it with a 1024×256 matrix A and a 256×1024 matrix B takes 524,288 bits. Averaged over the original matrix’s positions, that is 0.5 bits per weight.

Each entry in the reconstructed matrix combines multiple factor terms, so it can take more than two values. But the entries are now interdependent: AB has rank at most 256 and cannot represent an arbitrary 1024×1024 matrix. Saving space also limits the independent directions the layer can express. Tighter bit packing alone cannot remove this structural tradeoff.

NanoQuant explores low-rank binary factors with scaling parameters, using initialization and reconstruction optimization to reduce error. The dimensions above are illustrative, not its experimental configuration. Actual storage must also include scales and other tensors.

Different representations need different execution paths

Group-wise binary formats can use tiled loading, unpacking, or lookup-table computation. The official Bonsai documentation lists CPU backend support, and T-MAC’s evaluation includes OneBit’s 1-bit models.

A low-rank representation can instead compute h=Bx, then y=Ah, applying scales at the appropriate points. This avoids materializing a complete high-precision weight matrix. It reduces stored factor bytes but adds an intermediate vector and a second computation stage that depends on the first. Kernel efficiency for smaller matrices, scheduling, and fusion all affect the payoff. NanoQuant reports CUDA matrix-kernel experiments on the Jetson TX2, providing evidence for an edge-GPU implementation. Those results do not establish end-to-end translation speed on an ordinary CPU.

The 1.25-bit regime offers another structural choice. Sherry requires exactly one zero in each group of four ternary weights, encoding the 32 possible combinations in 5 bits. Hy-MT2 also reports an AngelSlim 1.25-bit scheme. This restricts local combinations of states, whereas low-rank factorization constrains matrix structure.

To compare these approaches, ask what is shared or constrained, how many bytes the complete artifact saves, and how the kernel consumes that representation. Quality evaluation and device measurements establish whether those tradeoffs are worthwhile.

6. Making it work in an offline translation app

Translation is sensitive to numbers, entities, negation, and terminology. Multilingual averages can also hide regressions in less well-represented languages. Fluent output alone does not establish that a quantized model translates correctly.

The execution structure matters, too. An encoder–decoder model processes the source sentence first, then generates the target sentence incrementally. Estimating its cost as “one read of the entire model per output token” misses that distinction. Architecture background: the original Transformer paper

  • Encoder. Processes the source once; weights can be reused across input positions. Affects time to first output; activations and computation also matter as inputs get longer.

  • Cross-attention. Source keys and values can be precomputed and cached, but are still read at each decoding step. Weight compression does not automatically remove cache costs that grow with source length.

  • Autoregressive decoder. Decoder layers run repeatedly; the self-attention cache grows with the output. Weight traffic matters at small batch sizes; test long outputs as well.

  • Embeddings and output projection. May share a weight matrix; the output projection scores the vocabulary. Precision can affect both input representations and word choice; count shared parameters only once.

Parameter count, quality sensitivity, and contribution to latency are three different considerations. Mixed precision can preserve capacity in sensitive modules while assigning the most expensive work to kernels the device executes efficiently.

Three connected checks turn a compression approach into a usable feature.

Numerical agreement. Verify alignment between fake quantization during training, exported codes and scales, and layer outputs from the deployed kernels. Start with fixed inputs to localize discrepancies, allow appropriate tolerances for floating-point reductions, then check generated outputs.

Task quality. Use held-out evaluation data and inspect regressions by translation direction, length, domain, and low-resource language. Check omissions, repetitions, numbers, and terminology. Calibration and training data should reflect real usage while excluding final test sets and public benchmark text. When comparing PTQ with QAT, account for additional training and teacher costs to avoid attributing gains to the wrong cause.

Device experience. Fix the device, backend, thread count, and decoding configuration. Measure cold start, time to first output, end-to-end sentence latency, peak memory, and energy use and speed under sustained operation. Tokenization differs across languages, so compare the complete task when assessing multilingual user experience. Verify the actual execution path: a backend may convert types or fall back to another implementation. CTranslate2 quantization documentation

Validation from task budgets through deployed artifacts to device measurements

Figure 7. A general engineering workflow. Quality and device results guide changes to precision and kernels. This diagram contains no experimental results from our project.

Entry-level chips can handle more AI tasks when these pieces work together. Compact representations reduce storage and memory traffic. Training helps preserve task quality. Suitable kernels let ordinary hardware use those representations efficiently.

For offline translation, the deliverable is an accurate translation returned promptly, with memory and energy use that remain acceptable over sustained use. Bit widths can keep falling. These requirements still determine whether the system actually works.