Scaling Large Models: Compute Planning, Memory Estimation, and Inference Deployment
This article examines the engineering path behind scaling very large models, from parameter growth and Mixture-of-Experts activation to memory estimation, training compute planning, parallel strategies, and inference cost control. It explains how to distinguish total parameters from activated parameters, estimate weight and KV-cache memory, balance training tokens with model size, choose parallelization methods based on cluster topology, and benchmark inference under realistic workloads. The goal is to help teams treat parameter scale as one variable in a broader engineering and business trade-off rather than an automatic path to better results.
Scaling Large Models: From Compute Planning to Inference Deployment
1. Why Parameter Counts Keep Growing
There is a relatively stable relationship among model capability, parameter count, training data volume, and training compute. Within a certain range, increasing parameter scale usually improves performance on tasks such as language understanding, reasoning, and code generation. As a result, large-model development in the industry generally moves in the direction of “more parameters, more data, and more compute.”
However, parameter growth does not automatically produce returns. Every time the parameter count doubles, the compute required for training, memory capacity, communication bandwidth, and inference latency all rise accordingly. After scale increases, engineering bottlenecks often appear before algorithmic gains. Therefore, at the project initiation stage, teams need to translate model capability goals into quantifiable resource metrics and then work backward to determine whether the model scale is reasonable.
2. Total Parameters vs. Activated Parameters
Very large models generally do not invoke all parameters during every inference. Sparse Mixture-of-Experts (MoE) architectures split the network into multiple expert sub-networks, and a routing module selects a small number of experts for each input token to participate in computation. In this way, the total parameter count can be very large, while a single forward pass uses only a subset of it.
Therefore, when describing an MoE model, two numbers need to be distinguished:
- Total parameters: the number of all weights, which determines the lower bound of weight storage and memory usage.
- Activated parameters: the number of parameters that actually participate in computation for each token, which mainly determines the per-step compute volume and inference speed.
The following example illustrates the estimation approach. The parameter values are hypothetical and do not represent any real model:
def moe_active_params(total_b: float, shared_b: float,num_experts: int, experts_per_token: int) -> float:"""Estimate the activated parameters per token for an MoE model (in billions).shared_b is the parameter count of shared parts such as attention layersand embedding layers; the remaining parameters are evenly distributedacross experts."""expert_total = total_b - shared_bper_expert = expert_total / num_expertsreturn shared_b + per_expert * experts_per_token# Assumption: 2000B total parameters, 100B shared parameters,# 128 experts, and 8 activated per tokenactive = moe_active_params(2000, 100, 128, 8)print(f"Activated parameters: about {active:.1f}B, "f"{active / 2000:.1%} of total parameters")
The cost of this structure lies in routing and communication. When experts are distributed across different devices, each token needs to be sent to the device hosting the corresponding expert, and load imbalance can cause some devices to sit idle. Design therefore needs to consider the number of experts, routing strategy, and load-balancing loss together, rather than focusing only on the total parameter count.
3. Estimating Memory and Weight Storage
Weight storage is the first barrier in large-model deployment. Taking the common 16-bit floating-point format (FP16 or BF16) as an example, each parameter occupies 2 bytes, so the memory required for model weights can be estimated directly:
def weight_memory_tb(params_billion: float, bytes_per_param: int = 2) -> float:"""Estimate memory occupied by model weights (TB). Default: 2 bytes per parameter."""total_bytes = params_billion * 1e9 * bytes_per_paramreturn total_bytes / 1024**4for p in [1000, 5000]:print(f"{p}B parameters, 16-bit precision: about {weight_memory_tb(p):.2f} TB")
The estimate shows that weights alone require terabyte-scale memory. Actual training also needs to store gradients, optimizer states, and activations, so training memory usage is usually several times the weight footprint. The inference stage also needs to reserve space for the KV cache, which grows with context length and the number of concurrent requests. Therefore, it is normal that a single device cannot hold the model, and the model must be partitioned across multiple GPUs or even multiple nodes.
Common memory compression methods include:
- Quantization: reducing weights from 16-bit to 8-bit or 4-bit, cutting memory in half or to one quarter. Precision loss needs to be validated with evaluation sets; looking only at memory numbers is not enough.
- Sharding: distributing parameters, gradients, and optimizer states across multiple devices to reduce the burden on each GPU.
- Activation recomputation: recomputing some intermediate results during backpropagation, trading additional compute for memory space.
4. Balancing Training Compute and Data
The compute required to train a model can be estimated with a rough rule of thumb: training compute is approximately 6 times the parameter count times the number of training tokens. This formula only gives an order of magnitude, but it is sufficient for early-stage resource assessment.
A common industry heuristic is that training data volume should maintain a certain ratio to parameter count. If parameters increase while data is insufficient, model capacity is not fully utilized. If data increases while parameters are insufficient, the model’s expressive capability is limited. Therefore, planning should determine both parameter scale and training token count at the same time, and then estimate the required number of accelerators and the training period.
A simple planning process is as follows:
- Define target capabilities and evaluation metrics, and determine an acceptable upper bound for inference cost.
- Work backward from the cost ceiling to the model’s activated parameter scale.
- Determine the number of training tokens according to the data ratio, and calculate total training volume.
- Combine the theoretical compute of accelerators with actual utilization, which is usually far below peak, to estimate training days.
- Reserve time for failure recovery, experiment reruns, and evaluation to avoid schedule overruns in the final stage.
Actual utilization is an easily overlooked variable. Communication overhead, data loading, checkpoint writes, and hardware failures all reduce effective compute. Experienced teams measure real throughput in small-scale experiments and then use it to correct time estimates for large-scale training.
5. Parallel Strategies for Training Infrastructure
When a single machine cannot hold a very large model, multiple parallelism methods need to be combined:
- Data parallelism: each device holds a complete model replica, processes different data batches, and then synchronizes gradients.
- Tensor parallelism: splitting the matrix operations of a single layer across multiple devices, suitable for environments with high-speed intra-node interconnects.
- Pipeline parallelism: dividing the model by layers across different devices, with each device processing different micro-batches in sequence to reduce idle waiting.
- Expert parallelism: for MoE structures, placing different experts on different devices and coordinating with routing for token dispatch.
The choice of parallel strategy depends on network topology. Intra-node environments usually have high-bandwidth interconnects and are suitable for tensor parallelism; inter-node bandwidth is lower and is better suited to data parallelism or pipeline parallelism. Before designing a solution, teams should measure the cluster’s actual bandwidth and latency rather than inferring from nominal specifications.
Checkpointing is equally critical. Very long training jobs last for weeks, and any hardware failure can cause lost progress. Model state and data reading positions should be saved periodically, and the recovery process should be verified to work at the target scale.
6. Inference Deployment and Cost Control
After training is complete, the cost of inference services is usually more persistent than training. Cost is mainly composed of three parts: the compute per request, the concurrency ceiling caused by memory usage, and user latency requirements.
Common methods for improving inference efficiency include:
- Continuous batching: dynamically combining different requests to improve accelerator utilization.
- KV cache management: allocating cache in paged or chunked ways to reduce memory fragmentation. For requests with the same prefix, already computed cache can be reused.
- Speculative decoding: using a smaller draft model to generate candidate tokens first, then having the large model verify them in parallel, reducing latency within an acceptable range of quality loss.
- Request tiering: routing simple requests to smaller models and sending only complex requests to large models, reducing overall cost.
Before deployment, teams should establish benchmarks covering first-token latency, throughput, and memory usage under different input lengths, output lengths, and concurrency levels. Only data measured under the target workload can serve as a basis for capacity planning.
7. Practical Recommendations
For teams preparing to introduce very large model capabilities, the following sequence can be used:
- First validate the business scenario with existing smaller models, and clarify whether the capability gap truly requires larger scale to close.
- Establish a unified evaluation set and use the same standard to compare the effects of different scales and quantization methods.
- Write resource estimates into a reviewable spreadsheet, record assumptions, and revise them after experimental data becomes available.
- Incorporate inference cost into product pricing and performance metrics, rather than focusing only on model leaderboard rankings.
- Develop degradation plans to keep core services available when compute is tight or failures occur.
Parameter scale is one factor in capability, but not the only factor. Data quality, training methods, evaluation coverage, and engineering efficiency also determine final results. Teams should start from business goals and manage parameter scale as one variable in a set of trade-offs.
