Inference Optimization for 100B-Scale Quantized LLMs on a Four-GPU Workstation

    This article describes an inference optimization practice for a 100B-class total-parameter, 10B-class active-parameter, low-bit weight-quantized LLM running on a four-GPU 32 GB workstation. It defines a practical metric set covering Decode and Prefill throughput, TTFT/TPOT percentiles, long-context retention, throughput variation, and errors; then details optimizations for KV-cache management, batch scheduling, operator fusion and quantized kernels, communication overlap, chunked Prefill, attention/cache reuse, parallel load balancing, and long-run stability. Under the same environment and workload, Decode improves from 64 to 77 token/s and Prefill from 2,300 to 4,400 token/s, with slower long-context degradation and lower throughput variation in continuous stress tests.

    Inference Optimization for 100B-Scale Quantized LLMs on a Four-GPU Workstation

    1. Background: Why Inference Optimization on a Multi-GPU Workstation Cannot Focus Only on Peak Performance

    In deploying a quantized LLM with 100B-class total parameters and 10B-class active parameters, a four-GPU workstation with 32 GB of memory per GPU is a common low-cost inference environment. It offers substantial single-machine compute and high-speed inter-GPU interconnect, but GPU memory capacity, memory bandwidth, inter-GPU communication, and long-run stability all become constraints. Many teams focus in the first deployment round only on whether it runs and on single-run peak throughput. Once continuous service begins, three types of issues often appear:

    1. Generation-stage speed is insufficient: Decode generates token by token and is significantly affected by memory bandwidth, KV cache management, batching scheduling, and sampling overhead. Peak values can be misleading, and sustained output speed may be unstable.
    2. Long-context Prefill degradation is obvious: as input length grows, attention computation and intermediate activation footprint increase, and the Prefill throughput curve drops quickly, causing jitter in time to first token.
    3. Long-run variance is large: under continuous stress testing, GPU memory fragmentation, queue backlog, batch-size changes, and communication waits amplify throughput variation, making version behavior less predictable.

    This iteration targets these three issue types. In an abstracted test environment, the model is a low-bit weight-quantized model with 100B-class total parameters and 10B-class active parameters, running on a workstation with four 32 GB GPUs, inter-GPU high-speed interconnect bandwidth of about 300 GB/s, and four-channel 64 GB system memory. Under the same environment and workload, Decode speed increased from 64 token/s to 77 token/s, and Prefill throughput increased from 2,300 token/s to 4,400 token/s. At the same time, performance degradation in long-context scenarios became slower, and throughput variation under continuous stress testing became smaller. The following sections describe metrics, optimization paths, and engineering methods.

    2. Metric Abstraction: First Define “Fast, Stable, and Predictable”

    Inference optimization cannot focus on a single number. It is recommended to establish at least the following metric set:

    • Decode throughput: output tokens per second in the generation stage, measured separately for single-request and concurrent scenarios.
    • Prefill throughput: input tokens processed per second in the prefill stage, reported in buckets by input length.
    • TTFT P95/P99: high-percentile time to first token, reflecting interactive experience.
    • TPOT P95/P99: high-percentile time per output token, reflecting generation smoothness.
    • Long-context retention rate: throughput under long input as a proportion of throughput under short input.
    • Throughput coefficient of variation: ratio of standard deviation to mean throughput during continuous stress testing, used to measure stability.
    • Error rate and timeout rate: must be included in long-duration stress tests to avoid pursuing throughput at the expense of availability.

    Only after metrics are clearly defined can optimization have a comparable baseline. In particular, Decode and Prefill must be viewed separately, single-request and concurrent-batch scenarios must be viewed separately, and short and long inputs must be bucketed. Otherwise, it is easy to produce a false optimization that improves peak values while degrading experience.

    3. Decode Speed Optimization: From 64 token/s to 77 token/s

    The Decode stage is essentially autoregressive token-by-token generation. Its compute density is relatively low, and it is more easily affected by memory access and scheduling overhead. The goal is not a one-off benchmark result, but to make sustained output speed in a multi-GPU environment closer to a serviceable high-throughput state. In practice, the following directions are important.

    3.1 KV Cache Management Must Reduce Fragmentation and Repeated Movement

    The generation stage repeatedly reads historical KV cache. If cache allocation is coarse-grained, GPU memory fragmentation, frequent allocation and release, and unnecessary copies are likely. Paged KV cache management, dynamic expansion by sequence length, and timely reclamation of cache blocks for finished sequences can reduce GPU memory pressure and reduce access jitter for long sequences. In a four-GPU environment, the cache layout must also match the parallel partitioning scheme to avoid amplifying latency through cross-GPU access.

    3.2 Batch Scheduling Must Balance Throughput and Tail Latency

    Continuous batching can combine the dynamic generation steps of different requests into a schedule and improve GPU utilization. However, a larger batch is not always better: an excessively large batch increases per-step latency and tail latency, while an excessively small batch cannot amortize communication and scheduling overhead. It is recommended to bucket requests by input length, output length, and priority; set dual constraints on maximum batch tokens and maximum concurrent sequences; and observe the balance point between TPOT P95 and throughput during stress testing.

    3.3 Operator Fusion and Quantized Kernels Must Match Actual Shapes

    In the Decode stage, low-bit weight-quantized models are often affected by small matrix multiplications and elementwise operations. Fusing common elementwise operations, normalization, residual connections, and lightweight computation before sampling can reduce kernel launches and intermediate write-backs. Quantized kernels need to cover the batch sizes and sequence lengths that actually occur, avoiding fallback to high-precision paths. Optimization should be judged by end-to-end token/s, not only by microbenchmarks of individual operators.

    3.4 Communication Overlap and Sampling Optimization Reduce Fixed Overhead

    In multi-GPU inference, tensor parallelism or pipeline parallelism introduces inter-GPU communication. Overlapping parallelizable communication with computation and reducing synchronization waits at each step can help improve sustained generation speed. At the same time, if high-temperature sampling, repetition penalty, and other sampling logic are implemented inefficiently, they introduce extra overhead. Where output quality permits, sampling steps can be merged and commonly used index structures can be cached to reduce the fixed cost per token.

    In this iteration, Decode increased from 64 token/s to 77 token/s. The key was not extreme optimization of a single operator, but the combined effect of cache management, batch scheduling, and fixed-overhead control.

    4. Prefill Throughput and Long-Context Degradation: From 2,300 token/s to 4,400 token/s

    The Prefill stage processes the input sequence at once. With long contexts, attention computation and intermediate activation footprint rise significantly. The goal is not only peak throughput, but also a gentler decline in throughput as input length increases.

    4.1 Chunked Prefill and Length Bucketing

    Splitting very long inputs into reasonable chunks for prefill can reduce peak GPU memory usage and allow the scheduler to insert generation requests more smoothly. Combined with input-length bucketing, this avoids mixing long and short requests in a way that lets long requests slow down short ones. Chunk size must be tuned against GPU memory capacity, attention kernel efficiency, and the TTFT target.

    4.2 Attention Computation and Cache Reuse

    The main cost of long context lies in attention computation. Using chunked attention kernels, reducing materialization of intermediate tensors, and reusing positional encoding and mask structures can reduce computation and GPU memory overhead. For repeated prefixes or multi-turn dialogue scenarios, prefix cache can be reused within safe boundaries to reduce repeated prefill. Cache reuse must be paired with request isolation and consistency checks to avoid contaminating results.

    4.3 Parallel Strategy and Load Balancing

    In a four-GPU environment, Prefill can be processed in shards in parallel. It is necessary to check whether each GPU’s load is balanced and avoid one GPU becoming a bottleneck because of uneven sequence partitioning. For variable-length inputs, load should be estimated by token count rather than request count, and shard granularity should be adjusted dynamically. Communication and computation overlap also applies to Prefill, especially dependency waits between chunks.

    This iteration increased Prefill from 2,300 token/s to 4,400 token/s and placed more emphasis on long-context curve convergence: as input length increased, performance declined more slowly and the overall curve became smoother. This shows that the optimization not only raised the peak but also improved usability for long sequences.

    5. Long-Run Stability: Making Version Behavior Predictable

    A single peak cannot represent production readiness. Stability optimization should focus on continuous stress testing, resource monitoring, and degradation strategies.

    5.1 Continuous Stress Testing and Variance Measurement

    It is recommended to run continuous stress tests for more than 30 minutes with fixed concurrency and a fixed input/output length distribution, recording per-minute throughput, P95/P99 latency, GPU memory usage, queue length, and error rate. Stability should be judged by throughput coefficient of variation, latency drift, and error rate, not only by the maximum value. In long-duration multi-GPU inference, overall throughput variation is smaller than in the previous version, output is more stable, and version behavior is more predictable. This is an important goal of this iteration.

    5.2 Resource Isolation and Timeout Control

    Set maximum waiting time, maximum input length, and maximum output length for the request queue to prevent abnormal requests from occupying resources for a long time. Set health checks for GPU memory, queues, and inter-GPU communication, and trigger rate limiting or degradation when backlog occurs. Degradation strategies can include reducing batch size, shortening maximum output, and pausing low-priority requests to keep core requests available.

    5.3 Observability and Regression Baselines

    Each version iteration should retain a fixed stress-test configuration and baseline results to form a regression-ready performance profile. Logs should record request length buckets, batch size, cache hits, communication waits, and error types to help locate sources of variation. Only by correlating performance data, resource data, and error data can one determine whether an optimization is truly stable.

    6. Engineering Example: Configuration and Stress-Test Pseudocode

    The following is a general illustration. Actual parameters need to be adjusted according to hardware and business goals.

    1. workload:
    2. input_len_buckets: [512, 2048, 8192, 32768]
    3. output_len: 512
    4. concurrency: [1, 4, 8, 16]
    5. duration_min: 30
    6. runtime:
    7. max_batch_tokens: auto
    8. max_concurrent_sequences: auto
    9. kv_cache_policy: paged
    10. prefill_chunk_size: auto
    11. metrics:
    12. - decode_tokens_per_s
    13. - prefill_tokens_per_s
    14. - ttft_p95_ms
    15. - tpot_p95_ms
    16. - throughput_cv
    17. - error_rate
    1. for concurrency in concurrency_list:
    2. warmup(concurrency)
    3. start = now()
    4. while now() - start < duration:
    5. submit_requests(input_len_bucket, output_len, concurrency)
    6. collect(metrics)
    7. assert error_rate < threshold
    8. report_percentile(ttft, tpot, throughput)
    9. report_cv(throughput)

    7. Conclusion and Next Steps

    The conclusion of this iteration can be summarized as follows: in a four-GPU 32 GB workstation environment running a 100B-class quantized LLM, Decode speed increased from 64 token/s to 77 token/s, and Prefill throughput increased from 2,300 token/s to 4,400 token/s. In long-context scenarios, performance degradation became slower, and throughput variation under continuous stress testing became smaller. The focus was not chasing a single peak, but improving generation speed, the Prefill curve, and long-run stability together.

    Going forward, three directions are recommended for continued iteration: first, further reduce fixed overhead in the Decode stage and improve sustained multi-GPU output capability; second, strengthen performance retention under long contexts, with emphasis on chunking strategy, cache reuse, and load balancing; third, improve stable throughput and observability for multi-GPU scenarios so that version behavior is more predictable and easier to regress.