Chip Foundry Services Request Assessment

Latency

Latency optimization is the systematic minimization of response delay across every hardware and algorithmic boundary in large language model inference, bridging the gap between raw computational throughput and real-time human conversational interaction. In interactive generative systems—such as conversational agents, voice-to-voice interfaces, and IDE code autocompletion—latency is not a single scalar metric, but a multi-dimensional timeline defined by two decoupled hardware regimes: Time-to-First-Token (TTFT), representing prompt ingestion latency, and Time-Per-Output-Token (TPOT) or Inter-Token Latency (ITL), representing the generation speed of streaming tokens. While prefill prompt encoding is compute-bound ($O(S^2)$ attention matrices executed on high-throughput Tensor Cores), autoregressive decoding is ruthlessly memory-bandwidth bound ($O(S)$ vectors fetched sequentially from high-bandwidth memory for every single generated token). Shaving milliseconds from these phases requires coordinated full-stack interventions: chunked prefills and prompt prefix caching to slash TTFT, speculative decoding to verify multiple tokens in a single forward pass, weight and KV cache quantization (FP8/INT4) to cut memory traffic in half, and kernel fusion (FlashAttention) to keep data pipelines inside on-chip SRAM. At an end-to-end systems level, the execution timeline of an inference request progressing through the serving stack operates like this:

Client request & transport
gRPC / HTTP connection established with keep-alive pooling
Prefix cache lookup
Radix-tree hash match reuses identical prompt KV pages directly from HBM
Prefill phase (Time-to-First-Token)Compute-bound parallel matrix multiplications
Chunked prompt encoding
Splits un-cached prompt tokens into 512-token chunks to bound execution latency
Tensor Core GEMM saturation
Parallel matrix multiplication across all SMs generates initial prompt KV tensors
First token emission (TTFT)
First sampled token transmitted to client; marks perceived application responsiveness
Autoregressive decode loop (Time-Per-Output-Token)Memory-bandwidth-bound single-token generation
Speculative draft generation
Compact draft model generates K candidate tokens ahead of verification
Target parallel verification
Target model evaluates all K tokens in a single forward pass over HBM weights
↻ Low-latency token emission
KV cache append & streaming
Verified tokens appended to PagedAttention tables; streamed immediately via SSE
EOS termination & tail latency
Request concludes; P95/P99 latency recorded for SLA compliance

A few principles are essential for understanding how inference latency is generated, why memory bandwidth dictates decoding speed, and how speculative execution bypasses physical memory walls:

The physical latency dichotomy: compute-bound TTFT versus memory-bound TPOT. Total inference turnaround time is mathematically defined by the sum of initial prompt ingestion latency and sequential token generation:

$$\text{Latency}_{\text{End-to-End}} = T_{\text{Queue}} + \text{TTFT} + \left(\text{TPOT} \times N_{\text{Output}}\right)$$

Because prefill processes all input tokens concurrently in large dense GEMM matrix operations ($QK^T$), it achieves high arithmetic intensity (FLOPs per byte) and fully saturates GPU Tensor Cores. Conversely, autoregressive decoding generates one token at a time: for each token, the GPU must fetch all model weights (e.g., 140 GB for a 70B parameter model in FP16) from HBM into on-chip cache just to execute matrix-vector multiplications. The maximum physical decoding speed is therefore strictly bounded by the memory bandwidth of the accelerator:

$$\text{TPOT}_{\text{Theoretical}} \approx \frac{\text{Model Size (Bytes)}}{\text{HBM Bandwidth (Bytes/sec)}} = \frac{140 \times 10^9 \text{ Bytes}}{3.35 \times 10^{12} \text{ Bytes/sec}} \approx 41.8 \text{ ms/token} \approx 24 \text{ tokens/sec}$$

The operational contrast between these two execution regimes is illustrated below:

LLM Latency Breakdown: Prefill vs. Decode Timeline Time-to-First-Token (compute-bound) vs. Time-Per-Output-Token (memory-bandwidth-bound) Queue 10–30 ms Network / gRPC Prefill Phase (TTFT) 100–350 ms (Compute-Bound GEMM) Parallel ingestion across all input tokens First Token Emitted Autoregressive Decode Phase (TPOT / ITL) 15–35 ms per token (Memory-Bandwidth Bound) Sequential token stream: Token 1 → Token 2 → Token N Tok 1 Tok 2 Tok 3 Tok 4 . . . <EOS> Hardware Resource Bottlenecks: • Time-to-First-Token (TTFT): Governed by arithmetic FLOPS. Slashed via Chunked Prefills & Prefix Caching. • Time-Per-Output-Token (TPOT): Governed by HBM bandwidth. Slashed via Quantization & Speculative Decoding. • Perceived Latency: Reading speed is ~15–20 tok/s (~50ms/token). Sub-50ms TPOT feels instant. • Tail Latency (P99): Driven by long prompt prefill interruptions. Solved by prefill-decode disaggregation. End-to-End Latency = Queue Time + TTFT + (TPOT × Output Token Count) Optimizing TTFT satisfies instant responsiveness; optimizing TPOT sustains fluent streaming generation

