<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kumar Pratik</title>
    <description>The latest articles on DEV Community by Kumar Pratik (@kumarpratiksahu).</description>
    <link>https://dev.to/kumarpratiksahu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3812526%2Ff13aa6ce-ad18-453d-84cc-33631d8cb49d.png</url>
      <title>DEV Community: Kumar Pratik</title>
      <link>https://dev.to/kumarpratiksahu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kumarpratiksahu"/>
    <language>en</language>
    <item>
      <title>Design Your LLM Prompts for KV Cache Reuse: Prompt Architecture Is Infrastructure Architecture</title>
      <dc:creator>Kumar Pratik</dc:creator>
      <pubDate>Sun, 15 Nov 2026 10:29:48 +0000</pubDate>
      <link>https://dev.to/kumarpratiksahu/design-your-llm-prompts-for-kv-cache-reuse-prompt-architecture-is-infrastructure-architecture-163</link>
      <guid>https://dev.to/kumarpratiksahu/design-your-llm-prompts-for-kv-cache-reuse-prompt-architecture-is-infrastructure-architecture-163</guid>
      <description>&lt;p&gt;&lt;em&gt;One timestamp at the top of a prompt can throw away 20,000 tokens of cached work.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When we tune an LLM inference server, the checklist is predictable: GPU memory, quantization, context length, batching, concurrency. But while building AntFabric.ai, an AI-native workspace powered by Digital Twins of the people in an organization, we keep learning that some of the most valuable optimizations happen much earlier, in how the prompt itself is assembled.&lt;/p&gt;

&lt;p&gt;Inference engines like vLLM keep the attention keys and values they compute for a prompt, in fixed-size token blocks, and reuse them when the next request starts with an identical prefix. A Digital Twin request carries 30K to 60K tokens of context, and around 20K of that (system instructions, organization policies, the twin's definition, tool schemas) is the same on every request. Reuse it, and prefill drops from 30K tokens to 10K.&lt;/p&gt;

&lt;p&gt;The catch: the cache matches a prefix, not a set. Each block's hash depends on every block before it, so one changed token near the top invalidates everything after it. Put "Current time: 10:21:32" or a request ID on the first line, and two prompts that look identical to a human share nothing as far as the cache is concerned.&lt;/p&gt;

&lt;p&gt;The fix costs nothing at build time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Order every prompt by how often its content changes: global instructions, policies, agent definition and tool schemas first; memory, retrieved documents, timestamps, conversation and the current request last.&lt;/li&gt;
&lt;li&gt;Make prompt construction deterministic: sorted tool lists, one canonical JSON serializer, schemas generated once.&lt;/li&gt;
&lt;li&gt;Snapshot-test the stable prefix, and measure the prefix hit rate, not just latency.&lt;/li&gt;
&lt;li&gt;Keep anything user-specific out of shared prefixes. Performance and trust boundaries have to agree.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Same tokens, same meaning, roughly 10x less prefill work. At 10,000 Digital Twins, that is about 11.5 billion prompt tokens a day the GPU would otherwise recompute.&lt;/p&gt;

&lt;p&gt;In the full post I cover how chained block hashing works, thinking in cache layers instead of "a 64K prompt", why &lt;code&gt;--max-num-batched-tokens&lt;/code&gt; does not change reuse, the security side of shared prefixes, and the 8-point checklist we are standardizing on.&lt;/p&gt;




&lt;p&gt;Originally published on kumarpratik.com: &lt;a href="https://kumarpratik.com/blog/design-llm-prompts-for-kv-cache-reuse" rel="noopener noreferrer"&gt;https://kumarpratik.com/blog/design-llm-prompts-for-kv-cache-reuse&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>performance</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
