LLM Parameter Counts and Model Size: A Practical Conversion Guide
Learn how to calculate parameter counts for CNNs and Transformers, convert those counts into storage requirements at different precisions, and estimate the scale of a 300 GB model file. This guide also explains how model size affects GPU memory planning, distributed deployment, and interconnect requirements.
Parameter count and model file size are closely related, but they are not interchangeable. The connection depends primarily on how many bytes are used to store each parameter and what else the model file contains.
In practice, developers may encounter a model file as large as 300 GB and need to determine whether it represents tens of billions, hundreds of billions, or trillions of parameters. That estimate helps inform GPU memory allocation, compute resource planning, and the need for high-speed communication between devices.
To understand the conversion, it helps to start with how parameters are counted in individual network layers.
1. Calculating Parameters in Traditional Neural Networks
Before examining large language models, consider a convolutional neural network (CNN). Most of its parameters reside in convolutional and fully connected layers.
Convolutional Layers
A convolutional layer contains kernel weights and, when enabled, biases. For a standard convolution with kernel dimensions (Kw \times K_h), input channels (C{\text{in}}), and output channels (C_{\text{out}}), the parameter count is:
[
P = (Kw \times K_h \times C{\text{in}} + 1) \times C_{\text{out}}
]
The (+1) accounts for one bias per output channel.
For example, consider the first convolutional layer of a classic CNN. It accepts an RGB image with three input channels and uses 96 kernels, each measuring (11 \times 11):
[
P = (11 \times 11 \times 3 + 1) \times 96
= 364 \times 96
= 34{,}944
]
Fully Connected Layers
A fully connected layer has one weight for every input-to-output connection, plus a bias for each output neuron.
Following a convolutional layer: The feature maps are typically flattened into a vector. If the feature map has spatial dimensions (O \times O), contains (N) channels, and connects to (F) output neurons, the parameter count is:
[
P = (O^2 \times N + 1) \times F
]
For an input of (6 \times 6 \times 256) and an output dimension of 4,096:
[
P = (6^2 \times 256 + 1) \times 4{,}096
= 37{,}752{,}832
]
Following another fully connected layer: With input dimension (F_{l-1}) and output dimension (F_l), the formula is:
[
P = (F_{l-1} + 1) \times F_l
]
For a final layer mapping 4,096 input features to 1,000 outputs:
[
P = (4{,}096 + 1) \times 1{,}000
= 4{,}097{,}000
]
These examples illustrate the basic rule: count the entries in each weight matrix or tensor, then add any bias parameters.
2. Calculating Parameters in Transformer Models
Transformer-based large language models concentrate their parameters in embedding layers, attention projections, and feed-forward networks.
Embedding Layers
In a classic pretrained language-model architecture, the embedding module may contain token embeddings, segment embeddings, learned position embeddings, and a LayerNorm layer.
Let:
- (V) be the vocabulary size.
- (H) be the hidden dimension.
- (L) be the maximum sequence length supported by the learned position embeddings.
The parameter counts are:
| Component | Parameter count |
|---|---|
| Token embeddings | (V \times H) |
| Segment embeddings for two segments | (2 \times H) |
| Learned position embeddings | (L \times H) |
| LayerNorm scale and bias | (2 \times H) |
For a vocabulary of 30,522 tokens, a hidden dimension of 1,024, and 512 learned positions:
[
P_{\text{embedding}}
= (30{,}522 + 2 + 512) \times 1{,}024 + 2 \times 1{,}024
]
[
= 31{,}036 \times 1{,}024 + 2{,}048
= 31{,}782{,}912
]
This calculation applies to the embedding design described here; the exact components depend on the model architecture.
Self-Attention and Transformer Blocks
Self-attention generates queries, keys, and values through three learned projections, commonly represented by (W_Q), (W_K), and (W_V).
For a standard attention module in which each projection maps from hidden dimension (H) to (H), the combined parameter count, including biases, is:
[
P_{\text{QKV}} = 3(H^2 + H)
]
The attention output is then passed through another linear projection:
[
P_{\text{output}} = H^2 + H
]
Together, these four projections contain:
[
P_{\text{attention}} = 4H^2 + 4H
]
For (H = 1{,}024), each projection is a Linear(1024, 1024) transformation. The sequence length does not determine the size of these projection matrices.
A standard Transformer block also contains a feed-forward network (FFN), typically with two linear layers and an intermediate dimension of (4H):
- The first layer maps (H) to (4H).
- The second layer maps (4H) back to (H).
Including biases, its parameter count is:
[
P_{\text{FFN}}
= (H \times 4H + 4H) + (4H \times H + H)
= 8H^2 + 5H
]
Adding attention, the FFN, and LayerNorm parameters gives approximately:
[
P_{\text{block}} \approx 12H^2
]
This approximation ignores biases and other relatively small terms. For a fixed hidden dimension and block design, the parameters in the Transformer stack grow linearly with the number of layers.
3. Converting Parameter Count to Model Size
Once the parameter count is known, the raw weight storage requirement follows from the storage precision:
[
\text{Weight size in bytes}
= \text{Parameter count} \times \text{Bytes per parameter}
]
Conversely:
[
\text{Parameter count}
\approx \frac{\text{Weight size in bytes}}{\text{Bytes per parameter}}
]
Storage Requirements by Precision
| Storage format | Nominal bytes per parameter |
|---|---|
| FP32 | 4 |
| FP16 / BF16 | 2 |
| INT8 | 1 |
| INT4 | 0.5 |
These figures describe the parameter data itself. Actual file sizes may also include metadata or other stored information, so the conversion is an estimate rather than an exact measurement of every checkpoint.
The calculations below use decimal gigabytes, where (1\text{ GB} = 10^9) bytes.
Example: A 130B-Parameter Model
A model with 130B parameters contains (130 \times 10^9) parameters.
FP32 storage:
[
130 \times 10^9 \times 4
= 520 \times 10^9 \text{ bytes}
= 520 \text{ GB}
]
FP16 storage:
[
130 \times 10^9 \times 2
= 260 \times 10^9 \text{ bytes}
= 260 \text{ GB}
]
INT8 storage:
[
130 \times 10^9 \times 1
= 130 \text{ GB}
]
The parameter count remains the same across these formats; what changes is the storage required per parameter.
What Does a 300 GB Model File Represent?
If a 300 GB file contains only FP16 or BF16 weights, its estimated parameter count is:
[
P \approx \frac{300 \times 10^9}{2}
= 150 \times 10^9
]
That places it in the roughly hundred-billion-parameter class.
A file around 300 GB could therefore be consistent with a model in the 130B–150B range when half-precision weights make up most of its contents. However, this estimate is conditional on the storage format and file contents.
If the file is a training checkpoint that also contains optimizer states, or if its tensors use mixed storage precisions, dividing the total file size by two is not sufficient. The file size alone cannot uniquely determine the model’s parameter count.
4. Hardware and Interconnect Implications
Model size provides a starting point for deployment planning, particularly when determining whether the weights fit on a single GPU.
With GPU memory capacities such as 40 GB or 80 GB, a 130B model requiring approximately 260 GB for half-precision weights cannot fit on one device. Its weights must be partitioned across multiple GPUs for a deployment using that precision and those memory capacities.
Communication in Multi-GPU Workloads
Distributed training and inference involve communication between GPUs. The amount and frequency depend on how the model and workload are partitioned.
For models with hundreds of billions of parameters, communication can become a major performance bottleneck. High-speed interconnects such as NVLink, InfiniBand, or RoCE are therefore important for efficient distributed execution, especially when the parallelism strategy requires frequent exchanges.
If interconnect bandwidth is insufficient, communication time can dominate execution and sharply reduce GPU utilization. The precise requirement depends on the deployment strategy, rather than parameter count alone.
Planning Cloud Resources
In cloud deployments, estimating weight storage helps teams select suitable GPU resources and plan:
- GPU memory allocation.
- Model partitioning across devices.
- Tensor parallelism strategies.
- Network topology and interconnect bandwidth.
When using GPU compute instances on platforms such as Baidu AI Cloud, understanding the relationship between parameter count and file size supports more informed distributed-training and deployment decisions.
The goal is to balance memory capacity, communication overhead, and compute utilization rather than select hardware based only on a model’s advertised parameter count.
Conclusion
Converting parameter counts into model sizes is a practical engineering skill. CNN parameters can be counted from convolutional kernels and fully connected matrices, while Transformer parameters are largely determined by embeddings, attention projections, and feed-forward layers.
The core storage rule is straightforward: multiply the parameter count by the bytes required per parameter. Applying that rule correctly requires knowing the storage precision and whether the file contains only weights or additional checkpoint data.
With those details established, developers can estimate model scale more reliably and make better decisions about GPU memory, distributed execution, and high-speed interconnects.
