A number on a grid
See how rounding to a grid changes a model weight.
Quantization replaces numbers with nearby values from a limited set. On a uniform grid with a known step, a value can be stored as a grid position. This reduces the number of distinct values to represent, at the cost of rounding error.
A small example
Take a grid with a step of 0.5. The nearest point to 1.4 is 1.5, an error of 0.1. The number 2 already lies on a grid point and is represented exactly. Try the same check with 0.6.
When two values become one
For 0.6 the nearest point is 0.5. Now try a second value, 0.4. Can you distinguish it from 0.6 after rounding? With a step of 0.5 both land on the same point. The stored code alone cannot tell you which original weight the model held. Reduce the step to 0.1 and the two numbers land on different points again.
See it happen
Where does a number land?
Quantization divides by a scale, rounds and clamps to the integer range. Compare the restored values.
Original numbers
[-2.5, -1.5, -0.5, 0.5, 1.5, 2.5]
scale = 1
Integer codes
[-2, -2, 0, 0, 2, 2]
round-to-even → clamp [−127, 127]
Restored numbers
[-2, -2, 0, 0, 2, 2]
integer code × scale
Scale 1: ties go to even. Maximum error: 0.5.
Explicit fixed-scale examples. Weight quantization later chooses a scale from the actual weight range.
Done reading?
Mark the lesson as read to move your track progress forward.
Lesson marked as done.
Now build your own version
Implement rounding and measure the error introduced by int8 values.
What practice includes and how much it costs
MCP includes the full lesson and a local project with starter files. Work through the task with your agent, ask for a hint and run the checks on your computer.
One payment, no auto-renewal · Terms
Progress saved in this browser
Clear your history or open this on your phone, and the marks will be gone. Leave your email and they'll move to your account. No password needed.
Done. moved to your account. You can see your progress on any device. My progress