Concept notebookChecking saved investigationReading browser-local route memory before showing a continuation.

Quantization: Compressing Models to Integers

Reduce memory and bandwidth by storing weights/activations in low-bit integers (INT8/INT4) with careful scaling to limit accuracy loss.

published · difficulty 3/5 · 16 min read

01

01

Intuition

Build the mental picture first so the rest of the page has something to attach to.

PredictName the object in plain language, then predict what should change.Leave with one reusable mental picture before notation appears.

Large models are often bottlenecked by memory bandwidth, not raw FLOPs. If memory bandwidth is the bottleneck, moving less data can improve throughput, though the actual speedup depends on kernels, hardware, batch size, and which tensors are quantized.

Quantization is the core trick: store weights (and sometimes activations) in low-bit integers like INT8 or INT4, with a scale factor that maps those integers back to approximate floating-point values.

A major enemy, especially in large LLM quantization, is outliers: a small number of large weights/activations can force a scale that wastes resolution for everything else.

Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

02

02

Math

Translate the story into symbols, assumptions, and a derivation you can inspect.

InspectTrack the same object through the notation and check each symbol.Leave with the invariant the equations preserve.

Uniform quantization (per-tensor)

Given a tensor of weights with min/max values, choose one step size for the whole tensor and round onto integer levels:

Δ=wmaxwmin2b1,wq=clip ⁣(round ⁣(wwminΔ),0,2b1),w^=wqΔ+wmin.\Delta = \frac{w_{\max}-w_{\min}}{2^b-1},\qquad w_q=\mathrm{clip}\!\left(\mathrm{round}\!\left(\frac{w-w_{\min}}{\Delta}\right),0,2^b-1\right),\qquad \hat w=w_q\Delta+w_{\min}.Δ=2b1wmaxwmin,wq=clip(round(Δwwmin),0,2b1),w^=wqΔ+wmin.

Here bbb is the number of bits (8 for INT8, 4 for INT4).

Finer-grained scaling: per-channel / row-wise

Instead of one scale for the whole matrix, use one scale per output channel/row. For signed symmetric quantization:

qmax=2b11,si=maxjWi,jqmax,Qi,j=clip ⁣(round ⁣(Wi,jsi),qmax,qmax),W^i,j=siQi,j.q_{\max}=2^{b-1}-1,\qquad s_i=\frac{\max_j |W_{i,j}|}{q_{\max}},\qquad Q_{i,j}=\mathrm{clip}\!\left(\mathrm{round}\!\left(\frac{W_{i,j}}{s_i}\right),-q_{\max},q_{\max}\right),\qquad \hat W_{i,j}=s_iQ_{i,j}.qmax=2b11,si=qmaxmaxjWi,j,Qi,j=clip(round(siWi,j),qmax,qmax),W^i,j=siQi,j.

This usually improves quality because different channels have different dynamic ranges.

Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

03

03

Code

Keep the implementation aligned with the notation so the algorithm is legible.

TraceMatch variables to symbols before reading the implementation.Leave with a runnable witness for the math.
import numpy as np

rng = np.random.default_rng(0)
w = rng.normal(size=10000).astype(np.float32)

def quantize_uniform(w, bits=8):
    qmin, qmax = 0, 2**bits - 1
    wmin, wmax = float(w.min()), float(w.max())
    delta = (wmax - wmin) / (qmax - qmin)
    wq = np.clip(np.round((w - wmin) / delta), qmin, qmax).astype(np.int32)
    what = (wq * delta + wmin).astype(np.float32)
    return what, float(delta)

what8, d8 = quantize_uniform(w, bits=8)
what4, d4 = quantize_uniform(w, bits=4)

print("RMSE INT8:", round(float(np.sqrt(((w - what8) ** 2).mean())), 6), "delta:", round(d8, 6))
print("RMSE INT4:", round(float(np.sqrt(((w - what4) ** 2).mean())), 6), "delta:", round(d4, 6))
print("memory reduction: fp16->int8 ~2x, fp16->int4 ~4x (weight storage)")
Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

04

04

Interactive Demo

Use direct manipulation to connect the explanation to a moving system.

ManipulateChange one control and predict the visible response before reveal.Leave with the observed invariant or a repaired model.

Live Concept Demo

Explore Quantization: Compressing Models to Integers

The stage is code-native and interactive. Use it to test the explanation against the mechanism.

difficulty 3/5undergraduatecode-aligned
Demo inquiry checkpoint

Manipulate one control and predict the visible change.

