Private Deployment of Large Models: A Practical Guide to Multi-Node Distributed Inference
Multi-node distributed inference is essential for deploying large models with limited resources. This guide explores engineering design principles for multi-node inference, covering compute topology, memory tiering, parallelism strategies, quantization, performance evaluation, and common pitfalls to help teams make informed deployment decisions.
The core challenge of privately deploying large models usually lies not in starting the service, but in keeping model weights, inference states, and concurrent requests running stably within limited resources. Multi-node distributed inference is a common solution to this problem. This article does not discuss a specific product but outlines general design principles from an engineering perspective for teams to reference during selection and deployment.
1. Core Problems Multi-Node Inference Must Solve
The bottlenecks of single-node deployment primarily come from three aspects.
First is capacity. Model weights must reside in memory or VRAM. The larger the parameter scale, the more space required. The estimation formula is:
Weight footprint ≈ Parameter count × Bytes per parameter
Taking 100 billion parameters as an example, using 16-bit floating-point requires about 200GB for weights, 8-bit floating-point about 100GB, and 4-bit quantization about 50GB. The actual footprint must also include runtime overhead, including framework memory, activations, and fragmentation.
Second is the KV cache. During generation, the model caches the key-value vectors of historical tokens. Its footprint grows with context length and concurrency:
KV cache footprint ≈ 2 × Number of layers × Number of KV heads × Head dimension × Sequence length × Concurrency × Bytes per element
The context for long document processing and multi-round agent tasks is often very long, and the KV cache sometimes exhausts space earlier than weights.
Third is latency and throughput. Multi-node introduces cross-machine communication, and communication overhead directly affects the Time To First Token (TTFT) and Tokens Per Second (TPS). Therefore, capacity, bandwidth, and latency must be weighed together, rather than looking at only one.
2. Compute Topology and Interconnect Design
The performance limit of a multi-node cluster is often determined by the communication capability between nodes. Multiple cards within a node communicate via high-speed intra-chip or on-board interconnects, while nodes depend on the network.
Pay attention to units when calculating network bandwidth. A 200Gbps link has a theoretical throughput of about 25GB/s, and the actual available value needs to deduct protocol overhead and congestion loss. When planning the network, it is recommended to follow these principles:
- Enable high-speed networks supporting Remote Direct Memory Access (RDMA) to reduce latency caused by CPU involvement in data copying.
- Keep communication within the same parallel group on the same node or the same switch domain as much as possible.
- Ensure the link rates of switches and NICs match to avoid bottlenecks on a single port.
- Plan separate network planes for management traffic and inference data streams to prevent management tasks from squeezing bandwidth.
Network jitter also needs monitoring. Meeting average bandwidth does not guarantee stable tail latency. You should continuously monitor P99 communication time and record packet loss and retransmission counts.
3. Memory and Storage Tiering Strategy
To allow limited fast memory to carry the most critical data, tiered storage is typically adopted. It can generally be divided into three tiers.
The first tier is the high-speed memory directly accessed by computing devices, storing active weight shards, activations, and hot KV caches. This tier has the highest bandwidth and the tightest capacity.
The second tier is system memory, used to store scheduling states, weight blocks to be loaded, and partial caches.
The third tier is high-speed solid-state storage (SSD), used to store less frequently accessed data, such as lookup table embeddings, model checkpoints, logs, and cold data backups.
The core principle of tiering is: push data with low access frequency, that is prefetchable, or can tolerate read latency down to lower tiers. The schematic placement logic is as follows:
# Pseudocode: Determine data tier based on access frequency and latency sensitivitydef place_tensor(tensor_info):if tensor_info["access_freq"] == "per_token" and tensor_info["latency_sensitive"]:return "accelerator_memory"if tensor_info["access_freq"] == "per_request":return "system_memory"if tensor_info["prefetchable"]:return "nvme_storage"return "system_memory"
Offloading to storage introduces read latency, and stress testing is required to confirm its impact on tail latency. If a certain type of data must be accessed per token, it should not be placed in a slow tier.
4. Selection of Parallelism Strategies
Common parallelism methods for multi-node inference have their own applicable scenarios and costs.
| Parallelism Method | Split Object | Main Benefit | Main Cost |
|---|---|---|---|
| Tensor Parallelism | Matrix operations within a single layer | Reduces single-card VRAM footprint, shortens single-step computation time | Requires frequent communication per layer, demanding on bandwidth and latency |
| Pipeline Parallelism | Model layers | Reduces the number of layers per card, fewer communication times | Pipeline bubbles exist, low utilization with small batches |
| Expert Parallelism | Expert modules in Mixture of Experts (MoE) architecture | Distributes expert parameters, reduces single-card burden | Requires all-to-all communication during routing, latency increases with unbalanced loads |
| Data Parallelism | Requests or batches | Increases overall throughput | Each replica must hold complete weights, limited capacity benefit |
When selecting, it is recommended to determine the primary contradiction first. If capacity is insufficient, prioritize tensor parallelism or expert parallelism; if inter-node bandwidth is limited, reduce the cross-node scope of tensor parallelism and use pipeline parallelism instead; if the goal is to improve concurrent throughput, increase the number of replicas provided the model can fully fit in memory.
5. Precision and Quantization
Precision determines weight footprint and computational efficiency. Common choices include 16-bit floating-point, 8-bit floating-point, and 4-bit quantization. Reducing precision can significantly reduce VRAM, but brings precision loss.
In practice, a mixed precision strategy is recommended: keep higher precision for output-sensitive layers, such as embedding layers, output heads, and some attention layers; use lower precision for feed-forward layers that account for a large proportion and have high error tolerance.
Quantization should not be judged solely by theoretical VRAM. You should use evaluation sets consistent with the business to compare performance before and after quantization in factual Q&A, long-text understanding, code generation, and tool calling. Only quantization schemes verified by business metrics are suitable for production environments.
6. Performance Evaluation Metrics
Performance evaluation requires unified metric definitions, otherwise different tests cannot be compared. The main metrics are as follows:
- Time To First Token (TTFT): The time from sending a request to receiving the first output token, mainly reflecting the efficiency of the prefill stage.
- Time Per Output Token (TPOT): The average interval between adjacent tokens during generation, mainly reflecting the speed of the decode stage.
- Throughput: The total number of output tokens per unit of time, usually counted under specified concurrency.
- Tail Latency: P95 and P99 percentiles, reflecting the worst-case user experience.
- Peak VRAM: The maximum footprint during runtime, used to determine whether the margin is sufficient.
When stress testing, note the following: perform a warm-up first to eliminate the impact of initial loading; use input/output length distributions close to real business; test low and high concurrency separately; record temperature, power consumption, and network metrics simultaneously to facilitate bottleneck identification.
Below is a framework-agnostic stress testing schematic:
# Pseudocode: Latency collection and summary for a single requestimport timedef measure_once(send_request, prompt, max_new_tokens):start = time.perf_counter()first_token_time = Nonetoken_count = 0for _ in send_request(prompt, max_new_tokens, stream=True):now = time.perf_counter()if first_token_time is None:first_token_time = nowtoken_count += 1end = time.perf_counter()ttft = first_token_time - starttpot = (end - first_token_time) / max(token_count - 1, 1)return {"ttft": ttft, "tpot": tpot, "tokens": token_count, "total": end - start}def percentile(values, p):ordered = sorted(values)index = int(p * (len(ordered) - 1))return ordered[index]def summarize(results, wall_time):ttfts = [r["ttft"] for r in results]tpots = [r["tpot"] for r in results]total_tokens = sum(r["tokens"] for r in results)return {"ttft_p95": percentile(ttfts, 0.95),"tpot_mean": sum(tpots) / len(tpots),"throughput_tps": total_tokens / wall_time,}
The send_request in the pseudocode needs to be replaced with the actual streaming request function. Concurrency testing can add a thread pool or async scheduling based on this.
7. Evaluation Based on Business Workload
Different businesses focus on different performance aspects and should be evaluated separately.
- Daily Q&A: Short input and output, high concurrency. Focus on TTFT and P95 metrics.
- Document Processing: Very long input, relatively short output. Focus on prefill throughput and VRAM margin under long context.
- Complex Reasoning Tasks: Long output, long inference chain. Focus on TPOT and long-term running stability.
- Coding Assistance and Agents: Multi-turn interaction, often accompanied by tool calls, continuously growing context. Focus on KV cache reuse efficiency, context switching overhead, and timeout handling.
Each type of workload should have a separate test set and acceptance criteria. For example, Q&A business may require P95 TTFT to be below a set threshold, while document business may require a target success rate for a specified input length.
8. Selection and Deployment Checklist
Before finalizing the solution, it is recommended to confirm the following items one by one:
- Whether the sum of weights, KV cache, and runtime overhead is below about 80% of available memory.
- Whether the cross-node communication volume of the parallelism strategy is within the tested network bandwidth range.
- Which data is offloaded to the storage tier, and whether its read latency has been verified by stress testing.
- Whether the quantization scheme has passed the evaluation set consistent with the business.
- Whether the stress test covers target concurrency, target context length, and long-term running scenarios.
- Whether node health checks, fault isolation, and fast rollback capabilities are available.
- Whether model versions, configuration parameters, and hardware batches are included in unified change records.
9. Common Pitfalls
First, comparing only theoretical compute power while ignoring memory bandwidth. The decode stage is usually limited by memory bandwidth, and high theoretical compute does not mean low TPOT.
Second, testing only averages. Average latency hides tail problems, and online complaints often come from P99 metrics.
Third, not re-stress testing after offloading. After data is pushed to the storage tier, tail latency may increase significantly and must be re-evaluated.
Fourth, ignoring operational costs. The failure probability of multi-node clusters is higher than single machines, requiring advance planning for monitoring, logging, alerting, and automatic recovery processes.
Private deployment is a long-term engineering effort. When selecting, capacity, latency, precision, and operational capabilities should be weighed in the same table, rather than making a decision based solely on a single parameter.
