Zero Labs
Industry News / AI

Understanding LLM Quantization: Why FP32, FP16, BF16 and INT8 Matter for Modern AI Systems

Source · Towards AI By Jiten Bhalavat

From the publisher’s feed, collected in the ZeroLabs newsroom.

Large Language Models are extremely large and computationally expensive, so techniques like reduced-precision data types (FP16, BF16) and quantization (INT8, INT4) are used to significantly lower memory usage and accelerate inference while maintaining acceptable model accuracy.OverviewLarge Language Models (LLMs) such as GPT, LLaMA, and Mistral contain billions of parameters and require massive computational resources to run. If every weight in these models were stored using standard 32-bit floating point precision (FP32), the memory and compute requirements would be extremely high. For example, a model with 70 billion parameters would require hundreds of gigabytes of memory just to store its weights.To make these models practical to run on modern hardware, researchers and engineers use techniques that reduce the numerical precision of model parameters while preserving performance. One of the most important techniques used for this purpose is quantization.Quantization is the process of converting high-precision numerical values (such as FP32) into lower-precision representations such as FP16, BF16, INT8, or even 4-bit formats. By doing this, the size of the model can be significantly reduced, enabling faster inference, lower memory consumption, and more efficient deployment on GPUs and other hardware accelerators.Different numerical formats provide different trade-offs between precision, dynamic range, and computational efficiency.For instance, FP32 provides high precision and stability but consumes more memory. FP16 and BF16 reduce memory usage while maintaining reasonable accuracy, making them popular for training and inference. INT8 and lower-bit representations further compress the model, enabling large models to run on limited hardware, though with some loss in numerical precision.Understanding these numerical formats and the role of quantization is crucial for modern machine learning engineers, especially when deploying large language models in production environments.In this article, we will explore the differences between FP32, FP16, BF16, and INT8, how quantization works, and why these techniques are essential for running large AI models efficiently.Before understanding quantization, we first need to understand hownumbers are represented inside neural networks.What Is a Data Type in Neural Networks?Neural networks are just matrix multiplications.Example: Y= W . XWhere:W = weightsX = inputY = outputThe numbers inside W and X are stored in memory using some data type.That’s where float32, float16, int8 come in.1.) float32 (FP32)Sign = 1 bitsExponent = 8 bitsMantissa= 23 bitsExample: 13.5Let’s see how the value 13.5 is stored in FP32.We must convert decimal → binary → scientific binary form.## Convert 13 to binary 1.) divide by 2 repeatedly 13/2 = 6 remainder 1 6/2 = 3 remainder 03/2 = 1 remainder 11/2 = 0 remainder 1Reading bottom up: 13 = 1101 base 2## Fractional Part1.) Multiply by 2 repeatedly0.5 * 2 = 1.0 --> 1So, 0.5 = 0.1 base 2Combine both: 13.5 = 1101.1 base 2Now, Convert to normalized binary scientific notationIn base 10, 263 = 2.63 x 10^2 In base 2, same idea: 1101.1 = 1.1011 x 2^3We now know, how FP32 Store value:--> Sign = 1 bit--> Exponent = 8 bits--> Mantissa = 23 bitsSo, Step-1: Sign13.5 is positive. So, sign =0 Step-2: Exponent Actual Exponent Value = 3 ( as we have 2³ , so 3 )---> Stored Exponent = 3 + bias = 3 + 127 = 130130 in binary = 10000010 [ 8 bits ]Why Bias = 127 ? As we have Exponent 8 bits, so 2^(8-1) -1 = 127Step-3: MantissaWe store everything after the leading 1.Our 13.5 decimal value is: 1.1011 x 2^3So, we store: 10110000000000000000000 [ 23 bits total ]Final FP32 Representation: 0 | 10000010 | 10110000000000000000000Lets Decode: Using formaulaFormula: (-1)^sign x 1.mantissa x 2^(exponent-127)We have, sign=0 , mantissa= 101100... exponent = 130So, (-1)^0 x 1.101100 x 2^(130-127)1x1.101100 x 2^3 1.101100000... x 8Convert that to decimal: 1.1011 base 2 = 1 + 1*(1/2) + 0*(1/4) + 1*(1/8) + 1*(1/16)+ 0+ ...= 1.6875 * 8 = 13.5 Why FP32?Very high precisionStable trainingDefault in older modelsMemory CostIf model has:1 billion parameters:1B x 4 Bytes = 4GBBecause: 32 bits = 4 bytes2.) float16 (FP16)FP16Sign= 1 BitsExponent = 5 bits ( it was 8 in FP32 )Mantissa = 10 bits ( For FP32, its 23 bits)We will use the same example: 13.5Lets see how the value 13.5 is stored in FP16.We must convert decimal → binary → scientific binary form.## Convert 13 to binary 1.) divide by 2 repeatedly 13/2 = 6 remainder 1 6/2 = 3 remainder 03/2 = 1 remainder 11/2 = 0 remainder 1Reading bottom up: 13 = 1101 base 2## Fractional Part1.) Multiply by 2 repeatedly0.5 * 2 = 1.0 --> 1So, 0.5 = 0.1 base 2Combine both: 13.5 = 1101.1 base 2Now, Convert to normalized binary scientific notationIn base 10, 263 = 2.63 x 10^2 In base 2, same idea: 1101.1 = 1.1011 x 2^3We now know, how FP16 Store value:--> Sign = 1 bit--> Exponent = 5 bits--> Mantissa = 10 bitsSo, Step-1: Sign13.5 is postive. So, sign =0 Step-2: Exponent Actual Exponent Value = 3 ( as we have 2³ , so 3 )---> Stored Exponent = 3 + Bias = 3 + 15 = 1818 in binary = 10010 [ 5 bits ]Why Bias = 15 ? As we have Exponent 5 bits, so 2^(5-1) -1 = 15Step-3: MantissaWe store everything after the leading 1.Our 13.5 decimal value is: 1.1011 x 2^3So, we store: 1011000000 [ 10 bits total ]Final FP16 Representation: 0 | 10010 | 1011000000Lets Decode: Using formaulaFormula: (-1)^sign x 1.mantissa x 2^(exponent-15)We have, sign=0 , mantisaa= 101100... exponent = 18So, (-1)^0 x 1.101100 x 2^(18-15)1x1.101100 x 2^3 1.101100000... x 8Convert that to decimal: 1.1011 base 2 = 1 + 1*(1/2) + 0*(1/4) + 1*(1/8) + 1*(1/16)+ 0+ ...= 1.6875 * 8 = 13.5Half the memory.Same 1B model:1B x 2 Bytes = 2GBWhat’s the catch?Smaller exponent rangeLess precisionCan cause overflow/underflow during trainingThat’s why we use:Mixed precision trainingLoss scaling3.) Brain float16 (BF16)Sign= 1 BitsExponent = 8 bits ( same as FP32 )Mantissa = 7 bits ( For FP32, its 23 bits and FP16: 10 bits)We will use the same example: 13.5Lets see how the value 13.5 is stored in BFP16.We must convert decimal → binary → scientific binary form.## Convert 13 to binary 1.) divide by 2 repeatedly 13/2 = 6 remainder 1 6/2 = 3 remainder 03/2 = 1 remainder 11/2 = 0 remainder 1Reading bottom up: 13 = 1101 base 2## Fractional Part1.) Multiply by 2 repeatedly0.5 * 2 = 1.0 --> 1So, 0.5 = 0.1 base 2Combine both: 13.5 = 1101.1 base 2Now, Convert to normalized binary scientific notationIn base 10, 263 = 2.63 x 10^2 In base 2, same idea: 1101.1 = 1.1011 x 2^3We now know, how BFP16 Store value:--> Sign = 1 bit--> Exponent = 8 bits--> Mantissa = 7 bitsSo, Step-1: Sign13.5 is postive. So, sign =0 Step-2: Exponent Actual Exponent Value = 3 ( as we have 2³ , so 3 )---> Stored Exponent = 3 + bias = 3 + 127 = 130130 in binary = 10000010 [ 8 bits ]Why Bias = 127 ? As we have Exponent 8 bits, so 2^(8-1) -1 = 127Step-3: MantissaWe store everything after the leading 1.Our 13.5 decimal value is: 1.1011 x 2^3So, we store: 1011000 [ 7 bits total ]Final BF16 Representation: 0 | 10000010 | 1011000Lets Decode: Using formaulaFormula: (-1)^sign x 1.mantissa x 2^(exponent-127)We have, sign=0 , mantisaa= 1011000 exponent = 130So, (-1)^0 x 1.1011000 x 2^(130-127)1x1.1011000 x 2^3 1.1011000 x 8Convert that to decimal: 1.1011 base 2 = 1 + 1*(1/2) + 0*(1/4) + 1*(1/8) + 1*(1/16)+ 0+ ...= 1.6875 * 8 = 13.5The Key DifferenceFP16:Smaller exponentLarger mantissaBF16:Same exponent size as FP32Smaller mantissaWhat That Means Practically ?Range: FP16 exponent bits = 5So exponent range is small.Max FP16 ≈ 65504 , That’s tiny.BF16 exponent bits = 8Same as FP32.Max BF16 ≈ 3.4×10^38 , Same range as FP32.| Type | Min (approx) | Max (approx) || ---- | ------------ | ------------ || FP32 | 1e-45 | 3.4e38 || FP16 | 6e-8 | 6.5e4 || BF16 | 1e-38 | 3.4e38 |Why This Matters for LLMs ?? : In transformers: Attention scores can get large, Gradients can explode, Activations can spike.FP16 is more prone to overflow because of its smaller exponent range,while BF16 has the same exponent range as FP32, making overflow much less likely.That’s why: Modern GPUs such as NVIDIA A100, H100, and A10G provide native support for BF16 tensor operations, making BF16 widely used for LLM training.Precision DifferenceNow look at mantissa.FP16 = 10 bitsBF16 = 7 bitsSo FP16 has more precision.BF16 has less precision but more range.Example: Representing 1.234567FP32 has 23 mantissa bits → very precise.FP16 (10 bits mantissa) → decent precision.BF16 (7 bits mantissa) → less precise.But neural networks tolerate small rounding noise.They do NOT tolerate overflow.Range > precision for training stability.Why BF16 Is So Popular in LLM Training ??Because:Same dynamic range as FP322× less memoryNo need for loss scalingStable trainingFP16 needs:Loss scalingCareful tuningBF16 usually just works.FP32 and BF16 has same rangeThat’s why modern LLM training prefers BF16.4.) INT8 (8-bit Integer)For INT8, things are different from FP32/FP16. INT8 does not store floating-point numbers directly. Instead, it stores integers from −128 to 127, and floating-point values are mapped to these integers using quantization (scale and zero-point).So floating-point values must be quantized.There are two formulas correspond to two different quantization schemes.Symmetric Quantization: Use when the data is centered around zero. ( example: Weights, faster matrix multiplication)Asymmetric Quantization: Use when the values are not centered around zero. ( example: Activations, range not centered at 0 )Symmetric quantization is preferred for neural network weights because they are centered around zero and allow faster computation, while asymmetric quantization is better for activations because their values are often non-negative.Why Symmetric Is Preferred for Weights ??Because:Weights are usually centered around 0Mean ≈ 0Distribution symmetricZero-point unnecessaryFaster hardware implementationThat’s why LLM weights use symmetric quantization.Quantization Formula1.) Symmetric Quantization1.) Compute Scale: scale = max_abs / 127 where,max_abs = max (|rmin|, |rmax|)2.) Quantise: q= round(value/scale) values are the weights of the matrix## here zeropoint = 03.) During Computation: real = q * scale Example: (Symmetric Quantization)Original weights: [-4.2, -2.5, 1.3, 3.6, 5.1]1.) Compute Scale:max_abs = 5.1So, scale = max_abs/127 = 5.1/127 = 0.04022.) Quantise = round(value/scale)for value -4.2 = round(-4.2/0.0402) = round (-104.4) = -105for value -2.5 = round(-2.5/0.0402)= -62and so on....so we will store INT8 values = [ -105, -62, 32, 90, 127 ]3.) De Quantisation:real = q * scale = -105 * 0.0402 = -4.221 which is close to -4.22.) Asymmetric Quantization1.) Compute Scale: scale = ( rmax - rmin ) / ( qmax - qmin )where,rmax = maximum value of the matrix rmin = minimum value of the matrix qmax = 127qmin = -1282.) Compute Zero Pointzeropoint = round ( qmin - (rmin/scale) )if the value, less than -128. then we keep -128 as thats the min range.3.) Quantise q= round(r/scale) + zeropointExample: Original weights: [-4.2, -2.5, 1.3, 3.6, 5.1]rmin = -4.2rmax = 5.1qmin = -128qmax = 1271.) Compute scale: scale = (rmax - rmin) / (qmax - qmin)scale = (5.1 - (-4.2)) / ( 255 )scale = 0.03652.) Compute Zero point:zeropoint = round ( qmin - (rmin/scale) ) = round ( -128 - (-4.2/0.0365) )= round ( -128 - (-115.06) )= -13 3.) Quantise each weight:q= round(r/scale) + zeropointfor value -4.2 = round(-4.2/0.0365) + (-13) = -128for value -2.5 = round(-2.5/0.0365) + (-13) = -814.) De quantise:real = scale x (q- zeropoint)= 0.0365 x ( -81- (-13)) = 0.0365 x (-68)= -2.482which is close to -2.5 | Feature | Symmetric | Asymmetric || ------------------- | ------------------ | --------------- || Zero point | 0 | Non-zero || Scale | max_abs / 127 | (rmax-rmin)/255 || Hardware efficiency | Faster | Slightly slower || Used for | weights (LLMs) | activations |INT8 quantization is widely used during inference because integer arithmetic is significantly faster on modern hardware accelerators, allowing large models to run efficiently with reduced memory bandwidth requirements.ConclusionIn this blog, we explored how different numerical formats store values in machine learning systems. We started with FP32, the standard floating-point representation that provides high precision but requires more memory and compute. We then looked at FP16 and BF16, which reduce memory usage and accelerate computation while still maintaining reasonable numerical stability for deep learning workloads.Finally, we examined INT8 quantization, where floating-point values are mapped to integers using scaling techniques. While this significantly reduces memory footprint and improves inference speed, it introduces quantization error due to reduced precision.Understanding these numerical representations is crucial when working with modern AI systems, especially large language models, where memory efficiency and computational performance directly impact scalability and deployment.Each format represents a trade-off between precision, memory usage, and computational efficiency, and choosing the right representation depends on the specific stage of the ML pipeline — training, fine-tuning, or inference.What’s Next?In the next blog, we’ll move one step further and explore how to fine-tune Large Language Models (LLMs). We’ll cover concepts like LoRA, QLoRA, parameter-efficient fine-tuning, and how quantization interacts with fine-tuning techniques.Stay tuned! 🚀Enjoyed this breakdown? Follow Jiten Bhalavat and subscribe via email to receive upcoming blogs on AI systems, LLM optimization, and practical machine learning engineering straight into your Mailbox.Understanding LLM Quantization: Why FP32, FP16, BF16 and INT8 Matter for Modern AI Systems was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.