01Choose lensTrace a quantity
02ObserveDemo state pending
03GroundName the equation, invariant, or control that explains it.
04CarryNext: Long Context Engineering: RoPE Scaling, KV Compression & Memory Optimization

Choose what to inspect in Quantization: Compressing Models to Integers. This shared fallback is an observation guide, not evidence of learning.

Loading interactive demo...

The demo below asks you to predict which scaling strategy survives an outlier before revealing the quantization error. The key invariant is that a single shared scale can waste most integer levels on one large value, while per-channel scales recover resolution for ordinary rows.

Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

4/4 sections ready

Concept: Quantization: Compressing Models to Integers

What is the smallest example that makes Quantization: Compressing Models to Integers click without losing the math?

BeforeEfficiency: Quantization, Distillation, LoRA & Sparse MoENow4/4 sections readyTryManipulate one control and predict the visible change.NextLong Context Engineering: RoPE Scaling, KV Compression & Memory Optimization
Object contextEfficiency
ConceptLearner lens

Quantization: Compressing Models to Integers

What is the smallest example that makes Quantization: Compressing Models to Integers click without losing the math?

Mode questionCan I say the mechanism back in one sentence before I reveal anything?

Start with the prediction checkpoint, then compare the reveal to the mental model.

Take this move

Study modes

Keep the object fixed; change the lens.

Route back through the notebook

Carry the same object through intuition, math, code, and demo.

4/4 sections ready
Carry inEfficiency: Quantization, Distillation, LoRA & Sparse MoE

Bring the mental model from Efficiency: Quantization, Distillation, LoRA & Sparse MoE; this page will reuse it instead of restarting from zero.

Work hereQuantization: Compressing Models to Integers

Reduce memory and bandwidth by storing weights/activations in low-bit integers (INT8/INT4) with careful scaling to limit accuracy loss.

Carry outLong Context Engineering: RoPE Scaling, KV Compression & Memory Optimization

The next edge should feel earned: use the demo prediction here before following Long Context Engineering: RoPE Scaling, KV Compression & Memory Optimization.

After The First Pass

Turn the concept into an inspected object.

The lower panels are one second act: keep the object fixed, inspect it visually, check source boundaries, practice transfer, then attach the research question.
ConceptQuantization: Compressing Models to IntegersEfficiency

Mechanism Storyboard

See the idea move before the page explains it

Reduce memory and bandwidth by storing weights/activations in low-bit integers (INT8/INT4) with careful scaling to limit accuracy loss.

Demo notes open01 / Intuition
Editorial efficiency illustration of smooth weights snapped to discrete integer levels with quantization error cues.
Prediction lens

Start with the picture, metaphor, or geometric mechanism.

Commit first

Before reading further, choose the kind of change Quantization: Compressing Models to Integers should make visible.

Visual Inquiry

Make the image answer a mathematical question

Reduce memory and bandwidth by storing weights/activations in low-bit integers (INT8/INT4) with careful scaling to limit accuracy loss.

4/4 stages readyDemo notes connected
Prediction

Which visible object should carry the first intuition?

Commit first

Pick the cue that should make Quantization: Compressing Models to Integers easier to reason about before the page gives the answer.

Source Grounding

Canonical references for the mechanism on this page.

Object - ConceptQuantization: Compressing Models to IntegersQuestion

What is the smallest example that makes Quantization: Compressing Models to Integers click without losing the math?

concept:efficiency/quantization
Boundary

sources: dettmers-2022-llm-int8, frantar-2022-gptq

Check

Open the closest source note before trusting the local explanation.

Evidence

2 selected-object sources shown first; 2 references total.

Next move

Audit the claim boundary, then ask from the same selected object.

selected object source · paper · 2022LLM.int8(): 8-bit Matrix Multiplication for Transformers at ScaleDettmers et al.
Located CF editorial boundary

Grounds transformer-scale INT8 inference, vector-wise normalization, and mixed-precision handling of emergent outlier feature dimensions.

Used here as

Dettmers et al. show transformer-scale 8-bit inference needs separate normalization constants and mixed-precision handling for emergent outlier features. Frantar et al. ground GPT-style p...

Caveat

Checks the page's finite uniform-quantization and scale/outlier lesson only; it does not claim a full GPTQ solver, exact LLM.int8 routing, calibrated model accuracy, hardware speedups, ac...

Open source
selected object source · paper · 2022GPTQ: Accurate Post-Training Quantization for Generative Pre-trained TransformersFrantar et al.
Located CF editorial boundary

Grounds GPT-style post-training weight quantization using approximate second-order information and error-compensating updates.

Used here as

