Choosing an LLM Inference Optimization Technique: A Decision-Tree Approach

Match an LLM inference optimization technique to your real bottleneck. A six-question decision tree routes you from model size to prefill-decode disaggregation.

Choosing an LLM Inference Optimization Technique: A Decision-Tree Approach

In this article, you will learn how to match an LLM inference optimization technique to the actual bottleneck in your workload by working through a six-question decision tree.

Topics we will cover include:

  • What each major inference optimization technique, from quantization to prefill-decode disaggregation, assumes about your workload.
  • How to work through a decision tree that routes you to the right technique based on your model and traffic.
  • How the techniques compare on trade-offs, and which symptoms show that a chosen technique isn’t working.

Choosing an LLM Inference Optimization Technique: A Decision-Tree Approach

Introduction

LLM inference gets slow and expensive as traffic grows. Requests queue behind long generations, GPU memory fills with cached attention state, and the hardware spends much of its time waiting on memory reads.

Inference optimization is the set of techniques that help here. Some techniques target memory, some target compute, and some target how requests are scheduled against each other. Each technique assumes something specific about your workload, so the right choice depends on which assumptions hold for yours. This article covers:

  • What each major inference optimization technique assumes about your workload
  • A decision tree that routes you to a technique
  • How the techniques compare on latency, throughput, and implementation cost
  • The symptoms that show a technique isn’t working

We start with what each technique assumes.

What Each Inference Optimization Technique Assumes

LLM inference has many optimization techniques, but each one addresses a different type of bottleneck. Before using one, it helps to understand the workload it is designed for.

TechniqueWhat It Assumes
Quantization / sparsity / distillationThe model itself is too large for the hardware or the latency budget, and shrinking it is worth some accuracy risk
Prefix cachingMany requests share an identical starting sequence of tokens, so recomputing that prefix is wasted work
Continuous (in-flight) batchingRequests arrive concurrently with unpredictable output lengths, and waiting for the slowest one in a batch wastes the GPU
PagedAttentionKV cache memory is fragmented or over-provisioned, capping batch size below what the hardware could otherwise hold
Speculative decodingDecode is the bottleneck, tokens are generated one at a time, and a cheaper draft model can guess several of them correctly
Prefill-decode disaggregationPrefill and decode are contending for the same GPU, and that contention is hurting both time-to-first-token and inter-token latency at once
Tensor / pipeline parallelismThe model doesn’t fit in a single device’s memory, or per-device compute is the ceiling on throughput
KV cache offloadingUseful cache entries are being evicted too early because GPU memory can’t hold everything you’d like to keep
Offline batch inferenceRequests don’t need an interactive response, and total throughput outweighs per-request latency

Choose the technique based on the bottleneck in your workload to avoid unnecessary complexity.

Working Through a Decision Tree to Choose a Technique

The tree below has six branching questions. Each one narrows the field based on a specific property of your model or your traffic. Every question ends the same way: a direct answer if the condition holds, and a pointer to the next question if it doesn’t.

Question 1: Does the Model Fit Comfortably on Your Target Hardware?

Before moving on to the serving stack, check whether the model itself is the problem. A model that barely fits in GPU memory leaves almost no room for KV cache, which caps your batch size no matter how good your scheduler is.

If the model is too large, or inference is compute-bound even at batch size one, start with model-level compression:

  • Quantization reduces the precision of weights and activations.
  • Structured sparsity removes less important weights to reduce computation.
  • Distillation trains a smaller model to mimic a larger model.

These techniques are mostly independent of the serving stack, and you may want to consider them first because they determine how much hardware capacity remains.

If the model already fits with headroom to spare, move to Question 2.

Question 2: Do Your Requests Share Repeated Prompt Structure?

Chat applications resend the full conversation history on every turn. Agent frameworks reuse the same system prompt across thousands of calls. Retrieval-augmented generation (RAG) pipelines often prepend the same instructions to different retrieved contexts.

If a meaningful share of your traffic has an identical prefix, whether that’s a system prompt or a growing chat history, prefix caching is the highest-leverage technique available. It skips recomputing the KV cache for tokens the model has already processed, and the gains compound as conversations get longer.

⚠️ Prefix caching only works when the shared prefix matches exactly, character for character. Put stable, reusable content first and variable content at the end of the prompt.

If your prompts are mostly unique with little shared structure, move to Question 3.

Question 3: Are Requests Arriving Concurrently With Variable Output Lengths?

A support chatbot that returns a one-sentence answer and a code assistant that returns four hundred lines rarely finish at the same time, even if they started together. Under naive batching, the whole batch waits on the slowest request.

