Macalinao StudioLearnAll enriched lessons ↗
College path · 7 sectionsSwitch to high school ↗

College / LONGER LESSON quantization

Quantization: trade numerical resolution for storage

Quantize and reconstruct values, separate clipping from rounding, account for metadata, and evaluate model-level tradeoffs.

Preparation: Rounding, signed numbers, averages and model weights.

Plan 25–40 minutes with the activities; this is a study estimate, not a timed requirement. Both paths have complete narration. Your notes and progress are kept separately for each level.

Section 01 / 07

A smaller codebook is a deliberate approximation

College path. Quantize and reconstruct values, separate clipping from rounding, account for metadata, and evaluate model-level tradeoffs. Preparation: Rounding, signed numbers, averages and model weights. Move between Signal Room, Workbench and Field Notes without losing your section. Pause before each worked solution.

Quantization represents numbers using a limited set of codes. Imagine marking measurements on a ruler with wider spacing: marks are easier to record compactly, but nearby measurements may map to the same mark. In a neural network, the numbers might be weights, activations or cached keys and values. These are different targets; quantizing one does not automatically quantize the others. Fewer stored bits can reduce payload, while the effect on model quality depends on information changed by the approximation. A smaller number format is a choice to evaluate, not an automatic improvement.

Integer quantization, low-bit floating-point formats and nonuniform codebooks use different representable sets. INT4 is not FP4 or a four-bit codebook such as NF4. Storage precision, multiplication precision and accumulation precision may differ. State these separately rather than treating a bit-width label as a complete implementation specification.

Worked example. A sixteen-bit stored number uses two bytes of payload. Four-bit codes pack two values into one byte, giving an ideal payload ratio of one quarter. But scales, zero points, grouping metadata and alignment also take space. Smaller checkpoint files do not alone establish peak device memory or speed.

Quantized target + code format + metadata + compute precision

The displayed notation records the process described in the example. Keep its assumptions and units attached to the result.

Try it yourself. If weights use four-bit storage, must activations and arithmetic also use four bits?

Pause the narration and explain your reasoning before continuing to the worked solution.

Reveal worked solution

No. Implementations can store weights compactly while using higher precision for activations, reconstruction or accumulation. The format and kernels determine computation.

Section 02 / 07

Map a value onto a symmetric integer grid

Workbench uses a symmetric integer codebook. For bit width b, the largest positive code is two raised to the power of one less than b, then subtract one. We use its negative as the smallest code, leaving one possible signed code unused. Threshold A sets the scale: A divided by the largest code. Divide a value by the scale, round to the nearest integer, clip to allowed codes, then multiply by the scale to reconstruct it. The original value is generally not recovered exactly. Each operation has a distinct purpose.

Let Q=2^(b-1)-1 and s=A/Q. Define q=clip(round(x/s),-Q,Q), with nearest ties rounded away from zero in this fixture. Reconstruction is x_hat=sq. Other runtimes may use ties-to-even or a different integer range. These conventions are part of the numerical contract, especially at half-step boundaries.

Worked example. Use four bits and threshold seven. Q is seven and scale is one. The value 2.4 maps to code two and reconstructs as two, with error minus 0.4. Minus 2.5 maps to minus three under our tie rule. Zero maps exactly to zero.

Q=2^(b−1)−1; s=A/Q; q=clip(round(x/s),−Q,Q); x̂=sq

The displayed notation records the process described in the example. Keep its assumptions and units attached to the result.

Try it yourself. Why retain the scale along with integer codes?

Pause the narration and explain your reasoning before continuing to the worked solution.

Reveal worked solution

The same code represents different values under different scales. Code two at scale one means two, but at scale one tenth means 0.2.

Section 03 / 07

Distinguish rounding error from clipping error

Inside the represented interval, rounding moves a value to a nearby grid point. Outside the clipping threshold, a value is forced to an endpoint. These are different errors. A large threshold accommodates outliers but makes the grid coarser for ordinary values. A smaller threshold improves resolution near zero but sacrifices extreme values. The best choice depends on the distribution and which errors matter to the model, not only maximum magnitude. Inspect small values as well as the largest one before deciding a setting is better.

