text
Here is how we can calculate the size of any LLM model:
Here is how we can calculate the size of any LLM model:
new_line
new_line
text
Each parameter in LLM models is typically stored as a floating-point number. The size of each parameter in bytes depends on the precision. 
Each parameter in LLM models is typically stored as a floating-point number. The size of each parameter in bytes depends on the precision. 
new_line
new_line
text
32-bit precision: Each parameter takes 4 bytes.
32-bit precision: Each parameter takes 4 bytes.
new_line
text
16-bit precision: Each parameter takes 2 bytes 
16-bit precision: Each parameter takes 2 bytes 
new_line
new_line
text
To calculate the total memory usage of the model:
To calculate the total memory usage of the model:
new_line
text
Memory usage (in bytes) = No. of Parameters × Size of Each Parameter
Memory usage (in bytes) = No. of Parameters × Size of Each Parameter
new_line
new_line
text
For example:
For example:
new_line
text
32-bit Precision (FP32)
32-bit Precision (FP32)
new_line
text
In 32-bit floating-point precision, each parameter takes 4 bytes.
In 32-bit floating-point precision, each parameter takes 4 bytes.
new_line
text
Memory usage in bytes = 1 billion parameters × 4 bytes
Memory usage in bytes = 1 billion parameters × 4 bytes
new_line
text
1,000,000,000 × 4 = 4,000,000,000 bytes
1,000,000,000 × 4 = 4,000,000,000 bytes
new_line
text
In gigabytes: ≈ 3.73 GB
In gigabytes: ≈ 3.73 GB
new_line
new_line
text
16-bit Precision (FP16)
16-bit Precision (FP16)
new_line
text
In 16-bit floating-point precision, each parameter takes 2 bytes.
In 16-bit floating-point precision, each parameter takes 2 bytes.
new_line
text
Memory usage in bytes = 1 billion parameters × 2 bytes
Memory usage in bytes = 1 billion parameters × 2 bytes
new_line
text
1,000,000,000 × 2 = 2,000,000,000 bytes
1,000,000,000 × 2 = 2,000,000,000 bytes
new_line
text
In gigabytes: ≈ 1.86 GB
In gigabytes: ≈ 1.86 GB
new_line
new_line
text
It depends on whether you use 32-bit or 16-bit precision, a model with 1 billion parameters would use approximately 3.73 GB or 1.86 GB of memory, respectively.
It depends on whether you use 32-bit or 16-bit precision, a model with 1 billion parameters would use approximately 3.73 GB or 1.86 GB of memory, respectively.
Here is how we can calculate the size of any LLM model:

Each parameter in LLM models is typically stored as a floating-point number. The size of each parameter in bytes depends on the precision. 

32-bit precision: Each parameter takes 4 bytes.
16-bit precision: Each parameter takes 2 bytes 

To calculate the total memory usage of the model:
Memory usage (in bytes) = No. of Parameters × Size of Each Parameter

For example:
32-bit Precision (FP32)
In 32-bit floating-point precision, each parameter takes 4 bytes.
Memory usage in bytes = 1 billion parameters × 4 bytes
1,000,000,000 × 4 = 4,000,000,000 bytes
In gigabytes: ≈ 3.73 GB

16-bit Precision (FP16)
In 16-bit floating-point precision, each parameter takes 2 bytes.
Memory usage in bytes = 1 billion parameters × 2 bytes
1,000,000,000 × 2 = 2,000,000,000 bytes
In gigabytes: ≈ 1.86 GB

It depends on whether you use 32-bit or 16-bit precision, a model with 1 billion parameters would use approximately 3.73 GB or 1.86 GB of memory, respectively.
👍
zzlxv John6666 danielus Ninjanimus san122 SporkySporkness AtAndDev adriszmar