Inferensys

Glossary

Latency

Latency is the time delay between a request being submitted to an inference system and the corresponding response being received, typically measured in milliseconds.
Incident responder handling AI system issue on laptop, logs and alerts visible, late night on-call session.
INFERENCE PERFORMANCE METRIC

What is Latency?

In machine learning inference, latency is the fundamental performance metric quantifying the delay between a request and its response.

Latency is the total time delay between submitting an inference request to a system and receiving the complete response, measured in milliseconds (ms) or seconds. In autoregressive models like large language models, this is often decomposed into Time to First Token (TTFT), covering prompt processing, and Time Per Output Token (TPOT), covering incremental generation. It is a critical user-facing metric directly impacting application responsiveness and experience.

For performance benchmarking, latency is analyzed as a distribution, not a single value. Key metrics include percentile latency (P50, P90, P99) and tail latency, which captures the slowest requests. Latency is inversely related to throughput; as request load increases, latency typically rises due to resource contention and queueing, a relationship visualized on a throughput-latency curve. Optimizations like continuous batching, KV cache management, and model quantization directly target latency reduction.

PERFORMANCE MEASUREMENT

Key Latency Metrics in AI Inference

Latency is the primary measure of responsiveness in AI systems. These metrics break down the total delay into specific, actionable components for engineers to optimize.

01

Time to First Token (TTFT)

Time to First Token measures the duration from request submission until the first output token is generated by an autoregressive model. This initial delay encompasses the entire prefill stage, including:

  • Prompt encoding and processing
  • Loading the model's KV cache
  • Executing the initial forward pass through all layers

TTFT is highly sensitive to prompt length and model size. For long-context models, this can be the dominant component of total latency.

02

Time per Output Token (TPOT)

Time per Output Token is the average latency to generate each subsequent token after the first. This metric represents the incremental cost of the decoding stage in autoregressive generation. Key factors influencing TPOT include:

  • Model architecture and size
  • Efficiency of the KV cache lookup
  • Hardware memory bandwidth (often the bottleneck)

Optimizations like speculative decoding target TPOT directly, using smaller draft models to propose multiple tokens for verification in a single pass of the large model.

03

Tail Latency (P90/P95/P99)

Tail latency refers to the high-percentile latencies (e.g., P95, P99) in a request distribution. While average latency is useful, tail latency determines user-perceived performance. The slowest 1% of requests (P99) often dictates Service Level Objectives (SLOs).

Causes of high tail latency include:

  • Resource contention from concurrent requests
  • Garbage collection pauses or other system noise
  • Cold starts for infrequently used models
  • Variable input/output lengths causing uneven processing times
04

End-to-End Latency

End-to-End Latency is the total elapsed time from the client's perspective, encompassing all system components beyond just model execution. This holistic metric includes:

  • Network transmission (client to server and back)
  • Request queuing and scheduling time
  • Pre/post-processing (tokenization, detokenization, formatting)
  • Model inference time (TTFT + TPOT * output length)

For real-time applications like chatbots, end-to-end latency must typically be under 200-300 milliseconds to feel instantaneous.

05

Inter-Token Latency

Inter-Token Latency measures the time gap between consecutive tokens as they are streamed to a client. In streaming response scenarios, consistent inter-token latency is critical for user experience. High variance can make output feel "jerky."

This metric is influenced by:

  • The underlying TPOT of the model
  • Network buffering and transmission protocols
  • Server-side batching strategies, where a single batch processes tokens for multiple requests, potentially delaying individual token delivery
06

Cold Start vs. Steady-State

Latency is measured in two distinct operational phases:

Cold Start Latency: The significant delay on the first request to a newly initialized service or model. This includes:

  • Loading model weights from disk into GPU memory
  • Just-in-Time (JIT) compilation of kernels (e.g., with PyTorch or TensorRT)
  • Warm-up inference passes to stabilize performance

Steady-State Latency: The consistent performance achieved after caches are populated, kernels are compiled, and the system has reached equilibrium. Performance benchmarks and SLOs are typically defined for steady-state operation.

INFERENCE PERFORMANCE

What Factors Affect Inference Latency?

Inference latency is determined by the complex interplay of computational, memory, and system-level bottlenecks during model execution.

Inference latency is the total time to process a request and is primarily governed by compute intensity, memory bandwidth, and system overhead. A workload is compute-bound when limited by processor FLOPs, common in dense matrix operations. Conversely, it is memory-bound when constrained by data movement, typical in attention mechanisms accessing the KV cache. System factors like cold starts, resource contention from concurrent requests, and network I/O introduce additional delays before steady-state performance is achieved.

The model architecture dictates fundamental latency characteristics. Autoregressive models exhibit distinct Time to First Token (TTFT) for prompt processing and Time per Output Token (TPOT) for generation. Optimization techniques directly target these phases: quantization reduces compute per operation, continuous batching improves GPU utilization, and speculative decoding reduces sequential steps. Ultimately, latency is a function of the slowest component in the pipeline, identified through bottleneck analysis and performance profiling against established performance baselines.

SYSTEM DESIGN

Latency vs. Throughput: The Fundamental Trade-off

A comparison of the two primary performance metrics in inference systems, illustrating their inverse relationship and the engineering trade-offs required to optimize for one versus the other.

Performance DimensionLatency-Optimized SystemThroughput-Optimized SystemBalanced System

Primary Goal

Minimize response time for individual requests

Maximize total requests processed per unit time

Maintain acceptable latency while maximizing throughput

Key Metric

P99 Latency (e.g., < 200ms)

Tokens Per Second (TPS) or Queries Per Second (QPS)

Throughput at a defined latency SLO (e.g., QPS @ P99<500ms)

Typical Architecture

Low-batch or batch size of 1, dedicated resources per request

Large, static batching, aggressive request queueing

Dynamic/continuous batching with adaptive queue limits

Resource Utilization

Often lower, as resources may be idle between requests

Very high, maximizing GPU/CPU usage at all times

High, but managed to prevent tail latency spikes

Scheduling Priority

First-in, first-out (FIFO) or priority queues for fairness

Maximum batch size formation, potentially starving small requests

Hybrid: prioritizes batch efficiency while respecting latency bounds

User Experience Impact

Predictable, fast response for interactive applications (e.g., chat)

High capacity for batch processing (e.g., document summarization)

Good for mixed workloads with both interactive and batch tasks

Cost Efficiency

Lower (higher cost per request) due to potential resource under-utilization

Higher (lower cost per request) due to maximal resource amortization

Moderate, optimized for total cost of ownership at target performance

Failure Mode Under Load

Latency increases linearly, then requests fail or timeout to protect SLO

Throughput plateaus, latency increases exponentially due to queueing

Graceful degradation: throughput stabilizes as latency approaches SLO limit

INFERENCE PERFORMANCE

Frequently Asked Questions

Latency is the primary metric for user-perceived responsiveness in AI inference systems. These questions address its measurement, optimization, and impact on production deployments.

Latency is the total time delay between submitting a request to an inference system and receiving the complete response, measured end-to-end in milliseconds. In machine learning, it encompasses the time for data pre-processing, model execution (forward pass), and result post-processing. For autoregressive models like LLMs, latency is often broken into Time to First Token (TTFT) and Time per Output Token (TPOT). It is the critical metric for interactive applications, directly impacting user experience, with lower latency correlating to higher perceived system quality and responsiveness.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.