For an unclipped value under nearest rounding, absolute reconstruction error is at most half the scale, subject to floating-point effects. This does not bound values outside [-A,A]. Mean squared error averages squared reconstruction errors; maximum error highlights the worst value. Neither alone guarantees preserved network behavior.

Worked example. At four bits and threshold seven, 2.4 rounds to two, with error magnitude 0.4. Ten clips to seven, with error magnitude three. Raising the threshold to fourteen gives scale two: ten becomes representable, but the grid is now wider for ordinary values. The storage bit width has not changed.

Unclipped: |x̂−x| ≤ s/2; clipped values need separate analysis

The displayed notation records the process described in the example. Keep its assumptions and units attached to the result.

Try it yourself. Can the half-a-scale error bound cover a value far beyond the clipping threshold?

Pause the narration and explain your reasoning before continuing to the worked solution.

Reveal worked solution

No. It describes nearest rounding within the represented interval. Clipping error can be much larger and must be measured separately.

Section 04 / 07

Grouping and zero points change the tradeoff

One scale for a whole tensor is simple, but one outlier can set a coarse grid for many small values. Smaller groups can use separate scales, improving local resolution at the cost of more metadata and sometimes more complicated kernels. An asymmetric scheme can shift the integer grid with a zero point when the useful range is not centered around zero. These choices change the mapping. They are not interchangeable labels for ordinary rounding, and their practical value depends on how data and kernels are arranged.

An affine mapping reconstructs x_hat=s(q-z), with q clipped to its supported integer range and integer zero point z. Per-channel and per-group describe how parameters are shared; specify the axes. Our experiment stays symmetric with z=0 and calculates a separate metadata budget instead of pretending to implement every groupwise method.

Worked example. Compare groups [0.1,0.2] and [6,7] under four-bit maximum-based scaling. Sharing threshold seven gives scale one, so small values round to zero. Giving the first group threshold 0.2 produces scale 0.2 divided by seven and preserves finer distinctions. Another scale must be stored.

Affine reconstruction: x̂=s(q−z); grouping determines shared s and z

The displayed notation records the process described in the example. Keep its assumptions and units attached to the result.

Try it yourself. Does using more groups always reduce total model size?

Pause the narration and explain your reasoning before continuing to the worked solution.

Reveal worked solution

No. More groups usually mean more scaling metadata. They may improve numerical accuracy, but total storage includes both codes and metadata.

Section 05 / 07

Trace an error into a dot product

Network computations combine many numbers. A small weight error can matter more when multiplied by a large activation. Compare an original dot product with one using reconstructed weights while holding activations fixed. Our fixture uses eight weights and alternating activations of plus one and minus one. Change the outlier, bit width or threshold, then inspect each reconstruction and the final dot-product error. This is more informative than assuming equally sized weight errors have identical effects. It also shows why an error statistic about weights is not a complete evaluation of a network.

When only weights change, the dot-product difference is the sum of activation_i times weight_error_i. Its absolute value is at most the sum of absolute activation_i times absolute error_i. This local bound does not model all later nonlinearities. Layer reconstruction and held-out task evaluation remain necessary.

Worked example. For weights [2.4,-1.2] and activations [2,1], the original dot product is 3.6. At scale one, weights [2,-1] produce three. The difference is minus 0.6: two times minus 0.4 plus one times 0.2. The first error contributes twice because its activation is two.

Δy=Σ a_i Δw_i; |Δy|≤Σ |a_i||Δw_i|

The displayed notation records the process described in the example. Keep its assumptions and units attached to the result.

Try it yourself. Must equal absolute weight errors contribute equally to output error?

Pause the narration and explain your reasoning before continuing to the worked solution.

Reveal worked solution

No. Activations have different magnitudes and signs. Sensitivity depends on how errors enter computation, not only their individual sizes.

