<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Syed Hussain Haider Zaidi on Medium]]></title>
        <description><![CDATA[Stories by Syed Hussain Haider Zaidi on Medium]]></description>
        <link>https://medium.com/@HussainZaidi14?source=rss-36248d2e9efa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bX7cIjHia4OcaCTqkSsPbQ.jpeg</url>
            <title>Stories by Syed Hussain Haider Zaidi on Medium</title>
            <link>https://medium.com/@HussainZaidi14?source=rss-36248d2e9efa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 00:27:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@HussainZaidi14/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why Your Load Balancer Breaks LLM Serving]]></title>
            <link>https://medium.com/@HussainZaidi14/why-your-load-balancer-breaks-llm-serving-05f69ce9b274?source=rss-36248d2e9efa------2</link>
            <guid isPermaLink="false">https://medium.com/p/05f69ce9b274</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Syed Hussain Haider Zaidi]]></dc:creator>
            <pubDate>Wed, 16 Sep 2026 03:53:45 GMT</pubDate>
            <atom:updated>2026-09-16T04:16:06.670Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*keKI2pOjkltevsvrJnsaYw.png" /></figure><p>Part 3 of 3 — The Fleet Problem, and What llm-d Does About It</p><h3>Where we left off</h3><p><a href="https://medium.com/@HussainZaidi14/what-actually-happens-when-you-press-enter-in-chatgpt-a2747f6137dc">Part 1</a> went down to the metal: a model is a big file of weights; GPUs win because the math is massively parallel; VRAM exists because system RAM is ~52× too slow to feed those cores; and every request splits into <strong>prefill</strong> (compute-bound, the pause, TTFT) and <strong>decode</strong> (bandwidth-bound, the stream, TPOT), where each token costs a full re-read of the entire model.</p><p><a href="https://medium.com/@HussainZaidi14/the-hidden-cache-that-makes-chatgpt-feel-fast-7de291478af4">Part 2 </a>built the software layer on top:</p><ul><li>The <strong>KV cache</strong> saves prefill’s output so decode never repeats it — that’s why the pause happens once.</li><li>It costs <strong>~128 KB per token</strong> for an 8B model, so <strong>KV memory, not compute, caps concurrency</strong>: ~60 GB of an H100 holds ~490,000 tokens of cache.</li><li><strong>PagedAttention</strong> manages that pool like OS virtual memory — no fragmentation, shared prefixes stored once.</li><li><strong>Prefix caching</strong> keeps blocks between requests, hashed by content, so turn 10 of a chat costs about what turn 2 did.</li><li><strong>Continuous batching</strong> amortises the <em>weight</em> read across every waiting user, but not the KV read, which is per-sequence and paid every step. Throughput scales by an order of magnitude; per-user latency degrades with context length, from ~4.8 ms/token alone to ~22 ms with the cache pool full.</li><li><strong>Tensor, pipeline and expert parallelism</strong> spread one model over many GPUs when it stops fitting on one.</li></ul><p>And it ended with the catch that sets up this article:</p><p><strong>Every single one of those optimisations is per-server state.</strong></p><h3>Q: So what actually goes wrong when I run this on a fleet?</h3><p>A real service can’t run on one box. You have to serve the whole world, so you run many servers — each with its own GPUs and its own complete copy of the model — and put a load balancer in front.</p><pre>[ your message ] ──▶ [ load balancer ] ──▶ [ Server 2 ]<br>                       round-robin      ──▶ [ Server 5 ]<br>                                        ──▶ [ Server 9 ]</pre><p>This is the most standard, boring, well-understood piece of infrastructure in the industry. It has worked perfectly for twenty-five years of web services.</p><p>It fails at LLM serving in <strong>two distinct ways</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mb7uQqRy5-y2uJNI0OMd-g.png" /></figure><p>Failure 1 — it scatters the cache you worked so hard to build</p><p>You send turn 1. Round-robin sends it to Server 2. Server 2 prefills your thread, builds a KV cache, streams an answer, and — thanks to prefix caching — holds on to those blocks.</p><p>You send turn 2. Round-robin sends it to <strong>Server 5</strong>.</p><p>Server 5 has never seen your conversation. It prefills the entire thread from scratch. Meanwhile the perfectly good cache on Server 2 sits there, paid for, unused, waiting to be evicted.</p><p><strong>Prefix caching has a hit rate of roughly zero across a randomly-balanced fleet.</strong> You built the most valuable optimisation in <a href="https://medium.com/@HussainZaidi14/the-hidden-cache-that-makes-chatgpt-feel-fast-7de291478af4">Part 2</a> and then threw it away at the routing layer.</p><h3>Failure 2 — it treats every request as if it costs the same</h3><p>Round-robin’s core assumption is that <strong>every request costs about the same</strong> — the same slice of time, and the same amount of memory. That assumption is inherited from ordinary web serving, where it is close enough to true: fetching a profile page, rendering a template, running an indexed query. They all finish in tens of milliseconds and hold a few kilobytes while they do. When every request is that cheap and that uniform, <em>which</em> server gets <em>which</em> request genuinely doesn’t matter — so counting connections is a perfectly good way to spread load.</p><p>An LLM breaks both halves of that assumption at once:</p><ul><li>one user sends a 40-token question</li><li>another pastes a 60-page PDF: 50,000 tokens</li></ul><p>That’s <strong>three orders of magnitude</strong> of difference in compute — and, because KV cache scales with tokens, roughly three orders of magnitude in memory too. One of those requests will occupy a slice of GPU memory 1,250 times larger than the other, for far longer.</p><p>Round-robin gives them one slot each. Worse, they queue behind whichever arrived first — so a fleet can have one machine buried under three giant prefills while a machine beside it sits idle, and the balancer which is either rotating blindly or, at best, counting open connections — sees a perfectly even distribution.</p><blockquote>Generic load balancers “do not account for prompt structure, token count, queue depth, or GPU load.” That’s not a subtle inefficiency — at the fleet level it dominates everything else you tuned.</blockquote><h3>Q: What would a router that understood LLMs actually do?</h3><p>It would stop asking <em>“whose turn is it?”</em> and start asking <strong>“which replica is best for this specific request, right now?”</strong></p><p>That’s what <strong>llm-d</strong> is built around. llm-d is a Kubernetes-native distributed inference stack — a CNCF Sandbox project founded by Red Hat, Google Cloud, IBM Research, CoreWeave and NVIDIA — that uses vLLM as its engine and coordinates a fleet of them.</p><p>Its front door is an <strong>Inference Gateway</strong>: a proxy plus an <strong>Endpoint Picker (EPP)</strong>, the component that actually chooses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Em-pxQo0K_MGrkAL93IrsA.png" /></figure><p>For every request, the EPP scores every candidate replica on signals a normal load balancer doesn’t have:</p><ul><li><strong>Prefix-cache overlap</strong> — how much of this prompt does that replica already hold?</li><li><strong>Queue depth</strong> — how much work is waiting there?</li><li><strong>KV-cache utilisation</strong> — is it near its memory ceiling, about to start evicting?</li><li><strong>Predicted latency</strong> — llm-d can run an XGBoost model to estimate how long this request will take on that replica.</li></ul><p>Notice the trade-offs in the diagram. Replica B is completely free but holds nothing — routing there means a full cold prefill. Replica C has an 88% prefix match but 31 requests queued — you’d wait longer in line than you’d save. Replica A, at 92% match with a queue of 2, wins. <strong>That is a judgement no round-robin balancer can make</strong>, because it requires knowing what’s inside the servers.</p><h3>Q: How does the router know what’s cached?</h3><p>Two implementations, with a real engineering trade-off between them:</p><p><strong>Approximate.</strong> The router splits the prompt into fixed-size blocks, builds a rolling hash chain, and keeps an in-memory LRU index of which prefix hashes it sent to which pod. Extremely lightweight — no tokenizer, no extra services. But it’s inferring the servers’ state from its own history, so it can drift when replicas evict blocks it doesn’t know about.</p><p><strong>Precise.</strong> The router gets exact tokenization from vLLM’s render endpoint, and vLLM emits <strong>KV-cache events</strong> over ZMQ as blocks are created and evicted. The router maintains a globally accurate index of which token blocks live where. Exact, handles complex eviction and disaggregated setups correctly — at the cost of more moving parts.</p><p>The reported effect of getting this right: <strong>~3× higher output throughput and ~2× faster TTFT.</strong> Not from new hardware. From sending requests to the machine that already did the work.</p><h3>Q: Prefill and decode share a GPU. Is that a problem?</h3><p>It’s a serious one, and it follows directly from <a href="https://medium.com/@HussainZaidi14/what-actually-happens-when-you-press-enter-in-chatgpt-a2747f6137dc">Part 1</a>.</p><p>Prefill is compute-hungry and bursty. Decode is bandwidth-hungry and long-running. Put them on the same GPU and they fight.</p><p>Here’s the failure you can feel as a user. Fifty people are mid-answer, happily streaming tokens. A fifty-thousand-token prefill arrives. That prefill monopolises the GPU for hundreds of milliseconds — and <strong>every one of those fifty streams stalls.</strong> One heavy request degrades everybody, and there is nothing the batching scheduler can do about it, because both jobs genuinely need the same silicon.</p><p>There’s a resource-shape problem too. If you size your GPUs for prefill you’re over-provisioned on bandwidth; size them for decode and you’re short on FLOPs. One pool cannot be right for both.</p><h3>The fix: stop making one GPU do two opposite jobs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R40b-IJSgRONvtICdxC2cg.png" /></figure><p><strong>Disaggregation</strong> splits the fleet into two pools:</p><ul><li>A <strong>prefill pool</strong>, sized for compute. It reads prompts, builds KV caches, and hands them off.</li><li>A <strong>decode pool</strong>, sized for memory bandwidth. It receives caches and streams tokens, batched hard, never interrupted by a prefill.</li></ul><p>Between them, the KV cache has to physically move from one GPU’s memory to another’s. That’s what <strong>NIXL</strong> (NVIDIA Inference Xfer Library) does — moving cache tensors over RDMA/InfiniBand, NVLink, NVMe or TCP at wire speed. It’s the transport layer that makes the whole idea practical; without it the handoff would cost more than the recomputation.</p><p>The payoff is that <strong>the two pools now scale independently</strong>:</p><ul><li>Long prompts, short answers (summarisation, RAG, code review)? Add prefill GPUs.</li><li>Short prompts, long answers (chat, agents)? Add decode GPUs.</li></ul><p>llm-d reports <strong>up to 70% higher tokens/sec</strong> from this split alone, and disaggregation is often described as giving an immediate ~25% improvement in typical deployments.</p><h3>Q: What else is at the fleet layer?</h3><p>Once you have a router that understands inference and pools that can specialise, a few more things become possible:</p><p><strong>Tiered KV offload.</strong> VRAM is the scarcest thing you own. Cache blocks that aren’t in active use can be pushed down to CPU RAM, then to local SSD, and pulled back when a matching request arrives. Much slower than VRAM — but enormously faster than recomputing prefill. On cache-heavy workloads llm-d reports up to <strong>13.9× throughput</strong> from hierarchical offload.</p><p><strong>SLO-aware autoscaling.</strong> Kubernetes’ default instinct is to scale on GPU utilisation, which is close to meaningless here — a GPU can be 100% “utilised” doing wasteful recomputation. llm-d scales on what you actually promised: TTFT and inter-token latency targets. It can also scale prefill and decode pools <em>separately</em>, which is only possible because they’re disaggregated.</p><p><strong>Wide expert parallelism.</strong> For Mixture-of-Experts models, experts are spread across many GPUs so only the ones a token routes to do work. This is what makes 671B-parameter models servable; llm-d cites <strong>~50k tokens/sec</strong> cluster throughput on this path.</p><p><strong>Flow control.</strong> In multi-tenant serving, one customer’s batch job shouldn’t starve another’s interactive traffic. Priority and fairness have to be enforced at the gateway, because by the time a request reaches a GPU it’s too late.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wyTjIXOn40zQVR3Y7uJYPg.png" /></figure><blockquote><strong>Read these numbers honestly.</strong> They come from the project’s own published v0.7 benchmarks on “well-lit paths” — tested, benchmarked reference configurations. They are ceilings under favourable, well-tuned conditions, not guarantees. Your results depend almost entirely on your traffic shape: if your prompts share no prefixes, cache-aware routing buys you nothing. Measure your own workload before believing any of it.</blockquote><h3>Q: Do I actually need any of this?</h3><p>Almost certainly not on day one. There’s a real progression here, and skipping ahead costs more than it saves:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y-0OgWGLJgE4lq2I9dK7Dg.png" /></figure><p>llm-d’s own framing is that its capabilities are <strong>composable</strong> — you adopt them one at a time as specific bottlenecks appear, not as a package. That’s good advice generally. Every layer in this series was invented to fix a measured problem in the layer below it, and adopting it without having that problem just buys you operational complexity.</p><p><strong>Measure first. The bottleneck is usually not where you assume it is</strong> — which, if this series has one theme, is it.</p><h3>The whole stack, bottom to top</h3><p>Here’s everything, in one picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ri1CLuAUy7eV0FmuM7ySxg.png" /></figure><p>Read it as a chain of consequences:</p><ol><li><strong>The GPU exists</strong> because a forward pass is billions of independent multiplications, and a CPU does them one at a time.</li><li><strong>VRAM exists</strong> because system RAM is ~52× too slow to feed thousands of cores.</li><li><strong>VRAM is small</strong>, so memory becomes the scarce resource that constrains everything above.</li><li><strong>vLLM exists</strong> because a PyTorch script isn’t a service.</li><li><strong>The KV cache exists</strong> because re-running prefill for every token would stall before every word.</li><li><strong>PagedAttention exists</strong> because naive KV allocation wastes most of your memory.</li><li><strong>Prefix caching exists</strong> because chat resends the whole thread every turn.</li><li><strong>Continuous batching exists</strong> because one weight read should serve everyone waiting, not one person.</li><li><strong>Parallelism exists</strong> because the model outgrew the card.</li><li><strong>llm-d exists</strong> because a round-robin load balancer throws away 7 and undermines 8 the moment you run more than one server.</li></ol><h3>Q: So — what actually happens when you type something into ChatGPT and press enter?</h3><p>Your message joins the rest of your thread and travels to an inference gateway. A router hashes its prefix, checks which replicas already hold that conversation, weighs their queue depths and cache pressure, and picks one.</p><p>That replica finds most of your thread already cached from your last turn, so it prefills only your newest message — possibly on a GPU pool dedicated to prefill, which then ships the resulting KV cache over RDMA to a decode pool.</p><p>There, your request slots into a batch alongside dozens of strangers. Every few milliseconds the entire model is dragged out of VRAM once, and that single read produces the next token for all of you simultaneously. Your cache grows by 128 KB. The batch is rebuilt. It happens again.</p><p>A few hundred times. And words appear on your screen.</p><p><strong>Behind that answer is a solution that is unreasonably hard to build.</strong> Now you know most of it.</p><h3>Sources and further reading</h3><ul><li><a href="https://llm-d.ai/">llm-d</a> — project site and architecture docs</li><li><a href="https://github.com/llm-d/llm-d">llm-d on GitHub</a> — well-lit paths and published v0.7 benchmarks</li><li><a href="https://llm-d.ai/docs/architecture/advanced/kv-management/prefix-cache-aware-routing">Prefix-Cache Aware Routing</a> — approximate vs precise routing</li><li><a href="https://developers.redhat.com/articles/2025/11/21/introduction-distributed-inference-llm-d">Introduction to distributed inference with llm-d</a> — Red Hat Developer</li><li><a href="https://developers.redhat.com/articles/2025/05/20/llm-d-kubernetes-native-distributed-inferencing">llm-d: Kubernetes-native distributed inferencing</a> — the original announcement</li><li><a href="https://docs.vllm.ai/en/latest/deployment/integrations/llm-d/">vLLM docs: llm-d integration</a></li><li><a href="https://docs.vllm.ai/en/v0.9.0/design/automatic_prefix_caching.html">vLLM docs: Automatic Prefix Caching</a></li><li><a href="https://vllm.ai/blog/2025-09-05-anatomy-of-vllm">Inside vLLM: Anatomy of a High-Throughput LLM Inference System</a></li><li><a href="https://github.com/ai-dynamo/nixl">NIXL</a> — NVIDIA Inference Xfer Library</li><li><a href="https://docs.vllm.ai/en/stable/features/nixl_connector_usage/">vLLM NixlConnector usage guide</a></li></ul><p><em>This was Part 3 of 3. </em><a href="#"><em>Part 1: From a GPU to a Model Server</em></a><em> · </em><a href="#"><em>Part 2: The Hidden Cache</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05f69ce9b274" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Hidden Cache That Makes ChatGPT Feel Fast]]></title>
            <link>https://medium.com/@HussainZaidi14/the-hidden-cache-that-makes-chatgpt-feel-fast-7de291478af4?source=rss-36248d2e9efa------2</link>
            <guid isPermaLink="false">https://medium.com/p/7de291478af4</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[vllm]]></category>
            <category><![CDATA[gpu]]></category>
            <dc:creator><![CDATA[Syed Hussain Haider Zaidi]]></dc:creator>
            <pubDate>Mon, 31 Aug 2026 19:00:41 GMT</pubDate>
            <atom:updated>2026-09-01T03:32:50.102Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aRUNxgSNUE5pq8nPCSxb3A.png" /></figure><p>Part 2 of 3 — The KV Cache, Many Users on One GPU, and Serving Giant Models</p><h3>Where we left off</h3><p><a href="https://medium.com/@HussainZaidi14/what-actually-happens-when-you-press-enter-in-chatgpt-a2747f6137dc">Part 1</a> followed a single keystroke down to the metal. The short version:</p><ul><li><strong>A model is a big file of weights</strong> — roughly 2 GB per billion parameters at FP16.</li><li><strong>GPUs win</strong> because a forward pass is billions of <em>independent</em> multiplications, and GPUs have thousands of lanes where a CPU has a handful.</li><li><strong>VRAM exists</strong> because system RAM over PCIe (~64 GB/s) is about 52× too slow to feed those lanes. VRAM is spectacularly fast and, at 80–192 GB, spectacularly small.</li><li><strong>vLLM</strong> turns a PyTorch script into a real server that loads the weights once and stays hot.</li><li><strong>Every request has two halves with opposite bottlenecks.</strong> <em>Prefill</em> reads your whole prompt in one compute-bound burst — that’s the pause, measured as TTFT. <em>Decode</em> then generates one token at a time, and each token requires <strong>re-reading the entire model out of VRAM</strong> — that’s the stream, measured as TPOT.</li><li>Which gives a hard ceiling: 3,350 GB/s ÷ 16 GB ≈ 209 tokens/sec for one user on an H100.</li></ul><p>And it ended on a problem.</p><p>If decode has to push everything through the model to produce each token, then generating word #200 means re-processing your prompt <em>and</em> the 199 words already written. Every single time. Every word would have a fresh pause in front of it, and the product would be unusable.</p><p>That’s not what happens. Words come out smoothly. <strong>So what is being saved?</strong></p><h3>Q: What is the KV cache?</h3><p>The prefill step is the expensive one. It burns a lot of GPU to read your prompt and work out an internal representation of it.</p><p>The naive implementation throws all of that away the instant it’s done, and recomputes it for the next token. The obvious fix is the right one:</p><p><strong>Don’t throw it away. Keep it in GPU memory.</strong></p><p>That saved work has a name — the <strong>KV cache</strong> — and it is the single most important object in LLM serving.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r7pSrKnheO8I4W1L9wlywA.png" /></figure><p>The name comes from the attention mechanism, which computes three things per token: a Query, a Key, and a Value. The Keys and Values for a token never change once computed — they don’t depend on anything that comes after. So they can be cached.</p><p>The flow becomes:</p><pre>your prompt  ──▶  PREFILL  ──▶  KV CACHE  ──▶  DECODE<br>                 (runs once)   (lives in VRAM)  (reads the cache,<br>                                                 appends one token,<br>                                                 writes back)</pre><p>Prefill runs <strong>exactly once</strong> per request. From then on, as the model writes the answer one token at a time, it never repeats prefill. It reaches into the cache, reuses everything it already worked out, and adds one new token on top.</p><p>That’s why the pause happens once, at the beginning, and the stream is smooth after.</p><h3>Q: If the cache is such a win, why not cache everything forever?</h3><p>Because the cache lives in VRAM, and VRAM is the scarce resource. Every gigabyte the cache takes is a gigabyte the next user can’t have.</p><p>Let’s do the arithmetic, because the result is genuinely surprising.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k2pgROBEyoecD2WDkwUCZA.png" /></figure><p>For Llama-3–8B — 32 layers, 8 key/value heads (it uses grouped-query attention), head dimension 128, FP16:</p><pre>2 (K and V) × 32 layers × 8 KV heads × 128 dims × 2 bytes  =  128 KB per token</pre><p><strong>128 KB. Per token. Per user.</strong></p><p>Worth noting what GQA saves you here: without it, using all 32 attention heads for keys and values, that figure would be <strong>512 KB per token</strong> — four times worse. Grouped-query attention is not an accuracy trick, it’s a serving-economics trick.</p><p>Now budget an 80 GB H100:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v8Q557FWiUIIJlANStAfzw.png" /></figure><pre>60 GB ÷ 128 KB  ≈  490,000 tokens of cache</pre><p>That is your <strong>entire concurrency budget</strong>. Spend it how you like:</p><ul><li>~50 users each holding a 10,000-token conversation, or</li><li>~490 users each holding a 1,000-token one</li></ul><p><strong>This is the thing people get wrong.</strong> They assume concurrency is limited by compute. It isn’t. It’s limited by KV cache memory, and long contexts eat it alive. Doubling your context window halves how many people you can serve.</p><h3>The other half of the answer: PagedAttention</h3><p>There’s a second problem hiding here. If you naively reserve a contiguous block of memory for each request’s maximum possible length, you waste enormous amounts of it — a request that <em>might</em> generate 4,000 tokens but stops at 200 has 95% of its reservation sitting empty.</p><p>vLLM’s founding idea is to steal the solution operating systems worked out decades ago. <strong>PagedAttention</strong> stores the KV cache in small fixed-size blocks and gives each sequence a page table mapping logical positions to physical blocks — exactly like OS virtual memory.</p><p>Two things fall out of that:</p><ol><li><strong>No fragmentation.</strong> Blocks are allocated as they’re needed, not reserved up front.</li><li><strong>Sequences can share physical blocks.</strong> If two requests start with the same system prompt, that prefix occupies memory <em>once</em>.</li></ol><p>That second property is about to become very important.</p><h3>Q: My first message is fast. Why does my fifth feel slower?</h3><p>Because the model <strong>remembers nothing between messages.</strong></p><p>This surprises people who assume the conversation “lives” on the server. It doesn’t. Each API call is stateless. So your chat app resends the <strong>entire thread every single time</strong>: your first question, the model’s first answer, your second question, its second answer, and your new message — all bundled into one request.</p><p>Which means, without further tricks: the server re-reads every word from the very beginning before it can reply. Every turn rebuilds all that work from scratch and then throws it away.</p><p><strong>So the longer you talk, the longer you wait.</strong> The cost of a conversation grows with every message, because it redoes the prefill for the whole thread on every turn.</p><h3>Q: So what if we just… didn’t throw the cache away?</h3><p>Right. Instead of clearing those cached blocks the moment the request ends, hang on to them — and <strong>label each block by the exact text that produced it.</strong></p><p>Now turn 3 arrives. The router hands the model your whole thread. The model looks at it and realises it has already done the work for all of it except your newest message. That newest message is the only part it has to prefill.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oQxDiCMlVZpWAU-h2HwaLQ.png" /></figure><p>The bars tell the story. Without prefix caching, prefill cost climbs every turn — turn 3 re-prefills 1,480 tokens. With it, turn 3 prefills only the ~130 tokens that are actually new. Turn 10 stays just as cheap.</p><p><strong>This is called prefix caching</strong> — in vLLM, <em>Automatic Prefix Caching (APC)</em>. The mechanism is simple and elegant:</p><p>vLLM hashes each 16-token block of the prompt <strong>together with the hash of every block before it</strong>. Identical prefix → identical chain of hashes → the blocks are already sitting in the pool, and prefill skips them entirely.</p><p>Because the hash chains the prefix, it’s exact: a match means the preceding text is genuinely identical, not merely similar.</p><p>Two workloads where this is enormous:</p><ul><li><strong>Multi-turn chat.</strong> Every turn shares a prefix with the last one.</li><li><strong>A long shared system prompt.</strong> A 2,000-token instruction block prepended to every request in your product gets prefilled once, for everybody.</li></ul><blockquote><strong>One caution.</strong> Prefix caching only helps when prefixes actually repeat, and cached blocks are evicted under memory pressure like any other cache. If every request is unique, you get nothing — and you’ve spent memory to get it.</blockquote><h3>Q: How does one GPU serve fifty people at the same time?</h3><p>Come back to the fact from <a href="https://medium.com/@HussainZaidi14/what-actually-happens-when-you-press-enter-in-chatgpt-a2747f6137dc">Part 1</a>: <strong>to produce one token, the GPU must read the entire model out of memory.</strong> On an H100 with an 8B model, that read is ~4.8 ms and it is the dominant cost.</p><p>Now ask the obvious question.</p><p><em>If the GPU has to drag all 16 GB out of memory anyway — why should that read only produce one token, for one user?</em></p><p>It shouldn’t. Load the weights once, and while they’re there, use them to compute the next token for <strong>every user currently waiting.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kZ2WGhRJNueqUK99GnOITA.png" /></figure><p>One read of the <strong>weights</strong> gives you one token for one user — or 64 tokens for 64 users. <strong>It’s the same single read.</strong></p><p>This is <strong>batching</strong>, and it is why serving economics work at all. But the weights are only half of what the GPU reads, and the other half does not behave like this.</p><h3>What batching amortizes — and what it doesn’t</h3><p>The weights are <em>shared</em>. Every sequence in the batch runs through the same 16 GB, so that read is paid once and split across everybody.</p><p><strong>The KV cache is not shared.</strong> Every sequence has its own, and attention has to read <em>all</em> of that sequence’s cache on <em>every</em> decode step. Fifty conversations means fifty separate caches dragged out of VRAM, every step. Nothing amortizes — the cost scales straight with batch size × context length.</p><pre>weights     16 GB                       ← read once, split across the batch<br>KV cache    batch × context × 128 KB    ← read per sequence, every step</pre><p>Which means the memory budget from earlier in this article is also a <strong>bandwidth</strong> budget. Fill that ~60 GB cache pool and the GPU is reading 76 GB per decode step, not 16 GB. The part that was supposed to be free is now four times larger than the part you amortized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SpG5mZFKERvFqaBhTN_TnA.png" /></figure><p>So the honest version of the claim: <strong>throughput scales enormously; per-user latency does not stay flat.</strong> With short conversations it barely moves — 4.8 ms per token becomes ~7 ms and nobody notices. At the 10,000-token contexts real products actually run, it becomes ~22 ms: a <strong>4–5× slower stream</strong> for every user, on the same hardware, serving fewer of them.</p><p>The free lunch is real. It’s just priced in context length.</p><h3>Why “continuous” batching</h3><p>There’s a catch. Requests don’t finish together. One user wants 20 tokens, another wants 800.</p><p>Naive <em>static</em> batching collects a batch, runs it to completion, and only then starts the next. The 20-token request finishes in step 20 — and its slot then sits idle for 780 steps waiting for its batchmates. You’ve paid for a GPU and left most of it empty.</p><p><strong>Continuous batching</strong> (also called iteration-level scheduling) rebuilds the batch <strong>every single decode step</strong>. The moment a request finishes, its slot is handed to a waiting request on the very next step. No bubbles.</p><p>PagedAttention is what makes this practical — you can only slot requests in and out freely if their memory isn’t locked into rigid contiguous reservations.</p><blockquote>Together, PagedAttention plus continuous batching are the reason vLLM delivers roughly 2–4× the throughput of a naive serving loop on the same hardware.</blockquote><h3>The walls batching runs into</h3><p>The textbook answer is that batching ends when you go <strong>compute</strong>-bound: enough math per weight read that the cores, not the bus, become the limit. On an H100 with short prompts that crossover sits somewhere in the low hundreds of concurrent sequences.</p><p>You will almost never get there, because the KV cache puts up two walls first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LrWesSa-uO6etv2O3wq2Gw.png" /></figure><p><strong>The bandwidth wall</strong> is the one we just did the arithmetic for. Per-step traffic grows with batch × context, so each extra user adds memory traffic rather than absorbing it. With 10,000-token conversations, the KV read overtakes the entire 16 GB weight read at about <strong>13 concurrent users</strong> — and past that point every user you admit is buying throughput with everybody else&#39;s latency.</p><p><strong>The capacity wall</strong> is the one you hit right after: you simply run out of room to hold everyone’s conversation. Compute is nowhere near saturated when this happens.</p><p>Look at what the GPU’s memory is actually doing in that picture. One block never changes size: the model weights. Everything else is <strong>everyone’s KV cache</strong>, one slice per live conversation — and each new user you admit carves off another slice. At 10,000-token conversations you fit about 46 of them. Let those conversations run to 20,000 tokens and you fit 23, on exactly the same hardware, with the cores no busier than before.</p><p>Which brings the two halves of this article together — <em>the cache is what limits the batch, and the batch is what pays for the GPU.</em> The KV cache bills you twice for the same gigabytes: once in <strong>capacity</strong>, for how many people you can hold at all, and again in <strong>bandwidth</strong>, for how fast you can serve any of them. Context length and concurrency are not two budgets. They are one budget, spent twice.</p><h3>Q: What if the model doesn’t fit on one GPU at all?</h3><p>Llama-3–70B is 140 GB in FP16. An H100 holds 80 GB. Even a B200’s 192 GB leaves you fighting for KV cache space. And frontier MoE models run to hundreds of gigabytes.</p><p>So you split the model across several GPUs. Together they hold what none of them holds alone. The general term is <strong>sharding</strong>, but the useful question is <em>how</em> you cut it — and there are two answers with very different characteristics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AOe6j0IRURpgqa8AfG4Pzg.png" /></figure><h3>Pipeline parallelism — split by layer</h3><p>GPU 0 holds layers 1–40. GPU 1 holds layers 41–80. A token goes through GPU 0, and its output is handed to GPU 1.</p><ul><li><strong>Good:</strong> communication is minimal — one handoff between stages.</li><li><strong>Bad:</strong> GPU 1 sits idle while GPU 0 works, unless you keep enough requests in flight to keep the pipeline full.</li></ul><h3>Tensor parallelism — split within a layer</h3><p>Every weight matrix is cut into pieces. GPU 0 holds half of every matrix; GPU 1 holds the other half. Both work on every token simultaneously and combine results.</p><ul><li><strong>Good:</strong> no idling. Every GPU contributes to every token, so latency drops.</li><li><strong>Bad:</strong> they must exchange results (an all-reduce) at <strong>every layer</strong>. That demands serious interconnect.</li></ul><h3>The rule of thumb</h3><blockquote><strong>Tensor-parallel within a node, where NVLink gives you ~900 GB/s between cards. Pipeline-parallel across nodes, where you’re stuck with the network.</strong></blockquote><p>Run tensor parallelism over PCIe or Ethernet and the interconnect becomes your bottleneck — you’ll have bought eight GPUs to go slower than four.</p><p>For Mixture-of-Experts models there’s a third axis: <strong>expert parallelism</strong>, where different experts live on different GPUs and only the experts a token actually routes to do any work. This is what makes 671B-parameter models economically servable at all, and it comes back in Part 3.</p><p>In vLLM these are flags — --tensor-parallel-size 4, --pipeline-parallel-size 2. The engine handles the splitting. Choosing the right combination for your hardware topology is the actual skill.</p><h3>What we’ve built so far</h3><p>Adding Part 2’s layers to <a href="https://medium.com/@HussainZaidi14/what-actually-happens-when-you-press-enter-in-chatgpt-a2747f6137dc">Part 1</a>&#39;s:</p><ul><li><strong>The KV cache</strong> stores prefill’s output so decode never redoes it. It’s why the pause happens once, not before every word.</li><li><strong>It costs ~128 KB per token</strong> for an 8B model — so KV memory, not compute, is what caps concurrency. ~60 GB of an H100 ≈ 490,000 cached tokens.</li><li><strong>PagedAttention</strong> manages that memory like OS virtual memory: no fragmentation, and shared prefixes stored once.</li><li><strong>Prefix caching</strong> keeps blocks across requests and hashes them by content, so turn 10 of a chat costs about what turn 2 did.</li><li><strong>Continuous batching</strong> amortises the <em>weight</em> read across every waiting user — throughput scales by an order of magnitude. It does <strong>not</strong> amortise the KV read, which is per-sequence and paid every step — so per-user latency degrades with context length (~7 ms/token at 1k contexts, ~22 ms with the cache pool full).</li><li><strong>Tensor / pipeline / expert parallelism</strong> spread one model over many GPUs when it no longer fits on one.</li></ul><p>Every one of these is a property of <strong>a single server</strong> — one box, one copy of the model, one KV cache pool.</p><h3>Q: So we’re done, right? Just run this on 200 servers?</h3><p>That’s the natural next move, and it’s where it all quietly falls apart.</p><p>A real service can’t run on one box — you have to serve the whole world. So you run a fleet: many servers, each with its own GPUs and its own complete copy of the model. You put a load balancer in front. Traffic goes round-robin. Standard, boring, well-understood infrastructure.</p><p>Except: <strong>every optimisation in Part 2 is per-server state.</strong></p><p>That KV cache you carefully preserved across turns? It lives on <strong>one specific machine</strong>. Your next message will be sent to a different one, by a load balancer that has no idea any of this exists — and the work gets thrown away after all.</p><h3>Coming in Part 3 — Why Load Balancing Falls Apart, and What llm-d Does About It</h3><p>Part 3 is the fleet layer:</p><ul><li>Why <strong>round-robin actively makes an LLM service worse</strong>, in two distinct ways</li><li>What a <strong>cache-aware router</strong> is, and how it knows what each replica is holding</li><li>Why running prefill and decode on the same GPU makes them fight — and what <strong>disaggregating</strong> them buys</li><li>What <strong>llm-d</strong> is, how it fits with vLLM and Kubernetes, and the numbers it publishes</li><li>And the finished picture: the complete stack, bottom to top</li></ul><p><em>This is where the hard problems live. See you there.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7de291478af4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Actually Happens When You Press Enter in ChatGPT]]></title>
            <link>https://medium.com/@HussainZaidi14/what-actually-happens-when-you-press-enter-in-chatgpt-a2747f6137dc?source=rss-36248d2e9efa------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2747f6137dc</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[gpu]]></category>
            <category><![CDATA[nvidia]]></category>
            <dc:creator><![CDATA[Syed Hussain Haider Zaidi]]></dc:creator>
            <pubDate>Sun, 30 Aug 2026 07:22:22 GMT</pubDate>
            <atom:updated>2026-09-01T03:12:13.335Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PQjY_RgpuQMLHk8eeXGnAA.png" /></figure><p>Part 1 of 3 — From a GPU to a Model Server, and How a Model Generates Text</p><p>You type a question. You press enter. There is a short pause, a second, maybe two, and then words start appearing, one after another, fast enough that you never really think about it.</p><p>That pause is not a loading spinner. It is a specific, expensive piece of computation. And the smoothness that follows it is not the absence of work, it is the presence of about six different optimization, stacked on top of each other, each one invented because the layer underneath it was too slow to ship.</p><p><strong>This series takes that one keystroke and follows it all the way down.</strong></p><p>By the end of Part 3 you will be able to answer, precisely:</p><ul><li>Why serving a language model needs a GPU, and what specifically breaks without one</li><li>Why the answer pauses before it starts, and why it streams after</li><li>What the KV cache is, why it is the single most important object in LLM serving, and what it costs you in memory</li><li>How one GPU serves fifty people at once without any of them noticing</li><li>What happens when the model is physically too large for any single card</li><li>Why the load balancer your company already runs will actively make an LLM service worse</li><li>And what the current generation of infrastructure , vLLM at the box level, llm-d at the fleet level, actually does about all of it</li></ul><p>This is a stack. Each layer exists <strong>only</strong> because the layer below it left something on the table. So we build it from the bottom.</p><p>Part 1 covers the bottom two layers: the hardware, and what the model does with a single request.</p><h3>Q: What even is a model?</h3><p>Strip away every bit of mystique and a model is a formula:</p><pre>input  ×  weights  =  output</pre><p>That’s it. A bigger formula with more weights is a better formula. The particular arrangement of that formula, the one that turned out to scale absurdly well when you made it enormous — is the Transformer.</p><p>So a model, as a <em>thing on your computer</em>, is just a very large file. Everything inside it is the weights that fell out of training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eQIjcWk8r_TNkZjoAmggBA.png" /></figure><p>A quick note on that last row, because the arithmetic looks wrong: 671 billion parameters at the usual 2 bytes each would be ~1.3 TB. DeepSeek-V3 is trained and shipped natively in <strong>FP8</strong>, one byte per weight, so it lands near 700 GB. This is your first hint that <em>precision is a lever</em>, and we’ll pull it again later.</p><p><strong>The number to remember: at FP16, a model costs roughly 2 GB of memory per billion parameters.</strong> Halve the precision and you halve the bill.</p><h3>Q: So why can’t I just run this on my laptop?</h3><p>Let’s look at what a normal computer actually does.</p><pre>[ CPU ] ──── reads the numbers ────▶ [ RAM ]<br>   ▲                                    │<br>   └──────── writes them back ──────────┘<br> the processor                       the memory</pre><p>Under the hood, one pass through the model is billions of multiplications. The crucial property: <strong>those multiplications do not depend on each other.</strong> Nothing in row 400 needs the answer from row 399. They can all happen at the same time.</p><p>A CPU is built for the opposite situation. It has a handful of very sophisticated cores, each one brilliant at doing one complicated thing quickly, then the next thing, then the next. Give a CPU a billion independent tiny multiplications and it will do them beautifully, one at a time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S_p5E77U8mgja9MnYMvekA.png" /></figure><p>A GPU has thousands of tiny, dumb cores. Each one is worse than a CPU core in every way except the one that matters here: there are thousands of them, and they can all do the same operation to different numbers simultaneously.</p><ul><li>CPU: ~1–3 TFLOPS. A few big cores.</li><li>GPU (H100): ~990 TFLOPS. Thousands of small cores.</li></ul><blockquote><strong>TFLOPS</strong> — trillions of FLoating-point OPerations per Second. It’s the raw rate at which a chip can multiply and add numbers. One TFLOPS is a trillion of those every second, so an H100 at ~990 TFLOPS is doing roughly a quadrillion multiply-adds per second. It’s the “compute” figure on every spec sheet — and, as we’re about to see, not the figure that ends up mattering most.</blockquote><p>The model’s math is <em>embarrassingly parallel</em>. So the hardware that wins is the one with the most lanes, not the fastest lane.</p><h3>Q: Fine, the GPU has the cores. Why does it need its own memory too?</h3><p>This is the question that explains almost everything that follows, so it’s worth slowing down.</p><p>A processor is useless if you can’t feed it. System RAM sits off the card, at the other end of a PCIe bus. PCIe 5.0 ×16 — current, good hardware — carries about <strong>64 GB/s</strong>.</p><p>Now: an H100’s cores can consume data at <strong>3,350 GB/s</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AajWhqbr8JS1imG2YKB2zg.png" /></figure><p>That’s roughly a <strong>52× gap</strong>. For a CPU doing a few things at a time, 64 GB/s is plenty. For thousands of GPU cores all screaming for numbers at once, it’s a drinking straw. The cores would spend virtually all their time idle, waiting.</p><p>So the fix is physical: put the memory <strong>on the card</strong>, packed tightly against the cores. That’s VRAM — HBM stacks soldered millimetres from the silicon. The data never has to travel far.</p><p>VRAM is spectacularly fast. It is also, for the same physical reasons, <strong>small</strong>: 80 to 192 GB, where a server motherboard will happily hold a terabyte of ordinary RAM.</p><p><strong>Fast but small.</strong> Every single design decision in the rest of this series is downstream of that trade.</p><h3>Q: What do the three numbers on a spec sheet mean?</h3><p>When you look at any accelerator, three numbers matter — and they matter for different reasons:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y6qHBjPdgIxJcpS39oqXsg.png" /></figure><ul><li><strong>Compute</strong> (TFLOPS) is how much math you can do per second.</li><li><strong>Memory</strong> (GB) is how big a model you can hold — and, as we’ll see in <a href="https://medium.com/@HussainZaidi14/the-hidden-cache-that-makes-chatgpt-feel-fast-7de291478af4">Part 2</a>, how many users you can serve at once.</li><li><strong>Bandwidth</strong> (TB/s) is the pipe between the two — how fast you can move data from memory into the cores. It is the least glamorous number and, for text generation, the most important one.</li></ul><p>Notice that H100 → H200 changed <em>nothing</em> about compute. It added bandwidth and memory. That tells you where the industry thinks the bottleneck is.</p><h3>Q: I’ve got a GPU and I’ve downloaded the model file. Can I just run it?</h3><p><strong>Yes. Genuinely — and it’s worth doing, because it makes everything after this concrete.</strong></p><p>The missing piece is <strong>PyTorch</strong>: the library that actually performs the model’s math on your GPU. Remember that a model is just a big pile of numbers. Something has to read those numbers, arrange them into matrices, ship them to the GPU, and run the multiplications in the right order. That’s PyTorch. It’s the standard tool for it, and essentially every open model you can download is built to be run this way.</p><p>In practice it’s about five lines:</p><pre>from transformers import AutoModelForCausalLM, AutoTokenizer<br><br>model = AutoModelForCausalLM.from_pretrained(<br>    &quot;meta-llama/Meta-Llama-3-8B-Instruct&quot;, device_map=&quot;cuda&quot;)   # 16 GB → VRAM<br>tok = AutoTokenizer.from_pretrained(&quot;meta-llama/Meta-Llama-3-8B-Instruct&quot;)<br>ids = tok(&quot;Why is the sky blue?&quot;, return_tensors=&quot;pt&quot;).to(&quot;cuda&quot;)<br>print(tok.decode(model.generate(**ids, max_new_tokens=100)[0]))</pre><p>Run it. It waits a minute or two, then prints an answer.</p><p><strong>That is a real large language model, running on your machine, answering your question.</strong> No API key, no cloud. If your mental image of “an LLM” was something that only exists inside OpenAI’s data centre, this is the moment to update it — the model is a file, and PyTorch runs it.</p><p>So why does anyone need anything else?</p><h3>Q: So why doesn’t OpenAI just run that script?</h3><p>Because look closely at what that script actually does:</p><ol><li>It starts.</li><li>It loads 16 GB of weights into VRAM, a minute or two of waiting.</li><li>It answers <strong>one</strong> prompt.</li><li>It exits, and the 16 GB is wiped from VRAM.</li></ol><p>Ask a second question and you pay that minute-long load <strong>again</strong>. And notice who this serves: <strong>you.</strong> Only you. Sitting at that terminal. There is no way for anyone else on earth to send it a prompt no network, no address, no queue.</p><p><strong>A script isn’t a service.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JJHrORETXIlFFFF2BWcj4Q.png" /></figure><p>The obvious patch is to wrap it in a small web server — load the model once at startup, expose a /generate endpoint — and that&#39;s a real improvement. It&#39;s also where the actual problems begin:</p><ul><li><strong>Two people at once?</strong> The second request waits for the first to finish completely. Not “shares the GPU” — <em>waits</em>. Ten users and your tenth is queuing behind nine full answers.</li><li><strong>Every request is a fresh start.</strong> Your follow-up message re-does all the work of your first one, as we’ll see shortly.</li><li><strong>The GPU is mostly idle anyway.</strong> For reasons that will be clear by the end of this article, generating for one user leaves most of the hardware you’re paying for doing nothing.</li></ul><p>None of these are bugs in your code. They’re the difference between <strong>running</strong> a model and <strong>serving</strong> one, and closing that gap is a genuinely hard systems problem, which is what the rest of this series is about.</p><p>That’s the gap <strong>vLLM</strong> fills. vLLM is built on PyTorch, same math underneath, but wraps a model into a real server with an ordinary web API: the same OpenAI-shaped /v1/chat/completions endpoint everything already speaks. Everything in Parts 2 and 3 is a technique that lives inside or above that server.</p><h3>Q: What does that server actually do when it boots?</h3><p>You run something like:</p><pre>vllm serve meta-llama/Meta-Llama-3-8B-Instruct</pre><p>And then you wait. vLLM reads the model weights off disk and loads them into GPU memory. That’s 16 GB to move, so you’re waiting a minute or two. Then the server is up, warm, and sitting there holding those weights in VRAM, waiting for a request.</p><p>From that point on, talking to it is just an HTTP call.</p><p><strong>A model server is a heavy beast: expensive to run, slow to start, and therefore something you keep alive rather than spin up on demand.</strong> Nobody boots a model server per request. It stays hot. Remember this, it’s why the fleet problems in Part 3 are hard.</p><h3>Q: What is the model really doing between reading my prompt and handing back text?</h3><p>Here’s the first thing that surprises people: <strong>a language model does not read or write whole words.</strong></p><p>It breaks text into small pieces called <strong>tokens</strong>. Sometimes a token is a whole word, often it’s a fragment — serv, ing, ., &quot; the&quot;. Roughly, 1 token ≈ 4 characters of English.</p><p>And then the model does exactly one thing, over and over: <strong>it predicts the next token.</strong></p><pre>&quot;Serving an LLM&quot;                    ──▶ model ──▶  &quot; needs&quot;<br>&quot;Serving an LLM needs&quot;              ──▶ model ──▶  &quot; a&quot;<br>&quot;Serving an LLM needs a&quot;            ──▶ model ──▶  &quot; GPU&quot;</pre><p>That’s the whole trick. Append the prediction to the input, feed it back in, predict again. A loop.</p><p>Two consequences fall straight out of this, and they shape everything:</p><ol><li><strong>Requests take a long time.</strong> A 500-token answer is 500 laps of that loop. Not one operation — five hundred.</li><li><strong>No two requests cost the same.</strong> One user sends 20 tokens and wants 20 back. Another pastes a 50,000-token document and wants a one-line summary. Same endpoint, wildly different cost.</li></ol><p>Hold on to point 2. It is the reason Part 3 exists.</p><h3>Q: What happens inside that loop?</h3><p>Think about the actual experience of using ChatGPT. You paste a big chunk of text, hit enter, and:</p><p><strong>there is a pause, </strong>a second or two where nothing happens, <strong>and then the answer streams out, word by word.</strong></p><p>Those are two genuinely different pieces of work with two different names and two different bottlenecks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p0LUYuJYjVVHN4lVK03mgQ.png" /></figure><h3>The pause — prefill</h3><p>Before the model can write a single word, it has to read everything you gave it. The whole prompt. And it reads it <strong>all at once, </strong>every token goes through the model in one enormous parallel burst, every core firing.</p><p>The metric is <strong>TTFT — Time To First Token.</strong> It’s the pause you feel.</p><p>Prefill is <strong>compute-bound</strong>. It’s a huge matrix multiplication and the limit is raw FLOPs. Longer prompt → longer pause.</p><h3>The stream — decode</h3><p>Then the loop starts. One token, then the next, then the next. The metric is <strong>TPOT — Time Per Output Token</strong>, the gap between words.</p><p>And here is the part that seems backwards the first time you hear it:</p><p><strong>To produce one single token, the GPU has to read the entire model out of VRAM.</strong></p><p>All 16 GB. To generate one word. Then it does it again for the next word.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e86UNSCR-3u0E2qDs0xugQ.gif" /></figure><p>A 200-token answer means loading the entire model out of memory, start to finish, <strong>200 times</strong>. Decode is <strong>memory-bandwidth-bound</strong>. The cores are barely working, there’s almost nothing to parallelize when you’re processing one token. They’re just waiting for weights to arrive.</p><p>Same model. Same request. <strong>Opposite bottlenecks.</strong></p><h3>Q: So how fast can this possibly go?</h3><p>Since decode is limited by how fast you can drag the model out of memory, the ceiling is just division:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D0mdrrw0eAaSxL4nADrz8g.png" /></figure><pre>3,350 GB/s  ÷  16 GB  ≈  209 full model reads per second</pre><p>One read gives you one token. So for a single user on an H100 running Llama-3-8B, the theoretical floor is <strong>TPOT ≈ 4.8 ms</strong>.</p><p>Treat that as a <strong>ceiling, not a promise</strong>. It assumes perfect bandwidth utilization and ignores attention over the KV cache, kernel launch overhead, and sampling. Real single-stream decode on an 8B model lands nearer 10–30 ms per token.</p><p>But the number is still the right mental model, because it tells you which knob to turn. <strong>Halve the model size, quantize those FP16 weights to FP8, and you roughly double the ceiling. Add more cores and literally nothing happens.</strong></p><p>That single insight is worth more than most performance tuning.</p><h3>What we&#39;ve built so far</h3><p>Reading top to bottom, here&#39;s the picture at the end of Part 1:</p><ul><li>A model is a big file of weights. ~2 GB per billion parameters at FP16.</li><li>CPUs can&#39;t serve it, because the work is massively parallel and CPUs are built for the opposite.</li><li>GPUs can, but only because the memory sits <em>on the card</em>. System RAM is ~52× too slow to feed them.</li><li>VRAM is fast but small, and everything downstream is a consequence of that.</li><li>PyTorch runs the math; vLLM turns it into a service that stays hot.</li><li>Every request splits into <strong>prefill</strong> (compute-bound, the pause, TTFT) and <strong>decode</strong> (bandwidth-bound, the stream, TPOT).</li><li>Decode re-reads the entire model for every single token.</li></ul><h3>Q: But hang on — if every token needs a full pass over the model, why doesn&#39;t the answer stall before every single word?</h3><p>Good. That&#39;s exactly the right question, and it&#39;s the crack the entire next layer is built into.</p><p>If decode really had to redo prefill for every token, ChatGPT would pause before every word and be unusable. It doesn&#39;t. Words come out smoothly, one after another, with no repeated stall.</p><p>Something is being saved.</p><h3>Coming in Part 2 — The Hidden Cache, Many Users on One GPU, and Serving Giant Models</h3><p><a href="https://medium.com/@HussainZaidi14/the-hidden-cache-that-makes-chatgpt-feel-fast-7de291478af4">Part 2</a> picks up right here and answers:</p><ul><li><strong>What is the KV cache</strong>, and why is it the most important object in LLM serving?</li><li>What does that cache <strong>cost you in VRAM</strong> — and why is it, not compute, that caps how many users you can serve?</li><li>Why does your fifth message in a chat cost more than your first — and how does <strong>prefix caching</strong> flatten that curve?</li><li>How does a single GPU serve fifty people at once and <strong>how much does each of them pay for it</strong>?</li><li>What do you do when the model is 140 GB and your biggest card is 80 GB?</li></ul><p><a href="https://medium.com/@HussainZaidi14/the-hidden-cache-that-makes-chatgpt-feel-fast-7de291478af4"><em>Part 2</em></a><em> is where the big wins live and where you find out what they cost. See you there.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2747f6137dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Techniques for Crafting Effective Prompts in Generative AI]]></title>
            <link>https://medium.com/@HussainZaidi14/techniques-for-crafting-effective-prompts-in-generative-ai-d13777f5962f?source=rss-36248d2e9efa------2</link>
            <guid isPermaLink="false">https://medium.com/p/d13777f5962f</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[writing-prompts]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Syed Hussain Haider Zaidi]]></dc:creator>
            <pubDate>Sat, 29 Aug 2026 20:50:50 GMT</pubDate>
            <atom:updated>2026-08-29T20:50:50.912Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kj8RHrjI5hwL-cTm_BrMiw.png" /></figure><p>In the rapidly evolving world of Generative AI, the quality of prompts can make or break the success of AI-driven projects. Prompts serve as the input that guides AI models in generating outputs, whether it be text, images, or code.</p><p>Crafting effective prompts requires a blend of creativity, precision, and an understanding of how AI models interpret language.</p><p>In this article, we will explore some techniques that we can use to prompt an LLM. Let’s explore them.</p><h3><strong>1. Zero-shot prompting:</strong></h3><p><strong>Zero-shot prompting</strong> means asking the model to perform a task without providing examples of how the task should be completed.</p><p>For example:</p><blockquote><strong><em>Prompt:</em></strong><em><br> “Classify the following customer review as positive, negative, or neutral:<br> ‘The product arrived quickly, but the packaging was damaged.’”</em></blockquote><p>The model must infer what “positive,” “negative,” and “neutral” mean from the instruction itself. Zero-shot prompting is useful for straightforward tasks where the desired behavior can be clearly described.</p><p>A stronger version makes the output format explicit:</p><blockquote><strong><em>Prompt:</em></strong><em><br>“Classify the following customer review as positive, negative, or neutral. Return only one label.<br>Review: ‘The product arrived quickly, but the packaging was damaged.’”</em></blockquote><p>The second prompt reduces ambiguity by specifying the expected output.</p><h3><strong>2. Few-shot prompting:</strong></h3><p><strong>Few-shot prompting</strong> provides the model with a small number of examples before asking it to perform the task. The examples demonstrate the pattern the model should follow.</p><p>For example:</p><blockquote><strong><em>Prompt:</em></strong><em><br>“Convert informal language into professional language.</em></blockquote><blockquote><em>Informal: ‘Can you fix this ASAP?’<br>Professional: ‘Could you please resolve this issue as soon as possible?’</em></blockquote><blockquote><em>Informal: ‘I need the report today.’<br>Professional: ‘Could you please provide the report by the end of today?’</em></blockquote><blockquote><em>Informal: ‘This isn’t working.’<br>Professional:”</em></blockquote><p>The examples establish the expected transformation, allowing the model to continue the pattern.</p><p>Few-shot prompting can be particularly useful when the task involves a specific format, style, or classification scheme that may be difficult to describe precisely in words.</p><h3><strong>3. Chain-of-thought:</strong></h3><p><strong>Chain-of-thought prompting</strong> encourages a model to approach a problem through intermediate reasoning steps rather than immediately producing an answer. The original research showed that prompting models to produce a reasoning process can improve performance on some reasoning tasks. However, detailed internal reasoning is not always necessary or appropriate to request; for many applications, asking for a concise explanation or a final answer with key checks is sufficient.</p><p>For example:</p><blockquote><strong><em>Prompt:</em></strong><em><br>“A store offers a 20% discount on a $150 product. After the discount, an additional $10 coupon is applied. What is the final price?<br>Explain the calculation briefly.”</em></blockquote><p>A good response would calculate:</p><blockquote><em>20% of $150 = $30<br>Discounted price = $120<br>$120 − $10 = </em><strong><em>$110</em></strong></blockquote><p>The important idea is to structure the task so that the model performs the calculation in a logical sequence rather than guessing the answer.</p><h3><strong>4. Least to most:</strong></h3><p>The paper by Zhou et al. defines least-to-most prompting as two sequential stages:</p><ol><li><strong>Decomposition:</strong> the model is prompted to break the original problem into simpler subproblems.</li><li><strong>Sequential solving:</strong> the model solves those subproblems from simplest to hardest, with the answers to earlier subproblems included as context for later ones.</li></ol><p>For Example:</p><blockquote><strong><em>Prompt:</em></strong><em><br> “Solve this problem using least-to-most prompting:</em></blockquote><blockquote><em>A school has 18 students. There are twice as many girls as boys. How many girls and boys are there?</em></blockquote><blockquote><em>First, generate the simpler subproblems needed to solve it. Then solve those subproblems from easiest to hardest, carrying each answer forward to the next step.”</em></blockquote><p>A model might decompose it into:</p><blockquote><em>Let the number of boys be </em><strong><em>x</em></strong><em>.</em></blockquote><blockquote><em>Girls = </em><strong><em>2x</em></strong><em>.</em></blockquote><blockquote><em>Total students = </em><strong><em>x + 2x = 18</em></strong><em>.</em></blockquote><blockquote><em>Solve for </em><strong><em>x</em></strong><em>, then calculate the number of girls.</em></blockquote><p>The key difference from ordinary task decomposition is that the <strong>model generates the decomposition and then solves the resulting subproblems sequentially</strong>, using previous answers as context.</p><h3><strong>5. Self-refine:</strong></h3><p><strong>Self-refine</strong> is an iterative approach in which an AI first generates an answer, then critiques or evaluates that answer, and finally produces an improved version. Research on Self-Refine describes this as a feedback → refinement loop that can be performed using the same model.</p><p>For example:</p><blockquote><strong><em>Prompt:</em></strong><em><br> “Write a 150-word introduction to a blog post about cybersecurity.”</em></blockquote><p>After receiving the first draft, follow with:</p><blockquote><strong><em>Prompt:</em></strong><em><br> “Review the introduction you just wrote. Identify unclear statements, unnecessary repetition, and overly technical language. Then rewrite it to be clearer and more engaging for a general audience.”</em></blockquote><p>You can repeat this process when quality matters more than producing the answer in a single pass.</p><p>The key lesson is simple: <strong>the first output does not have to be the final output.</strong></p><h3><strong>6. Maieutic prompting:</strong></h3><p>Maieutic Prompting is a specialized research technique for improving <strong>logical consistency in true/false reasoning</strong>. It recursively generates explanations and their logical relationships, then reasons over those relationships as a satisfiability problem.</p><p>A simplified illustration is:</p><blockquote><strong><em>Statement:</em></strong><em> “A person who is standing is not sitting.”</em></blockquote><blockquote><strong><em>Prompt:</em></strong><em><br> “Consider both possibilities:</em></blockquote><blockquote><em>The statement is TRUE. Explain why. Then recursively examine whether that explanation is consistent.</em></blockquote><blockquote><em>The statement is FALSE. Explain why. Then recursively examine whether that explanation is consistent.</em></blockquote><blockquote><em>Compare the resulting explanations and determine which truth value is most logically consistent.”</em></blockquote><p>The important idea is to <strong>explore explanations recursively and check their consistency</strong>, rather than simply asking the model to “think of some exceptions.” The published method was evaluated on true/false commonsense reasoning tasks.</p><h3>Final thoughts</h3><p>Effective prompting is less about finding a magical phrase and more about communicating clearly with an AI system.</p><p>For simple tasks, <strong>zero-shot prompting</strong> may be enough. When examples matter, use <strong>few-shot prompting</strong>. For reasoning problems, structured or decomposed approaches such as <strong>chain-of-thought</strong> and <strong>least-to-most prompting</strong> can help. When the first response needs improvement, <strong>self-refinement</strong> provides an iterative workflow. For specialized logical reasoning tasks, <strong>maieutic prompting</strong> offers a more advanced approach.</p><p>Ultimately, good prompts define the <strong>task, context, constraints, examples, and expected output</strong> clearly. As you become better at thinking about these components, you become better at working with generative AI, not by writing longer prompts, but by writing <strong>more intentional ones</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d13777f5962f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Compiling Bitcoin Core in Windows 10 Environment]]></title>
            <link>https://medium.com/@HussainZaidi14/compiling-bitcoin-core-in-windows-10-environment-4723255e88a7?source=rss-36248d2e9efa------2</link>
            <guid isPermaLink="false">https://medium.com/p/4723255e88a7</guid>
            <category><![CDATA[bitcoin-code]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[windows-10]]></category>
            <category><![CDATA[compiling]]></category>
            <category><![CDATA[bitcoin]]></category>
            <dc:creator><![CDATA[Syed Hussain Haider Zaidi]]></dc:creator>
            <pubDate>Thu, 10 Oct 2019 15:19:36 GMT</pubDate>
            <atom:updated>2019-10-10T15:19:36.844Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*srSCMt4XzFYJGRW752x4LA.jpeg" /><figcaption>Bitcoin</figcaption></figure><p>My intention to write this blog is to provide exact information to the readers on how to run bitcoin core on windows 10 machine. I’m reading “Mastering Bitcoin” and I faced a lot of issues configuring the code. So here is an uncomplicated way to tackle this problem.</p><h4>Step 1: Configure Ubuntu and Dependencies</h4><p>First, you have to install the Ubuntu from Microsoft Store. You can download any version of Ubuntu (18.04 or 16.04). Follow the instructions from this link (<a href="https://docs.microsoft.com/en-us/windows/wsl/install-win10">https://docs.microsoft.com/en-us/windows/wsl/install-win10</a>) to download the Linux in window 10 system. This Ubuntu is Windows Subsystem for Linux which is a command-line program. I’m using Ubuntu 18.04 LTS for this article. After installing and setting up the password for the Linux environment, we have to configure Ubuntu and install the dependencies needed to run Bitcoin Core, type the following commands:</p><p><strong>Note:</strong> For sudo commands, you have to enter the password which you set in start of the setting the Ubuntu.</p><pre>$ sudo apt update</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UDDJ6DF9LKrhGOHnpJR4Eg.png" /></figure><pre>$ sudo apt upgrade</pre><p>This command updates all packages that you have just installed on your system. (this command may take some time)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dGwFsCeDvyMbRbdbTu8KZw.png" /></figure><pre>$ sudo apt install g++-mingw-w64-x86-64<br>$ sudo apt install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl git</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*osLJaAwL556P0I3XX1zoQQ.png" /></figure><p><strong>Note:</strong> It will show the errors if any of the packages are uninstalled.</p><p>If you want to build the windows installer with ‘make deploy’, you need NSIS:</p><pre>$ sudo apt install nsis</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0uvA1fwrRwl0BR1RxisprA.png" /></figure><h4>Step 2:<strong> Get the Bitcoin directory locally</strong></h4><p>Perfect. You have finished installing dependencies on Ubuntu. Now, to copy the Bitcoin directory locally, you will use the command git.</p><p>If you do not have the function gittype the command directly:</p><pre>$ sudo apt-get install git</pre><p>This command allows you to create a local copy (clone) of the source code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Ap7vd6ZmpaD5c0dmBlfnQ.png" /></figure><pre>$ git clone <a href="https://github.com/bitcoin/bitcoin.git">https://github.com/bitcoin/bitcoin.git</a></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nf9-ZisGncbNYPOhTeWf-g.png" /></figure><p>In Ubuntu, use the command cd to move into the directory:</p><pre>$ cd bitcoin</pre><p>As you can see in the second line of the image below, the $ has been moved after ~/bitcoin.</p><p>Previously, we were in the home/hussain directory. Now we are in the home/hussain/bitcoin directory.</p><p>Then, use the ls (list) command. It allows you to display the list of files in the current directory.</p><pre>$ ls</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uSIxVzKDLIXJQI7Cl9d6AQ.png" /></figure><h4>Step 3: Selecting a Bitcoin Core Release</h4><p>Bitcoin Core code changes over time to make improvements and remove bugs. These improvements are proposed by various developers. To know the different delivered versions of Bitcoin Core, you can use the command:</p><pre>$ git tag</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cP33RPhtp3-OYWqODuyavA.png" /></figure><p>The list of tags shows all the released versions of bitcoin. By convention, release candidates, which are intended for testing, have the suffix “rc.” Stable releases that can be run on production systems have no suffix. <br><strong>Note:</strong> to quit from the command press ‘q’.</p><p>To synchronize the local code with this version, use the git checkout command:</p><pre>$ git checkout v0.16.0rc1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jGSRsMu_hI6fMiQmhkdm-Q.png" /></figure><p>To confirm that you have the desired version, you can use the command:</p><pre>$ git status</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*irveDWeTCNt20BQ7-PgyRQ.png" /></figure><h4><strong>Step 4: Configuring the Bitcoin Core Build</strong></h4><p>Once you have installed all the dependencies, you can start the build process by generating a set of build scripts using the autogen.sh script.<br>Type the command:</p><pre>$./autogen.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LP4eF-78y2JpjgjYUVpOhw.png" /></figure><p>The <em>autogen.sh</em> script creates a set of automatic configuration scripts that ensure you have all the necessary libraries to compile the code. Due to this command, a configure file generated. that offers different options for setting up the build process. To see the different options of this script, type:</p><pre>$./configure –help</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pohzgJoER72_VjR60v5uug.png" /></figure><p>Some useful options:</p><p><strong><em>— disable-wallet</em></strong></p><p>This is used to disable the reference wallet implementation.</p><p><strong><em>— with-gui=no</em></strong></p><p>Don’t build the graphical user interface, which requires the Qt library. This builds server and command-line bitcoin only.</p><p>Next, run the configure script to automatically discover all the necessary libraries and create a customized build script for your system:</p><pre>$./configure</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vbqy5AXNmjKhZGvNCo48Ug.png" /></figure><p>There might be a couple of errors after running the above command and the most common is of “<em>Berkeley DB</em>”. There are two ways to solve the problem. One is run the above command with disabled wallet option like:</p><pre>$./configure --disable-wallet</pre><p>The second option is to install the required package. So according to the above error, I use the command:</p><pre>$ sudo apt-get install libdb++-dev</pre><p>Run again the <strong>$ ./configure</strong> command and check the errors</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N8h3wWSKLrh1SJlk-_6pRA.png" /></figure><p>If you encounter the above image error then run the following commands:</p><pre>$ sudo add-apt-repository ppa:bitcoin/bitcoin<br>$ sudo apt-get update<br>$ sudo apt-get install -y libdb4.8-dev libdb4.8++-dev</pre><p>and Re-run the <strong>$ ./ configure</strong> command. I get an error message again: “no working boost sleep implementation found “.<br>To solve this, use the command:</p><pre>$ sudo apt-get install libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev</pre><p>When I run ./configure command again, I get a new error message: &quot; <em>open ssl not found</em> &quot;. Use the following command to solve the problem:</p><pre>$ sudo apt-get install libssl-dev</pre><p>I re-run the command ./configure and got “libevent not found” error. Run the following command:</p><pre>$ sudo apt-get install libevent-dev</pre><p>We re-run the command ./configure and this time we have no error message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JsG-525FmRB2M9cPVZwivQ.png" /></figure><p>We now have all the scripts that will allow us to compile bitcoind.</p><h4><strong>Step 5: Building the Bitcoin Core Executables</strong></h4><p>Next, you will compile the source code, a process that can take up to an hour to complete, depending on the speed of your CPU and available memory.<br>Type **make** to start compiling the executable application:</p><pre>$ make</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*53P5vIDHO6NV9vhVHWUc3A.png" /></figure><p>Great! Bitcoin core is now compiled.</p><p>The last step is to install different executable on your system using the command:</p><pre>$ make check &amp;&amp; sudo make install.</pre><p>The default installation of bitcoind puts it in <em>/usr/local/bin</em>. You can confirm that Bitcoin Core is correctly installed by asking the system for the path of the executables, as follows:</p><pre>$ which bitcoind</pre><p>Should you return: <em>/ usr / local / bin / bitcoind</em></p><pre>$ which bitcoin-cli</pre><p>Should you return: <em>/ usr / local / bin / bitcoin-cli</em></p><h4>Step 6: Running a Bitcoin Core Node:</h4><p>Bitcoin’s peer-to-peer network is composed of network “nodes,” run mostly by volunteers and some of the businesses that build bitcoin applications.</p><p><strong>Configuring the Bitcoin Core Node:</strong><br>Bitcoin Core will look for a configuration file in its data directory on every start. In this section, we will examine various configuration options and set up a configuration file.</p><p>To locate the configuration file, run bitcoind -printtoconsole in your terminal and look for the first couple of lines.</p><p>Bitcoin Core offers more than 100 configuration options that modify the behavior of the network node, the storage of the blockchain, and many other aspects of its operation. To see a listing of these options, run bitcoind — help:<br>We have to set the password and other configuration options.<br>Use this command <strong>$ vim ~/.bitcoin/bitcoin.conf</strong> to open/edit the file <br>Then paste the following lines in it.</p><pre>txindex=1<br>rpcuser=bitcoinrpc<br>rpcpassword=[CHANGE TO SOMETHING DIFFERENT]</pre><p>Press Esc and then ‘:wq’ to quit and save the file.</p><p>Now To run Bitcoin Core in the background as a process, start it with the daemon option, as</p><pre>$ bitcoind -reindex -daemon</pre><p>Once the server starts, we can get different types of information using JSON RPC.</p><p>To monitor the progress and runtime status of your bitcoin node, use</p><pre>$ bitcoin-cli getblockchaininfo</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MvIt2rXTK7wU1q671qcC5A.png" /></figure><p>This shows a node with a blockchain height of 0 blocks and 33340 headers. The node currently fetches the block headers of the best chain and afterward continues to download the full blocks.</p><p>In general, to explore the blockchain database, there are many other commands. Hopefully, this article helps you to get started with bitcoin. Comment under the article if you need help.</p><h4>Source: Mastering Bitcoin.</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4723255e88a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[First Android Application]]></title>
            <link>https://medium.com/@HussainZaidi14/first-android-application-da6d0b1e48db?source=rss-36248d2e9efa------2</link>
            <guid isPermaLink="false">https://medium.com/p/da6d0b1e48db</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[androidarsenal]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Syed Hussain Haider Zaidi]]></dc:creator>
            <pubDate>Fri, 04 Nov 2016 14:25:04 GMT</pubDate>
            <atom:updated>2016-11-04T14:25:04.839Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ejg_uKSVhWC4ZDBuw704iw.png" /></figure><p>Well its a very new(amazing) experience when I enter in the field of computer Science.It not a bed of roses in start of this degree. <br>When I first got into tech, I felt overwhelmed. And I felt inadequate. It seemed that everyone knew how to code except me, though I resolved to find a way to learn. And I powered through a few classes about who to write code.I came to know that it just like math.It didn’t stick in the way that would allow me to build an app or site.</p><p>Now building first android application is somewhat make me crazy about my future development. This application is based on Theroy of Automata concepts. TOA is very important and amazing course to learn as it told some basic stuff about (computer Science)compiler construction and AI.<br>I personally believe that it is a very tough subject. Well that would not be much of a problem anymore.Here comes an “Automata” app for your assistance.</p><p>Its basically my friend’s idea to convert the TOA concepts (algorithms) into Code. We both implement it.</p><p>This app will help you calculate Regular Expression of a DFA, NFA and NFA-Null. Furthermore, it will allow you to convert from NFA-Null and NFA to its lowest forms. Therefore, you wouldn’t have to go through the hectic and troublesome process of calculating a regular expression yourself.<br>If you do, you can always cross check your answers. Feel free to report any problems that you come across. <br>We will be more than delighted to answer all your queries regarding the app. OH YES, don’t forget to rate it.<br>Encouraging remarks will be really appreciated. Have fun using it and spread the word around.<br>We’ll be adding many more features and functions as well. Stay tuned peeps!!</p><blockquote>Here is the Link…<br><a href="https://play.google.com/store/apps/details?id=com.abdul.automata">https://play.google.com/store/apps/details?id=com.abdul.automata</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da6d0b1e48db" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>