Dettmers et al. show transformer-scale 8-bit inference needs separate normalization constants and mixed-precision handling for emergent outlier features. Frantar et al. ground GPT-style p...

Caveat

Checks the page's finite uniform-quantization and scale/outlier lesson only; it does not claim a full GPTQ solver, exact LLM.int8 routing, calibrated model accuracy, hardware speedups, ac...

Open source

Claim Review

Reduce memory and bandwidth by storing weights/activations in low-bit integers (INT8/INT4) with careful scaling to limit accuracy loss.

Object - ConceptQuantization: Compressing Models to IntegersQuestion

What is the smallest example that makes Quantization: Compressing Models to Integers click without losing the math?

concept:efficiency/quantization
Boundary

sources: dettmers-2022-llm-int8, frantar-2022-gptq

Check

Treat every claim as provisional until source support and a local witness agree.

Evidence

1 structured claim check on this concept.

Next move

Run the prediction or practice transfer before asking for a grounded review.

1 CF editorial source-scope review recorded

Publisher-side editorial review is not independent replication. Claims without it still need exact source-support review. 2 references and 3 local witnesses are available for inspection.

Quantization maps floating tensors to low-bit integer levels with scales/dequantization rules, reducing storage/bandwidth but adding reconstruction error; if an outlier sets one shared scale, ordinary values lose resolution, so finer-grained scales or outlier-aware handling can preserve accuracy.
Used here as

Dettmers et al. show transformer-scale 8-bit inference needs separate normalization constants and mixed-precision handling for emergent outlier features. Frantar et al. ground GPT-style post-training weight...