Speculative decoding breaks memory bandwidth constraints through parallel verification. Because fetching model weights from HBM takes tens of milliseconds regardless of how many tokens are processed, standard autoregressive generation executes strictly token-by-token. Speculative decoding bypasses this memory wall by coupling a small, ultra-fast "draft" model (e.g., LLaMA-3 8B) with a large "target" foundation model (e.g., LLaMA-3 70B):
1. *Speculative Drafting:* The draft model runs $K$ sequential forward steps rapidly due to its compact parameter footprint, producing a candidate speculative tree of tokens $[\hat{y}_1, \hat{y}_2, \dots, \hat{y}_K]$.
2. *Parallel Target Verification:* The large target model evaluates all $K$ draft tokens concurrently in a single forward pass over its memory-resident weights. Because verifying $K$ tokens in parallel has roughly the exact same memory-fetching cost as generating a single token, any accepted tokens represent pure latency speedup.
3. *Lossless Acceptance Criterion:* Tokens are accepted probabilistically according to the ratio of target model logits to draft model logits ($p_{\text{target}}(x) / p_{\text{draft}}(x)$). If token $i$ is rejected, execution halts at the mismatch, a replacement token is sampled directly from the target distribution, and unverified tokens are discarded—guaranteeing that the mathematical output distribution remains completely identical to running the large model alone:

Speculative Decoding: Multi-Token Parallel Verification bypassing memory bandwidth bottlenecks by verifying K draft tokens in a single target forward pass Step 1: Small Draft Model (e.g., 8B Model, 10ms per token) Generates K=4 candidate tokens rapidly via low memory footprint Candidate 1: "The" Candidate 2: "capital" Candidate 3: "of" Candidate 4: "France" Cost: ~40 ms Step 2: Target Foundation Model (e.g., 70B Model, 40ms per forward pass) Evaluates all 4 candidate tokens concurrently in 1 single forward pass over HBM weights "The" [Accepted] p_target / p_draft ≥ 1.0 "capital" [Accepted] Accepted via sampling "of" [Accepted] Exact match confirmed "France" [Rejected] Target resamples: "Paris" Net Output: 4 tokens emitted ("The capital of Paris") in ~80ms total Effective Speedup: 2.0× Faster Mathematical equivalence guarantee: modified rejection sampling preserves the exact target model distribution Converts sequential memory-bandwidth delays into parallel compute verification on underutilized Tensor Cores Production standard in vLLM, TensorRT-LLM, and Medusa speculative heads

Target production SLAs and optimization benchmarks across hardware tiers. Interactive generative AI systems require distinct optimization stacks depending on end-user latency tolerance:

Interaction DomainTarget TTFT (P95)Target TPOT / ITLDominant Latency BottleneckRecommended Hardware & Optimization Stack
Real-Time Voice Agent$<250$ ms$<25$ ms/token (40+ tok/s)Network roundtrip & streaming packet jitterFP8 H100 with Speculative Decoding + WebSocket streaming
IDE Code Autocompletion$<100$ ms$<20$ ms/token (50+ tok/s)Prefill TTFT on massive source file contextRadix prefix caching + 3B–8B specialized model on L40S/A10G
Interactive Chat (ChatGPT / Claude)$<400$ ms$<35$ ms/token (30+ tok/s)KV cache memory exhaustion under high concurrencyContinuous batching + Chunked Prefills + PagedAttention on H100 SXM
Complex Reasoning / Agent Tools$<1,500$ ms$<30$ ms/tokenLong multi-turn context accumulationMulti-GPU Tensor Parallelism + Disaggregated Prefill-Decode

Advanced algorithmic and infrastructure mitigations. Beyond speculative execution, engineering teams deploy four critical optimization levers to eliminate latency regressions:
- *Prefix Caching (Radix Attention):* Many enterprise applications submit prompts with identical system instructions, few-shot demonstration blocks, or retrieved documents. Frameworks like SGLang and vLLM organize KV cache blocks into a Radix Tree: when an incoming prompt matches an existing prefix hash, its KV tensors are loaded instantly from GPU memory, dropping TTFT from 400ms to under 10ms.
- *Weight and Activation Quantization:* Lowering precision from FP16 to FP8 (via Hopper Transformer Engines) or INT4 (via AWQ/GPTQ) directly halves or quarters the byte volume transferred across the HBM bus for every token. Because TPOT is inversely proportional to memory transfer size, FP8 delivers an instantaneous $1.8\times$ to $2\times$ reduction in token generation latency with negligible degradation in benchmark perplexity.
- *Prefill-Decode Disaggregation:* In mixed-traffic clusters, sudden arrivals of long 8k-token documents cause "prefill starvation," stalling active decoding streams for hundreds of milliseconds and causing severe user-perceived stutter (P99 tail latency spikes). Disaggregating prefill workers from decode workers over 400 Gbps InfiniBand RDMA networks ensures that active conversational streams generate tokens at completely steady 25ms intervals regardless of background prompt volume.

Read latency optimization through a *memory-bus-transfer-speed* lens rather than a *raw-GPU-computing-power* lens: adding more compute TFLOPs to a single-token decoding loop does almost nothing to accelerate generation if the memory controller is already saturated moving gigabytes of weights across high-bandwidth memory. Latency engineering is the discipline of manipulating memory traffic—caching prefixes so weights are not re-read, quantizing matrices so fewer bytes traverse the bus, and speculating candidate tokens so multiple predictions amortize a single memory fetch. When these interventions align, foundation models transform from sluggish web forms into instantaneous, fluid extensions of human thought.