Section 06 / 07

Compare methods without merging their promises

Post-training quantization adapts an already trained model to a lower-precision representation. Quantization-aware training exposes training to quantization effects. Among post-training methods, GPTQ uses approximate second-order information when choosing weight approximations. Activation-aware weight quantization uses activation statistics to guide protective channel scaling. LLM.int8 uses a mixed-precision treatment for outlier features. These are different procedures, not names for ordinary rounding. Their reported results apply to studied configurations. A useful comparison states which tensors change, how scales are chosen, and which computation remains at higher precision.

Calibration data should represent intended use and remain distinct from held-out evaluation. Weight-only quantization does not imply quantized activations or KV cache. Low-bit floating-point training differs from integer weight compression. This fixed grid does not reproduce GPTQ optimization, AWQ calibration or outlier decomposition.

Worked example. A model may have four-bit stored weights, sixteen-bit activations, higher-precision accumulation and a separate cache format. Calling it a four-bit model hides important details. Packages with that label may use different grouping, protected tensors and kernels, with different memory, quality and speed.

Bit width alone is not a method, quality score or speed guarantee

The displayed notation records the process described in the example. Keep its assumptions and units attached to the result.

Try it yourself. Does choosing the same bit width make methods equivalent?

Pause the narration and explain your reasoning before continuing to the worked solution.

Reveal worked solution

No. Mapping, calibration, grouping, protected values, computation and implementation can differ. Compare complete configurations and measured outcomes.

Section 07 / 07

Budget honestly and test the intended tasks

Start a memory estimate with code payload, then add metadata. Our separate budget uses one million weights, groups of sixty-four, one two-byte scale per group and no zero-point metadata. At four bits, codes occupy 500,000 bytes. The 15,625 scales add 31,250 bytes, totaling 531,250 before alignment or other tensors. This exceeds bare four-bit payload but is much smaller than two million bytes of sixteen-bit weight payload. It is not total serving memory. Keep the unit bytes visible instead of casually switching between decimal and binary units.

Evaluate held-out quality, representative tasks, long-context behavior and rare failures. Measure peak memory and latency with supported kernels on target hardware. Include reconstruction overhead and distinguish prefill from decode. Quantizing a cached tensor can have different sensitivity from quantizing weights; validate that target separately.

Worked example. Predict the payload when switching from four to eight bits: codes double in size. Scale metadata in this fixed grouping example does not, so total size grows by less than a factor of two. Vary threshold next: memory stays fixed while reconstruction error changes. Storage and numerical quality are separate axes.

Total estimate = packed codes + scales + zero points + alignment + other tensors

The displayed notation records the process described in the example. Keep its assumptions and units attached to the result.

Try it yourself. What evidence is missing if a quantized checkpoint loads and uses less memory?

Pause the narration and explain your reasoning before continuing to the worked solution.

Reveal worked solution

Task quality and workload performance still need evaluation. Loading establishes compatibility for that execution path, not preserved accuracy or useful latency improvement.

Final checkpoint. For unclipped nearest rounding with scale s, what is the scalar error bound? Option 1: s divided by two. Option 2: Always zero. Option 3: The bound also covers arbitrary clipped outliers.

Pause and choose an answer before continuing.

Reveal worked solution

Option 1 is correct. Nearest rounding within the interval is bounded by half a grid step. Clipping is a separate error.

LONGER ADAPTATION LESSONS

Learn the update and the teaching signal

Worked examples, local narration and connected experiments at your level.

Continue the learning path

Sources and scope

Original worked examples and teaching text, grounded in these primary references. Numerical fixtures explain mechanisms; model quality and hardware performance require separate measurements. Both levels share key examples, with different explanations and checkpoints.

EXTENDED FIELD NOTES

Smaller numbers, larger consequences

Understand the storage saving, reconstruction error, and runtime accounting behind quantization.

Additional reading · original lesson audio remains unchanged.

Read the full explanation · 580 words + college extension
Round, reconstruct, compare

