Most of us met large language models through an HTTP API. That abstraction holds until the first latency complaint. A support bot that answered in 900 ms starts taking four seconds after someone adds a long policy document to the system prompt. A summarisation job that was cheap becomes expensive when we ask for longer outputs. A self-hosted model that handled 40 concurrent users falls over at 60 even though GPU utilisation looks low. All of these come from a few mechanics inside a decoder-only...
Transformers for app engineers: tokens, attention and the KV cache behind LLM latency
Why does a long prompt make the first token slow while a long answer makes everything slow? A working model of tokens, prefill, decode and the KV cache, with the arithmetic we use to size GPUs and predict LLM latency and cost.
This is a paid story
Subscribe to read the full content, access all paid stories, and support the authors.
Add a label
Embed this post
<iframe src="https://www.hibug.me/transformers-for-app-engineers-kv-cache" width="700" height="420" frameborder="0" loading="lazy"></iframe>
I am a Senior Software Engineer with over a decade of hands-on experience building, scaling, and maintaining complex systems across the full stack—spanning frontend, backend, and DevOps. Over the last 10 years, I have navigated diverse architectures and untangled some of the most frustrating, elusive bugs in production. I believe that every production incident is a massive learning opportunity. Having discovered hibug.me, I am excited to contribute to this knowledge base, breaking down root causes, and sharing verified fixes to help fellow developers debug faster and build more resilient systems.
Comments
0No comments yet. Be the first to comment!
Sign In to post a comment.