Optimizing LLM Inference on Domestic NPU Hardware: A 53.5% Throughput Boost on 8 Cards
This article walks through a real-world inference tuning case for a quantized MoE model deployed on an 8-card server powered by next-generation domestic NPUs. By rebalancing tensor and data parallelism, enabling expert parallelism and sequence parallelism, and applying NPU graph compilation and kernel-level optimizations, the tuned configuration achieved up to 53.5% higher total throughput than the baseline—all while meeting strict latency SLOs. The article also distills a reusable methodology for production inference tuning, from profiling and bottleneck analysis to asset-based deployment practices.
Optimizing LLM Inference on Domestic NPU Hardware: A 53.5% Throughput Boost on 8 Cards
Background: The Real Challenges of Inference Deployment on Domestic NPUs
As large language models move into large-scale production, more teams are deploying inference services on domestic NPU hardware. However, there is a significant gap between “getting it to run” and “running it well.” Common pain points in practice include:
- Suboptimal default configurations: The default parallelism parameters provided by inference engines are typically designed for general-purpose scenarios and are not tuned for a specific chip’s compute, memory bandwidth, or interconnect topology, resulting in low resource utilization.
- Difficulty choosing a parallelism strategy: Tensor parallelism (TP), data parallelism (DP), and expert parallelism (EP) each have their own sweet spots. A poorly chosen mix can amplify communication overhead or create single-card memory bottlenecks.
- Tuning complexity under SLO constraints: Production environments usually require time-to-first-token (TTFT) and time-per-output-token (TPOT) to meet defined service level objectives. Simply maximizing throughput or minimizing latency in isolation won’t work—the goal is finding the global optimum within the constraints.
- Hard-to-reuse tuning experience: A successful tuning effort is often scattered across documents, scripts, and engineers’ heads. When the team switches models or hardware, everything has to be redone from scratch.
This article is based on a real optimization case: tuning inference for a quantized, lightweight Mixture-of-Experts (MoE) model on an 8-card server with next-generation domestic NPUs. The final result showed that, under SLO constraints, the optimized configuration improved total throughput by up to 53.5% compared to the baseline. Below, we break down the approach from methodology to concrete configuration.
The Baseline Setup and Bottleneck Analysis
The baseline used the domestically adapted version of a mainstream inference engine to serve the quantized model, running on 8 NPUs with the following initial parallel configuration:
# Baseline configuration (illustrative)tensor_parallel_size = 8 # TP8: tensor parallelism across 8 cardsdata_parallel_size = 1 # DP1: single instance
The problems with this configuration:
- TP8 communication overhead is disproportionately high. Tensor parallelism requires an AllReduce across all cards after every layer’s attention and feed-forward computation. When the model is relatively small (as in this case, a lightweight MoE model), the per-card compute share is small, so communication becomes a significant fraction of total time and interconnect bandwidth turns into the bottleneck.
- Concurrency is capped by a single instance. With DP=1, all requests are scheduled by a single inference instance. KV Cache space is managed across all 8 cards, and continuous batching operates at a coarse granularity, causing queuing latency to rise under high concurrency.
- Communication and compilation optimizations are disabled. The baseline did not enable sequence parallelism, NPU graph compilation, or operator fusion, leaving extra host-device synchronization and kernel launch overhead in place.
The diagnostic approach followed standard inference performance analysis: first, use profiling to break down the time distribution of a single forward pass and determine the relative shares of communication, computation, and scheduling; then optimize accordingly.
The Optimization Plan: A Three-Layer Tuning Path
3.1 Adjusting the Parallelism Strategy: Let More Cards Serve Concurrent Requests
The core change was switching from TP8/DP1 to TP2/DP4—every 2 cards form a tensor parallel group, creating 4 data-parallel instances across the machine:
# Optimized configuration (illustrative)tensor_parallel_size = 2 # TP2data_parallel_size = 4 # DP4: four instances serving in parallelenable_expert_parallel = True # Expert parallelism to carry MoE expert weights
The rationale for this change:
- Smaller communication domains: Reducing TP from 8 to 2 means AllReduce happens between only 2 cards, dramatically cutting communication latency and bandwidth usage and shortening per-token compute time.
- Higher concurrency capacity: With 4 independent DP instances scheduling requests, the machine’s request-processing channels are effectively quadrupled. Queuing latency under high concurrency improves significantly, and throughput scales better with batch size.
- Expert parallelism (EP) fits the MoE architecture: For MoE models, expert weights are naturally suited to being sharded across cards. With EP, each card holds only a subset of experts, and tokens are routed via AllToAll. This reduces per-card memory pressure and avoids unnecessary TP sharding of expert layers.
Note that there is no universally optimal TP/DP ratio: the larger the model and tighter the per-card memory, the higher TP should be; the higher the request concurrency and smaller the model, the more you should lean toward DP. During tuning, use “total throughput under SLO constraints” as the objective function and run a small grid search.
3.2 Enabling Communication Optimization: Sequence Parallelism Further Cuts Communication Volume
On top of TP2, we enabled sequence parallelism combined with communication fusion. The idea is to partition sequence-dimension-agnostic components such as LayerNorm and Dropout along the sequence dimension, replacing AllReduce with finer-grained ReduceScatter/AllGather operations, which reduces both communication volume and the number of communication rounds. For small and medium TP groups, this type of optimization often improves end-to-end latency by several percentage points, and it is orthogonal to the TP/DP/EP strategy, so the gains stack.
3.3 Compilation and Operator Optimization: Squeezing Out Single-Card Compute
The third layer leverages the NPU software stack’s compilation capabilities:
- NPU graph mode: Compile the operator sequence in the inference graph into a device-side executable graph, eliminating per-operator host dispatch and synchronization overhead. This is especially beneficial for small-batch, high-frequency operator calls.
- Kernel compilation tuning: Enable platform-specific compilation optimizations (such as operator fusion and tiling strategy adjustments) for hot kernels like quantization operators and Attention variants, improving per-operator execution efficiency.
- Quantization path alignment: Ensure the weight quantization format matches the optimal kernels in the NPU acceleration library, avoiding fallback to generic compute paths.
Each of these optimizations delivers limited gains on its own, but combined with the parallelism adjustments, they form a complete optimization loop spanning “system-level scheduling” down to “chip-level execution.”
Test Results: Up to 53.5% Higher Throughput Under SLO Constraints
Under identical latency SLO constraints (i.e., TTFT and TPOT both within the baseline-allowed thresholds), we benchmarked the baseline against the optimized configuration:
| Configuration | Parallel Setup | Key Features | Relative Total Throughput |
|---|---|---|---|
| Baseline | TP8/DP1 | Default settings | 1.00x |
| Optimized | TP2/DP4 + EP | Sequence parallelism + graph compilation + kernel optimization | Up to 1.535x |
Throughput gains varied across concurrency levels, with the best tier reaching +53.5%. It’s worth emphasizing that this figure represents effective throughput improvement under SLO constraints—not an inflated number obtained by relaxing latency requirements. That is the essential difference between production tuning and benchmark chasing.
Distilling the Methodology: Making Inference Tuning Experience Reusable
The greater value of this case lies in the transferable process it produced:
- Define SLOs and workload profiles first: Establish acceptable TTFT/TPOT thresholds and expected concurrency before touching any tuning knobs.
- Profile to locate bottlenecks: Use profiling to break down the shares of computation, communication, and scheduling—avoid changing parameters based on guesswork.
- Parallelism first, operators second: The parallelism strategy determines the order of magnitude of performance; compilation and kernel optimizations determine the final margin. Iterating in this order is the most efficient.
- Turn solutions into assets: Record the model, hardware, engine version, image, resource requirements, parallelism parameters, and performance report as a complete “deployment recipe” in a searchable, comparable catalog. When the team onboards a new model or hardware, starting from the closest historical recipe and fine-tuning can dramatically shorten validation cycles.
- Automate synchronized deployment: Integrate the recipe catalog with the deployment backend so configurations can be pushed with one click and results are automatically archived, creating a positive feedback loop of “deploy—benchmark—refine.”
Conclusion
Optimizing LLM inference on domestic NPUs is fundamentally a “hardware-software co-design” systems effort: the parallelism strategy must match the model architecture and interconnect topology, communication optimization must compress synchronization overhead, and compilation and operator tuning must unlock single-card compute. All three are indispensable. The 53.5% throughput gain in this case didn’t come from a single silver-bullet parameter—it was the compounding result of layered optimization. For teams driving adoption of domestic compute, what matters more than any single optimization result is building reusable solution assets and tuning processes, so that every practice becomes the starting point for the next deployment.
