<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>LLM推理 on KnightLi Blog</title>
        <link>https://knightli.com/en/tags/llm%E6%8E%A8%E7%90%86/</link>
        <description>Recent content in LLM推理 on KnightLi Blog</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en</language>
        <lastBuildDate>Sat, 11 Jul 2026 09:36:02 +0800</lastBuildDate><atom:link href="https://knightli.com/en/tags/llm%E6%8E%A8%E7%90%86/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>What to do if vLLM KV Cache has insufficient memory: video memory, context and concurrency troubleshooting</title>
        <link>https://knightli.com/en/2026/07/11/vllm-kv-cache-memory-not-enough-troubleshooting/</link>
        <pubDate>Sat, 11 Jul 2026 09:36:02 +0800</pubDate>
        
        <guid>https://knightli.com/en/2026/07/11/vllm-kv-cache-memory-not-enough-troubleshooting/</guid>
        <description>&lt;p&gt;When the following error occurs when vLLM is started, it is usually not because the model weight download is broken:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;The model&amp;#39;s max seq len ... KV cache is needed, which is larger than the available KV cache memory
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;It means that after the model weights and runtime overhead take up the video memory, the remaining space is not enough to prepare the KV Cache for the maximum context length you set. The most direct processing sequence is: **Reduce &lt;code&gt;--max-model-len&lt;/code&gt; first, then check concurrency, and finally consider improving memory utilization, quantifying KV Cache, or expanding capacity. **&lt;/p&gt;
&lt;p&gt;Don&amp;rsquo;t pull &lt;code&gt;--gpu-memory-utilization&lt;/code&gt; to 1 right off the bat. That may allow vLLM to pass initialization, but be more prone to OOM when real requests, CUDA graph, or other processes compete for video memory.&lt;/p&gt;
&lt;h2 id=&#34;first-understand-why-kv-cache-fills-up-the-video-memory&#34;&gt;First understand: why KV Cache fills up the video memory
&lt;/h2&gt;&lt;p&gt;The model weight determines &amp;ldquo;whether the model can be loaded&amp;rdquo;, and the KV Cache determines &amp;ldquo;how many tokens the model can remember at the same time and how many requests it serves.&amp;rdquo; Every time a token is generated or read, the attention layer needs to save the corresponding Key/Value state.&lt;/p&gt;
&lt;p&gt;Therefore, KV Cache usage will increase with the following items:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;max_model_len&lt;/code&gt;: The longer the maximum context allowed, the greater the cache requirements.&lt;/li&gt;
&lt;li&gt;Number of concurrent requests: Each concurrent request will occupy its own context space.&lt;/li&gt;
&lt;li&gt;Model structure: number of layers, number of KV heads, hidden size and data type all affect cache size.&lt;/li&gt;
&lt;li&gt;Cache precision: The default usually follows the model data type; low-precision caches such as FP8 can save space, but have compatibility and quality boundaries.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The most overlooked thing is concurrency. Even if each request is only given 8K context, the total demand on KV Cache will still grow rapidly when multiple requests are running simultaneously.&lt;/p&gt;
&lt;h2 id=&#34;first-determine-what-kind-of-problem-it-is-from-the-logs&#34;&gt;First determine what kind of problem it is from the logs
&lt;/h2&gt;&lt;p&gt;Startup logs usually give three key pieces of information:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The maximum sequence length specified by the model or configured by you.&lt;/li&gt;
&lt;li&gt;How many GiB does KV Cache require.&lt;/li&gt;
&lt;li&gt;The actual space currently available for the KV Cache, and the maximum feasible length estimated by vLLM.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If the log says &amp;ldquo;Maximum length 32768 requires 10GiB KV Cache, but currently only 4GiB&amp;rdquo;, don&amp;rsquo;t worry about whether the model supports 32K first. Model &lt;strong&gt;Support&lt;/strong&gt; does not mean that your card can serve 32K requests under the current configuration.&lt;/p&gt;
&lt;p&gt;Start by taking note of the estimated maximum length provided by the log, and set your first test at around 60% to 80% of it, and then work your way up.&lt;/p&gt;
&lt;h2 id=&#34;first-priority-lower---max-model-len&#34;&gt;First priority: lower &lt;code&gt;--max-model-len&lt;/code&gt;
&lt;/h2&gt;&lt;p&gt;This is the adjustment with the highest success rate and the most predictable impact. For example, the model natively supports 32K, and your actual business only handles ordinary conversations, short codes and small documents, you can start with 8K:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;vllm serve Qwen/Qwen3-8B &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  --max-model-len &lt;span class=&#34;m&#34;&gt;8192&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;If it&amp;rsquo;s still not enough, try again:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;vllm serve Qwen/Qwen3-8B &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  --max-model-len &lt;span class=&#34;m&#34;&gt;4096&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Do not write the model card&amp;rsquo;s nominal 128K, 256K or longer context directly into the service parameters. For single-card deployments, the actual available length depends on weight, video memory, concurrency, and cache accuracy.&lt;/p&gt;
&lt;p&gt;A practical starting point:&lt;/p&gt;
&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Video memory and usage&lt;/th&gt;
          &lt;th&gt;Context length to try first&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;12GB–16GB single-card, Class 8B model&lt;/td&gt;
          &lt;td&gt;4096 or 8192&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;24GB single card, 7B–14B models&lt;/td&gt;
          &lt;td&gt;8192 or 16384&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;24GB single card, 30B level quantized model&lt;/td&gt;
          &lt;td&gt;Start with 4096&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Long Document/RAG/Multi-User Service&lt;/td&gt;
          &lt;td&gt;Make decisions based on log estimates and stress testing, don’t just follow the table&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;These values ​​are a starting point for troubleshooting, not memory commitments. KV Cache size can vary significantly between models.&lt;/p&gt;