Local witness
Equation 1
Δ=wmaxwmin2b1,wq=clip ⁣(round ⁣(wwminΔ),0,2b1),w^=wqΔ+wmin.\Delta = \frac{w_{\max}-w_{\min}}{2^b-1},\qquad w_q=\mathrm{clip}\!\left(\mathrm{round}\!\left(\frac{w-w_{\min}}{\Delta}\right),0,2^b-1\right),\qquad \hat w=w_q\Delta+w_{\min}.
Equation 2
qmax=2b11,si=maxjWi,jqmax,Qi,j=clip ⁣(round ⁣(Wi,jsi),qmax,qmax),W^i,j=siQi,j.q_{\max}=2^{b-1}-1,\qquad s_i=\frac{\max_j |W_{i,j}|}{q_{\max}},\qquad Q_{i,j}=\mathrm{clip}\!\left(\mathrm{round}\!\left(\frac{W_{i,j}}{s_i}\right),-q_{\max},q_{\max}\right),\qquad \hat W_{i,j}=s_iQ_{i,j}.
Code witness 1import numpy as np rng = np.random.default_rng(0) w = rng.normal(size=10000).astype(np.float3...
Caveat

Checks the page's finite uniform-quantization and scale/outlier lesson only; it does not claim a full GPTQ solver, exact LLM.int8 routing, calibrated model accuracy, hardware speedups, activation quantizatio...

Review stateCF editorial source-scope reviewClaim metadata: source checkedPublisher-side editorial review only; not independent replication. Check caveats and exact source scope.

Oracle PASS: Dettmers supports Int8 scaling/dequantization, single-scale outlier precision loss, vector-wise constants, and mixed-precision outlier handling; Frantar supports low-bit GPT weight quantization as compression with reconstruction-error control and reduced memory movement. Scope excludes full GPTQ, exact LLM.int8 routing, calibrated accuracy, speedup, activation coverage, and all low-bit methods.

Reviewer: codex+oracle; reviewed 2026-05-07

Practice notebook

Use the idea, then test it somewhere new

Reduce memory and bandwidth by storing weights/activations in low-bit integers (INT8/INT4) with careful scaling to limit accuracy loss.

AttemptNo learning claim inferred
Object - ConceptQuantization: Compressing Models to IntegersQuestion

What is the smallest example that makes Quantization: Compressing Models to Integers click without losing the math?

concept:efficiency/quantization
Boundary

sources: dettmers-2022-llm-int8, frantar-2022-gptq

Check

Use one state from Quantization: Compressing Models to Integers to explain what changes, why it changes, and which assumption the explanation needs.

Evidence

No learner move yet; no learning state is inferred.

Next move

Write first, use only the help you need, then try a new case without it.

Explain

Use one state from Quantization: Compressing Models to Integers to explain what changes, why it changes, and which assumption the explanation needs.

Hint 1

Reveal when your model needs a nudge.

Hint 2

Reveal when your model needs a nudge.

Hint 3

Reveal when your model needs a nudge.

Grounded object roomClose
Selected object routeAsk from this object; carry one invariant back.sources: dettmers-2022-llm-int8, frantar-2022-gptq
  1. ObjectConceptQuantization: Compressing Models to Integers
  2. PredictBefore revealQuantization: Compressing Models to Integers prediction
  3. WitnessCompare codeQuantization: Compressing Models to Integers code witness 1
  4. RoomAsk groundedChecking local snapshot
ConceptQuantization: Compressing Models to IntegersEfficiency

Research Room

Attach the question to an exact object

Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.
Next local actionNo local draft saved yet

Open the draft below to save one note and next action in this browser.

conceptEfficiency

Quantization: Compressing Models to Integers

Anchored question

What is the smallest example that makes Quantization: Compressing Models to Integers click without losing the math?

Source boundaryInspect source ids: dettmers-2022-llm-int8, frantar-2022-gptqStable content-object key attached
Role lenses for this object

These are fixed, deterministic perspectives derived from the selected object. They do not represent people, community contributions, or independent review.

Learner evidence requestAsk what would make "Quantization: Compressing Models to Integers" feel predictable rather than familiar.
Assumption

Source ids dettmers-2022-llm-int8, frantar-2022-gptq must support the exact object, not just the surrounding topic.

Source-checking summary

Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion.

Proposed experiment

Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo.

Next action

The learner can state the mechanism in their own words

Evidence4 checks
PredictionChecking carried observation
ActionReady for one action
AILearner handoff ready
Open source object
01PredictionChecking browser-local route memory
02EvidenceChecking for a carried observation
03BoundaryInspect source ids: dettmers-2022-llm-int8, frantar-2022-gptq
04Next moveSave one next action
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
Local action draft

This draft stays locally in this browser for concept:efficiency/quantization.

No local draft saved.
Evidence to inspect
  • Source ids to inspect: dettmers-2022-llm-int8, frantar-2022-gptq
  • Definition, prerequisite, and contrast concept links
  • The equation or code witness that makes the concept operational
  • One demo state that shows the invariant instead of a slogan
What would resolve this
  • The learner can state the mechanism in their own words
  • The learner can name the prerequisite that would repair confusion
  • The learner can predict how the mechanism changes under one perturbation
Object-attached AI handoff

I am working in Continuous Function's research reading room. Object: concept - Quantization: Compressing Models to Integers Object key: concept:efficiency/quantization Context: Efficiency Anchor id: concept/concept-notebook/efficiency/quantization Open question: What is the smallest example that makes Quantization: Compressing Models to Integers click without losing the math? Evidence to inspect: - Source ids to inspect: dettmers-2022-llm-int8, frantar-2022-gptq - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan Deterministic role lenses for this object: - Boundary: fixed perspectives, not people, community contributions, or independent review - Source-checking summary: Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Teach/transfer move: Turn the mechanism into one sentence that predicts a neighboring concept. - Assumptions: - Source ids dettmers-2022-llm-int8, frantar-2022-gptq must support the exact object, not just the surrounding topic. - The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. - The concept explanation is local atlas prose until checked against its math, code, and source support. - Prerequisite gaps should become a repair route, not a reason to leave the object vague. - Role-lens requests: - Learner: ask for "Ask what would make "Quantization: Compressing Models to Integers" feel predictable rather than familiar." | assumption: Source ids dettmers-2022-llm-int8, frantar-2022-gptq must support the exact object, not just the surrounding topic. | next action: The learner can state the mechanism in their own words - Researcher: ask for "Source ids to inspect: dettmers-2022-llm-int8, frantar-2022-gptq" | assumption: The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. | next action: The learner can name the prerequisite that would repair confusion - Experimenter: ask for "Choose one variable or condition to perturb before asking for an explanation." | assumption: The concept explanation is local atlas prose until checked against its math, code, and source support. | next action: The learner can predict how the mechanism changes under one perturbation - Professor: ask for "Find the smallest transferable rule a learner could reuse without the AI." | assumption: Prerequisite gaps should become a repair route, not a reason to leave the object vague. | next action: Teach or transfer: Turn the mechanism into one sentence that predicts a neighboring concept. What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action. Current deterministic role lens for this object: - Role lens: Learner - Evidence request: Ask what would make "Quantization: Compressing Models to Integers" feel predictable rather than familiar. - Assumption to keep visible: Source ids dettmers-2022-llm-int8, frantar-2022-gptq must support the exact object, not just the surrounding topic. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Next action: The learner can state the mechanism in their own words

concept/concept-notebook/efficiency/quantization concept:efficiency/quantization