Low-VRAM LLM Inference Deep Tuning: Token Throughput, Memory Bandwidth, and KV Cache Optimization

    This article examines how to optimize large language model inference on GPUs with only 8 GB of VRAM. It breaks inference into prompt processing and token generation, explains why prompt processing is parallel and throughput-bound while token generation is serial and memory-bandwidth-bound, and discusses practical tuning approaches such as aggressive quantization, coordinated system-memory/VRAM scheduling, fine-grained KV cache management, and long-context warm-up caching. The goal is to help developers improve token throughput and interactive experience under tight memory constraints while keeping the underlying hardware limits in view.

    In the current wave of AI applications, local deployment and inference of large language models (LLMs) have become a major focus for developers. However, memory requirements of tens or even hundreds of GB put such workloads out of reach for many ordinary developers. In low-resource environments with only 8 GB of VRAM, how can an LLM run smoothly and reach usable performance levels? The answer depends not only on efficient lightweight inference frameworks but also on deep tuning of underlying hardware behavior and inference algorithms. This article focuses on a core performance metric in LLM inference—token processing speed—and examines practical tuning approaches through a technical lens.

    1. Performance Analysis of the Two LLM Inference Stages

    To optimize LLM inference speed, it is first necessary to understand how inference works. LLM inference is not a single uniform process. It consists of two stages with fundamentally different underlying mechanisms: prompt processing and content generation. Their computational characteristics are very different, and so are their optimization priorities.

    1.1 Prompt Processing: Fast Parallel “Reading”

    Prompt processing is the stage in which the AI “reads” the user’s input document or instruction. Its core characteristic is parallel computation. Because the context text provided by the user is already known, the inference framework can split the entire input text into multiple tokens and use the GPU’s parallel computing capability to process a large number of tokens at once.

    In practical tests, for example in a 32k-context mode, a typical low-VRAM configuration can reach up to 941 tok/s. This high throughput means that even for a long document of tens of thousands of characters, the model can complete “reading” and feature extraction in a very short time. The performance of this stage directly determines the warm-up time when processing long documents. If warm-up takes too long, the interactive experience suffers significantly, so improving throughput in this stage is key to optimizing long-text scenarios.

    1.2 Token Generation: Serial and Constrained “Writing”

    Token generation is the stage in which the AI “writes” the response. Unlike the parallel prompt processing stage, generation is strictly serial. Because LLMs use an autoregressive mechanism, each new token must be appended to the previous sequence and the attention weights must be recomputed.

    This one-token-at-a-time mechanism shifts the performance bottleneck in this stage from compute capacity to memory bandwidth. Under the same low-VRAM configuration, output speed usually stabilizes at around 25 tok/s. This may be acceptable for everyday conversation, but it becomes a clear limitation in scenarios that require generating large amounts of text.

    2. Why Does Memory Bandwidth Become the Generation Bottleneck?

    In the serial generation stage, why is compute no longer the bottleneck, and why does memory bandwidth take its place?

    The reason is that at every step of autoregressive generation, the inference framework must move the entire model’s weights from VRAM to the compute cores, such as CUDA Cores or Tensor Cores, for a forward pass. Suppose a model has 7B parameters and is stored in half precision (FP16); its weight size is about 14 GB. On an 8 GB VRAM device, quantization is usually used to compress it to around 4 GB, for example with 4-bit quantization.

    Even with only 4 GB of weights, every generated token requires this 4 GB of data to be transferred once between VRAM and the compute units. If memory bandwidth is 200 GB/s, the theoretical maximum generation speed is 200 / 4 = 50 tok/s. Taking KV cache reads and writes and system overhead into account, actual speed is often lower. This is the fundamental reason output speed is usually only 20–30 tok/s: the compute units are waiting for data movement and remain idle for much of the time.

    3. Deep Tuning Strategies for Low-VRAM Environments

    Faced with hardware resource limits, developers need to tune across multiple dimensions to extract maximum performance from limited VRAM.

    3.1 Aggressive Quantization and Memory Compression

    Quantization is the foundation for running large models with limited VRAM. By quantizing model weights from FP16 to INT8 or INT4, memory usage and bandwidth pressure can be greatly reduced. For example, group quantization can not only fit the model into 8 GB of VRAM but also reduce the amount of data moved in each forward pass, thereby linearly improving tok/s in the generation stage. However, excessive quantization may cause accuracy loss, so it is necessary to find a balance between speed and accuracy according to the specific task, such as code generation versus casual conversation.

    3.2 Coordinated Scheduling Between System Memory and VRAM

    When the sum of model weights and KV cache exceeds physical VRAM, modern inference frameworks often support offloading part of the data to system memory. This coordinated VRAM-memory scheduling mechanism solves out-of-memory (OOM) problems, but because PCIe bandwidth is much lower than VRAM bandwidth, it introduces significant latency.

    The optimization strategy lies in reasonable task allocation: keep compute-intensive core weights in VRAM, while placing less frequently accessed layers or currently inactive KV cache in system memory. In addition, prefetching can be used to asynchronously load the next layer’s weights from memory while computing the current layer, thereby hiding data transfer latency.

    3.3 Fine-Grained KV Cache Management

    In long-text processing, KV cache size grows linearly with context length and can easily fill VRAM. By implementing KV cache quantization, such as compressing FP16 KV cache to INT8, half of the cache memory can be saved. At the same time, using a sliding-window attention mechanism that keeps only the most recent N tokens of cache is also an effective way to control memory growth.

    4. Warm-Up Optimization for Long-Context Scenarios

    Returning to the warm-up problem in the prompt processing stage: when processing a long document of tens of thousands of characters, even with parallel throughput of 900 tok/s, the warm-up process still takes several seconds. If the user needs to resend the entire document with every question, the experience will be very poor.

    To optimize this scenario, context persistence and precomputation mechanisms can be introduced. The specific approach is:

    1. When the system is idle, pre-send commonly used documents to the model for prompt processing and generate the corresponding KV cache.
    2. Serialize and save this KV cache locally on disk or in memory.
    3. When the user asks a question about that document, load the serialized KV cache directly into VRAM, skip the cumbersome prompt processing stage, and enter the generation stage directly. This method can reduce repeated warm-up time to the millisecond level.

    5. Conclusion and Cloud Evolution

    Tuning LLM inference in low-VRAM environments such as 8 GB is essentially an exercise in pushing compute parallelism, memory bandwidth, and memory scheduling to their limits. Understanding the parallel throughput of the prompt processing stage and the serial bandwidth bottleneck of the token generation stage is the prerequisite for choosing the right tuning strategy. Through aggressive quantization, KV cache optimization, and warm-up caching mechanisms, developers can achieve a smooth inference experience on limited hardware.

    Of course, for enterprise applications, tuning local low-spec hardware is valuable for exploration, but it can still fall short when facing high concurrency and complex workloads. In such cases, elastic compute and managed model inference services from cloud providers such as Baidu AI Cloud can address compute bottlenecks more efficiently, allowing developers to focus on business logic rather than low-level resource tuning. Whether optimizing carefully on local hardware or using elastic cloud resources, a deep understanding of the underlying principles remains the foundation for technology selection and optimization.