&lt;h2 id=&#34;second-priority-limit-concurrency-and-batch-processing&#34;&gt;Second priority: Limit concurrency and batch processing
&lt;/h2&gt;&lt;p&gt;Just because the service can be started does not mean it will be stable under high concurrency conditions. First, control concurrency to a small value:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;vllm serve Qwen/Qwen3-8B &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  --max-model-len &lt;span class=&#34;m&#34;&gt;8192&lt;/span&gt; &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  --max-num-seqs &lt;span class=&#34;m&#34;&gt;4&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;&lt;code&gt;--max-num-seqs&lt;/code&gt; limits the number of sequences that can be processed in one iteration. A larger number may result in higher throughput, but also greater KV Cache and scheduling pressure.&lt;/p&gt;
&lt;p&gt;If requests often contain long prompts, you should also pay attention to &lt;code&gt;--max-num-batched-tokens&lt;/code&gt;. It determines the maximum number of tokens that can be processed at one time; if it is too high, the prefill phase may occupy more resources instantly. Be conservative when troubleshooting, and then gradually expand after confirming stability.&lt;/p&gt;
&lt;p&gt;It is recommended to perform stress testing in this order:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Single request, 4K context, confirmed service stability.&lt;/li&gt;
&lt;li&gt;Single request, 8K context, observe first token latency and video memory.&lt;/li&gt;
&lt;li&gt;Two concurrent requests confirm that there will be no OOM.&lt;/li&gt;
&lt;li&gt;Then gradually increase &lt;code&gt;max_num_seqs&lt;/code&gt; or the number of batch tokens.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Do not adjust context, concurrency, batch and model quantization at the same time, otherwise it will be difficult to locate which parameter is causing the video memory to be exhausted.&lt;/p&gt;
&lt;h2 id=&#34;third-priority-properly-set---gpu-memory-utilization&#34;&gt;Third priority: Properly set &lt;code&gt;--gpu-memory-utilization&lt;/code&gt;
&lt;/h2&gt;&lt;p&gt;&lt;code&gt;--gpu-memory-utilization&lt;/code&gt; specifies the proportion of GPU memory that can be used by the current vLLM instance, with a value between 0 and 1. vLLM will plan the weight, runtime and KV Cache based on this part of the space.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;vllm serve Qwen/Qwen3-8B &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  --gpu-memory-utilization 0.90 &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  --max-model-len &lt;span class=&#34;m&#34;&gt;8192&lt;/span&gt; &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  --max-num-seqs &lt;span class=&#34;m&#34;&gt;4&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;When the error message clearly says &amp;ldquo;Too few available KV Cache&amp;rdquo; and there are no other processes on the GPU, you can improve it in small steps, such as trying from &lt;code&gt;0.90&lt;/code&gt; to &lt;code&gt;0.92&lt;/code&gt; or &lt;code&gt;0.94&lt;/code&gt;. Add just a little at a time and test with real requests.&lt;/p&gt;
&lt;p&gt;It is not recommended to deadlift high in the following situations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Also running on the same card is a desktop program, another inference service, or a training task.&lt;/li&gt;
&lt;li&gt;Available video memory will fluctuate after startup.&lt;/li&gt;
&lt;li&gt;Spikes are prone to occur when using CUDA graphs, vision models, or high-concurrency prefills.&lt;/li&gt;
&lt;li&gt;You&amp;rsquo;ve encountered a CUDA OOM on the fly, not just a failed initialization check.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If multiple instances share the same GPU, you should have an explicit budget for each instance rather than setting them all to 0.9.&lt;/p&gt;
&lt;h2 id=&#34;fp8-kv-cache-confirm-the-model-and-version-before-saving-graphics-memory&#34;&gt;FP8 KV Cache: Confirm the model and version before saving graphics memory
&lt;/h2&gt;&lt;p&gt;vLLM supports changing the cache data type via &lt;code&gt;--kv-cache-dtype&lt;/code&gt;. CUDA 11.8+ environments are available with FP8 related options, such as:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;vllm serve Qwen/Qwen3-8B &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  --kv-cache-dtype fp8 &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  --max-model-len &lt;span class=&#34;m&#34;&gt;16384&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;FP8 KV Cache can significantly reduce cache usage, but don’t think of it as a completely free switch:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;First confirm that the current vLLM, CUDA and hardware support this data type.&lt;/li&gt;
&lt;li&gt;Whether the model checkpoint provides an appropriate KV scale will affect the results; its absence needs to be evaluated with caution.&lt;/li&gt;
&lt;li&gt;Long contexts, complex reasoning, tool calls, and structured output should all be tested against the default cache accuracy.&lt;/li&gt;
&lt;li&gt;If you just want to fit an unsuitable large model into the graphics card, it is usually more stable to lower the context first or change to a more suitable model.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Therefore, the more recommended order is: first use the default precision to run 4K/8K stably, and then test whether FP8 can really allow the business to obtain the required context or concurrency.&lt;/p&gt;
&lt;h2 id=&#34;know-priorities-when-manually-specifying-kv-cache-size&#34;&gt;Know priorities when manually specifying KV Cache size
&lt;/h2&gt;&lt;p&gt;Newer vLLMs provide &lt;code&gt;kv_cache_memory_bytes&lt;/code&gt; to specify the KV Cache size precisely in bytes per GPU. It is suitable for scenarios where multiple services share a card and require a fixed graphics memory budget.&lt;/p&gt;
&lt;p&gt;Note: Explicitly setting the number of cache bytes will override the automatic inference of the cache size via &lt;code&gt;gpu_memory_utilization&lt;/code&gt;. Don&amp;rsquo;t think of both as additive gains; first decide whether to use a &amp;ldquo;proportional budget&amp;rdquo; or a &amp;ldquo;fixed cache budget&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;Fixed budget is suitable for servers with clear operation and maintenance constraints. It is more intuitive to use &lt;code&gt;--gpu-memory-utilization&lt;/code&gt; and &lt;code&gt;--max-model-len&lt;/code&gt; for single-machine troubleshooting.&lt;/p&gt;
&lt;h2 id=&#34;what-can-cpu-offload-solve-and-what-cant-it-solve&#34;&gt;What can CPU offload solve and what can’t it solve?
&lt;/h2&gt;&lt;p&gt;The new version of vLLM supports offloading part of the KV Cache to the CPU, or combining it with back-end processing cache layers such as LMCache. This can scale capacity when the GPU cache is insufficient, but at the cost of PCIe/memory transfers and latency.&lt;/p&gt;
&lt;p&gt;It is more suitable for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Occasionally very long context requests;&lt;/li&gt;
&lt;li&gt;The business can accept higher initial token delay;&lt;/li&gt;
&lt;li&gt;There is sufficient system memory and real stress testing has been done;&lt;/li&gt;
&lt;li&gt;Want to make a degradation path for long prompts instead of pursuing the highest throughput.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is not suitable to cover up the problem of &amp;ldquo;the model weight cannot be put down&amp;rdquo;, nor can it replace the management of concurrency and context upper limits. If all requests are swapped out and in frequently, throughput will often drop significantly.&lt;/p&gt;
&lt;h2 id=&#34;a-replicable-troubleshooting-template&#34;&gt;A replicable troubleshooting template
&lt;/h2&gt;&lt;p&gt;Start with a conservative configuration:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;vllm serve Qwen/Qwen3-8B &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  --gpu-memory-utilization 0.90 &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  --max-model-len &lt;span class=&#34;m&#34;&gt;4096&lt;/span&gt; &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  --max-num-seqs &lt;span class=&#34;m&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;After confirming that the order request can be processed stably, adjust in the following order:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;4096 上下文稳定
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-&amp;gt; 8192 上下文稳定
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-&amp;gt; max_num_seqs 从 2 调到 4
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-&amp;gt; 调整 max_num_batched_tokens
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-&amp;gt; 再测试 FP8 KV Cache 或 CPU offload
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Four pieces of data are recorded in each round: number of available KV Cache tokens, first token delay, generated tokens/s, and peak video memory. This way you can tell whether an optimization is improving throughput or simply deferring OOMs to higher concurrency.&lt;/p&gt;
&lt;h2 id=&#34;common-misunderstandings&#34;&gt;Common misunderstandings
&lt;/h2&gt;&lt;h3 id=&#34;misunderstanding-1-the-model-supports-long-context-so-the-service-must-be-fully-enabled&#34;&gt;Misunderstanding 1: The model supports long context, so the service must be fully enabled
&lt;/h3&gt;&lt;p&gt;The upper limit of model capabilities and the upper limit of serviceability of your graphics card are two different things. The server&amp;rsquo;s &lt;code&gt;max_model_len&lt;/code&gt; should be set according to the hardware and business upper limit.&lt;/p&gt;
&lt;h3 id=&#34;misunderstanding-2-set-gpu_memory_utilization-to-1-to-solve-the-problem&#34;&gt;Misunderstanding 2: Set &lt;code&gt;gpu_memory_utilization&lt;/code&gt; to 1 to solve the problem
&lt;/h3&gt;&lt;p&gt;This reduces the safety margin and does not reduce the need for the KV Cache itself. Runtime spikes are more likely to trigger CUDA OOM.&lt;/p&gt;
&lt;h3 id=&#34;misunderstanding-3-only-reduce-weight-quantization-regardless-of-concurrency&#34;&gt;Misunderstanding 3: Only reduce weight quantization, regardless of concurrency
&lt;/h3&gt;&lt;p&gt;Weight quantization can free up video memory, but concurrency and context will still cause the KV Cache to expand rapidly. Service configurations must limit both length and number of requests.&lt;/p&gt;
&lt;h3 id=&#34;myth-4-cpu-offloading-is-definitely-better-than-rejecting-long-requests&#34;&gt;Myth 4: CPU offloading is definitely better than rejecting long requests
&lt;/h3&gt;&lt;p&gt;If latency is sensitive, frequent offloading may be worse than explicitly routing long requests to nodes with larger memory. First define the delay and cost boundaries of the business.&lt;/p&gt;
&lt;h2 id=&#34;summarize&#34;&gt;Summarize
&lt;/h2&gt;&lt;p&gt;vLLM KV Cache has insufficient memory. The most reliable processing priority is:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;降低 max_model_len
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-&amp;gt; 限制 max_num_seqs 与 batch
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-&amp;gt; 小步调整 gpu_memory_utilization
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-&amp;gt; 验证 FP8 KV Cache
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-&amp;gt; 最后考虑固定缓存预算或 CPU offload
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Let a short context and low concurrency configuration work stably first, and then gradually expand it according to business data. As long as the model weight, KV Cache, concurrency and real context length are looked at separately, most &amp;ldquo;out of memory&amp;rdquo; problems can be located faster.&lt;/p&gt;
&lt;p&gt;refer to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://docs.vllm.ai/en/stable/api/vllm/config/cache/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;vLLM Cache Config&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://docs.vllm.ai/en/stable/api/vllm/v1/core/kv_cache_utils/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;vLLM KV Cache calculation and error reporting logic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://docs.vllm.ai/en/stable/configuration/engine_args/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;vLLM Engine Arguments&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://knightli.com/en/2026/06/25/lmcache-vllm-kv-cache-guide/&#34; &gt;LMCache Practical Guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        </item>
        
    </channel>
</rss>
