Local LLM Inference Speed: How to Measure and Optimize It

    This article explains why a single tokens-per-second figure is insufficient for evaluating local LLM inference speed. It separates prefill from decode, reviews the main variables that affect observed throughput—quantization, context length, speculative decoding, multimodality, and batching—and provides a reproducible measurement workflow. It also outlines optimization priorities and offers guidance on combining local and cloud deployments and interpreting published speed claims.

    Reporting only a tokens-per-second number says little about whether a local LLM is actually fast. The same phrase—“a hundred-plus tokens/s”—could describe decode speed with a short prompt, pure text, and aggressive quantization. It could also describe the combined feel of a very long context, visual input, and multi-token prediction all enabled at once. The former is suitable for casual chat; the latter is closer to real office or engineering scenarios. To discuss speed clearly, you must first break down the metrics, then examine how hardware budget, precision, and feature switches interact.

    First, Distinguish What You Are Measuring

    LLM inference usually has two phases. The prefill phase reads the entire input, computes and writes the KV cache, and its latency grows mainly with input length. It is better described as “input tokens processed per second” or time to first token. The decode phase generates new tokens one at a time or in small batches; when people say tokens/s, they usually mean generation speed in this phase. The bottlenecks differ: prefill depends more on a combination of compute and bandwidth utilization, while decode at batch size 1 is often limited by memory bandwidth, because every generated token requires moving large weights and a growing cache.

    Therefore, external communication should at minimum report: output generation speed, time to first token, input length, output length, whether streaming is enabled, and batch size or number of concurrent users. Writing only “speed falls in a certain range” without context gives readers no way to judge whether the number applies to their own document Q&A or coding assistant.

    Measurements should also fix randomness. Temperature, sampling, and different stop conditions change generation length and indirectly affect average speed. Comparison experiments should use the same prompt set and the same maximum generation length, and disable unrelated logging and UI refresh so that front-end rendering time is not counted as model time.

    The Main Variables Behind One Number

    Precision and quantization. Lowering weights from a higher bit width to a lower one reduces memory footprint and memory traffic, and decode often becomes faster. However, calibration data, grouping strategy, and whether activations are quantized all affect numerical error. Low-bit floating-point or integer formats are not “the lower, the better”: in math, code, and long-chain reasoning, errors may appear as occasional wrong answers or premature stopping rather than awkward-sounding sentences. If a speed gain comes at the cost of a higher task failure rate, effective throughput is actually falling.

    Context length. When context grows from tens of thousands to over one hundred thousand tokens, the KV cache grows linearly. It competes with weights for memory and increases attention reads and writes at every step. Many implementations reduce concurrency or trigger recomputation under very long context, and apparent generation speed drops noticeably. When reporting speed, state the context limit and actual occupancy for the run, not just “set very large.”

    Multi-token prediction and speculative decoding. One forward pass attempts to produce multiple candidate tokens, which are then verified against the target distribution; accepted tokens effectively increase output per step. This is especially visible in interactions where “the reasoning process is long and the screen updates quickly,” but the speedup depends on agreement between draft and target, candidate length, and verification overhead. Peak acceleration should not be treated as average speed across all prompts.

    Multimodality. Vision encoding, image tiling, and cross-modal alignment consume compute and memory before or during text generation. Enabling vision does not mean text decode speed stays unchanged: cache layout, batching, and additional modules can invalidate pure-text numbers. If the workload is mainly document screenshots and UI mockups, report time to first token and generation speed with images separately.

    Runtime shape. Single-request and small-batch concurrency curves are completely different. When decode is bandwidth-bound, moderately increasing batch size can sometimes improve total throughput, but single-user latency gets worse. Local personal use usually has batch size 1, while enterprise gateways care more about requests completed per unit time. Do not use one promotional number for both scenarios.

    Hardware sets the upper bound, not the point you measure. The memory capacity, bandwidth, and low-precision compute of a consumer flagship GPU determine whether medium-sized weights can stay resident and how far context can be extended. Binding “a certain card + a certain quantization + a certain engine” into a single conclusion will fail as soon as context or task changes. A safer statement is: under the conditions of a single card, weights fully resident in memory, and batch size 1, observe decode speed; once context or vision modules fill the cache, speed and stability must be measured again.

    How to Make Measurements Reproducible

    Use a fixed process rather than the feeling of one chat session:

    1. Prepare short, medium, and long prompts that cover the percentiles of your real workload, not just a one-line greeting.
    2. Repeat each tier multiple times, discard the first warm-up round, report the median, and note the variation range. Warm-up is for kernel compilation and cache allocation, not steady state.
    3. Record prefill time and decode time separately. Generation speed should use only output tokens in the decode phase divided by decode time.
    4. State the quantization level, context limit, whether multi-token prediction is enabled, whether an image is passed in, sampling parameters, and maximum output length.
    5. Also record peak memory usage and whether paging or recomputation occurred. A sudden speedup may mean context was truncated; a sudden slowdown may mean cache spilled to slower storage.

    The timing logic can be simple; the key is clear boundaries:

    1. t0 = now()
    2. # Submit input only, until the first output token appears
    3. t_first = now()
    4. # Keep receiving until completion
    5. n_out, t_end = stream_generate()
    6. prefill_s = t_first - t0
    7. decode_s = t_end - t_first
    8. tok_per_s = n_out / decode_s

    A UI that “scrolls through the reasoning process quickly” is only a user-experience signal. The reasoning chain itself is also output tokens. If the product displays reasoning and answer in separate channels, state whether reasoning tokens are counted. Counting them produces a higher number, but it does not mean the answer appears earlier.

    Where to Optimize First

    Do the memory budget first, then talk about speed. Weights, runtime overhead, vision modules, and KV cache must be added together. Cache grows approximately with layers, head dimension, context, and concurrency. When the budget is insufficient, a common order is: shorten the default context, summarize history instead of concatenating it indefinitely, reduce concurrency, and only then consider lower bit width. Cutting context to the point where the workload is unusable just to chase tokens/s produces a meaningless speed number.

    Validate quantization by task, not by file size. Keep a small regression set covering math, code, extraction, and long-document Q&A, and compare failure rates and speed across bit widths. If a low bit width performs clearly worse on the regression set, restrict it to drafts, classification, or high-tolerance scenarios, and keep higher precision for final answers. The community impression that “a screen full of reasoning looks smart” mostly comes from long reasoning chains being printed quickly; it reflects decode bandwidth and whether speculative decoding runs smoothly, not task accuracy.

    Long context needs a cache strategy. Sliding windows, chunked retrieval, and placing cold documents in external retrieval are usually more stable than stuffing all material into one forward pass. Retrieved short contexts make decode speed and time to first token more predictable. Pay the cost of full cache only when you must compare against a very long source text word by word.

    Treat speculative decoding as a switch, not a default belief. For fluent continuation and relatively fixed output formats, acceptance rates are high and acceleration is obvious; for strongly constrained formats and tool calls with frequent branching, verification failures can cancel the benefit. Before launch, measure acceptance rate and end-to-end latency with real prompts, not just engine-provided samples.

    Separate multimodal requests from text-only queues. Image preprocessing time is unstable, and mixing it into the same queue raises tail latency for text requests. When layout analysis can be completed before the LLM and only text plus a few key images are sent into the model, it is often cheaper and faster than putting all images into context unchanged.

    On the engineering side, note that if every turn in a continuous conversation resends the full history, prefill becomes repeatedly expensive; incremental cache reuse can significantly improve multi-turn experience. If logging, tokenization, and network packaging run synchronously on the critical path, they also consume time that should belong to decode. During local demos, disable unnecessary tracing, then compare once against the production configuration to avoid writing environment noise into model performance.

    Combining Local and Cloud Deployments

    For individuals or small teams, running a medium-sized model locally has clear advantages: data does not leave the device, interactive latency is stable, and it is easy to iterate on quantization and prompts. The limits are equally clear: once memory is capped, context, concurrency, and multimodality cannot all be maxed out at the same time; drivers, runtime, and weight formats must be maintained by the team.

    When request volume rises, multiple GPUs are needed, or capacity must scale with peaks and valleys, placing the same class of model on cloud inference or heterogeneous compute resources is more reasonable. Public cloud providers such as Baidu AI Cloud can offer elastic compute and inference hosting capabilities suitable for burst traffic, unified releases, and centralized monitoring; specific specifications, availability zones, and billing should be confirmed in the console and official documentation. Do not use the tokens/s of one local device as an analogy for a cloud instance. A common practice is to keep sensitive or low-concurrency interactions local, send batch evaluation, overnight indexing, and peak customer support to the cloud, and use the same prompt and regression set on both sides—comparing quality and latency, not slogan-like single-point speed.

    On either side, observed metrics should feed into logs and monitoring: time to first token, generation speed, context length distribution, failure rate, and memory or instance utilization. Without these distributions, optimization remains at the level of “it feels faster.”

    How to Read Someone Else’s Speed Claims

    When you see “basically consistent with official marketing” or “smarter than a certain cloud model,” ask five questions first: Is it measuring prefill or decode? Are context and images enabled? Did quantization change the task score? What is the batch size? Are reasoning tokens counted? If any one answer differs, the numbers are not comparable. Smartness cannot be replaced by screen-scrolling speed; use accuracy on a fixed question set, citation faithfulness, and manual spot checks instead.

    If you need to share your own results externally, one table is enough: hardware class (no need for marketing model names), weight size class, quantization level, context, vision switch, speculative decoding switch, batch size, prefill speed or time to first token, decode tokens/s, and regression set score. Such a table is more useful than a paragraph of experience description and avoids treating one local demo as a universal law.

    Summary

    Local LLM generation speed is the result of decode bandwidth, cache size, quantization error, and feature switches acting together. A reproducible approach is to separate prefill and decode, fix prompts and sampling, and always report context, vision, and speculative decoding alongside the number. The optimization order should be memory budget, task regression, cache and retrieval, and only then more aggressive low precision and multi-token prediction. Local deployment suits low concurrency and data locality; traffic and elasticity requirements belong to general compute and inference capabilities in the cloud. Once these boundaries are written clearly, the question “what tokens/s does everyone get?” has reference value.