This toy quantizer introduces +0.04 error. Clipping is a separate source of error.

  1. Original: 0.26
  2. Scale: 0.1
  3. Code: 3
  4. Reconstructed: 0.30

Original: 0.26

A ruler with fewer marks

Imagine measuring a length with a ruler marked every millimeter and then recording it only to the nearest centimeter. The object has not changed, but your representation has become less precise. Quantization makes an analogous trade: it maps numerical values onto a more limited set of representable values. The analogy has limits because neural computations combine many values, and their errors can interact. Still, it explains why a smaller representation can save memory without being numerically identical to the original.

Take a toy scale of 0.1. A weight of 0.26 is rounded to the integer code 3 and reconstructed as 0.3. The reconstruction error is 0.04. If the representable range ends at 0.3, a value of 0.9 may be clipped to that boundary. Its error is much larger. Rounding and clipping are different problems. Choosing a wider range can reduce clipping while leaving fewer representable values near zero; choosing a narrower range can improve local resolution but lose outliers.

One number cannot describe every tensor

A model contains many kinds of tensors, and a quantization method may treat them differently. Some can remain at higher precision while others use fewer bits. Groups of values may share scales or other metadata needed to reconstruct approximate values. That metadata consumes space too. Therefore, multiplying the parameter count by a nominal bit width provides an estimate, not a promise of an exact file size.

For a deliberately simplified example, 122 billion values at exactly four bits each occupy 488 billion bits. Dividing by eight gives 61 billion bytes, or 61 decimal gigabytes. This excludes scales, other metadata, unquantized tensors, and everything required while the model runs. Decimal gigabytes also differ from binary gibibytes. The arithmetic is useful because it makes assumptions explicit; it should not be presented as the measured size or memory requirement of a particular Ornith artifact.

The file and the computation have different jobs

A file format packages information. A numerical format describes how values are represented. A runtime must understand both the architecture and the stored representation, then provide operations that execute on the available hardware. A smaller download does not automatically produce a faster answer. Unpacking values, transferring data, or using a slower fallback operation can outweigh a theoretical arithmetic saving.

Nor is runtime memory limited to the weights. The system needs temporary activations, attention state, workspaces, and output buffers. Multiple simultaneous requests can increase those requirements. A model that loads successfully can still run out of memory when given a longer prompt. This is why a useful comparison reports context length and concurrency alongside the weight format. “It fits” should mean that the intended workload fits, not merely that startup reaches a ready message.

Evaluate the approximation where it matters

Small weight errors do not translate into an identical amount of answer error. Some computations tolerate approximation better than others. A rounding change can alter a token score slightly; when candidate scores are close, a different token can be selected, and the later continuation can diverge. Conversely, different wording does not necessarily mean worse quality. Evaluation must examine whether the answer still satisfies the task.

Use the Workbench to compare original and reconstructed numbers before discussing whole-model quality. Then consider a task suite: factual questions, calculations, structured output, and the actual applications you care about. Hold the prompts and evaluation method stable. Report memory savings separately from measured quality and speed. QLoRA adds another distinction: it trains adapters around a quantized base; it is not simply a new label for running a four-bit model. Keeping representation, training, and execution separate makes technical comparisons much easier to understand.

College extension · make the assumptions explicit

For symmetric uniform quantization, a simplified code is q = clip(round(w/s), qmin, qmax), with reconstruction ŵ = sq. Let ΔW = Ŵ − W. For a fixed input x, the linear output error is Δy = ΔW x; its norm is bounded by ‖ΔW‖‖x‖ for compatible norms. This is a local statement, not an end-to-end language-quality bound. Nonlinearities, attention normalization, routing, and autoregressive decisions can amplify or suppress effects. Groupwise scales change metadata cost and the distribution of reconstruction errors.

Sources and further investigation

Source review: October 28, 2026. Model-release claims are attributed to their publishers.

Open the focused reading page →

Reset this college path?

This removes only this path’s notes, progress and experiments from this browser.