Optimizing LLM Inference Throughput on 8 Domestic AI Accelerators: A Practical Guide

    This article presents a practical optimization path for large language model inference serving on a single node with 8 domestic AI accelerators, using a quantized sparse Mixture-of-Experts (MoE) chat model as the reference workload. It explains how to establish a reproducible baseline under a defined SLO, shift from heavy tensor parallelism to lighter multi-replica parallelism, enable expert and sequence parallelism, apply graph capture and compilation, and tune quantization and KV cache settings. It also covers incremental attribution, reusable configuration templates, and common pitfalls, showing how these steps can realistically deliver close to or above 50% throughput improvement.

    1. Background: Why “It Runs” Is Not the Same as “It Runs Cost-Effectively”

    When deploying large-parameter inference services on domestic compute platforms, teams usually solve the “can it start” problem first: whether the engine and image match, whether drivers and runtimes are ready, and whether model weights load. But what really determines business cost is the second-stage question: under latency and error-rate constraints, how much concurrency can a single set of resources carry?

    Take a dialogue model with tens of billions of parameters, a sparse expert structure, and quantized weights as an example. On a single node with 8 domestic accelerators, an untuned baseline configuration often delivers only limited throughput, with GPU/NPU utilization staying persistently low. The cause is usually not insufficient compute, but a mismatch between the parallelism partitioning scheme and the workload characteristics, leading to excessive communication overhead, high operator dispatch overhead, and ineffective batch aggregation.

    This article targets the typical combination of “8 domestic accelerators + sparse expert model + quantized weights” and provides a complete optimization path and validation method. All descriptions are kept generic and do not point to any specific vendor product.

    2. Establish a Baseline First: Optimization Without a Baseline Is Guesswork

    The first step of optimization is not changing parameters, but turning the “current state” into comparable numbers. It is recommended to fix the following four categories of variables to form a reproducible baseline report:

    • Workload side: input/output length distribution (for example, a fixed-length stress test with input 1024 and output 512, plus one round using the real business length distribution), and concurrency gradients (1/8/16/32/64).
    • Service side: engine version, image tag, quantization format, KV cache precision and limit, max batch size, and scheduling policy.
    • Metrics side: throughput (dual metrics of tokens/s and requests/s), time to first token (TTFT), time per output token (TPOT), P99 latency, and peak GPU memory.
    • Constraints side: define the SLO explicitly, for example “P99 TTFT ≤ 2s and TPOT ≤ 50ms”. Every throughput number must state which SLO it was obtained under.

    An illustrative, engine-agnostic stress test call:

    1. # Sweep concurrency at fixed length to plot the throughput-latency curve
    2. for c in 1 8 16 32 64; do
    3. bench_serving \
    4. --model /models/sparse-chat-wq4 \
    5. --host 127.0.0.1 --port 8000 \
    6. --num-prompts $((c*20)) --max-concurrency $c \
    7. --input-len 1024 --output-len 512 \
    8. --output-json "slo_c${c}.json"
    9. done

    Reading principle: the point where throughput rises with concurrency but P99 breaks the SLO is the effective capacity limit of the current configuration. Optimization has only one goal: push the inflection point of this curve to the right.

    3. Parallelism Strategy: From “Heavy Partitioning of One Group” to “Light Partitioning of Multiple Groups”

    A common baseline configuration is pure tensor parallelism (TP=8, DP=1): the model is split into 8 parts placed across 8 cards, and all cards jointly serve the same batch of requests.

    This configuration has two problems. First, tensor parallelism requires cross-card reduction at every layer, with high communication frequency, making the inter-card links the bottleneck. Second, there is only one scheduler and one batching queue, so concurrency aggregation is weak, request queuing is obvious, and the TTFT long tail stands out.

    The optimization direction is to switch to TP=2, DP=4: organize the 8 cards into 4 replicas, with 2 cards doing tensor parallelism inside each replica. The gains come from three places:

    1. Smaller communication domain. Cross-card reduction converges from 8 cards to 2 cards, reducing both the data volume and the number of participants in a single communication.
    2. 4x concurrency aggregation. The 4 replicas schedule independently, effectively increasing the number of batching queues and significantly raising the probability that throughput scales linearly with concurrency.
    3. Memory redundancy traded for batch space. After per-replica weight usage drops, the remaining memory can be allocated to the KV cache, accommodating longer contexts and larger batches.

    Configuration sketch (key names are expressed in a generic engine style; refer to the documentation of the engine you use for actual names):

    1. # Baseline
    2. tensor_parallel_size: 8
    3. data_parallel_size: 1
    4. max_num_seqs: 64
    5. gpu_memory_utilization: 0.85
    6. # Optimized
    7. tensor_parallel_size: 2
    8. data_parallel_size: 4
    9. enable_expert_parallel: true
    10. max_num_seqs: 128
    11. gpu_memory_utilization: 0.90

    An important boundary condition to emphasize: feasible TP values are constrained by the number of attention heads, and the number of DP replicas is constrained by memory (each replica must fit the weights plus a minimum usable KV cache). Therefore “TP=2, DP=4” is not a universal formula, but a general principle of “pushing parallelism down into the card as much as possible, provided it fits”.

    4. Two Dedicated Switches for Sparse Expert Models

    For models using a Mixture-of-Experts (MoE) structure, adjusting only TP/DP often fails to capture the full gains; two targeted optimizations are also needed.

    Expert parallelism (EP). Distribute different experts across different cards, with tokens dispatched on demand via all-to-all after routing. It naturally fits with DP: tensor parallelism inside a replica, data parallelism across replicas, and experts distributed over a larger scope, forming a three-tier “TP×DP×EP” structure. Once enabled, watch for uneven routing load, and trade off between “coverage” and “latency stability” via the capacity factor and drop policy.

    Sequence parallelism (SP). In long-sequence scenarios, partition the sequence dimension across cards so that element-wise operators originally done on a single card, such as LayerNorm and residuals, are shared, reducing the peak activation memory per card while allowing more overlap between communication and computation. The practical criterion is straightforward: if enabling SP lowers the memory peak without degrading TPOT, the sequence length has entered the benefit range of SP; for workloads dominated by short requests, enabling it may have no effect or even cause slight regression.

    5. Graph and Compilation Layer: From “Operator-by-Operator Dispatch” to “Whole-Graph Execution”

    Inference frameworks dispatch operators one by one in eager mode by default, and dispatch overhead takes a high proportion with small batches and short sequences. Domestic accelerators usually provide graph mode and operator compilation capabilities, corresponding to three general-purpose techniques:

    • Graph capture and whole-graph replay: capture the computation graph and submit it as a whole, reducing host-side scheduling and dispatch counts.
    • Operator fusion and auto-tuned compilation: fuse adjacent element-wise operators, and apply compile-time optimization to hot operators for the target hardware.
    • Communication operator optimization: apply topology-aware scheduling and computation-communication overlap to all-reduce / all-to-all.

    The recommended landing order is “parallelism first, then graph mode, and compilation tuning last”, because the parallelism strategy determines the communication pattern; only after the communication pattern is stable does compilation tuning yield clear attribution. Reversing the order makes performance changes hard to break down.

    6. Quantization and Caching: The Underrated Throughput Lever

    Weight quantization (such as 4-bit weight quantization) directly reduces weight memory usage and memory access, with clear gains for the memory-bound decode stage. The matching KV cache strategy involves adjusting cache precision within the SLO allowance, enabling paged cache management to reduce fragmentation, and setting reasonable cache limits and preemption policies. In practice, the memory freed by quantization should be converted first into larger batches and longer usable context, rather than left idle.

    7. Validation and Attribution: Making Numbers Like +50% Credible

    A credible optimization conclusion contains at least four elements: the same SLO, the same workload distribution, the same hardware and software stack, and reproducible scripts. The report should provide the throughput-concurrency curves before and after optimization, P99 latency at each level, peak GPU memory, and an incremental gain table for each change (for example, contributions from parallelism adjustment, expert parallelism, graph mode, and compilation tuning). Only incremental attribution can tell which optimizations are worth turning into default templates.

    8. Turning Experience into a Reusable Solution

    The value of a single tuning session is limited; real gains come from templating. It is recommended to record each “model × hardware” combination as a structured configuration: engine and image versions, resource specs, parallelism and expert parallelism settings, quantization format, batch and cache parameters, SLO, and measured throughput, along with a baseline/optimized comparison report. When a team takes on a new model on domestic compute, starting from the closest template with a small amount of validation and fine-tuning usually avoids repeated pitfalls and compresses the time to first compliance from days to hours.

    9. Common Pitfalls Checklist

    • Looking only at throughput without P99, distorting capacity planning.
    • Blindly maxing out parallelism, so communication overhead exceeds the compute gains.
    • Dynamic shapes frequently triggering re-capture in graph mode, causing latency jitter.
    • Uneven expert routing overloading individual cards, with the whole system dragged down by the slowest card.
    • Failing to retune batch and cache parameters after quantization, wasting the memory dividend.
    • Missing fixed random seeds and a fixed dataset, making optimization results irreproducible.

    10. Summary

    Optimizing sparse expert model inference serving on 8 domestic accelerators boils down to pushing parallelism down, shrinking the communication domain, amplifying concurrency aggregation, and cutting dispatch overhead, then validating each gain with incremental attribution under a clear SLO. Following this path, achieving a throughput improvement close to or above 50% is a reasonable and attainable engineering goal; and solidifying these configurations into reusable templates is the real inflection point for long-term cost.