real-quant -- int4 on actual GPT-2 weights
A trained model is an enormous pile of numbers, and storing each one less precisely makes the model smaller and faster at the cost of getting it slightly wrong. This page takes one real block of GPT-2's numbers — fetching just that block, about 9 MB, rather than the whole model — and rounds it off in front of you, measuring how much accuracy is actually lost at 8, 4 or 3 bits per number, where four bits leaves only fifteen values to land on. Real weights turn out to be tightly bunched with a few far-out stragglers, which is why splitting them into small groups that each get their own scale helps so much. This is the decision behind "will the 4-bit version be good enough on my laptop?"
Interactive page: the real counterpart to the synthetic quantization page. It runs group-wise integer quantization on actual GPT-2 weights and shows the real error. Anchor: quantization. One of the real-model grounding pages, which run a real trained model instead of synthetic weights.
What it shows
Pick a weight tensor. The page range-fetches just that tensor (~9 MB via HTTP Range — fetchTensor reads the safetensors header, then only that tensor's bytes, not the whole 548 MB file) and draws:
- its distribution — real GPT-2 weights are a tight Gaussian (σ≈0.14) with a few big outliers (to ~4.6), with the int-N quantization levels overlaid;
- RMSE vs bits — the quantization error at 2/3/4/5/6/8 bits for the chosen group size, the current setting highlighted.
Drag bits and group size: more bits and smaller groups (each block gets its own scale, so one outlier doesn't coarsen the rest) drop the error fast — exactly why int4/int8 quantization works. This grounds the abstract quantization page in numbers from a real model.
Verified against numpy
The quant math (quant.js) and the range-fetch (fetchTensor) are checked against numpy by quant.test.mjs on the real h.0.mlp.c_fc.weight tensor: the Range-read values, the stats (σ=0.141, range [−2.31, 4.59]), and the group-quant RMSE (int4/int8 × group 64/128) all match the reference (fixture quant-groundtruth.fixture.json). Run it: WEIGHTS_URL=https://huggingface.co/gpt2/resolve/main/model.safetensors node real-quant/quant.test.mjs
Render tier
T1 (Canvas2D histogram + bar chart).
Wiring
layout.mount + a tensor select + bits / group controls + "load real GPT-2 weights". Reuses fetchTensor from ../real-attention/gpt2.js; async, degrades to a labelled synthetic Gaussian+outliers stand-in offline. Two challenges (?ch=N): range-fetch a real tensor, and get RMSE < 0.005. Headless hooks: ?tensor=, ?bits=, ?group=, ?real=0. Source: page.js, quant.js.