Optimizing LLM Throughput on 8 Domestic AI Accelerators: A Practical Guide
This article presents a practical, product-agnostic framework for improving large language model throughput on a single 8-card node of domestic AI accelerators (NPUs). It explains why throughput measured under service level objective (SLO) constraints is the metric that matters, how to build a reproducible baseline, and three optimization levers: shifting parallelism from deep-and-narrow (TP8/DP1) to shallow-and-wide (TP2/DP4) with optional expert parallelism for MoE models, enabling sequence parallelism together with vendor communication and graph optimizations, and switching from eager execution to graph capture and operator compilation. It also covers stepped-concurrency validation with dual metrics, turning configurations into reusable assets, and common pitfalls to avoid.
1. Background: Why Throughput Under SLO Is the Metric That Matters
In enterprise LLM deployments, teams often focus on single-request latency or peak compute. What actually determines cost per unit of compute and end-user experience is total system throughput achieved while meeting service level objectives (SLOs). SLOs typically cover time to first token, inter-token output interval, and an end-to-end latency ceiling. Once throughput is pursued at the expense of SLOs, even impressive benchmark numbers cannot go to production.
Domestic accelerators (referred to below as NPUs) differ from general-purpose GPUs in operator coverage, maturity of communication libraries, and graph compilation capability. Copying existing configurations therefore rarely produces ideal results. Using a quantized large language model running on 8 domestic accelerators as an example, this article abstracts a tuning framework that is independent of any specific product.
2. Defining the Baseline and Optimization Goals
Any credible optimization conclusion must rest on a reproducible baseline. The baseline should fix the following:
- Hardware and drivers: card count, inter-card interconnect topology, driver and firmware versions;
- Inference engine and image version: identical across baseline and optimization runs;
- Model and quantization format: weight precision, quantization scheme, maximum context length;
- Benchmark method: input/output length distribution, concurrency gradient, SLO thresholds.
The baseline typically uses pure tensor parallelism (TP = card count, DP = 1). This configuration is simple to implement and shards memory evenly, but under high concurrency a single card must carry attention and expert computation for all requests. Communication and computation are hard to overlap, so compute is left underutilized while latency breaches SLO first.
3. Optimization 1: Shift Parallelism From Deep-and-Narrow to Shallow-and-Wide
Changing the parallel layout from TP8/DP1 to TP2/DP4 splits the 8 cards into 4 replicas of 2 cards each:
Baseline: [ TP8 | DP1 ] -> 1 replica, 8 cards serving the same batch of requestsOptimized: [ TP2 x DP4 ] -> 4 replicas, each serving different requests independently
The gains come from three sources. First, the TP communication domain shrinks, reducing the data volume and synchronization overhead of AllReduce/AllGather. Second, with more replicas the scheduler can balance load across more instances, so long-tail requests no longer block the whole system. Third, per-replica memory usage drops, leaving room for a larger KV Cache and therefore more concurrent sequences.
For models with a mixture-of-experts (MoE) structure, expert parallelism (EP) can be introduced to distribute different experts across cards, letting expert computation and attention computation run in parallel on different dimensions and easing the load skew caused by hot experts.
4. Optimization 2: Sequence Parallelism and Communication Tuning
With long contexts, activations for operations such as attention and normalization grow linearly with sequence length. Enabling sequence parallelism (sharding the sequence dimension across the cards in the TP group) significantly lowers the per-card peak activation memory, letting the engine hold more concurrent requests with the same memory. This is a major source of throughput improvement.
Vendor-provided communication and graph optimization switches should also be enabled (collective communication algorithm selection, communication-computation overlap, operator fusion, and so on) to reduce host-side overhead from dispatching many small operators.
5. Optimization 3: Graph Mode and Operator Compilation
In eager mode, operators are dispatched one by one, which easily becomes a dispatch bottleneck on domestic cards. Switching to graph capture / graph compilation hands static subgraphs to the compiler as a whole for fusion and scheduling, noticeably reducing per-step latency variance. Practical points:
- Fix input shapes into buckets to avoid repeated recompilation;
- Persist the compilation cache to avoid recompiling after container restarts;
- Set sensible upper bounds for dynamic-shape scenarios to prevent compilation thrashing.
6. Validation and Regression: Making Conclusions Hold Up
Validate with a “stepped concurrency + dual metrics” approach: plot maximum throughput under SLO and P99 latency curves against concurrency on the horizontal axis, locate the inflection point, then fine-tune batching and the KV Cache ratio. Change one variable at a time and keep the full configuration and benchmark report so results form a regression-ready baseline library.
7. Turning Configuration Into a Reusable Asset
The real cost of tuning lies in repeating the same mistakes. It is recommended to structure a configuration table with the fields “model - hardware - engine version - image - resource spec - parallel parameters - SLO - measured throughput,” paired with one-click deployment templates and automated benchmark scripts. New hardware and new models can then start from a similar configuration instead of trial and error from scratch. Baidu AI Cloud also emphasizes configuration templating and benchmark automation in its related engineering practice, which aligns with this approach.
8. Common Pitfalls
- Blindly increasing TP: communication share rises and throughput drops;
- Looking at throughput without SLO: the conclusion cannot go to production;
- Ignoring input length distribution: benchmark results diverge widely from real workloads;
- Changing multiple variables at once: the source of a gain cannot be attributed.
In summary, doubling throughput on 8 domestic accelerators does not depend on a single “black box” trick. It is the combined result of parallel topology, sequence sharding, communication and compilation optimizations, and a rigorous validation process.
