By Sagar Shankaran, Founder of CallSphere
A technical guide to modern LLM inference optimization techniques — quantization, speculative decoding, KV-cache optimization, continuous batching, and PagedAttention. Make models faster and cheaper.
Key takeaways
Training a large language model is a one-time cost. Inference — serving predictions to users — is the ongoing expense that determines whether a model is economically viable in production. A model that costs $10 million to train but $0.001 per query can generate billions of responses profitably. The same model at $0.10 per query may be commercially unviable.
Inference optimization is the discipline of making models faster, cheaper, and more memory-efficient without sacrificing output quality. Here are the techniques that matter most in 2026.
Quantization reduces the numerical precision of model weights from 16-bit or 32-bit floating point to lower bit widths (8-bit, 4-bit, or even 2-bit integers).
Why it works: Most model weights cluster around small values. The difference between representing a weight as 0.0234375 (FP16) versus 0.023 (INT8) is negligible for output quality but halves memory usage.
Common quantization methods:
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
| Method | Bits | Quality Loss | Speed Gain | Memory Reduction |
|---|---|---|---|---|
| FP16 (baseline) | 16 | None | 1x | 1x |
| INT8 (W8A8) | 8 | Minimal | 1.5-2x | 2x |
| GPTQ (W4A16) | 4 | Small | 2-3x | 4x |
| AWQ | 4 | Small | 2-3x | 4x |
| GGUF Q4_K_M | 4 | Small | 2-3x | 4x |
| QuIP# | 2 | Moderate | 4-5x | 8x |
Practical example: A 70B parameter model requires ~140GB in FP16, needing 2x A100 80GB GPUs. With 4-bit quantization, it fits on a single A100 or even a consumer RTX 4090 (24GB).
# Quantizing with llama.cpp
./quantize model-f16.gguf model-q4_k_m.gguf Q4_K_M
# Serving with vLLM and AWQ quantization
python -m vllm.entrypoints.openai.api_server \
--model TheBloke/Llama-3.3-70B-AWQ \
--quantization awq \
--tensor-parallel-size 1
LLM inference is bottlenecked by sequential token generation — each token requires a full forward pass. Speculative decoding breaks this bottleneck by using a small, fast "draft" model to generate candidate tokens, then verifying them in parallel with the large model.
flowchart TD
HUB(("Why Inference<br/>Optimization Matters"))
HUB --> L0["Quantization: Trading<br/>Precision for Speed"]
style L0 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L1["Speculative Decoding: Draft<br/>and Verify"]
style L1 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L2["KV-Cache Optimization"]
style L2 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L3["PagedAttention and vLLM"]
style L3 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L4["Continuous Batching"]
style L4 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L5["Putting It All Together"]
style L5 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
style HUB fill:#4f46e5,stroke:#4338ca,color:#fff
How it works:
Speedup: When the draft model's predictions match the target model (which happens 70-90% of the time for well-chosen pairs), you get K tokens for the cost of ~1 forward pass of the large model. Typical speedups: 2-3x for well-matched model pairs.
During autoregressive generation, the Key-Value cache stores computed attention states for all previous tokens. This cache grows linearly with sequence length and can consume more memory than the model weights for long contexts.
Techniques:
PagedAttention, the innovation behind vLLM, manages KV-cache memory the way operating systems manage virtual memory — in non-contiguous pages.
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
Problem solved: Traditional KV-cache allocation pre-allocates memory based on maximum sequence length, wasting memory for shorter sequences. With batch sizes of 100+ concurrent requests, this waste becomes the primary bottleneck.
How PagedAttention helps:
# vLLM automatically uses PagedAttention
from vllm import LLM, SamplingParams
llm = LLM(
model="meta-llama/Llama-3.3-70B-Instruct",
tensor_parallel_size=2,
max_model_len=32768,
gpu_memory_utilization=0.90
)
outputs = llm.generate(
prompts=["Explain quantum computing" for _ in range(100)],
sampling_params=SamplingParams(temperature=0.7, max_tokens=512)
)
Traditional static batching waits for a full batch before processing and waits for the longest sequence to finish before returning any results. Continuous batching (also called iteration-level batching) inserts new requests and returns completed requests at every generation step.
Impact: Reduces average latency by 50-80% under load and increases throughput by 2-3x compared to static batching. All modern serving frameworks (vLLM, TGI, TensorRT-LLM) implement continuous batching by default.
A production-optimized inference stack combines multiple techniques:
Request → Continuous Batching Engine
├── PagedAttention (memory efficiency)
├── Quantized Model (INT8/INT4)
├── GQA/MQA (reduced KV-cache)
├── Speculative Decoding (speed)
└── Prefix Caching (shared prompts)
The compound effect of these optimizations is dramatic: a well-optimized serving stack can serve 10-50x more requests per GPU compared to a naive implementation, reducing per-query costs proportionally.
Sources: vLLM — PagedAttention Paper, Hugging Face — Quantization Guide, DeepSpeed — Inference Optimization
flowchart LR
IN(["Input prompt"])
subgraph PRE["Pre processing"]
TOK["Tokenize"]
EMB["Embed"]
end
subgraph CORE["Model Core"]
ATTN["Self attention layers"]
MLP["Feed forward layers"]
end
subgraph POST["Post processing"]
SAMP["Sampling"]
DETOK["Detokenize"]
end
OUT(["Generated text"])
IN --> TOK --> EMB --> ATTN --> MLP --> SAMP --> DETOK --> OUT
style IN fill:#f1f5f9,stroke:#64748b,color:#0f172a
style CORE fill:#ede9fe,stroke:#7c3aed,color:#1e1b4b
style OUT fill:#059669,stroke:#047857,color:#fff
flowchart TD
HUB(("Why Inference<br/>Optimization Matters"))
HUB --> L0["Quantization: Trading<br/>Precision for Speed"]
style L0 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L1["Speculative Decoding: Draft<br/>and Verify"]
style L1 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L2["KV-Cache Optimization"]
style L2 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L3["PagedAttention and vLLM"]
style L3 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L4["Continuous Batching"]
style L4 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
HUB --> L5["Putting It All Together"]
style L5 fill:#e0e7ff,stroke:#6366f1,color:#1e293b
style HUB fill:#4f46e5,stroke:#4338ca,color:#fff

Written by
Sagar Shankaran· Founder, CallSphere
LinkedInSagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
GPT-5.5's biggest under-the-hood change is output token efficiency. Here is what that means for cost, latency, and how you should architect prompts for both models.
Ollama matured significantly through 2025-26 and added serious features. The honest take on whether it belongs in production for agent workloads, and where the limits sit.
Sub-second agent decisions need explicit budgets at every step. The 2026 latency-engineering patterns from real production deployments.
Multi-layer cache designs for AI apps — prompt cache, response cache, retrieval cache, embedding cache — and how they compose in 2026.
When custom CUDA via Triton beats stock PyTorch ops in 2026 — the patterns, the tooling, and what production teams have shipped.
Flash Attention 3 is the kernel behind nearly every fast 2026 LLM. How it works, what it changed, and what's next.
© 2026 CallSphere Inc. All rights reserved.
Made within San Francisco