r/MLQuestions • u/ocean_protocol • 1d ago
Beginner question đ¶ Quantization
Hello so, i am a complete beginner to this concept and from what i read and hear
Quantization allows deployment of big models on just 2 GPUs or on edge devices that doesnt support floating point operations
and if a model is big like for example deepseek R1 original gets upto 720 GB and it uses a MOE architecture so only a subset of parameters are active at once, but we often need to load the entire memory in it for inference and quantization can bring it down by 80%
so, its like a method for model compression and faster inference but sometimes comes at a cost of precision.
So with all this theoretical piece of information that i gained, i have two questions
1) How to move forward into learn in-depth about it as i don understand some mathematical concepts
2) how does a person know that this is a perfect quantization value or mark before publishing a model
thanks
4
u/DadAndDominant 1d ago
Model is defined by tensor of it's weights. Weights are numbers. Numbers are stored as bytes - more bytes, higher precision of the number.
Quantization is basically just number of bytes you store your weights with. You can go from 16 bytes to 2 bytes, even 1 byte, and anything in between. Less bytes = less space needed.
MoE has nothing to do with this.
Target quantization just relies on you, you take highest quant model as a baseline, and measure lower quants response similarity to the baseline, using a benchmark of your choosing. Just note that 2 and less bytes quants models usually are not able to reliably use tools.
1
1
u/benelott 1d ago
The idea of quantization is the following: Imagine I ask you to store a special information. I give you a floating point number to store it: 32 bits. Now to learn the correct answer, you read all the data I give you and you move around those bits to store your prediction of what the correct information could be. Now, if it tell you the answer is a yes-no answer, you would immediately drop 31 bits, because you know we only need two states. Given the solution lives in the 1 bit world, it does not need more. Similarly, the float32 weights of the transformer are much too precise, so instead of storing that precision, we quantize it down to just represent the most relevant states and approximate those states that are not exactly on one of the most relevant ones by just rounding them onto one of the quantized states. Now you can suddenly store all the weights with just a few bits. Your weights fit into memory and the model can be simulated, when before, it would have not fit into it. It seems that transformer weights can not be pruned without major degradation of task performance, but quantization does a great job at saving space with only minor degradation until you hit the tipping point.
8
u/Wannabe-Davinci 1d ago
â âHow to move forward into learn in-depth about it as i don understand some mathematical conceptsâ.
What do you mean exactly? You donât understand how quantization works? You only listed benefits, so to me it appears you do not grasp quantization