If your traffic mixes short and long generations and arrives in overlapping bursts, continuous batching fixes the idle time this creates. Finished sequences leave the batch immediately, allowing new requests to start without waiting for a batch boundary. Most serving engines enable this by default.

If your traffic is already well-batched and GPU idle time is not a problem, move to Question 4.

Question 4: Is KV Cache Fragmentation Limiting Your Batch Size?

Some engines reserve a fixed, contiguous block of memory per request sized for the maximum possible sequence length, even when most requests are much shorter. That reserved space sits unused for the life of the request and blocks other requests from using it.

If KV cache is wasting memory or limiting batch size, PagedAttention can help. It splits the cache into fixed-size pages, allowing memory to be allocated in smaller chunks instead of large contiguous blocks. Most modern serving engines already support it, so check whether it is enabled before adding new configuration.

If memory is not the constraint, move to Question 5.

Question 5: Is Per-Token Decode Latency the Metric You’re Focusing On?

If your goal is faster token streaming for each user rather than higher overall throughput, consider speculative decoding.

A smaller draft model predicts several tokens ahead, and the main model verifies them in a single pass. When the draft model predicts correctly, multiple sequential decode steps can be completed together, reducing inter-token latency.

The trade-off is the extra model and verification overhead. If you don’t have a suitable draft model or its predictions are accepted too rarely, the added complexity may not pay off. In that case, move to Question 6.

Question 6: Are Prefill and Decode Contending for the Same GPU at Scale?

This is mainly a production-scale concern because it changes the serving architecture.

If long prefills are delaying decode requests and hurting both time-to-first-token and inter-token latency, prefill-decode disaggregation can separate the two phases onto dedicated hardware. Prefill nodes process prompts, then pass the KV cache to decode nodes optimized for token generation.

This adds KV-cache transfer and routing overhead, so it makes sense only when the traffic justifies that complexity. For smaller workloads or non-interactive requests, offline batch inference is often simpler. If none of these conditions apply, start with continuous batching and prefix caching.

inference-optimization-decision-tree

Mapping the Decision Tree to an Optimization Technique

Working through the tree lands you on one of the techniques in the following table:

TechniqueBest ForTrade-off
Quantization / sparsity / distillationModels too large for the target hardware or latency budgetSome accuracy loss, and quantized activations are harder to get right than quantized weights
Prefix cachingChat, agents, and RAG workloads with repeated prompt structureBreaks on any character-level mismatch in the shared prefix
Continuous batchingConcurrent traffic with variable output lengthsMinimal downside; mostly a matter of whether it’s enabled
PagedAttentionWorkloads bottlenecked by KV cache fragmentationAdds a page table layer to attention computation
Speculative decodingLatency-sensitive single-user generationNeeds a draft model with a reasonably high acceptance rate to pay off
Prefill-decode disaggregationLarge-scale traffic where prefill and decode contend for the same GPUNetwork cost of moving the KV cache between nodes, plus routing complexity
Tensor / pipeline parallelismModels that don’t fit on a single devicePipeline bubbles and inter-device communication overhead
KV cache offloadingLong-context or high-concurrency workloads running out of GPU memory for cacheFetching offloaded cache back adds latency
Offline batch inferenceNon-interactive workloads prioritizing total throughputNot usable for anything with a strict response-time requirement

Recognizing Common Inference Optimization Pitfalls

A technique that you think will work may behave quite differently once it meets real traffic, because each one depends on the workload assumption behind it. The trade-offs in the table above point to the symptoms to watch for:

  • Prefix caching shows little benefit: the shared prefix is probably not matching exactly. Check that stable content comes first and variable content comes last.
  • Speculative decoding doesn’t speed up streaming: the draft model’s predictions are likely being accepted too rarely to offset the extra model and verification overhead.
  • Batch size stays low despite a good scheduler: the model may be leaving too little room for KV cache, or cache fragmentation may be wasting memory. Confirm that PagedAttention is enabled.
  • Disaggregation adds latency instead of removing it: the KV-cache transfer and routing overhead may outweigh the gains at your traffic level.
  • Offloaded cache slows responses: fetching entries back from offloaded storage adds latency that interactive workloads may not tolerate.

Conclusion

Inference optimization works best when the technique matches the bottleneck. Start by checking whether the model fits the hardware, then work through the questions on prompt reuse, concurrency, cache fragmentation, decode latency, and prefill-decode contention. If none of the conditions clearly apply, continuous batching and prefix caching are a sensible starting point. Whichever technique you choose, watch for the symptoms above, since they show when its assumptions don’t hold for your workload.