页面简介
Prefill sets time to first token and decode sets the rest. See how TTFT, TPOT, batching, GPU memory, and serving choices change latency and cost.
正文摘录
ModelsProductsPricingDocsBlogAboutContactGet Started🎉 MiniMax-H3 is available on SiliconFlow. Try it NOW.🎉 MiniMax-H3 is available on SiliconFlow. Try it NOW.Back to BlogsWhat Is LLM Inference? Latency, Throughput, Batching, and Cost ExplainedOct 30, 2026Table of ContentsEvery response from an LLM-powered chatbot, coding assistant, or document summarization tool depends on LLM inference. The model must process the prompt, manage its working context, and generate output tokens while sharing compute resources with other requests. Prompt length, output length, GPU memory, request concurrency, batching, and serving architecture all affect the result. Understanding these factors helps teams choose models, interpret benchmarks, control costs, and design more reliable production applications.What Is LLM Inference?LLM inference is the process of running a trained large language model on new input. The model uses its existing parameters to calculate token probabilities and generate an output. Its weights remain unchanged during this process.Training creates the model's general capabilities by updating its parameters across large datasets. Fine-tuning continues that training on a narrower dataset or task. Inference uses the completed model to answer questions, generate code, summarize documents, or produce other outputs.AI inference also covers image classification, speech recognition, computer vision, and recommendation systems. Large language model inference specifically concerns models that process and generate tokens.In production, inference usually runs behind a serving layer. An LLM inference server loads model weights, accepts API requests, schedules concurrent workloads, manages GPU memory, and returns generated output to the application.What Happens When an LLM Processes a Request?An inference request moves through several stages:The serving system receives and validates the API request.The request may enter a queue while compute resources are occupied.A tokenizer converts the prompt into token IDs.The model processes the input and builds a key-value cache.A sampling method selects the first output token from the model's probability distribution.The model generates additional tokens one step at a time.The tokenizer converts the output tokens back into text.The server streams tokens to the application or returns the completed response.Network transfer, queueing, tokenization, model execution, scheduling, and streaming all contribute to user-visible latency. A benchmark that measures GPU execution alone may therefore look faster than the complete API experience.Our OpenAI-compatible API gives developers access to optimized language and multimodal models without requiring them to build and maintain the serving layer independently.Prefill vs. Decode: The Two Main Stages of LLM InferenceGenerative LLM inference has two main computational stages.During prefill, the model processes all input tokens in the prompt. These calculations can run in parallel because the full input sequence is already available. The model also creates the initial KV cache. Longer prompts require more prefill work and usually increase time to first token.During decode, the model generates output tokens autoregressively. Each new token depends on the input and all previously generated tokens. The process continues until the model reaches a stopping condition or output limit.Prefill is often compute-intensive, especially with long inputs. Decode repeatedly reads model weights and cached attention states, so memory bandwidth often becomes a major constraint.Workload shape determines which stage dominates. A summarization request with a long document and short answer places more pressure on prefill. A short prompt requesting a long report spends more time in decode.TTFT, TPOT, TPS, Latency, and Throughput ExplainedA single response-time figure cannot describe the complete inference experience.TTFT can include network time, queueing, tokenization, and prefill. TPOT, also called inter-token latency, focuses on token delivery after generation begins.TPS needs a clearly stated scope. Higher concurrency may increase system TPS while reducing per-user TPS. Different tokenizers also represent text differently, so tokens per second cannot always be compared directly across models.MetricWhat it measuresWhere it shows upTTFTNetwork time, queueing, tokenization, and prefill before the first tokenInteractive assistants where the first token drives perceived speedTPOT (inter-token latency)Token delivery after generation beginsStreaming output that stalls mid-answerTPSToken output rate, per user or for the whole systemThroughput-oriented serving configurationsEnd-to-end latencyTotal time from request to completed responseLong outputs and queueing under loadGoodputThroughput that still meets the required latency targetHigh raw throughput with missed latency targetsThese metrics can help locate performance problems:High TTFT with normal TPOT can indicate long prompts, prefill pressure, queueing, or network delay.Normal TTFT with high TPOT points more strongly toward decode speed, memory bandwidth, or heavy concurrency.High system TPS with slow per-user TPS indicates a throughput-oriented serving configuration.High raw throughput with low goodput means many requests are missing the required latency target.Production tests should report model version, input and output lengths, concurrency, precision, streaming mode, and hardware. Percentiles such as p50 and p95 reveal performance variation that an average can hide.Why GPU Memory Capacity and Bandwidth Matter for LLM InferenceGPU memory capacity determines which models can run and how much concurrent traffic the system can support. The main memory consumers include model weights, KV cache, intermediate activations, and runtime workspaces.Model-weight memory grows with parameter count and numerical precision. As a rough estimate, a 7-billion-parameter model stored in 16-bit precision requires about 14 GB for weights before other memory allocations.KV cache usage grows with the number of active requests and the total sequence length of each request. Long prompts, long outputs, and high concurrency can consume substantial memory. Limited capacity may restrict batch size, context length, or the number of simultaneous requests.Memory bandwidth controls how quickly weights and cached states move between GPU memory and compute units. It has a particularly strong effect during decode.Quantization can reduce weight or cache memory, while efficient attention kernels and KV cache management can improve resource use. Model parallelism allows larger models to run across multiple GPUs, although communication between devices can add latency. Effective LLM inference optimization depends on balancing these techniques against model quality and workload requirements.How Batching Improves Throughput and Affects LatencyBatching groups multiple requests into shared execution steps. The GPU performs more useful work each time it reads model weights, which can raise total LLM inference throughput and reduce infrastructure cost per token.Static batching starts a group of requests together. Requests often produce different output lengths, leaving shorter sequences waiting while longer ones continue.Continuous or in-flight batching allows completed requests to leave and new requests to enter as capacity becomes available. This scheduling approach helps maintain GPU utilization under changing traffic.Larger batches also consume more KV cache memory. They can increase queueing time, TTFT, or TPOT when the system prioritizes total throughput. Interactive assistants usually need tight first-token and streaming latency targets. Offline extraction, evaluation, and document-processing jobs can often accept more latency for higher throughput.What Affects the Cost of LLM Inference?For API users, inference cost begins with model choice and token consumption. Text generation on SiliconFlow uses separate input and output pricing:Total cost = input tokens × input unit price + output tokens × output unit priceCurrent prices vary by model and can be checked in the Model Plaza.Several application choices affect total spending:Larger or more compute-intensive models may carry higher token prices.Long system prompts and conversation histories increase input usage.Verbose responses and reasoning content increase output usage.Repeated context adds tokens when prompt caching is unavailable.Uncontrolled retries can duplicate token consumption after timeouts.Routing simple tasks to the largest available model can waste budget.Input and output tokens also create different infrastructure demands. Prefill processes input tokens with substantial parallelism. Output generation requires repeated decode steps. Providers may price these workloads differently, so teams should use the published rates for each model.At the infrastructure level, hardware type, model precision, GPU utilization, batch efficiency, replica count, and idle capacity all influence cost. The most useful comparison is often cost per successful task under a defined quality and latency target.Serverless vs. Dedicated InferenceServerless inference works well for development, prototypes, traffic spikes, and applications with variable demand. The provider manages the serving infrastructure and scaling, while usage-based billing reduces the cost of idle capacity.SiliconFlow serverless inference provides immediate access to optimized language and multimodal models. Developers can test different models through one integration and allow capacity to scale with changing request volume.Dedicated inference assigns isolated compute resources to a workload. It can provide more predictable capacity for stable, high-volume production traffic. Its economics depend on sustained utilization because reserved resources continue to generate cost during quiet periods.SiliconFlow currently provides serverless inference and re