How Tokens Are Generated and Consumed in LLM Inference: A Full-Chain Observability Guide

    This article explains why GPU utilization alone is no longer enough to describe production LLM services. It traces the token lifecycle from prefill and decode through KV Cache behavior, introduces an eight-layer observability framework spanning hardware to cost, and outlines common token-consumption patterns and practical steps for token-centric capacity planning, performance analysis, and cost governance.

    Over the past few years, GPU scheduling has been one of the most discussed topics in AI infrastructure. Scheduler extensions on container orchestration platforms, batch scheduling frameworks, and heterogeneous compute management systems all address the same basic question: how can expensive and scarce GPUs be used more efficiently?

    As more enterprises begin running production-grade large language model (LLM) services, however, new symptoms have emerged:

    • GPU utilization is high, but users still complain that the system responds slowly.
    • GPU clusters are close to full, but business throughput does not grow proportionally.
    • GPU memory and compute still have headroom, but Time To First Token (TTFT) continues to degrade.

    These symptoms point to one conclusion: GPU utilization is no longer sufficient to describe the real operating state of modern AI systems. The bridge between user experience and hardware cost is the token. Understanding how tokens are generated, how they are consumed, and where they are effectively “wasted” is therefore central to building a modern AI observability system.

    1. Why Observability Must Expand from GPUs to Tokens

    For traditional cloud-native applications, we focus on four basic resources: CPU, memory, network, and disk. These metrics have a relatively direct relationship with business output. AI inference systems, by contrast, are multi-stage pipelines in which any stage can become a hidden bottleneck:

    • Whether the GPU is performing useful computation rather than idling or waiting.
    • Whether collective communication has become a bottleneck for parallel batching.
    • Whether the scheduling layer has correctly allocated GPU memory and compute resources.
    • Whether KV Cache has been exhausted, causing requests to be rejected or swapped out.
    • Whether token latency meets user experience requirements.
    • Whether the cost per useful token is reasonable.

    In other words, the observability target for AI infrastructure has expanded from a single GPU to the entire inference chain. The token is the only unit of measurement that runs through hardware, engine, and business: hardware compute ultimately appears as tokens generated per second; user experience appears as token arrival rate and Time To First Token; and business cost appears as the depreciation and operating expense allocated to each token.

    2. How Tokens Are Generated: The Inference Engine Perspective

    From the perspective of model execution, token generation for a conversational request consists of two distinct phases:

    1. Prefill phase: The user’s prompt is sent through the model in one pass. This phase is computationally intensive and highly parallel. It determines TTFT, or how long the user waits for the first token. The longer the prompt, the longer prefill takes.

    2. Decode phase: The model generates tokens autoregressively, one token at a time. Each forward pass processes only one token, making this phase memory-bandwidth-intensive. It determines TPOT (time per output token), which directly affects how smoothly users can read the output.

    The two phases have very different resource requirements: prefill is compute-bound, while decode is memory-bandwidth-bound. If the engine does not schedule them separately, the prefill of a long prompt can block a batch of requests that are decoding, causing token streams to stall for all users. This is why modern inference engines commonly introduce techniques such as prefill/decode disaggregation, continuous batching, and chunked prefill: they make token generation flow more smoothly.

    KV Cache is key to understanding token consumption. For every generated token, the engine caches its corresponding key-value state so that later attention computation can reuse it. GPU memory usage for KV Cache is proportional to context length and the number of concurrent requests. When model weights and KV Cache fill GPU memory, the system cannot admit new requests even if compute is idle. This is one typical cause of “high GPU utilization but stagnant throughput.”

    3. An Eight-Layer Observability Architecture: The Full Chain from Hardware to Tokens

    To attribute token generation and consumption end to end, teams can use the eight-layer observability framework widely discussed in the industry. From bottom to top, the layers are:

    Layer 1: GPU hardware layer. Focus on SM occupancy, memory bandwidth utilization, memory capacity, hardware errors, and throttling events. This layer answers whether the chip itself is healthy and fully utilized. Note that high SM occupancy does not mean more useful computation; memory stalls can also drive occupancy up.

    Layer 2: Communication layer. In tensor parallelism and pipeline parallelism scenarios, the share of time spent on collective communication directly determines scaling efficiency. Observe communication time, bandwidth utilization, and synchronization waits to identify situations where compute is waiting on communication.

    Layer 3: Node and operating system layer. Focus on data movement between CPU and GPU (host memory copies), driver and runtime status, and process-level GPU memory isolation. If data preprocessing happens on the CPU side, it can become a hidden bottleneck.

    Layer 4: Container and scheduling layer. The container platform is responsible for allocating GPUs to workloads. Observe whether resource allocation matches requests, whether fragmentation occurs, and how long requests wait in queues. Problems at this layer often appear as “the request should fit, but it is not scheduled for a long time.”

    Layer 5: Inference engine layer. This is where tokens are actually “produced.” Core metrics include batch size, KV Cache usage and hit rate, prefill and decode queue lengths, and the frequency of request preemption or swapping. This layer directly explains fluctuations in token latency.

    Layer 6: Service layer. Focus on TTFT, TPOT, end-to-end latency, throughput, error rate, and timeout rate. This is the layer that directly maps to user experience and where SLOs are defined.

    Layer 7: Application and business layer. Focus on average tokens per session, the ratio of prompt tokens to generated tokens, cache reuse rate (whether the same prefix is reused), and token consumption caused by无效 retries.

    Layer 8: Cost layer. Convert GPU hours into the token dimension to obtain “cost per million tokens,” and compare it with business revenue or value to close the loop between investment and output.

    4. Typical Token Consumption Patterns and Optimization Directions

    In real business scenarios, token consumption often follows the patterns below, each with corresponding optimization actions:

    • Long prompt, short output: Prefill dominates, and TTFT is sensitive. Prefix caching can reuse system prompts and significantly reduce repeated computation.
    • Short prompt, long output: Decode dominates, and throughput is sensitive. Increasing concurrent batch size and optimizing KV Cache management can improve overall token output.
    • High-frequency repeated context: KV Cache grows noticeably across multi-turn conversations, requiring careful cache eviction and session management.
    • Invalid consumption: Failed retries, truncated outputs, and fallback responses all consume tokens without producing business value. Budget controls should be implemented at the application layer.

    5. Practical Recommendations for Using Tokens as the North-Star Metric

    1. Unify measurement definitions: In the monitoring system, place hardware-layer metrics (utilization, bandwidth), service-layer metrics (TTFT/TPOT), and cost metrics (cost per million tokens) on the same timeline for correlated analysis.
    2. Build a habit of layered attribution: When token latency degrades, investigate from the service layer to the engine layer, scheduling layer, and hardware/communication layer in a top-down manner. Avoid attributing the problem to insufficient GPUs immediately.
    3. Include token budgets in capacity planning: Derive required GPU specifications, concurrency limits, and KV Cache capacity from target business token throughput rather than simply estimating from request QPS.
    4. Focus on validity: Distinguish between “tokens generated” and “tokens consumed by users.” The former is a compute metric; the latter represents business value.

    GPU utilization is not the destination. Tokens are the true north-star metric for AI infrastructure. When a team establishes a complete observability chain from chips to tokens and from tokens to business, capacity planning, performance optimization, and cost governance for AI systems can become truly quantifiable and continuously improvable.