Part 10 of ten. Each post is a short, plain-words tour of one lesson from e=mc², a free build-an-LLM-from-scratch course; the full lesson, notebook and numbers are on the site.

Shrinking a model is the easy part. Proving it has earned its place is the work. For the last lesson of e=mc² I took the two small decision models from Lesson 9, wrote their weights with fewer digits, measured how much smaller and faster they got, and then handed them to a judge that does not care how clever the trick was. The judge said no to both. The idea inside it is one you can hold in your hand.

The one idea: a smaller backpack

A model is millions of dials, and every dial is a number. Normally each one is stored as a float with about seven digits of precision, four bytes each; the engineers call that fp32. int8 quantization rounds each dial to a one-byte whole number times a single scale. Fewer digits, a quarter of the bytes, and the hope that whole-number arithmetic is also faster.

In the lesson's story, Momo the monkey (he is the model) has learned to dispatch, fill in forms, and has studied the teacher's decisions. Before he gets his own desk, Ella the elephant lays down the house rule: act alone only if, on questions you have never seen, you are right 98 times in 100. And travel light. His notes go into a smaller backpack, written with fewer digits.

The desk has a name in the software this lesson plugs into. pankhllm, a small open-source router that decides which operation a plain-English request wants, calls a decision engine it trusts first a lane. A lane earns its place only if it holds 98% precision on unseen questions and decides more of them than the 262 KB regression pankhllm already ships. That is the contract. Everything below is measured against it.

What rounding did to the tiny one

The from-scratch decider has 0.84 million parameters. The one-line PyTorch quantizer, applied to every linear layer, worked beautifully on paper: its decisions were unchanged on 99.0% of a 300-question check, and on 99.59% of all 2,172 test questions. The file went from 3.37 MB to 1.10 MB.

And it got slower. A decision took 1.30 milliseconds at the median against 0.68 before. The reason is size, in the other direction: its matrices are only 128 wide, so the cost of converting activations to whole numbers and back is bigger than what the integer multiply saves. int8 pays off on large matrices where fetching the weights, not the arithmetic, is the slow part. On a tiny model the backpack is lighter and the walk is longer.

What rounding did to the big one

Then the same one-liner on Qwen2.5-0.5B with Lesson 9's adapter merged in. It kept only 44.7% of its decisions. Not slightly worse; broken.

The glossary word for why is outlier, and the Momo version is "one shout that drowns every whisper". Dynamic quantization gives each activation tensor one shared scale. Measuring every linear layer's input on 200 calibration questions found a few feed-forward inputs near 1,700, while everything around them was small. Round all of that to one byte on one scale and the whispers become zero. The LLM.int8() paper from 2022 describes exactly this.

Two more tries. Per-channel scales (one per output row instead of one per matrix) with the output head left in fp32 got 48.7%. Keeping the seven outlier layers in fp32 brought agreement to 92.0% on the check and 94.29% across all test questions. The lesson says plainly that attempts two and three were chosen after seeing attempt one.

Size fell from 1,976 MB to 1,000 MB, half rather than a quarter, because Qwen's 545 MB embedding table stays fp32. Speed was about the same, 42.4 milliseconds before and 40.5 after. The whole quantization-and-serve recipe is a few lines:

from torch.ao.quantization import quantize_dynamic, per_channel_dynamic_qconfig attempt1 = quantize_dynamic(model, {nn.Linear}, dtype=torch.qint8) # the one-liner keep = {"lm_head", *outlier_layers} # inputs above 100 on calibration questions spec = {n: per_channel_dynamic_qconfig for n, m in model.named_modules() if isinstance(m, nn.Linear) and n not in keep} attempt3 = quantize_dynamic(model, spec, dtype=torch.qint8) # what pankhllm sends the lane, and what the stdlib server answers {"state": "who covers T-412?", "questions": {"operation": {"type": "choice", "criteria": {"coverage_owner": "...", "prescriber_list": "...", "UNSUPPORTED": "..."}}}} {"answers": {"operation": {"choice": "coverage_owner", "answer_confidence": 0.999851}}} 

The judge

Instead of grading the models myself, I served them the way pankhllm talks to outside engines: one POST to /v1/systemone, carrying the question and a choice among the operations it structurally fits, with UNSUPPORTED last. The server is plain Python standard library, nothing installed, and a round trip took 1.62 milliseconds. It also applies pankhllm's known-words gate: if fewer than 70% of a question's words were seen in training, the lane stays quiet and pankhllm falls back to its planner.

Ask it "who covers T-412?" and the lane answers:

{"answers": {"operation": {"choice": "coverage_owner", "answer_confidence": 0.999851}}}

Then pankhllm's own 0.1.1 binary ran its offline scorer, decide-eval, against the lanes. First a sanity check: trained on 20,000 templates alone, pankhllm's regression decided 52.45% of held-out templates at 100% precision, 1,049 right and none wrong. The published figure is 52.5%. Reproduced, on my CPU, before judging anything of mine.

The numbers, honestly

On Lesson 9's teacher-written questions, with the gate on:

  • pankhllm's regression, plus Lesson 9's 183 labels: decided 36.6% at 92.1% precision. The incumbent.
  • The from-scratch decider, int8: decided 30.2% at 96.2%, in 1.73 ms including HTTP. More precise than the regression, less coverage, short of 98%. Does not earn a lane.
  • Qwen2.5-0.5B, int8: decided 36.0% at 93.5%, in 36.9 ms. Does not earn a lane.
  • Lanes that earned their place: 0 of 2. Turning the gate off flips neither verdict.

One run, 11 October 2026, on an Apple Silicon Mac CPU. The whole notebook took 181.5 seconds. It was not timed on Colab.

Why I am glad it said no

Two things I will carry from this. First, quantization is easy to do and easy to get wrong: check agreement with fp32 before you look at megabytes, and expect no speed-up on a model this small. Second, every decider in the lesson holds 98% on held-out templates, and none holds it on questions a different author wrote, pankhllm's regression included. The number format was never the problem. Precision on other people's phrasings was.

So the lane config the lesson ships starts in shadow mode: Momo answers on paper beside the planner, and nobody acts on his answers until real traffic brings real labels. That is what a 98% rule looks like when you actually apply it, and I would rather end the series on a true "not yet" than a flattering "done".

The full lesson has the three-attempt quantization table, the complete decide-eval table with the published rows beside the measured ones, the glossary in Momo's words, and the notebook that does all of it on any CPU.

Want to actually build it?

This post is the postcard. The lesson is the trip. Lesson 10 of e=mc² on theaivibe.org walks you through every piece with widgets you can poke, a notebook that runs on a free GPU in minutes, and the honest numbers at every step. No account, no paywall, nothing to install.

That is the whole journey. If you did all ten, you now hold a language model you trained from random dials, read the mind of, fine-tuned, taught to take instructions, LoRA'd with 2% of its weights, turned into a decision model, made to fill a form, distilled from real phrasings, and finally quantized and judged. The hub lists all ten in order, so if you joined late, start at lesson one.