Boosting LLM Inference Throughput by 53.5%: An 8-Accelerator Optimization Practice
This article explains how to raise total inference throughput under SLO constraints on a single-node 8-accelerator setup running large MoE generative models. It covers building a measurable baseline, locating four common hidden throughput ceilings (load imbalance, KV cache fragmentation, excessive operator boundaries, and parallelism-versus-topology mismatch), and four optimization paths: global request scheduling and load balancing, fine-grained memory and cache management, operator fusion and graph optimization, and aligning parallel strategy with hardware topology. Readers will find benchmark pseudocode, a KV cache capacity estimation formula, attribution of the 53.5% gain, common pitfalls, and a recommended rollout order.
1. Background: Why “Faster on One Card” Does Not Mean “Higher Cluster Throughput”
When deploying large-parameter generative models with a Mixture-of-Experts (MoE) structure onto a single node with 8 high-bandwidth accelerators, teams often run into a counterintuitive pattern: per-card operator efficiency already looks strong in single-card benchmarks, yet as concurrency climbs, whole-machine throughput stalls and latency starts to jitter. Take the inference service of an AI coding tool as an example: after optimization on hardware such as the 8-card Ascend 950DT, total throughput under SLO (service level objective) constraints improved by up to 53.5%. That number did not come from a single trick. It is the cumulative result of several engineering layers.
One point deserves emphasis: the throughput gain is conditional on “not breaking the SLO.” Talking about throughput without a latency constraint is meaningless. Enlarging the batching window without limit makes the throughput figure look great, but time-to-first-token and time-per-output-token will blow past what users can accept. So every optimization in this article targets a single objective function: maximize completed requests per second while meeting the latency targets.
2. Start With a Measurable Baseline
Any optimization should begin from a trustworthy baseline, otherwise results cannot be attributed. At minimum, collect these metrics:
- Throughput: output tokens per second, completed requests per second;
- Latency: time-to-first-token, inter-token latency, and end-to-end latency percentiles (P50/P90/P99);
- Resources: peak memory usage per card, compute utilization, memory bandwidth utilization, share of inter-card communication;
- Stability: request rejection rate caused by out-of-memory, number of recomputation triggers.
The pseudocode below is illustrative. The key points are “fixed input/output distribution + fixed concurrency gradient + record percentiles”:
# Pseudocode: throughput sweep under SLO constraintsfor concurrency in [8, 16, 32, 64, 128]:metrics = run_benchmark(model=engine,concurrency=concurrency,input_len_dist="fixed_p50=1024",output_len_dist="fixed_p50=512",)ok = metrics.p99_e2e_latency <= SLO_MSprint(concurrency, metrics.tokens_per_sec, ok)
Only by comparing before-and-after curves at the same concurrency gradient can you tell whether a change is a real gain or just pressure shifted somewhere else.
3. Locating the Bottleneck: Four Common Hidden Ceilings on Whole-Machine Throughput
- Load imbalance. Expert routing in an MoE structure is naturally prone to hotspots. With naive per-card partitioning, a few cards carry the popular experts long-term while the rest idle, and whole-machine utilization is dragged down by the slowest card.
- Memory fragmentation and insufficient reservation. Long contexts and large concurrent batches make KV cache demand swing sharply. Static reservation either wastes memory or triggers fallback at peak.
- Too many memory-access and operator boundaries. Issuing small per-layer operators serially adds launch overhead, and repeated reads and writes of intermediate tensors significantly lower the effective share of compute.
- Parallel strategy mismatched with hardware topology. If the partition granularity of tensor parallelism, pipeline parallelism, and expert parallelism is not aligned with inter-card interconnect bandwidth, communication becomes a serial segment on the critical path.
4. Optimization Path 1: Request Scheduling and Load Balancing From a Global View
The core idea is to change the scheduling objective from “shortest queue on a single card” to “whole machine meets the SLO.” Practical measures include:
- Continuous batching: dynamically assemble batches at iteration granularity, so new requests can be inserted in the next iteration instead of waiting for the whole batch;
- Length-aware queuing: bucket by estimated output length to reduce idling caused by mixing short and long requests in one batch;
- Expert load feedback: feed per-card expert popularity back to the routing and scheduling layer at runtime, and softly spread hotspots;
- Priority and admission control: make admission decisions for new requests when approaching the SLO boundary, protecting the tail latency of in-flight requests.
This step usually delivers the most stable gain, because it does not change the model’s numerical semantics and carries the lowest risk.
5. Optimization Path 2: Fine-Grained Memory and Cache Management
Treat the KV cache as a manageable “paged resource” rather than a one-off large allocation:
- Paged cache management that grows on demand and reduces fragmentation;
- Prefix reuse, keeping a single copy of the cache for identical system prompts and identical code context;
- Tiered placement, pushing cold data down to host memory or object-storage-style services while keeping hot data in high-speed memory;
- A reservation watermark that keeps a safety margin for bursty concurrency and avoids peak fallback.
Illustrative capacity estimation logic:
Per-request cache ≈ layers × 2 × kv_heads × head_dim × (input + output length) × byte widthMax concurrency ≈ (available memory - weight footprint - safety margin) / per-request cache
Making this estimate adaptive at runtime instead of hard-coded at startup is the key to handling long-tail inputs.
6. Optimization Path 3: Operator Fusion and Compute Graph Optimization
The goal is to raise the share of “effective compute on the critical path”:
- Fuse adjacent operators such as normalization, activation, and residual to reduce intermediate tensor materialization;
- Fuse the scaling, masking, and softmax inside attention to cut memory accesses;
- For quantized matrix multiplications, pick a matching compute path and avoid frequent format conversions;
- Replace per-operator interpreted execution with compiled graph optimization to reduce dispatch overhead;
- For memory-bound operators, adjust the data layout first rather than blindly chasing higher parallelism.
The test is simple: if an operator gets faster but whole-machine throughput does not move, the bottleneck has shifted to communication or scheduling, and you should go back to Section 4 and keep investigating.
7. Optimization Path 4: Aligning Parallel Strategy With Topology
- Keep tensor parallelism inside the high-bandwidth domain to reduce cross-domain traffic;
- When combining expert parallelism with data parallelism, control the cross-card fan-out of a single routing step;
- Split pipeline stages so compute volume per stage is close, reducing bubbles;
- Overlap communication with computation, hiding asynchronous transfers inside compute windows;
- Decide partition granularity from a measured bandwidth matrix rather than copying default configurations.
8. Attributing Results and Common Pitfalls
In this class of 8-card environment, whole-machine total throughput under SLO constraints improved by about 53.5% over the baseline. The gains break down roughly as follows: scheduling and load balancing contributed the most stable first tier of improvement; memory management removed the long-tail loss caused by peak fallback; operator and graph optimization raised effective per-card compute; and aligning the parallel strategy eliminated the serial communication segment on the critical path.
Three pitfalls to avoid: first, looking only at average latency while ignoring tail percentiles; second, treating the batching window as the only knob; third, skipping numerical consistency checks after optimizing. It is worth fixing a regression suite before each release and comparing output consistency before and after optimization, so performance gains do not come at the cost of quality.
9. Implementation Advice
To reproduce similar gains in an environment such as Baidu AI Cloud, proceed in this order: baseline measurement → scheduling and batching → memory and cache → operators and graph → parallelism and topology. Run the same benchmark script as a regression at every step, and use monitoring, alerting, and logging services to watch percentile shifts. In engineering practice, the most effective order is often not to start with the most complex parallel redesign, but with the lowest-risk, easily rollback-able scheduling and memory strategies.
