SLO-Constrained Throughput Optimization for LLM Inference on an 8-GPU Cluster

    In large model inference services, chasing peak throughput alone often worsens tail latency, while focusing only on single-request latency wastes accelerator compute. A better goal is maximizing goodput—the number of requests or tokens that meet latency and availability SLOs per unit time. This article walks through a practical optimization case on an 8-GPU AI cluster, showing how coordinated design across scheduling, memory, compute, communication, and observability improved SLO-compliant total throughput by up to 53.5% under specific workloads, configurations, and SLO constraints. It covers defining SLOs before optimizing, continuous batching and dynamic batch sizing, paged KV cache management, operator fusion and parallel communication tuning, and closed-loop benchmarking to validate gains.

    SLO-Constrained Throughput Optimization for LLM Inference on an 8-GPU Cluster

    In production LLM inference services, chasing peak throughput alone often worsens tail latency, while optimizing only for single-request latency wastes accelerator compute. A more sensible optimization target is goodput—the number of requests or tokens per unit time that satisfy latency and availability SLOs. This article uses a real-world optimization case on an 8-GPU AI accelerator cluster running autoregressive LLM inference to show how coordinated design across scheduling, memory, compute, communication, and observability can raise total SLO-compliant throughput by up to 53.5%. Note that this figure is the peak result from a public case under a specific workload, configuration, and SLO constraint; it is not a universal guarantee for all scenarios.

    1. Define the SLO Before Talking About Throughput

    The most common mistake in inference optimization is tuning batch size or parallelism strategy before the SLO is clearly defined. For LLM services, at least the following metrics should be observed jointly:

    • TTFT (Time to First Token): reflects queuing, prefill, and scheduling overhead;
    • TPOT/ITL (Time per Output Token / Inter-Token Latency): reflects decoding-stage stability;
    • P99 tail latency: reflects user experience and SLO attainment far better than averages;
    • Goodput: only requests or tokens that meet the SLO are counted;
    • Resource utilization: accelerator compute, HBM/VRAM, inter-GPU communication, and host-side balance;
    • SLO attainment rate: the percentage of requests that meet constraints at the target concurrency.

    During load testing, build a matrix across input length, output length, concurrency, and tenant priority, and record TTFT, TPOT, P99, and throughput curves separately. Only by finding the inflection point where “throughput rises but P99 collapses first” can you determine whether the bottleneck lies in scheduling queuing, KV cache capacity, kernel efficiency, or inter-GPU communication.

    2. Scheduling: Saturate Compute with Continuous Batching

    The decoding phase is inherently autoregressive: each step has relatively fixed compute, but request lengths vary widely. Static batching creates head-of-line blocking—short requests wait for long ones, inflating tail latency. The more effective approach is continuous batching with dynamic batch size: at every decoding step, re-evaluate the waiting and running queues and fill the batch as much as possible within the KV budget and SLO constraints.

    Illustrative pseudocode:

    1. def build_batch(waiting, running, kv_budget, slo):
    2. candidates = bucket_by_length(waiting)
    3. batch = list(running)
    4. for req in candidates:
    5. if not kv_budget.enough(req):
    6. continue
    7. if estimate_tpot(batch + [req]) <= slo.tpot_p99:
    8. batch.append(req)
    9. else:
    10. break
    11. return batch

    The scheduling strategy should also include length bucketing, tenant quotas, priorities, and admission control. Length bucketing reduces wasted compute within a batch; admission control rejects or queues low-priority requests at high watermarks so all requests don’t time out together; tenant isolation prevents a single burst of traffic from breaking the overall SLO. The key is not “the bigger the batch, the better,” but letting batch size vary dynamically with KV capacity, per-step decoding latency, and remaining SLO headroom.

    3. Memory: KV Cache Management Sets the Batch Size Ceiling

    The memory bottleneck in LLM inference is usually not the weights but the KV cache. Allocating KV cache contiguously per request tends to cause fragmentation and reservation waste; a more robust approach is block-based or paged management—divide the cache into fixed-granularity blocks, allocate on demand, reclaim step by step, and maintain capacity watermarks. For multi-turn conversations or shared-prefix scenarios, prefix reuse avoids redundant prefill.

    Key optimization points include: managing cache layout per layer and per head to reduce memory access jumps; setting high-watermark alerts to prevent frequent eviction under request bursts; giving long requests a dedicated queue so they don’t occupy large numbers of blocks for extended periods; and prioritizing compression of low-priority requests’ residency time when capacity runs short. KV management directly determines how many requests can run in parallel, so it is as much a throughput problem as a memory problem. In practice, dashboards should track KV block utilization, fragmentation rate, eviction counts, and queuing time caused by insufficient capacity.

    4. Compute and Communication: Eliminate Idle Time and Waiting

    On the compute side, start with operator fusion, kernel selection, graph compilation, and low-precision strategies. Fuse adjacent small operators to reduce kernel launches and intermediate memory writes; select appropriate kernels separately for prefill and decoding; use graph compilation to cut dynamic scheduling overhead. Low-precision quantization increases compute density, but accuracy loss and SLO stability must be validated—never judge by peak throughput alone.

    An 8-GPU cluster also requires handling parallel communication. Tensor parallelism, pipeline parallelism, and data parallelism each have their boundaries: tensor parallelism reduces per-GPU memory pressure but introduces frequent collective communication; pipeline parallelism suits deep models but requires managing bubbles; data parallelism suits multi-replica serving. During optimization, overlap communication with compute, place replicas according to the inter-GPU topology, reduce cross-node traffic, and batch-merge communication operations such as global reductions. If communication wait time accounts for a large share, increasing batch size only amplifies the waiting and worsens TPOT.

    5. Observability and Load Testing: Validate Gains with a Data-Driven Loop

    Any optimization must be validated through a reproducible benchmarking loop. Fix the model version, input/output distribution, and SLO thresholds; ramp up load gradually and record the goodput curve as concurrency increases; run A/B comparisons for every change, checking whether P99, SLO attainment, and resource utilization improve together. Long-running stability tests should cover traffic bursts, rising cache watermarks, single-GPU failures, and network jitter, with rollback plans ready.

    In Baidu AI Cloud’s general-purpose inference service engineering practice, SLO attainment, goodput, and resource utilization are observed jointly to avoid pseudo-optimizations where “throughput goes up but the experience gets worse.” Ultimately, in the public case, the combined optimization of scheduling, KV cache, operators, and communication on an 8-GPU cluster delivered up to a 53.5% improvement in total SLO-compliant throughput. This shows that beyond hardware, software stack coordination is equally critical to unlocking a cluster’s effective compute. Gains will vary across model sizes, input/output ratios, and SLO strictness—always rely on your own benchmarking curves.