<?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 Abhinandan Malhotra on Medium]]></title>
        <description><![CDATA[Stories by Abhinandan Malhotra on Medium]]></description>
        <link>https://medium.com/@abhinandanmalhotra?source=rss-f707d6e2e7e3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IIoFZenWGLR33Tr6V_x4HQ.jpeg</url>
            <title>Stories by Abhinandan Malhotra on Medium</title>
            <link>https://medium.com/@abhinandanmalhotra?source=rss-f707d6e2e7e3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 21:19:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhinandanmalhotra/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[FreeToken Just Shipped. Is It Better Than Ollama and llama.cpp?]]></title>
            <link>https://pub.towardsai.net/freetoken-just-shipped-is-it-better-than-ollama-and-llama-cpp-42c0a4c948ab?source=rss-f707d6e2e7e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/42c0a4c948ab</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Abhinandan Malhotra]]></dc:creator>
            <pubDate>Fri, 28 Aug 2026 14:01:04 GMT</pubDate>
            <atom:updated>2026-09-01T05:35:54.194Z</atom:updated>
            <content:encoded><![CDATA[<h4>Testing the radical new MoE serving engine against the reigning champions on a 6GB laptop</h4><p>FreeToken shipped recently. As a new serving engine for Mixture of Experts (MoE) models, its headline claim of running a 753B parameter model on a single GPU garnered a lot of attention fast.<br>I have a laptop with an RTX 3050 and 6GB of VRAM. I installed FreeToken on it alongside Ollama and llama.cpp, ran all three against the same model and the same three questions, and measured tokens per second and time to first token.<br>This piece is a breakdown of that comparison. But more than that, it is an attempt to explain what each of these three tools is actually doing under the hood, because the performance numbers only make sense once you understand the underlying mechanism.</p><h3><strong>Three Engines, Two Designs</strong></h3><p>An MoE model has a very large number of parameters, but only a small number of them i.e. the “experts” gets used for any given token. Most of the model sits idle at any moment. The three engines disagree about what to do with those idle weights.</p><p><strong>llama.cpp and Ollama share the same answer: Split the model once, at load time, and leave the split alone. </strong>Some layers go on the GPU, and the rest go to system RAM and run on the CPU. With llama.cpp, you set that split yourself with a flag. Ollama runs llama.cpp underneath, but it looks at your hardware first and picks the split for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YQae_87-7Q85jZxr73iTbw.png" /><figcaption><strong>How llama.cpp and Ollama split a model across CPU and GPU. (Image by Author)</strong></figcaption></figure><p>I saw this directly. Running <strong>ollama ps</strong> while a model was loaded showed a 71% CPU and 29% GPU split, chosen automatically. With llama.cpp, I had to choose, and I chose badly on my first attempt. More on that shortly.</p><p><strong>FreeToken’s answer is different:</strong> Do not commit to one split at all. According to the team’s August 2026 paper, “<strong>FreeToken: Efficient Edge-Native MoE Serving with Bandwidth-Adaptive Execution</strong>”, FreeToken keeps the complete set of experts in CPU RAM as the source of truth. It then turns the GPU’s spare memory into a shared LRU cache that holds whichever experts were recently used. When the model needs an expert that is not in that VRAM cache, FreeToken uses a “bandwidth adaptive” policy i.e. it decides on the spot whether to pull the weights over PCIe or compute them directly on the CPU, based on the actual bandwidth it measures on your machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hRYZwKJqV9sJG_HpH1kHww.png" /><figcaption><strong><em>FreeToken’s dynamic expert cache and routing mechanism. (Image by Author)</em></strong></figcaption></figure><p>This is a genuinely more complicated thing to build than a fixed split. That complexity is the entire story of what follows.</p><h3>Setup</h3><p><strong>Hardware:</strong></p><ul><li><strong>GPU:</strong> RTX 3050 Laptop GPU, 6GB VRAM</li><li><strong>CPU:</strong> Intel i5–13450HX (6 performance cores, 4 efficiency cores)</li><li><strong>RAM:</strong> 24GB</li><li><strong>OS:</strong> Windows 11 (all three engines running natively)</li></ul><p><strong>The Model:</strong> gpt-oss-20b in MXFP4</p><p>It takes up about 13GB on disk and was identical across all three engines. Ollama reports MXFP4 for its build, and the GGUF I used for llama.cpp is Unsloth’s MXFP4 quant, published under an F16 filename with a note in their README explaining why.</p><p>I ran everything natively on Windows rather than WSL. FreeToken’s command line version stalled partway through loading under WSL, which shares memory with Windows and left too little room. The desktop app worked fine natively, so I moved everything to Windows rather than testing one engine on Linux and two on Windows, which would have measured the platform instead of the engines.</p><p><strong>The Prompts:</strong></p><p>I tested the engines against three distinct prompts to evaluate different types of generation: a direct factual answer, logical reasoning, and longer prose.</p><ul><li><strong>Short explainer:</strong> “Explain the difference between MoE and dense models in three sentences.”</li><li><strong>Trick question:</strong> “Seventeen sheep, all but nine die; how many are left?”</li><li><strong>Long explainer:</strong> “Write two hundred words on how MoE routing works.”</li></ul><p>I ran each prompt four times, prefacing the sequence with a throwaway “hi” so that cold-start times wouldn’t skew the results. The numbers reported below are the medians. Because all three engines expose an OpenAI-compatible API on localhost, I drove the entire benchmark using a single Python script. This guaranteed that the timing code was perfectly identical across all three contenders.</p><h3><strong>Results</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QrzV0aSER7zaBMEOTLzszw.png" /><figcaption><strong><em>Generation speed by engine across three different prompt types. (Image by Author)</em></strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*WtsKn3oPfWavC3gRFIHLTg.png" /><figcaption><strong>Results (Image by Author)</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OPKj0BoXgpLZXfR_rwO7bA.png" /><figcaption><strong>Time to first token (TTFT) compared across engines. (Image by Author)</strong></figcaption></figure><p>Ollama started answering in about <strong>0.38 seconds</strong>. llama.cpp took <strong>0.5 seconds</strong>. FreeToken took <strong>1.17 seconds, </strong>roughly three times the wait.</p><h3>Reading the Results Against the Mechanism</h3><p>None of this is surprising once you look at how each engine operates.</p><p><strong>Ollama and llama.cpp,</strong> with the split set correctly, do almost nothing extra during generation. The layers are where they are, the boundary does not move, and the only cost is the fixed computational cost of some layers living on a slower device.</p><p><strong>FreeToken,</strong> on the other hand, is doing continuous work that the other two skip entirely: checking whether an expert is cached, deciding what to evict, measuring bandwidth, and calculating whether a miss goes over PCIe or gets computed on the CPU. On a 20B model, that overhead has almost nothing to buy back. A 20B model’s experts do not change fast enough, or often enough, to make dynamic caching pay for itself. <strong>You are paying FreeToken’s machinery cost with none of its benefit.</strong></p><p>The 1.17 second wait before the first token fits the exact same story. That startup work, checking the cache state and deciding on a routing strategy happens before generation can begin. It is the same overhead showing up as latency instead of throughput.</p><h3><strong>Where FreeToken’s Approach Could Actually Pay Off</strong></h3><p>FreeToken lost every measurement here, but I do not think a 20B model on a 6GB laptop is a fair test of what it was built to do.</p><p>The paper behind FreeToken is explicit that its target is agent workloads whose execution patterns keep changing, scaling up to workstation GPUs, not a single 20B model answering three static questions. Its own model list makes this point without needing the paper: when I checked what else was available in the desktop app, a 35B model and a 27B model were both marked “Insufficient RAM” on my 24GB machine.</p><p><strong>That matters for the argument I want to make, because it also limits it:</strong> FreeToken’s own numbers show it needs more system RAM than I have just to load a 35B model, well before you reach the scale where its caching and bandwidth-adaptive machinery is supposed to start earning its keep.</p><p>I cannot tell you FreeToken wins on bigger models, because I could not get a bigger model to load on this machine under <em>any</em> engine, FreeToken included. The 753B headline that got everyone’s attention sits well outside anything I was able to test.</p><p><strong>What I can say is narrower and more honest: </strong>the overhead I measured losing here is not wasted effort in general, it is effort with no problem to solve at this specific size. Whether it becomes worth its cost on a workstation running a model that genuinely does not fit any other way is an open question and it is the one question this test could not answer.</p><h3>What I Would Use Tomorrow</h3><p>On a hardware like mine, running models in this size range, my pick is <strong>Ollama</strong>. It was the fastest, picked sensible settings without being asked, and took about four minutes to set up.</p><p>If you want control over the settings yourself, <strong>llama.cpp</strong> gets within the Ollama range once configured properly and may even outperform it. That performance gap is simply the price of doing it by hand.</p><p><strong>FreeToken</strong> is something I would revisit with a machine that has enough RAM to load something the other two cannot. That is the test its design is actually built for, and a 6GB laptop with 24GB of RAM simply cannot run it.</p><h3>Practical Notes &amp; Loose Ends</h3><p>If you plan on benchmarking this yourself, keep a few oddities in mind:</p><ul><li><strong>FreeToken on Windows:</strong> Use the desktop app, not the command line path. My first load failed with an error saying it needed about 1.01GB for its cache and had 756MB available. Raising memory_ratio from 0.9 to 0.95 in settings fixed it. The error told me exactly what to change.</li><li><strong>llama.cpp on Windows:</strong> Setting this up took longer than everything else combined. The binaries are not code-signed, and Windows Memory Integrity blocked the DLLs with a Bad Image error that produced no output at all in a normal terminal. I only saw the real error by running as administrator. Turning Memory Integrity off in Windows Security fixed it.</li></ul><p>The benchmarking script, the raw numbers, and both diagrams are available on <a href="https://github.com/abhinandan-084/local_llm_benchmarks/tree/main/windows-native-freetoken-comparison"><strong>GitHub</strong></a>. I would love to see this run on a machine with real RAM headroom, since that is the test I couldn’t do.</p><h3>References</h3><ul><li><strong>Yang, S., Fan, X., Pan, M., et al. (2026).</strong> <em>“FreeToken: Efficient Edge-Native MoE Serving with Bandwidth-Adaptive Execution.”</em> arXiv preprint. <a href="https://www.google.com/url?sa=E&amp;q=https%3A%2F%2Farxiv.org%2Fabs%2F2608.16157">arXiv:2608.16157</a>.</li><li><strong>FlashML / FreeToken GitHub Repository:</strong> The open-source edge-native MoE serving engine. Available at: <a href="https://www.google.com/url?sa=E&amp;q=https%3A%2F%2Fgithub.com%2FFlashML-org%2FFreeToken">https://github.com/FlashML-org/FreeToken</a></li><li><strong>llama.cpp GitHub Repository:</strong> Port of Facebook’s LLaMA model in C/C++. Available at: <a href="https://www.google.com/url?sa=E&amp;q=https%3A%2F%2Fgithub.com%2Fggml-org%2Fllama.cpp">https://github.com/ggml-org/llama.cpp</a></li><li><strong>Ollama:</strong> The official runtime and model manager for local AI. Available at: <a href="https://www.google.com/url?sa=E&amp;q=https%3A%2F%2Follama.com">https://ollama.com</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42c0a4c948ab" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/freetoken-just-shipped-is-it-better-than-ollama-and-llama-cpp-42c0a4c948ab">FreeToken Just Shipped. Is It Better Than Ollama and llama.cpp?</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why My LLM Guardrail Flagged the Right Answers (And Why I Refused to Fix It)]]></title>
            <link>https://pub.towardsai.net/why-my-llm-guardrail-flagged-the-right-answers-and-why-i-refused-to-fix-it-0db77efb0644?source=rss-f707d6e2e7e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/0db77efb0644</guid>
            <category><![CDATA[llm-evaluation]]></category>
            <category><![CDATA[hallucinations]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Abhinandan Malhotra]]></dc:creator>
            <pubDate>Fri, 17 Jul 2026 17:01:03 GMT</pubDate>
            <atom:updated>2026-07-17T17:01:03.390Z</atom:updated>
            <content:encoded><![CDATA[<h4>Benchmarking a numerical hallucination checker against a frontier API and a local 8B model taught me a harsh lesson about system design.</h4><h3><strong>Introduction</strong></h3><p>Ask a Large Language Model (LLM) to write an executive strategy document based on your machine learning pipeline’s outputs, and sooner or later, it will invent a number. It will confidently claim a “47% lift” when your optimizer actually said 12%. In a boardroom setting, this single hallucinated metric is enough to burn the credibility of the entire dashboard. Due to this, most data teams either force a human into the loop for every generated figure, or they simply refuse to ship the LLM layer at all.</p><p>I decided to take the third route while building <a href="https://github.com/abhinandan-084/GTM-Wargame">GTM Wargame</a> (an open source go-to-market strategy simulator). I wanted to treat “<strong>don’t hallucinate</strong>” as a systemic architectural property, rather than relying on prompt engineering tricks. To do this, every number the agents were allowed to use - SHAP attributions, optimizer outputs, market context was stored in a strict Ground Truth Pool. Before any text reaches the UI, a <strong>ConsistencyChecker </strong>cross-references every number the agents write against that pool.</p><p>Building this guardrail was the easy part. The harder question was: <strong>How often does it actually fire in a real world scenario, and when it does, is it right?</strong></p><p>To find out, I ran 60 paired simulations pitting a frontier API model against a local 8B model, and I hand audited every flagged number against a deterministically rebuilt ground truth. The first finding was expected: <strong>the local model fabricated numbers at a materially higher rate (7.2%)</strong>. The second finding is what this article is really about: every single flag the guardrail raised against the frontier model was a false positive. The model wasn’t hallucinating. It was doing correct arithmetic that my checker simply had no way to understand.</p><p>My first instinct as an engineer was to “fix” the checker. By the end of the audit, I realized those false positives are the guardrail working as designed, and expanding its matching logic to eliminate them would make the whole system less trustworthy.</p><h3>The guardrail pattern</h3><p>The guardrail’s logic is deliberately boring, which is exactly why it works:</p><ol><li><strong>Build the Ground Truth Pool</strong>: Every number the agents might reference (SHAP values, market signals, optimizer results) gets flattened into one unified pool of floats.</li><li><strong>Let the agents write freely:</strong> The Analyst-Strategist-Manager chain produces unconstrained prose using chain-of-thought reasoning. There is no rigid JSON schema they have to fight against.</li><li><strong>Parse the output after the fact:</strong> A regex pass extracts every number the LLM generated and checks it against the pool. It allows for rounding, percentage-vs-fraction scaling (“12” for a stored 0.12), and k-notation (“176k” for a stored 176,432.11).</li><li><strong>Surface the verdict:</strong> An unmatched number is flagged as a hallucination in the UI. The user sees the warning as the system doesn’t quietly try to “fix” the figure behind the scenes.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JzoXXEc4atQkJuTHiOY7hw.png" /><figcaption><strong>The GTM Wargame pipeline: Every layer upstream of the agents exists to populate the Ground Truth Pool that the guardrail checks against. (Image by Author)</strong></figcaption></figure><p>Before testing it on real models, I evaluated the checker itself as a classifier using 75 labeled cases built from authentic pipeline artifacts. The cases were split into <strong>clean cases, injected cases (seeded with unmatchable numbers), and trap cases (filled with naive-checker bait formatting like $1,234, negative signs, and k-notation of real pool values)</strong>. The checker scored a perfect 1.000 precision and 1.000 recall, with zero false positives across the 258 numbers it ran on.</p><pre>result = ConsistencyChecker.validate_response(<br>   text=manager_summary,<br>   shap_info=shap_values,<br>   market_context=market_context,<br>   opt_results=optimizer_output,<br>)<br># Returns: {&quot;is_valid&quot;: False, &quot;hallucinated_values&quot;: [47.0], &quot;error_msg&quot;: &quot;...&quot;}</pre><p>However, a perfect score deserves skepticism. The labels for this evaluation were defined by the checker’s own matching rules, so by construction, this eval couldn’t disagree with itself. It validated everything layered around the rule - number extraction, currency and comma cleaning, sign handling, pool flattening. This however says nothing about whether the matching rule itself was the right architectural contract. That question needs real models.</p><h3>The Experiment: Two Models, 30 Paired Seeds (60 Runs)</h3><p>I ran the full pipeline (XGBoost forecasting, SHAP attributions, SciPy budget optimization, followed by the agent boardroom) across 30 identical seeds. The pipeline runs on a synthetic sales dataset generated by the repo itself, so no proprietary data is involved and every result can be rebuilt from a seed. Both models faced the exact same scenarios: Gemini (gemini-3-flash-preview, the repo’s pinned default) over the API, and Llama 3.1 8B Instruct (Q4_K_M) running fully locally through llama.cpp. These runs were recorded in July 2026 − preview models change over time, so the exact version and date matter for anyone comparing against these numbers. The checker scored the analyst and strategist nodes of every run.</p><p>Before looking at the outputs, I established a strict methodological rule: <strong>A flag is not a fabrication. A flag means a number failed pool matching. That is an upper bound on hallucination, not a measurement of it. Reporting raw flag rates as “fabrication rates” is exactly the kind of unverified claim the guardrail exists to prevent.</strong></p><p>Here are the raw flag counts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*tnAknX6ZrQhoY7TowLEp3Q.png" /><figcaption><strong>Source: Image by the author.</strong></figcaption></figure><p>Two things immediately stood out. First, the frontier model engaged with the quantitative data far more densely, writing nearly four times as many numbers per run yet triggered fewer absolute flags. Second, 13 total flags across all runs is a small enough population to audit exhaustively by hand.</p><h3>Auditing the Flags: Mechanical Evidence &amp; Judgment</h3><p>For every flagged run, I used an offline audit script with zero LLMs in the loop to deterministically rebuild that run’s exact Ground Truth Pool from its seed. It revalidates the stored agent transcripts, and asserts the flags reproduced exactly, ensuring I was examining exactly what the checker saw at runtime.</p><p>Then, I ran two mechanical passes per flag:</p><ol><li><strong>Notation Pass:</strong> Is the value a valid x1,000 or x1,000,000 scaling of a pool value?</li><li><strong>Derivation Pass</strong>: Does the value result from a pairwise combination of pool values (difference, sum, ratio, percentage gap, per week average, etc.)?</li></ol><p>The derivation pass comes with a built-in trap. With roughly 50 values in a pool, the number of pairwise combinations runs into the thousands. By pure chance, some derivation will land near almost any small number. Therefore, a mechanical hit isn’t enough. The final classification required semantic support from the text: the model had to explicitly name the operands it was combining. Any ambiguous flags defaulted to <strong>FABRICATED</strong>.</p><p>Here are the final verdicts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*dKOAuxmws1DVtMvR2TLFhw.png" /><figcaption><strong>Source: Image by the author.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RUOjsAX8YR4aNd9XvIU4yA.png" /><figcaption><strong>Classification of the 13 raw flags against the deterministically rebuilt ground truth pool. (Image by Author)</strong></figcaption></figure><p>Every single one of the local model’s 10 flags survived the audit as a genuine hallucination. Conversely, not a single one of the frontier model’s flags was an actual fabrication.</p><h3>The False Positives: Correct, But Derived</h3><p>All three of Gemini’s flags followed the exact same pattern. Let’s look at the flag from Seed 1015. The ground truth pool contained an optimized price of 535.68 and a market leader price of 715.18. The LLM strategist wrote: “<em>…our reliance on a 25 percent price gap relative to the leader (715.18) makes us highly vulnerable to any aggressive downward moves from the competition.</em>”</p><p>Check the arithmetic: (715.18 − 535.68) / 715.18 = 25.1%. Both operands are real pool values. Both are named in the surrounding text. The model computed a mathematically correct, highly relevant business metric. And the checker flagged it, simply because the number “25” wasn’t explicitly stored in the original pool. Seeds 1019 and 1023 produced the same pattern with different numbers, each verifiably correct, each flagged.</p><p>I call this category <strong>correct-but-derived</strong>. It’s a failure mode that standard guardrail evaluations miss entirely because the eval’s labels are defined by the checker’s own matching rules. It took real model behavior and a manual audit to expose the flaw.</p><h3>Why I Refuse to “Fix” It</h3><p>The obvious engineering patch writes itself: teach the checker arithmetic. Extend matching logic to cover pairwise derivations over ground truth pool values and all three of Gemini’s false positives would vanish.</p><p>I actually built that logic (it’s the derivation pass used in the audit script), but running it offline convinced me to never put it into a live guardrail. Here is why:</p><ol><li><strong>The collision problem:</strong> Thousands of pairwise combinations over 50 pool values create chance hits everywhere. The audit handles this by requiring semantic support from the sentence, which works when a human reads thirteen flags with full context. To prevent the checker from accidentally validating a hallucination at scale just because it mathematically collided with a random derivation, I would need to put an LLM inside the guardrail to judge the semantic context. At that point, the component whose only job is to catch LLM errors becomes dependent on an LLM being right.</li><li><strong>The asymmetry of the two failure modes: </strong>A false positive is cheap and transparent; a user sees a warning on a correct number, verifies it, and moves on. The system’s skepticism is visible. A false negative, however, is expensive and invisible: a hallucinated figure sails into an executive playbook wearing a “System Verified” badge.</li></ol><p>The entire value of a guardrail is that a green light signifies a strict, undeniable truth: this number exists in the raw data. Every time the guardrail matching contract is expanded, the value of that green light is silently diluted.</p><p>So, the contract stays narrow. The checker verifies existence, not derivability. Deriving new true values is legitimate LLM behavior that falls outside the contract. It gets flagged, and the human user resolves it.</p><h3>The Grounding Tax</h3><p>Now, let’s address the local model, because this is where the guardrail proved it was heavily load-bearing. After the audit, the true fabrication rates separated cleanly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*KWye-VDHNSXcB76g5UYMYQ.png" /><figcaption><strong>Source: Image by the author.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v-wY2aT1uZUi9IEON2sUmw.png" /><figcaption><strong>Post-audit fabrication rates with 95% Confidence Intervals. (Image by Author)</strong></figcaption></figure><p>The character of the local model’s hallucinations is highly instructive. It didn’t just get numbers slightly wrong; it invented entire quantitative structures that the pipeline never produced. It hallucinated an entire ROI table − $100k spend, $500k revenue” − in a pipeline that computes neither revenue nor ROI. My personal favorite was from Seed 1017: “<em>Reduce budget by 20% to $X.</em>” The model fabricated a metric and left the template variable sitting right next to it in the exact same sentence unfilled.</p><p>In my last article, I wrote about the “<a href="https://medium.com/towards-artificial-intelligence/optimizing-local-llm-inference-on-constrained-hardware-783a14af365d"><strong>Abstraction Tax</strong></a>”, the throughput you sacrifice when using convenient local inference wrappers on constrained hardware. This is the other side of the coin: <strong>The Grounding Tax</strong>. A quantized 8B running on your laptop buys you complete data privacy and zero API costs. But in a highly analytical workload, it pays for that privacy with a 7.2% hallucination rate on executive-facing outputs. This in part is mitigated by using bigger models on better hardware.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B4SluXkB8ztYidQ1DLbuAw.png" /><figcaption><strong>The guardrail firing on a live local-model run, catching an invented ROI fabrication. (Image by Author)</strong></figcaption></figure><p>This presents an operational paradox. The deployments that force engineers onto local models − regulated data, air-gapped systems, strict client confidentiality − are the exact environments where output verification is the hardest to outsource, and where a hallucinated number does the most damage. If your privacy requirements push you toward local inference, a grounding check isn’t just a nice-to-have feature − it is the only thing that makes the deployment defensible.</p><p>Two caveats. First, this guardrail benchmarks numerical grounding against a known pool, not semantic correctness. Second, K=30 runs on a single local model quantization is enough to establish confidence intervals, but it is not a definitive industry leaderboard. The takeaway isn’t “Gemini beats Llama”; the takeaway is that fabrication rates vary wildly across deployment architectures, and you need to measure yours.</p><h3>Conclusion</h3><p>I set out to measure how often LLMs invent numbers when summarizing ML outputs, and I walked away with a system design principle I didn’t expect: <strong>the audit matters more than the guardrail</strong>.</p><p>Raw metrics told a highly misleading story (0.6% vs 7.2% flag rates). Only a manual classification audit revealed the truth: a 0% vs 7.2% actual fabrication rate, where every single flag against the frontier model was a mathematically correct derivation that the checker was right to be suspicious of, but wrong to condemn.</p><p>If you are building numerical guardrails for LLMs, here are the rules I’m carrying forward:</p><ol><li><strong>A flag is an upper bound, not a claim: </strong>Audit your flags before reporting fabrication rates, and resolve ambiguities against the model.</li><li><strong>Keep the checker’s contract narrow: </strong>Verify existence, not derivability. A strict, trustworthy green light is worth the cost of a few honest warnings.</li><li><strong>Evaluate against real model behavior: </strong>The most interesting failure class in this system (the correct-but-derived false positive) was entirely invisible to my standard, perfect-scoring evaluation script.</li></ol><p>All code, raw data, and empirical setups used to generate these profiles are fully reproducible. The checker evaluation can be rebuilt offline without API keys, and every flagged transcript is available in the <a href="https://github.com/abhinandan-084/GTM-Wargame">GTM Wargame repository</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0db77efb0644" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/why-my-llm-guardrail-flagged-the-right-answers-and-why-i-refused-to-fix-it-0db77efb0644">Why My LLM Guardrail Flagged the Right Answers (And Why I Refused to Fix It)</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizing Local LLM Inference on Constrained Hardware]]></title>
            <link>https://pub.towardsai.net/optimizing-local-llm-inference-on-constrained-hardware-783a14af365d?source=rss-f707d6e2e7e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/783a14af365d</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[generative-ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Abhinandan Malhotra]]></dc:creator>
            <pubDate>Wed, 10 Jun 2026 14:31:00 GMT</pubDate>
            <atom:updated>2026-07-18T18:47:00.817Z</atom:updated>
            <content:encoded><![CDATA[<h4>An engineering deep dive into KV cache quantization, asymmetric thread tuning, and PCIe bottlenecks</h4><h3><strong>Introduction</strong></h3><p>New frontier models launch weekly, and for most developers, the testing phase abruptly ends when the API bill arrives or the rate limit error appears. While proprietary models are the standard for rapid prototyping, they remain a black box. Users do not own the data, cannot strictly control latency, and are constrained by pricing tiers.</p><p>Local LLMs are the obvious alternative, offering privacy and zero recurring costs. However, for an engineer running inference on constrained hardware, the challenge isn’t just getting the model to run, it is optimizing how well it performs.</p><p>Recently, I transitioned my RAG and analytics pipelines to run locally on an older machine: an Intel i5–13450HX paired with a modest NVIDIA RTX 3050 (6GB VRAM). I initially chose Ollama for its ‘it just works’ appeal. But as context windows expanded, performance faltered. This led to an interesting hypothesis: the convenience of a high-level, Go-based wrapper was masking the true potential of the underlying hardware.</p><p>To reclaim performance, I bypassed the Ollama orchestration layer and interacted directly with llama.cpp. By manually tuning execution variables, managing direct memory addressing, and optimizing KV cache footprints, I achieved a ~100% performance increase on an 8-Billion parameter model.</p><p>This post details the raw benchmarks comparing high-level wrappers against bare-metal execution, and outlines the precise hardware tuning strategies required to maximize token generation on a strict 6GB VRAM budget.</p><h3><strong>The Mechanics of Local Inference: Understanding the Bottleneck</strong></h3><p>To optimize llama.cpp beyond its default configuration, we must understand the physical journey of a tensor. LLMs are auto-regressive, predicting the next token based on the sequence of all preceding tokens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JLtGWBy4GCDlgtFG5BIW7g.png" /><figcaption><strong>Source: Image by the author.</strong></figcaption></figure><p>Every user request moves through two distinct, hardware-bound phases. Understanding which phase acts as the bottleneck is the prerequisite to optimization.</p><ol><li><strong>The Prefill Phase (Compute-Bound)</strong>: During prefill, the model ingests the initial prompt and context. Because the entire prompt is known upfront, the engine processes the tokens in parallel. This phase is heavily reliant on raw computational power and is designed to fully saturate the GPU’s Tensor Cores.</li><li><strong>The Decode Loop (Memory-Bandwidth Bound)</strong>: This phase is where sequential generation of tokens takes place. Here, the bottleneck shifts entirely. The GPU is no longer limited by the mathematical operations per second, but by how fast it can fetch weights from the VRAM. For every single token generated, the engine must move the model’s weights from memory to the GPU cores. Therefore, Tokens Per Second (TPS) is primarily a function of memory bandwidth.</li></ol><p><strong>The KV Cache and the 6GB VRAM Wall</strong></p><p>If an LLM had to reevaluate the entire context history to generate every single new token, the computational cost would scale quadratically, O(N²). To solve this, inference engines utilize a Key-Value (KV) Cache.</p><p>The KV Cache is a dedicated memory buffer in the VRAM that stores the computed hidden states (Keys and Values) of all previous tokens. Instead of reprocessing the entire history for every new word, the model fetches previous states from the cache and computes the math only for the single new token.</p><p>If your context is 100 tokens long and you want to predict token 101:</p><ul><li><strong>Without KV Cache</strong>: All 100 tokens are passed back into the transformer layers. The model re-calculates the Key (K) and Value (V) transformations for tokens 1 through 99 all over again, just to see how token 100 relates to them</li><li><strong>With KV Cache</strong>: The K and V tensors for tokens 1 through 99 never change. They are static historical properties of those tokens within this context. By storing them in VRAM (the KV Cache), we only feed the single latest token into the model network.</li></ul><p>The size of the KV cache scales linearly with context length and can be calculated using the formula.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uHetiXcRUyAWnb6XrQzMoQ.png" /><figcaption><strong>Source: Image by the author.</strong></figcaption></figure><p>For a Llama 3.1 8B model with a 16,000 token context window at standard FP16 precision, the exact memory overhead is as follows:</p><ul><li><strong>Model Weights (Q4_K_M):</strong> ~4.50 GB</li><li><strong>KV Cache (16k context @ FP16):</strong> ~2.15 GB</li><li><strong>Total Required VRAM:</strong> ~6.65 GB</li></ul><p>This is where the physical limitations of a 6GB RTX 3050 become an impassable wall. When an orchestrator hits this ceiling, the system either crashes with an Out-Of-Memory (OOM) error or begins swapping the cache to system RAM. The moment tensor data spills over the PCIe bus into CPU memory, performance collapses.</p><h3><strong>Quantifying the “Abstraction Tax”</strong></h3><p>The local LLM ecosystem is heavily bifurcated: GUI-focused wrappers (like Ollama and LM Studio) versus high-throughput core engines (like vLLM and llama.cpp).</p><p>Written in Go, Ollama wraps llama.cpp, manages model distribution via a Docker-like manifest system, and provides a clean REST API. It abstracts away the friction of deployment. However, on a heavily constrained hardware budget, this abstraction introduces a “tax.”</p><p>To quantify this tax, I ran head-to-head benchmarks comparing Ollama against bare-metal execution via llama-cli (compiled natively with CUDA support DGGML_CUDA=ON). I tested three distinct real-world engineering scenarios and three different models:</p><p><strong>Models :</strong></p><ol><li><strong>Llama 3.2 3B:</strong> Fits entirely in VRAM</li><li><strong>Llama 3.1 8B: </strong>A tight VRAM fit sitting exactly on the 6GB boundary</li><li><strong>Mistral 24B: </strong>Massively oversized; forces a severe CPU/GPU split</li></ol><p><strong>Scenarios :</strong></p><ol><li><strong>Simple QA (128 token prompt):</strong> Basic architectural Q&amp;A</li><li><strong>Coding Logic (512 token prompt):</strong> Writing optimized, tiled matrix multiplications</li><li><strong>Long Context (16384 token prompt):</strong> Ingesting and summarizing Chapter 4 of the EU AI Act</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*G1g3FZ-uORYP_ATf6L_hVg.png" /><figcaption><strong>Source: Image by the author.</strong></figcaption></figure><p><strong>Performance Results (Tokens Per Second)</strong></p><ul><li><strong>Llama 3.2 3B (Full VRAM Fit): </strong>When a model easily fits entirely inside the 6GB boundary, the abstraction tax is minimal. For short Q&amp;A and medium coding logic, llama.cpp provided only marginal gains (~4–5% uplift, reaching ~73 TPS). Interestingly, during the Long Context scenario, Ollama actually outperformed llama.cpp execution by 15.8% (38.9 vs. 32.8 TPS). This suggests that when VRAM is abundant, high-level wrappers are highly optimized to handle standard context scaling out-of-the-box.</li><li><strong>Llama 3.1 8B (The Edge of Capacity): </strong>Performance between the two engines was virtually identical for short and medium contexts (hovering around 33–34 TPS). However, the “abstraction tax” became glaringly obvious during the Long Context scenario. As the KV cache ballooned, Ollama conservatively spilled data into system RAM to prevent a crash, tanking performance to 7.7 TPS. By manually tuning llama.cpp, I forced those critical layers to remain in VRAM, yielding a 99.5% uplift (15.3 TPS).</li><li><strong>Mistral 24B (Heavy CPU/GPU Split): </strong>Because this model vastly exceeds the 6GB limit, weights must constantly travel across the PCIe bus. Here, bare-metal execution dominated across the board. llama.cpp provided a steady ~28% uplift for short and medium prompts, but delivered a staggering 125.3% uplift (6.6 vs. 2.9 TPS) in the Long Context scenario. This proves that when memory bandwidth is severely bottlenecked, the overhead of a Go-based orchestration layer drastically amplifies PCIe latency.</li></ul><p><strong>The 8B Threshold and Conservative Scheduling</strong></p><p>The 99.5% performance leap on the 8B model highlights the fundamental difference in memory management. When a model sits on the edge of VRAM capacity, high-level wrappers act conservatively to prevent crashes. Ollama offloads fewer layers to the GPU than the hardware can physically handle, preemptively spilling into the slow PCIe lane. By using llama.cpp directly, I manually forced the GPU to retain critical layers in VRAM, yielding double the throughput.</p><p><strong>The PCIe Wall</strong></p><p>When a model is massively oversized, standard orchestrators like Ollama struggle to manage the massive PCIe traffic, causing throughput to collapse to a nearly unusable 2.9 TPS. By switching to llama.cpp, we can streamline how memory is addressed across the CPU/GPU split, rescuing performance with a 125% uplift-proving that the heavier the hardware bottleneck, the more bare-metal tuning matters.</p><h3><strong>Advanced Optimization Strategies for llama.cpp</strong></h3><p>To understand how low-level configurations affect performance boundaries, I ran extensive benchmarking sweeps using llama-bench. Below are the empirical findings and the exact tuning parameters required to maximize hardware efficiency.</p><p><strong>CPU Thread Optimization (-t): The Asymmetric Topology Trap</strong></p><p>When a model (like Mistral 24B) exceeds VRAM, the CPU must shoulder the workload. On modern asymmetric processors (like the Intel i5–13450HX), simply maxing out the thread count usually degrades performance.</p><pre>./build/bin/llama-bench \<br>  -m models/Mistral-Small-24B-Instruct-2501-Q2_K.gguf \<br>  -ngl 12 \<br>  -fa 1 \<br>  -p 512 \<br>  -n 128 \<br>  -t 4,6,8,10,12 \<br>  -o csv &gt; thread_optimization.csv</pre><p>My benchmarks showed a clear prefill performance peak at 10 threads (263.9 tokens/s). Pushing execution to 12 caused prefill speeds to drop to 217.9 tokens/s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*yXYPWdcPMt2CrLHUmdwBpg.png" /><figcaption><strong>Source: Image by the author.</strong></figcaption></figure><p>Why? The i5–13450HX features 6 Performance cores and 4 Efficiency cores (10 total physical cores). Allocating threads beyond the physical core count forces the fast P-cores to idle while waiting for the slower E-cores to complete synchronized matrix multiplications.</p><ul><li><strong>The Takeaway:</strong> Match your -t flag strictly to your physical core count. Ignore logical hyper-threading for LLM inference.</li></ul><p><strong>KV Cache Quantization Symmetry (-ctk / -ctv)</strong></p><p>As context grows, compressing the KV cache is the only way to avoid an OOM crash on a 6GB card. However, the compression architecture matters immensely. I tested cache precision scaling from 16-bit float (f16) down to 4-bit quantization (q4_0).</p><pre>./build/bin/llama-bench \<br>  -m models/Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf \<br>  -ngl 24 \<br>  -fa 1 \<br>  -p 4096 \<br>  -n 128 \<br>  -ctk f16,q8_0,q4_0 \<br>  -ctv f16,q8_0,q4_0 \<br>  -o csv &gt; kv_cache_tradeoff.csv</pre><p>The data revealed that mismatched precision formats (e.g., an f16 Key cache with a q4_0 Value cache) introduces a massive architectural penalty. Mixed precision breaks the optimized processing paths in llama.cpp, forcing the engine to perform format conversions mid-execution and collapsing prefill speeds to just 33.4 tokens/s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*hZvgfB2dKnX6GeFbN_L3dQ.png" /><figcaption><strong>Source: Image by the author.</strong></figcaption></figure><p>Conversely, using symmetric quantization (e.g., q4_0 for both Key and Value) routes data through highly optimized kernels. This reduced memory-bus congestion, increased token generation speed from 17.7 to 20.3 tokens/s, and slashed the cache’s VRAM footprint by nearly 75%.</p><p><strong>The GPU Layer Offload Cliff (-ngl)</strong></p><p>Offloading splits the model’s layers between the GPU and CPU. Because LLM layers process sequentially, intermediate tensors must constantly traverse the PCIe bus.</p><pre>./build/bin/llama-bench \<br>  -m models/Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf \<br>  -fa 1 \<br>  -p 512 \<br>  -n 128 \<br>  -ngl 0,8,16,24,32 \<br>  -o csv &gt; ngl_test_8b.csv</pre><p>Benchmarking revealed a distinct performance trough. Moving from pure CPU execution (0 layers) to light hybrid offloading (4 to 8 layers) actually decreased decode performance (from 10.3 to 9.4 tokens/s). The overhead of moving intermediate tensors across the PCIe bus costs more time than the computational acceleration gained from the GPU. Performance only begins to scale positively once more than 50% of the layers (16+ layers) are offloaded.</p><ul><li><strong>The Takeaway:</strong> Offload all layers, or almost none. If you cannot fit a significant portion of the model in VRAM, the PCIe latency penalty will render your GPU effectively useless.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*ed6y0msD9wZuJ3KDWWBECQ.png" /><figcaption><strong>Source: Image by the author.</strong></figcaption></figure><p><strong>Batch vs. Micro-Batch Ingestion (-b vs -ub)</strong></p><p>By adjusting batch sizes, we can tune how the GPU ingests massive blocks of text to prevent the “Warmup Spike”, a scenario where transient memory allocations crash the GPU driver.</p><p>I ran parameter sweeps altering the total batch size (-b) versus the physical micro-batch chunks (-ub) fed into the GPU.</p><pre>./build/bin/llama-bench \<br>  -m models/Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf \<br>  -ngl 24 \<br>  -fa 1 \<br>  -p 1024 \<br>  -n 128 \<br>  -b 512,2048 \<br>  -ub 128,512 \<br>  -o csv &gt; batch_size_evaluation.csv</pre><p>Increasing the micro-batch size (-ub) from 128 to 512 massively increased prefill speed by up to +85%. However, because it forces the GPU to process larger tensor chunks simultaneously, it requires more available VRAM padding to prevent an OOM crash. Decode speed remained entirely unaffected. This proves that micro-batch tuning is the single most effective lever for optimizing RAG pipelines (which are heavily prefill-dependent) on constrained hardware.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*NiX4qC3D2D7fydbGJmZlyA.png" /><figcaption><strong>Source: Image by the author.</strong></figcaption></figure><h3>Conclusion</h3><p>High-level wrappers like Ollama are incredible tools for velocity, prioritizing stability and ease of deployment. However, velocity often comes at the direct cost of hardware efficiency.</p><p>For data scientists and engineers operating on the edge, whether utilizing an aging 6GB gaming laptop or a constrained IoT device, defaults are usually the enemy. The “abstraction tax” is real, but entirely manageable. By dropping down to the bare metal, managing asymmetric CPU threads, symmetrically quantizing the KV cache, and understanding PCIe transfer limits, it is possible to double the throughput of standard local models.</p><p>When hardware is scarce, stripping away the orchestration layer transforms an underpowered machine from a struggling testing environment into a highly responsive inference engine.</p><p>All raw automated benchmarking scripts, configuration files, and datasets used to generate these profiles are open source and available in my <a href="https://github.com/abhinandan-084/local_llm_benchmarks">GitHub repository</a>.</p><p><strong>Update (July 2026):</strong> Performance was only half the trade-off. I’ve since measured the other half, how often a local 8B fabricates numbers versus a frontier model — in <a href="https://medium.com/p/0db77efb0644">The Grounding Tax, published in Towards AI</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=783a14af365d" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/optimizing-local-llm-inference-on-constrained-hardware-783a14af365d">Optimizing Local LLM Inference on Constrained Hardware</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>