LLM Inference Deployment: Hardware Requirements and Performance Tuning Practices

    This article explains how to deploy large language model inference locally, focusing on the gap between getting a model to run and running it cost-effectively. It covers how to estimate memory usage across weights, KV cache, activations, and temporary buffers; the hardware thresholds involving memory capacity, bandwidth, and inter-GPU interconnect; key configuration options such as FP8 KV cache, block size, expert parallelism, and FP4 index cache; data and expert parallelism under topology constraints; prefill and decode disaggregation; multi-tier reasoning modes; and a performance validation methodology based on baselines and single-variable testing. It also lists common pitfalls and general guidance for building an inference platform on the cloud.

    1. Background: Why “It Runs” and “It Runs Affordably” Are Different Problems

    Local deployment of large language model inference is shifting from “can the model load?” to “how many useful tokens do we get per unit of compute?” Once parameter counts cross into the hundreds of billions, any one of three factors—memory capacity, memory bandwidth, or inter-GPU interconnect topology—can become the bottleneck, and throughput drops off a cliff. So evaluating whether a deployment is viable is not just about whether a single card can hold the weights. It is about whether the combined memory footprint of four categories—weights, KV cache, activations, and temporary buffers—leaves enough headroom.

    A practical estimation order looks like this: first estimate weight usage (parameter count multiplied by bytes per parameter, reduced proportionally after quantization); then estimate peak KV cache using “max context length × concurrent requests × KV elements per layer × bytes per element”; finally reserve 10%–20% for activations, communication buffers, and fragmentation. Many teams fail load testing not because of the model, but because maxing out concurrency causes the KV cache to overflow, leaving requests queued or interrupted.

    2. Hardware Thresholds: First “Can It Fit,” Then “How Fast”

    The simplest deployment form given in official guidance typically targets the latest generation of accelerator cards, with two single-node configurations: 4 cards or 8 cards. Mid-size model variants use 4-card data parallelism; extra-large variants use 8-card data parallelism. The key takeaway is that the threshold is genuinely high, and it is not simply a matter of “enough memory.”

    There are three reasons. First, newer operators and data types (such as FP8 KV cache and FP4 index cache) depend on relatively recent compute platforms and driver stacks; an older environment may be unable to enable the corresponding kernels even with sufficient memory. Second, ultra-long context tiers (for example, inference workloads approaching 400K tokens) require a large enough context window configuration, and KV cache usage rises linearly with it. Third, inter-GPU interconnect bandwidth determines parallel efficiency; if intra-node interconnect degrades to relaying through host memory, communication overhead will eat up the gains from parallelism.

    For teams without the latest-generation cards, the pragmatic path is to choose a mid-size model variant, shorten the maximum context, enable KV cache quantization, and validate a baseline with lower concurrency before gradually increasing load.

    3. Key Configuration Options, One by One

    The following is an illustrative set of startup parameters (it only expresses configuration dimensions, not a specific product command):

    1. serve <model-path> \
    2. --kv-cache-dtype fp8 \
    3. --block-size 256 \
    4. --enable-expert-parallel \
    5. --data-parallel-size 4 \
    6. --compilation-config '{"cudagraph_mode":"FULL_AND_PIECEWISE","custom_ops":["all"]}' \
    7. --attention-config.use-fp4-indexer-cache true \
    8. --tokenizer-mode <model-specific> \
    9. --tool-call-parser <model-specific> \
    10. --reasoning-parser <model-specific>
    • FP8 KV cache: Dropping the KV cache from half precision to 8 bits roughly halves memory usage, effectively increasing the concurrency and context length you can fit. The cost is a small precision loss; for long-text retrieval tasks, run before/after comparative evaluations.
    • Block size 256: The block is the allocation granularity of the KV cache. Larger blocks mean lower metadata overhead for allocation and addressing and friendlier contiguous access, but more internal fragmentation; smaller blocks are the opposite. Treat it as a “hard constraint” tightly coupled to the model structure, and do not change it casually and push it straight to production.
    • Expert parallelism: For mixture-of-experts structures, spreading different experts across multiple cards reduces per-card weight pressure, at the cost of extra routing and communication. It can be stacked with data parallelism, but first confirm the interconnect bandwidth can support it.
    • Full-graph and piecewise graph hybrid capture: Setting the compute graph capture mode to use full-graph and piecewise together can reduce kernel launch overhead; enabling all custom operators depends on a newer compilation stack, so fall back to a conservative configuration when the environment does not match.
    • FP4 index cache: Low-bit caching for the index structures in attention is a newer memory optimization technique. Its benefit shows up in long-context scenarios, but it requires hardware and kernel support.
    • Dedicated tokenizer and parsers: New model versions often come with new tokenizer modes, tool-call parsing, and reasoning-content parsing. Reusing the previous generation’s parsers leads to malformed output and thinking content bleeding into the main text—this is a “must upgrade in sync” item.

    4. Parallelism Strategy: Data Parallelism, Expert Parallelism, and Topology Constraints

    Data parallelism essentially distributes requests across multiple model replicas to increase throughput; expert parallelism splits the model internally to relieve per-card capacity pressure. When the two are combined, communication volume adds up, so pay attention to three things: whether the node has high-bandwidth interconnect, whether the parallelism degree matches the card count, and whether cross-node communication exists. The rule of thumb is to make the parallelism degree evenly divide the card count to avoid the last few cards sitting idle, and to keep high-communication parallel groups within the same node.

    5. Prefill and Decode Disaggregation: Scheduling the Two Workload Types Separately

    The prefill phase is compute-intensive and maxes out compute; the decode phase is memory-access-intensive and strains memory bandwidth. Putting both in the same instance causes interference: a long-prompt prefill blocks requests that are decoding, causing jitter in time-to-first-token.

    The idea behind disaggregated deployment is to dedicate one group of instances to prefill and another to decode, transfer the KV cache between them over a high-bandwidth link, and put a router in front for round-robin and load balancing. Illustratively:

    1. router ---> prefill instance group --(KV transfer/RDMA)--> decode instance group

    Engineering-wise, note the following: physically isolate the KV transfer link from the compute link to avoid competing for bandwidth; the routing strategy needs to be queue-length aware rather than simple round-robin; and the ratio of instance counts after disaggregation should be tuned by actual load testing—scenarios with long prompts and short outputs should get more prefill instances.

    6. Multi-Tier Reasoning Effort: Trading Controllable Cost for Quality

    Splitting reasoning effort into three tiers—non-thinking, high thinking, and max thinking—has been a common inference-service design over the past year. In implementation, request-level parameters control template behavior; the stronger the thinking, the longer the output and the higher the latency, and the max tier also requires a larger context window. Illustratively:

    1. resp = client.chat.completions.create(
    2. model="<model-name>",
    3. messages=[{"role": "user", "content": "Compute 17*19 and return only the final integer"}],
    4. extra_body={"chat_template_kwargs": {"thinking_mode": "max"}},
    5. )

    Implementation advice: make the tiers a business-configurable option. Route simple classification and extraction tasks to the non-thinking tier; route tasks needing multi-step reasoning to the thinking tier; and use the max tier only in offline batch processing, with output length limits and timeouts set to prevent a single request from dragging down the queue.

    7. Performance Validation: Baseline First, Then Single Variables

    1. Correctness baseline: Fix a small concurrency and verify output format, tool-call parsing, and whether thinking content is correctly separated.
    2. Single-variable load testing: Change only one parameter at a time (concurrency, context length, block size, quantization toggle), and record time-to-first-token, per-output-token latency, throughput, and peak memory.
    3. Stability observation: Run sustained load testing for 30 minutes or more, watching memory fragmentation, request queuing, and error rate.
    4. Cost conversion: Replace a pure QPS metric with “card-hours consumed per million tokens” to make cross-configuration comparison easier.

    8. Common Pitfalls

    • Assuming that if it fits in memory, it is ready to ship, while ignoring peak KV cache and fragmentation.
    • Reusing the previous generation’s tokenizer and parser configuration, causing abnormal output structure.
    • Parallelism degree not matching the card count, or letting high-communication parallel groups span nodes.
    • After disaggregated deployment, having the router do only round-robin without queue awareness.
    • Enabling the most aggressive compilation options across the board, which makes troubleshooting extremely costly when the environment does not match.

    9. General Guidance for Cloud Deployment

    If you lack the conditions for a self-built data center, you can rely on general cloud capabilities to fill in the engineering chain: use a container platform to host inference instances and elastic scaling, use object storage to distribute model weights, use logging and monitoring/alerting to track latency, throughput, and memory metrics, and use a message queue to smooth out offline batch workloads. The general product categories offered by Baidu AI Cloud in these scenarios can serve as a component-selection reference when building an inference platform; refer to the official documentation for specific specifications and quotas.

    Overall, local deployment of ultra-large-scale models has formed a fairly stable methodology: first calculate the memory budget clearly, then choose parallelism according to topology, then use quantization and cache optimizations to trade for concurrency headroom, and finally balance latency, throughput, and cost with a disaggregated architecture and tiered reasoning. Turning this process into a repeatable load-testing and regression mechanism delivers more long-term value than chasing a single “optimal parameter set.”