ProductsRabbit HoleCase StudiesProving GroundBuild YoursResearchAbout
The Rabbit Hole · Part XII

Local AI

Less “what is AI?” More “how do I run the thing myself, and should I?”

October 2026·Michael Gibbs, Onyx AI Labs·Guide ~45 min · with every panel open ~70 min · 2 demos

Read the prose straight through for the argument. Open “Go deeper” under any section for the boards, diagrams and sources behind it, or switch them all on from the chapter bar.

In this part

Five rabbit holes, one of them costs money

Part XII is the last numbered chapter in the series. Part I said what AI is; Parts II to XI covered how it works, agents, harnesses, your data, risk and the landscape, and this chapter assumes all of them. It is about owning the inference: downloading a model, running it on hardware you control, and deciding whether that was a good idea. The harness half, the software body around the model, lives in Part V, which you should have read.

Five topics. First, why own the inference: four good reasons, four bad ones, and what “privacy” actually means on either side of the wire. Second, the stack in plain words: weights, quant, runtime, endpoint, harness, with a ten-minute exercise you can run on your own laptop so none of them stay abstract. Third, what it costs: gigabytes, dollars and time, with the current hardware board, the current API board and the break-even arithmetic.

Fourth, what you can do with it: the model board, four jobs local models are good for, and the local-plus-frontier architecture. Fifth, a plan: LM Studio first, one model made boring, measure, decide.

One rule runs through all of it, and it comes from Part I and has not aged: if you cannot name the data that must not leave the building, the volume that makes the arithmetic work, or the site with no network, you do not have a requirement. You have a hobby. Local inference is a decision about data and money, not a personality. Hobbies are allowed. They should be called hobbies.

01
Why own the inference
Four good reasons, four bad ones, and what “privacy” actually means on either side of the wire.
02
The stack, in plain words
Weights, quant, runtime, endpoint, harness. And an exercise you run yourself in ten minutes.
03
What it costs
Gigabytes, dollars and time. The current hardware board, the current API board, the break-even arithmetic.
04
What you can do with it
The model board, four jobs local models are good for, and the local-plus-frontier architecture.
05
Use it Monday
LM Studio first. One model made boring. Measure. Decide.
01 / 05

Why own inference

Owning the inference means deciding where intelligence is allowed to live, and paying for that decision.

Reasons · not vibes

The reasons that survive a hard look, the reasons that do not, and the uncomfortable fact that “local” moves the security problem onto your desk rather than removing it.

01 · Why own the inference

Four reasons to own the inference that hold up.

There are four reasons to run a model on hardware you control, and they are not equal. The first is privacy and sovereignty, and it is the one that wins arguments fastest; the other three are real reasons too, and they follow. If a specific body of data must not cross an external API boundary, whether because a contract says so, a regulator says so, or the site has no network, then local inference is the requirement. The test is whether you can name the data.

“Sensitive stuff” is not a name. “The claims database” is. The second is economics at volume. A per-token bill is a variable cost; a machine is a fixed cost. At some volume the fixed cost wins. This argument needs the volume, the price you would actually pay in the cloud for the same quality, and the cost of the person who keeps the machine running.

The cost topic below works through it, and the answer in 2026 is less flattering to local than it was two years ago. The third is latency and offline operation, which is real and specific: ships, mines, clinics, factory floors, places where the network is slow or absent. The fourth is experimentation. Engineers want a local model because every layer is inspectable and swappable, and that is a good reason to give a team a learning budget.

It is not a reason for the company to run production on it. Call it a learning budget and nobody is misled.

Three of these are business reasons. The fourth is a learning budget. Label it as one and it is fine.

Go deeper4 panels

Privacy and sovereignty

A named corpus that must not cross an external API boundary: customer records, unreleased code, a contract that says so, an air-gapped site. Note the word “named”. “Sensitive stuff” is not a name.

Economics at volume

If inference runs all day, every day, owned hardware turns a per-token bill into a capacity-planning problem. Only at real volume, and only against the price you would actually pay. Section 03 does the arithmetic.

Latency and offline

No network round-trip, and it keeps working when the WAN does not. Ships, mines, clinics, factory floors, and the demo you give in a basement conference room.

Experimentation

You can swap weights, change the quantisation, fine-tune, instrument every token. The whole stack is inspectable. This is why engineers want one; it is not, by itself, why the company should buy one.

01 · Why own the inference

Four reasons that don’t. Keep this list; you will hear all of them.

This list is worth keeping, because every one of these sentences will be said in a meeting near you. “No API means no risk” is the most dangerous, because it feels like common sense. What actually happens is that the risk changes shape: instead of trusting a vendor’s contract and security team, you are now running a network service on a machine you patch, loading model files you downloaded from strangers, and deciding who can reach the port.

The next section has the numbers. “We can beat the frontier” is occasionally true for a narrow task with a good test set, and almost never true for general work on a hard day; the right response is not to argue but to measure, which the cost topic covers. “The GPU is already paid for” ignores the only line item that reliably grows: the human hours.

“Open weights means open source” is a definitional error with legal consequences, and Part XI spent two sections on it. The short version is that the Open Source Initiative’s definition of open source AI, version 1.0, requires not only the parameters but the complete code used to train and run the system, and enough information about the training data that a skilled person could rebuild something substantially equivalent. Almost no open-weight model meets that. What you get is a file and a licence, and the licences differ: Apache 2.0, MIT, and vendor-specific community licences all appear on the model board later in this chapter. The licence is usually one page. Read it before you build on it.

None of these is stupid. Each is half of a true sentence. The missing half is where the cost lives.

Go deeperwhat goes wrong · 1 source
THE REASON YOU WILL HEAR → WHAT IS ACTUALLY TRUE
“No API means no risk.”
→
You moved the attack surface onto your own desk. Exposed servers, poisoned model files, your own patching. Next section.
“We can beat the frontier.”
→
Usually not, and not on the hard days. Quality is one beat behind, sometimes two. Section 03 says how to measure the gap on your own work.
“The GPU is already paid for.”
→
Your time is not. Drivers, quants, context settings, “why is it broken after the reboot”. Budget a human, or you have a hobby with a power bill.
“Open weights means open source.”
→
It does not. The OSI definition needs the training code and data information too. Most open-weight models give you a file and a licence. Read the licence.
Sources (1)
  1. https://opensource.org/ai/open-source-ai-definition
01 · Why own the inference

“No API means no risk.” The attack surface moved. It did not leave.

Two findings make the point. In September 2025 Cisco’s Talos team used Shodan, the search engine for internet-connected devices, to look for Ollama servers reachable from the public internet. They found over 1,100, more than a thousand of them within ten minutes of starting. That is less time than it takes to download a large model. About one in five was actively serving a model to anyone who connected, which means free compute for strangers, the ability to query the model repeatedly and reconstruct its behaviour, and a platform for generating whatever the model can be talked into.

The other four in five had no model loaded but still accepted uploads and configuration changes, which is arguably worse. None of these exposures needed a sophisticated attack; they were default settings on a port nobody closed. Separately, in early 2025 ReversingLabs found two models on Hugging Face whose PyTorch files contained a reverse shell, a payload that connects back to an attacker’s machine.

PyTorch’s default format is a Pickle file, and loading an untrusted Pickle without weights-only mode can execute code; these were compressed in a non-standard way so the platform’s scanner, Picklescan, errored before it reached the malicious part. Hugging Face removed them within a day and fixed the scanner. So the lesson is to follow the ordinary rules for a network service and a downloaded file: bind to localhost, put it behind authentication, prefer safetensors or GGUF files over Pickle, and download from the model’s own organisation. Part X goes deeper.

A local model is a network service plus a file you downloaded from a stranger. Treat both exactly that way.

Go deeper3 panels · 3 sources
1,100+

Ollama servers found open to the public internet by Cisco Talos using Shodan. Over 1,000 of them turned up in the first ten minutes of scanning.

Cisco Talos via The Register, Sep 2025
~20%

of those were actively serving models to anyone who asked: free compute, model extraction, jailbreaks. The other 80% were idle but still accepted model uploads and config changes.

Cisco Talos via The Register, Sep 2025
2

model files on Hugging Face found carrying a reverse shell inside a PyTorch (Pickle) payload, built to slip past the platform’s scanner. Removed within 24 hours of the report.

ReversingLabs, Feb 2025
Sources (3)
  1. https://www.theregister.com/2025/09/02/exposed_ollama_servers_insecure_research/
  2. https://tailscale.com/blog/AI-endpoints-on-public-web
  3. https://www.reversinglabs.com/blog/rl-identifies-malware-ml-model-hosted-on-hugging-face
01 · Why own the inference

Privacy is a contract on one side and a wire on the other.

It helps to be precise about what “privacy” buys on each side. A cloud API is a contract. OpenAI’s enterprise privacy page, read in October 2026, says API inputs and outputs are not used to train its models unless you opt in, may be retained for up to thirty days for abuse monitoring, and can be put under zero data retention for eligible endpoints. It also says the platform is SOC 2 Type 2 audited, with business associate agreements available for healthcare. Anthropic publishes the equivalent.

That is a strong set of promises, and for most businesses it is enough. What it is not is the data staying in the building: it crosses a wire, it is processed on a third party’s machines, and unless you pin the region, in a jurisdiction you did not choose, and the terms are theirs to change. A local model is a wire that stops at your wall. LM Studio’s documentation is explicit that nothing you type into a chat leaves the device, and that once models are downloaded the application does not need the internet.

In exchange you now own everything the vendor used to own: the port, the file, the patching, the access list, the backups and the person who is awake when it breaks. The exposed-server count in the section above is what it looks like when people take the wire and skip the ownership. Neither choice is wrong. One of them is a contract you read; the other is a job you staff.

Pick local because a named dataset must not leave. Pick cloud because you read the contract. Both are decisions. Only one of them has no per-token bill.

Go deeper2 panels · side by side · 2 sources
Cloud API · what you actually get

A contract, and someone else’s ops.

  • OpenAI’s API: not used for training by default; inputs kept up to 30 days for abuse monitoring; zero-data-retention available for eligible use; SOC 2 Type 2; BAAs for HIPAA. Anthropic publishes equivalents.
  • What you do not get: the data stays on your premises. It crosses the wire, is processed on their machines, and is subject to their jurisdiction and their terms, which can change.
  • What you do get: their security team, their patching, their uptime. None of which you have to hire.
Local · what you actually get

Nothing leaves. Everything is yours.

  • LM Studio’s own docs: “Nothing you enter into LM Studio when chatting with LLMs leaves your device.” Model search and downloads do call out (to Hugging Face). Then it runs offline.
  • What you own now: the open port, the downloaded file, the patch schedule, the access list, the logs, the backups, and the 3am reboot.
  • What you must still write down: which data, which machine, who can reach it. The exposed-server study was mostly people who skipped this step.
Sources (2)
  1. https://openai.com/enterprise-privacy/
  2. https://lmstudio.ai/docs/app/offline
Questions to take back

Name the data. Then name the reason.

Four questions before you buy anything. The first and third are the ones that end most local-AI projects, and that is a good outcome: better to end them here than after the hardware arrives.

  1. Name one dataset that must never cross an external API boundary. Who decided, and is it written down?
  2. Which of your current AI uses would be noticeably worse if they were one model generation behind the frontier?
  3. Who, by name, would patch the box, close the port and restore the backup?
  4. Would a cloud contract with zero data retention and a signed BAA actually satisfy the requirement? If not, what is the requirement?
02 / 05

The stack

Five words you will hear, in the order they happen. Then a ten-minute demo so none of them stay abstract.

Weights → tokens

“I run Qwen” tells you almost nothing; the quantisation, runtime, context setting and harness decide whether the same weights feel brilliant or broken.

02 · The stack, in plain words

Stop saying “I run Qwen” like that explains anything.

The whole local stack fits in five words. Weights are the model: the billions of learned numbers, shipped as a file you download, usually tens of gigabytes. Part I called them the knobs. Quantisation is compression: storing each of those numbers in fewer bits so the file is smaller and runs faster, at some cost to quality that depends on how far you push it and which method you use. “4-bit” is a family of methods. More on that below.

The runtime is the engine: the program that takes the weights and your hardware and produces tokens. llama.cpp runs almost anywhere; vLLM and SGLang are built for serving many requests on GPUs; MLX is Apple’s framework for its own chips. Speed lives here, and so do most of the failures.

The endpoint is the single most useful idea in the chapter: a URL on your machine that speaks the same protocol as the cloud APIs, so every application you own can talk to it without knowing or caring what is behind it. The harness is the software body around the model: tools, memory, the loop and permissions. It has its own chapter now, Part V. The reason the order matters is that each layer can ruin the one above it.

Someone who says “Qwen is bad” has usually tested a particular quant, on a particular runtime, at a particular context setting, on particular hardware. Change any of the four and the verdict changes.

A model name without the quant, runtime, context and hardware is not a specification. It is a brand.

Go deeperstep diagram · 5 sources
THE MODEL

Weights

The learned numbers. A file you download: tens of gigabytes. Qwen, DeepSeek, GLM, Gemma, Mistral, gpt-oss. Part I: “weights are the knobs.”

COMPRESSION

Quant

Quantisation: store each number in fewer bits. Smaller, faster, slightly dumber. “4-bit” is a family of methods, not one setting.

THE ENGINE

Runtime

Turns weights plus hardware into tokens. llama.cpp, vLLM, MLX, SGLang. This is where speed lives, and where it breaks.

ONE URL

Endpoint

An OpenAI-compatible address on your machine, e.g. localhost:1234/v1. Every app talks to this. It does not care what is behind it.

THE BODY

Harness

Tools, memory, the loop, permissions. The thing that gives the model hands. Part V is entirely about this.

Sources (5)
  1. https://github.com/ggml-org/llama.cpp
  2. https://docs.vllm.ai/
  3. https://docs.sglang.io/
  4. https://github.com/ml-explore/mlx-lm
  5. https://lmstudio.ai/docs/developer/openai-compat
02 · The stack, in plain words

Open weights: a file you can download. Not open source.

An open-weight model is a file. Qwen3.8-27B, released by Alibaba in August 2026, is a dense model of about 27 billion parameters under the Apache 2.0 licence; stored at 16 bits per parameter that is roughly 54 gigabytes before anyone compresses it. You can download it, run it, inspect it, quantise it, fine-tune it, and never send a token anywhere. What you cannot do is reproduce it. The Open Source Initiative’s definition of open source AI, version 1.0, requires the complete training and inference code and enough information about the training data that a skilled person could build something substantially equivalent. Almost no open-weight release includes that. That is why “open weights” and “open source” are different phrases, why Part I warned you not to conflate them, and why Part XI gave the licence table a section of its own.

The licences also differ. Among the models on this chapter’s board, Qwen3.8-27B, Gemma 4 and OpenAI’s gpt-oss are Apache 2.0; DeepSeek-V4.1-Flash and GLM-5.3-Flash are MIT; Qwen3.8-Flash-Next carries a Qwen community licence with its own conditions. Each is about a page.

Two more words you will meet. Dense means every parameter participates in every token, so memory tracks the parameter count. Mixture of experts means many parameters exist but only a subset is used per token: GLM-5.3-Flash has 320 billion in total and 18 billion active. That makes it fast per token and still enormous to store, because every expert has to be in memory in case it is needed.

Part II explained the mechanism; Part XI covers who makes these models and why that matters to procurement.

Go deeper5 panels · 7 sources

What you get

The parameters, as a file. Qwen3.8-27B is 27 billion numbers; at 16-bit that is about 54 GB on disk before quantisation. You can run it, inspect it, quantise it, fine-tune it, and never send a token to anyone.

What the licence says

It varies. Qwen3.8-27B: Apache 2.0. DeepSeek-V4.1-Flash and GLM-5.3-Flash: MIT. Gemma 4: Apache 2.0. gpt-oss: Apache 2.0. Qwen3.8-Flash-Next: a Qwen “community” licence with its own terms. One page each. Read it.

What “open source” would add

The OSI definition (v1.0) requires the training code and enough data information to rebuild the system. Almost no open-weight model ships that. You can use the file; you cannot reproduce it.

Dense vs mixture of experts

Dense: every parameter works on every token; memory need tracks the parameter count. MoE: many parameters, few active per token (GLM-5.3-Flash: 320B total, 18B active). Fast per token, but all the experts still have to live in memory. Part II covered why.

Where they come from

Mostly Chinese labs (Alibaba, DeepSeek, Zhipu), plus Google, Mistral and OpenAI’s gpt-oss. Part XI covers the geopolitics and what that means for procurement. Here we only care that the file runs.

Sources (7)
  1. https://huggingface.co/Qwen/Qwen3.8-27B
  2. https://huggingface.co/Qwen/Qwen3.8-Flash-Next
  3. https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash-1017
  4. https://huggingface.co/zai-org/GLM-5.3-Flash
  5. https://huggingface.co/google/gemma-4-31B-it
  6. https://huggingface.co/openai/gpt-oss-20b
  7. https://opensource.org/ai/open-source-ai-definition
02 · The stack, in plain words

Quantisation: compression at a cost. Here is the cost.

Quantisation makes local AI possible, and the numbers are worth seeing once. Weights are stored as numbers, and the bits used for each one set the file size: parameters times bits divided by eight gives bytes. Qwen3.8-27B at its released 16 bits is about 54 gigabytes, more memory than most people have. At 8 bits it is 27 gigabytes and, in most published measurements, indistinguishable from the original. At 4 bits it is about 13.5 gigabytes, fits a 16 gigabyte graphics card or a modest Mac, and loses a small, measurable amount of quality. At 2 bits it fits a 12 gigabyte card and is noticeably worse. The one public measurement here comes from a MiaAI_Lab recipe for this exact model, which reports mean KL divergence from the 16-bit original (how far the compressed model’s predictions drift; lower is closer): 0.007 at 6 bits, 0.05 at 4 bits, 0.35 at 2 bits.

One author, one method, so treat it as shape rather than gospel. The shape matches everything else published. Real downloads run larger than the formula because quantised files mix precisions, keep the vision tower uncompressed, and exclude the context cache, which the appendix at the end of this chapter covers. The formats are different engines’ containers for the same idea: GGUF for llama.cpp and the tools built on it, MLX for Apple silicon, EXL3 for aggressive NVIDIA quants, FP8 and NVFP4 for server GPUs. The rule is simple.

Start at 4-bit. Go up if memory allows; go down only when your own test set says it still passes.

Quantisation is why a 27B model fits a laptop. And why “the same model” gives two people different answers.

Quantisation: round the numbers, measure what you lost

Try it

Pick a bit-width and watch 64 real numbers snap to fewer allowed values; the readouts show the memory saved and the error introduced.

Real rounding of real numbers. Production quantisers are cleverer about which numbers to protect; the trade is the same.
What it is
Real rounding of real numbers.
What it shows
Memory saved and error introduced at each bit-width.
What it does not show
Production quantisers, which protect the numbers that matter most, or the effect on answer quality for your task.
Go deeper3 panels · table · 3 sources
16-bit (as released)≈ 54 GBReference quality. Needs about 80 GB with cache and headroom.
8-bit≈ 27 GBNear-identical. Fits a 32 GB GPU tightly, a 48 GB Mac comfortably.
4-bit≈ 13.5 GBThe usual local choice. Small, measurable loss.
2-bit≈ 6.75 GBFits a 12 GB card. Noticeably dumber.

The rule

Start at 4-bit. Go up if you have the memory. Go down only after your test set says it still passes.

The formats you will see

GGUF (llama.cpp, LM Studio, Ollama), MLX (Apple), EXL3 (NVIDIA, aggressive), FP8/NVFP4 (server GPUs). Same idea, different engines.

What “a cost” means

One public recipe measured Qwen3.8-27B quants against the 16-bit original (mean KL divergence, lower is closer): 6-bit 0.007, 4-bit 0.05, 2-bit 0.35. Seven times further from the original at 2-bit than at 4-bit, and fifty times further than at 6-bit.

QWEN3.8-27B · MEMORY FOR THE WEIGHTS ALONE · PARAMETERS × BITS ÷ 8

Weights only. Real downloads run larger: mixed-precision layers, the vision tower, and the context cache (appendix) are extra.

Sources (3)
  1. https://github.com/MiaAI-Lab/Qwen3.8-27B-16gb-NVIDIA-GPUs-one-click-install
  2. https://github.com/ggml-org/llama.cpp
  3. https://huggingface.co/Qwen/Qwen3.8-27B
02 · The stack, in plain words

First contact: two runtimes that install like normal software.

Two tools cover first contact, and both install like ordinary software. LM Studio is a desktop application for Apple-silicon Macs, Windows and Linux. You browse a catalogue, download a model, chat with it, and drop documents into the chat, with no terminal involved. Underneath it runs llama.cpp or, on Macs, Apple’s MLX, but you do not have to know that. Its documentation recommends 16 gigabytes of RAM and says 8 may work with small models. Treat that may as a polite no.

One switch in the Developer tab turns on a local server, by default at localhost port 1234, that speaks the OpenAI and Anthropic API formats; there is also a command-line tool. The docs are specific about privacy: chats and documents do not leave the device, while model search and download call out to Hugging Face. Ollama is the terminal-flavoured equivalent. Its quickstart is one command, ollama run followed by a model name, which downloads the model and opens a chat.

It runs as a background service on port 11434 with an OpenAI-compatible endpoint, and its library lists models with download sizes: Gemma 4 at 12 billion parameters is about 8 gigabytes, Qwen3.5 at 9 billion about 7. It has fewer knobs than a serving stack and is also the product behind most of the exposed servers in the first topic, because binding it to a public interface is a one-line change people make without thinking.

Either one gets a non-engineer from zero to a running model in ten minutes. Pick one; the demo uses LM Studio.

Go deeper2 panels · side by side · 8 sources
LM Studio · the one with a window

Best first contact.

  • A desktop app for Mac (Apple silicon), Windows and Linux. Browse models, download, chat, drop in documents. 16 GB RAM recommended.
  • Runs llama.cpp or MLX underneath; you never see them unless you want to.
  • One switch turns on a local server with OpenAI-compatible and Anthropic-compatible endpoints at localhost:1234. Also a CLI: lms server start.
  • Its docs are explicit that chats do not leave the device. Model search and downloads call Hugging Face.
Ollama · the one in the terminal

Best simple daemon.

  • Install, then ollama run gemma4:e2b. It downloads the model and starts a chat. That is the whole quickstart.
  • A background service at localhost:11434 with an OpenAI-compatible /v1 endpoint. No API key needed locally.
  • A model library with sizes and download weights listed: gemma4 12b is about 8 GB; qwen3.5 9b about 7 GB.
  • Fewer knobs than a serving stack. Also the product behind most of the 1,100 exposed servers: it is easy to put on the internet by accident.
Sources (8)
  1. https://lmstudio.ai/docs/app/system-requirements
  2. https://lmstudio.ai/docs/developer/core/server
  3. https://lmstudio.ai/docs/developer/openai-compat
  4. https://lmstudio.ai/docs/app/offline
  5. https://docs.ollama.com/quickstart
  6. https://docs.ollama.com/api/openai-compatibility
  7. https://ollama.com/library/gemma4
  8. https://ollama.com/library/qwen3.5
02 · The stack, in plain words

When you outgrow the toy: four engines.

Four engines matter once a desktop app is not enough, which usually means more than one person or one program needs the model at once. llama.cpp is plain C and C++ and runs on nearly everything: CPUs, NVIDIA, AMD, Apple and Intel GPUs, Vulkan, even phones. It uses the GGUF file format, quantises from 1.5 to 8 bits, splits a model between CPU and GPU when it does not fit in video memory, and ships a server with an OpenAI-compatible API. Its hard part is the number of command-line flags. vLLM, from UC Berkeley’s Sky Computing Lab, is a GPU serving engine built for throughput: PagedAttention for memory, continuous batching, prefix caching, and an OpenAI-compatible server. Reach for it when many requests arrive at once.

SGLang, from the LMSYS organisation, is in the same category with its own tricks, RadixAttention and speculative decoding, and turns up in the more aggressive published recipes for running large mixture-of-experts models on specific hardware. MLX is Apple’s framework for its own chips; mlx-lm loads models from Hugging Face, quantises them and serves them, and is the fast path on a Mac with a lot of unified memory. The one thing all four share with LM Studio and Ollama is the shape of the endpoint.

All four expose the same kind of endpoint as LM Studio. That is the point: your apps never find out you upgraded.

Go deepertable · 4 sources
EngineWhat it isReach for it whenThe hard part
llama.cppPlain C/C++ inference. CPU, NVIDIA, AMD, Apple, Intel, Vulkan, even phones. GGUF files, 1.5 to 8-bit quants. llama-server gives an OpenAI-compatible API.You want the same model on any hardware, or CPU+GPU split for a model bigger than VRAM.Flags. Dozens of them. Record the ones that worked.
vLLMA GPU serving engine from UC Berkeley: PagedAttention, continuous batching, prefix caching. OpenAI-compatible server built in.Many simultaneous requests on NVIDIA or AMD GPUs: a team, an app, a batch job.CUDA versions, model support lag, memory tuning.
SGLangA high-throughput serving framework (LMSYS): RadixAttention, speculative decoding, multi-GPU. Common in aggressive MoE recipes.You are squeezing a large MoE onto specific hardware and following a published recipe.Same as vLLM, with fewer people to ask.
MLXApple’s framework for its own chips. mlx-lm loads Hugging Face models, quantises them, chats.You own Macs with lots of unified memory and want the fastest path on them.Mac only. Smaller ecosystem than GGUF.
Sources (4)
  1. https://github.com/ggml-org/llama.cpp
  2. https://docs.vllm.ai/
  3. https://docs.sglang.io/
  4. https://github.com/ml-explore/mlx-lm
02 · The stack, in plain words

The endpoint: one URL. Everything else is a client.

If you remember one technical idea from this chapter, make it this one. Every local runtime in the two sections above exposes an address on your machine that speaks the same protocol the cloud vendors use. LM Studio defaults to localhost port 1234, Ollama to 11434, llama.cpp’s server to 8080, and each offers a /v1 path that an OpenAI-style client library will accept without modification; LM Studio and Ollama also offer Anthropic-compatible paths.

The code above is the entire integration: a client library, a base URL pointing at your own machine, and a model identifier copied from the runtime. The consequence is that every harness, workflow tool and script you already use with a cloud vendor can be pointed at a local model by changing one line, and pointed back just as easily.

That is what makes the local-plus-frontier architecture in the fourth topic possible, and it is why the endpoint is the important abstraction. Part XI’s abstraction layer is the same idea seen from the buyer’s side. Two cautions. First, the model identifier names what you loaded, which is weights plus quant plus runtime. Two endpoints advertising the same name can behave differently, so pin and record what is actually behind it.

Second, the API key is a placeholder locally, and the runtimes make it easy to serve on the local network. That is a feature inside a trusted office and the exposed-server study everywhere else. Keep it on localhost, or put a real gate in front of it before anyone else can reach the port.

Compatible is not interchangeable. The URL format is shared; tool calling, chat templates and the model’s behaviour are not. Switching the endpoint is a change you test with Part VI’s eval, not a configuration edit you ship.

A harness should not care whether the provider is OpenAI, LM Studio or a basement rack.

Go deeper2 panels · code · 5 sources
# Three local runtimes, one shape of address
http://localhost:1234/v1     # LM Studio (default port)
http://localhost:11434/v1    # Ollama
http://127.0.0.1:8080/v1     # llama.cpp: llama-server -hf <model>

# Any OpenAI-style client, pointed at your machine
from openai import OpenAI
client = OpenAI(base_url="http://localhost:1234/v1", api_key="local")
r = client.chat.completions.create(model="<id from LM Studio>",
      messages=[{"role": "user", "content": "Summarise this ticket: ..."}])

Same shape as the cloud

LM Studio also exposes an Anthropic-compatible endpoint; Ollama exposes /v1/chat/completions, /v1/responses and /v1/messages. Tools built for either vendor work unchanged.

What “model” means here

The identifier of whatever you loaded: weights + quant + runtime. Two endpoints with the same model name can behave differently. Pin and record it (section 03).

Sources (5)
  1. https://lmstudio.ai/docs/developer/openai-compat
  2. https://lmstudio.ai/docs/developer/core/server
  3. https://docs.ollama.com/api/openai-compatibility
  4. https://docs.ollama.com/quickstart
  5. https://github.com/ggml-org/llama.cpp
02 · The stack, in plain words

Try it yourself. Ten minutes, five steps, nothing leaves your desk.

You can do this on the laptop you have, in about ten minutes, and only the first two steps need the internet. Step one: install LM Studio from lmstudio.ai on a Mac with Apple silicon, a Windows machine or Linux; the documentation’s recommended floor is 16 gigabytes of RAM. Step two: download a model in the 9 to 12 billion parameter class. In the Discover tab, search for “Qwen3.5 9B” or “Gemma 4 12B” and pick a 4-bit GGUF; each is roughly 6 to 8 gigabytes, going by the Ollama library’s listed sizes for equivalent builds. Step three is the point of the exercise: chat with it, paste in a document and ask a question about it, then switch the wifi off and ask again. Nothing changes, because nothing was leaving.

While it answers, watch the tokens-per-second counter at the bottom of the window; that number, on your hardware, is what you would be buying with a bigger machine. Step four: open the Developer tab and start the server, which runs at localhost port 1234. Open that address in a browser to prove it exists. Step five: point a tool at it. Use the Python snippet from the section above, or a harness from Part V with its base URL changed to the local address, and ask the same question.

Same answer, no cloud. Three things come out of this: the download size, the speed, and the one line in step five. The rest of the chapter is about what those cost and what they are good for.

What to notice: the download size, the speed counter, and that step 5 took one line. Those three things are the whole chapter.

Go deepertimeline · 5 sources
1

Install LM Studio

lmstudio.ai, download, open. Mac with Apple silicon, Windows x64/ARM, or Linux. 16 GB RAM is the recommended floor.

1 min
2

Pull a ~9B model

Discover tab → search “Qwen3.5 9B” or “Gemma 4 12B”. Pick a 4-bit GGUF, roughly 6 to 8 GB. This is the only step that needs the internet.

3–5 min on office wifi
3

Chat. Then unplug.

Ask it something about a pasted document. Turn wifi off. Ask again. Watch the tokens-per-second counter at the bottom of the window.

2 min
4

Start the server

Developer tab → Start server. Note the address: localhost:1234/v1. Open it in a browser to prove it is there.

30 sec
5

Point a tool at it

Any OpenAI-compatible client: the Python snippet from the previous section, or a harness from Part V with its base URL changed. Same question, same answer, no cloud.

2 min
Sources (5)
  1. https://lmstudio.ai/docs/app/system-requirements
  2. https://lmstudio.ai/docs/developer/core/server
  3. https://lmstudio.ai/docs/developer/openai-compat
  4. https://ollama.com/library/qwen3.5
  5. https://ollama.com/library/gemma4
Questions to take back

What did you just see, and what didn’t you?

Four questions to ask while the numbers from the exercise are still fresh. The second is the one that separates “chat with a model” from “run a workload”; most people have never thought about tokens per second as a budget.

  1. The model answered with the wifi off. Where would that property alone matter to you?
  2. The speed counter showed a number. Is that fast enough for a person waiting? For a batch job overnight? For an agent making forty calls per task?
  3. The download was one file from one organisation. Would your IT team let that file onto a company laptop? What would they want to check?
  4. Step five changed one line. Which of the tools you use could be pointed at that URL, and should they be?
03 / 05

What it costs

Gigabytes, dollars and hours. All three change this year: memory prices did something nobody planned for.

GB · $ · hours

Three costs follow: the box, the cloud alternative and the people. The memory price shock of 2026 runs through all of them, and the people are the cost nobody budgets.

03 · What it costs

Fit it in the box: parameters × bits ÷ 8. Then add the context.

Sizing a box starts with one line of arithmetic: parameters times bits divided by eight gives the bytes needed for the weights. The table applies it to models from this chapter’s board. Qwen3.5 at 9 billion parameters is about 18 gigabytes at 16-bit and 4.5 at 4-bit, and the Ollama library lists its 9B downloads at 6.6 to 7.6 gigabytes; the gap between formula and real file is mixed precisions, an uncompressed vision tower and metadata. Qwen3.8-27B is 54 and 13.5; Gemma 4’s 31B dense model is 62 and about 15.5, with Ollama listing it at 19 to 20. Then come the mixture-of-experts models. OpenAI’s gpt-oss-120b has 117 billion parameters, of which about 5 billion are active per token. That makes it fast, but all 117 billion must be in memory, and it ships at roughly 4-bit precision to fit a single 80 gigabyte GPU. GLM-5.3-Flash at 320 billion total needs about 160 gigabytes at 4-bit, and DeepSeek-V4.1-Flash at 763 billion needs about 380: 512 gigabyte Mac Studio or rack territory.

All of this is the weights alone. The context cache, the stored attention state for every token in the window, sits on top and grows with the context length; for a representative 32-layer model one published calculation gives about 16 gigabytes at 128K tokens, and for an 80-layer model about 40. That is why a model that fits at a 4K window stops fitting at 64K, and why the runtime’s context setting is part of the specification. The appendix has the formula.

The rule gives the floor. Downloads are bigger, the context is extra, and the runtime wants headroom. Leave a third of the memory free.

Go deepertable · 8 sources
ModelParametersAt 16-bitAt 4-bitWhat that means
Qwen3.5-9B (dense)9B≈ 18 GB≈ 4.5 GB · download 6.6–7.6 GBAny 16 GB laptop. The demo model.
Qwen3.8-27B (dense)27B≈ 54 GB≈ 13.5 GB · download 17–20 GB (3.5 class)24 GB GPU comfortably; 16 GB only with an aggressive 2.5-bit quant and a 4-bit cache, per the appendix recipe.
Gemma 4 31B (dense)31B≈ 62 GB≈ 15.5 GB · download 19–20 GB32 GB GPU or 48 GB+ Mac.
gpt-oss-120b (MoE, 5B active)117B≈ 234 GBships at ~4-bit (MXFP4)128 GB unified box: Spark, Strix Halo, M5 Max.
GLM-5.3-Flash (MoE, 18B active)320B≈ 640 GB≈ 160 GB2× DGX Spark, or a 256 GB M5 Ultra.
DeepSeek-V4.1-Flash (MoE)763B≈ 1.5 TB≈ 380 GB512 GB Mac Studio, or a rack. Section 04.
Sources (8)
  1. https://ollama.com/library/qwen3.5
  2. https://ollama.com/library/gemma4
  3. https://huggingface.co/Qwen/Qwen3.8-27B
  4. https://huggingface.co/google/gemma-4-31B-it
  5. https://huggingface.co/openai/gpt-oss-20b
  6. https://huggingface.co/zai-org/GLM-5.3-Flash
  7. https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash-1017
  8. https://www.hivenet.com/post/kv-cache-llm-gpu-memory-context-window
03 · What it costs

The hardware board, checked October 2026.

The hardware board, the most perishable section here, read from vendor pages and launch reporting in October 2026. The first tier costs nothing extra: a laptop with 16 to 32 gigabytes of RAM, or a desktop with any 8 to 16 gigabyte graphics card, runs the 4 to 9 billion parameter models.

The middle tier is now unified-memory machines, with CPU and GPU sharing one pool. Apple’s M5 Max goes to 128 gigabytes at 614 gigabytes per second, Studio from $2,499, 16-inch laptop from $2,699, before the memory upgrade. The Framework Desktop (Ryzen AI Max+ 395, 128 gigabytes) lists at $3,449, up from $1,999 at launch, and was out of stock when checked.

The RTX 5090, 32 gigabytes and 575 watts, is the fastest single card for models up to about 31 billion parameters, but its $1,999 list price is fiction. A 19 October 2026 survey found the cheapest US listing at $7,998, and other trackers $5,000 to $6,500. The lab tier is NVIDIA’s DGX Spark, 128 gigabytes at 273 gigabytes per second, now $6,950 after two increases from about $4,000, with a 64 gigabyte model at $4,999, and the Mac Studio M5 Ultra from $5,499, with 512 gigabytes due late October.

The cause is the 2026 DRAM shortage from AI datacentre demand; Framework’s CEO said in January he expected it to last years. Part I’s tiers of $0 to 800, $1,500 to 5,000 and $8,000 and up were right in 2025; the middle tier now starts nearer $2,500, and the consumer GPU route is the dear one.

Part I said $0–800, $1.5–5k, $8–25k+. Memory prices rewrote that: the middle tier now starts nearer $2.5k and the GPU route is the dear one.

Go deepertable · 11 sources
TierBoxMemory for modelsPrice, Oct 2026Fits
Already paid forThe laptop you have (16–32 GB RAM, or any 8–16 GB GPU)8–24 GB$0 extra4–9B at 4-bit. The demo. Classifiers, summaries, private notes.
Serious individualMacBook Pro M5 Max, up to 128 GB unified (614 GB/s)up to ~100 GB16" from $2,699 base; 128 GB costs more27–31B dense at 8-bit; 120B MoE at 4-bit. A daily driver.
Mac Studio M5 Max, up to 128 GB (614 GB/s)up to ~100 GBfrom $2,499 baseSame, on a desk, quieter.
Framework Desktop, Ryzen AI Max+ 395, 128 GBup to ~96–110 GB$3,449 (was $1,999 at launch; out of stock)Same class on x86/Linux. Slower memory than the Macs.
RTX 5090, 32 GB GDDR7, 575 W32 GBMSRP $1,999; street $5,000–8,000Fastest 27–31B box. If you can find one.
Lab / companyNVIDIA DGX Spark, 128 GB unified (273 GB/s)~120 GB$6,950 (launched ~$4,000); 64 GB model $4,999Up to ~200B MoE; two linked for ~400B class.
Mac Studio M5 Ultra, up to 512 GB (1.2 TB/s)up to ~450 GBfrom $5,499 base; 512 GB “late October”DeepSeek-class MoE at 4-bit in one quiet box.

Base prices from vendor pages and launch reporting; street prices from a 19 Oct 2026 price survey. The 2026 DRAM shortage pushed DGX Spark up ~75%, Framework up $1,450 from launch, and the RTX 5090 to 2.5–4× its MSRP. These change: re-check before you quote them.

Sources (11)
  1. https://www.apple.com/mac-studio/
  2. https://www.iclarified.com/101883/apple-launches-mac-studio-with-m5-max-and-m5-ultra-starting-at-2499
  3. https://macworld.com/article/3220024/apple-announces-the-m5-ultra-mac-studio-with-up-to-512gb-of-ram.html
  4. https://www.apple.com/macbook-pro/
  5. https://www.theregister.com/2026/03/03/apples_m5_pro_max_macbooks/
  6. https://frame.work/products/desktop-diy-amd-aimax300/configuration/new
  7. https://www.pcworld.com/article/3031562/framework-raises-prices-yet-again-as-memory-costs-go-up.html
  8. https://www.nvidia.com/en-us/geforce/graphics-cards/50-series/rtx-5090/
  9. https://www.digitalcitizen.life/gpu-prices-surge-in-2026-as-nvidia-rtx-5090-reaches-7998-and-amd-graphics-cards-also-get-more-expensive/
  10. https://www.theregister.com/a/5300622
  11. https://aiweekly.co/alerts/nvidia-launches-64gb-dgx-spark-at-4999-as-128gb-hits-6950
03 · What it costs

When cloud wins. The arithmetic, with the real prices.

The arithmetic nobody usually shows, with real prices. Cloud prices are from vendor pages, October 2026: OpenAI’s GPT-6 Luna, “our most efficient model for focused, high-volume tasks”, at $0.10 per million input tokens and $0.50 output; Anthropic’s Haiku 5.5 from $0.10 and $0.50; Sonnet 5.5 at $2 and $10; GPT-6 Astra, the current flagship, at $10 and $50. Blended assumes three input tokens per output token, typical of summarisation and classification.

Divide a $6,950 DGX Spark by the blended price per token and you get the tokens the box must process before it beats the cloud. Against the cheap tier that is about 35 billion tokens, twenty-nine years at a hundred million a month; the machine will be in a recycling bin long before. Against Sonnet-class prices about 1.7 billion tokens, or seventeen months; against GPT-6 Astra about 350 million, or three and a half months.

The table is generous to local: it ignores electricity (a 240-watt DGX Spark run eight hours a day is about sixty kilowatt-hours a month, a 575-watt RTX 5090 about a hundred and forty), the person who runs the box, and the fact that the local model is not as good as the cloud model it replaces. So the economic case for local is narrow, but real: work you would otherwise pay frontier prices for, that a local model does well enough on your own test set, at serious volume.

Part I’s rule, cloud wins under fifty to a hundred million tokens a month, was right in 2025; at 2026 cheap-tier prices the line sits far higher. The data question from the first topic is unaffected.

Local vs cloud: your volume, their prices, the hardware-only payoff month

Try it

Enter how many tokens a month you would run and what the box costs; the chart shows how many months it takes to beat each cloud price.

Real arithmetic with editable prices. Defaults are the October 2026 list prices shown here; change them when they move.
What it is
Real arithmetic over prices you can edit.
What it shows
The month a box pays for itself at your volume, against each cloud price.
What it does not show
Operating hours, failures, capacity limits, the engineer's time, or whether the local model's output is good enough for the job.
Go deeper2 panels · table · 6 sources
Cloud model (Oct 2026)In $/M tokOut $/M tokBlended*Tokens to pay off a $6,950 SparkAt 100M tokens / month
GPT-6 Luna (cheap tier)$0.10$0.50$0.20≈ 35 billion≈ 29 years
Claude Haiku 5.5 (cheap tier)from $0.10from $0.50$0.20≈ 35 billion≈ 29 years
Claude Sonnet 5.5 (mid)$2.00$10.00$4.00≈ 1.7 billion≈ 17 months
GPT-6 Astra (frontier)$10.00$50.00$20.00≈ 350 million≈ 3.5 months

What the table says

Against the cheap cloud tier, local does not pay off on price at any volume in this table. Against frontier prices it pays off in months. So the case is: work you would otherwise pay frontier prices for, that a local model does well enough. Prove the second half with a test set.

What Part I said, corrected

Part I: “cloud wins under ~50–100M tokens a month.” At 2026 cheap-tier prices that line sits far higher. Local wins on economics only at very high volume, or against frontier prices. It still wins outright on the data question.

*Blended assumes 3 input tokens per output token. Illustrative: it ignores electricity (a 240 W DGX Spark run 8 hours a day is about 60 kWh a month; a 575 W graphics card about 140), the person who runs the box, and the fact that the local model is not Sonnet or GPT-6 Astra. Prices from vendor pages, 26 Oct 2026.

Sources (6)
  1. https://developers.openai.com/api/docs/pricing
  2. https://developers.openai.com/api/docs/models/gpt-6-luna
  3. https://developers.openai.com/api/docs/models/gpt-6-astra
  4. https://platform.claude.com/docs/en/about-claude/models/overview
  5. https://www.theregister.com/a/5300622
  6. https://www.nvidia.com/en-us/geforce/graphics-cards/50-series/rtx-5090/
03 · What it costs

Hours: ops is the hidden line item. The local AI checklist.

The third cost is hours, and it is the one that does not appear on any invoice. Write down the model and the exact quant, by file hash rather than name, because two files called the same thing can differ. Like two jars both labelled sugar, one of which is salt.

Write down the runtime, its version and the flags, the hardware and driver versions, and the context length and cache settings. CUDA, kernels, runtime, quantisation tooling and model code all move independently, and “it worked last week” is not a reproducible state. Write down who patches it.

Then test it: a set of prompts and tool calls drawn from your real work, measured on this box for speed and time to first answer. If a harness will use the model, test the exact tool schema that harness sends, because a model that writes pleasant prose can be a poor agent, and the only way to know is to try it. Re-run the set after every change to anything in the first column.

Then own it. That means the fallback path when it fails, which might be a cloud call, a queue or a person. It means who can reach the port and from where, backups of the whole working stack and not just the weights, and a date to come back to this list. The line at the bottom is the test. If you cannot write all of this down, you have a successful demo. Call it that.

If you cannot write this down, you do not have a deployment. You have a successful demo.

Go deeper3 panels

Write it down

  • Model + exact quant (file hash, not name)
  • Runtime + version, and the flags
  • Hardware + driver versions
  • Context length + cache settings
  • Who patches it, and when

Test it

  • A prompt and tool-call eval set from your real work
  • Tokens/sec and time-to-first-token on this box
  • The exact tool schema your harness sends: a model that writes nice prose can be a bad agent
  • Re-run after every change to any line on the left

Own it

  • The failure and fallback path (cloud? queue? a person?)
  • Access: who can reach the port, from where
  • Backups of the working stack, not just the weights
  • A date to re-check this section
03 · What it costs

Calibrate your disappointment in advance.

Three disappointments are standard, and knowing them in advance turns them from surprises into line items. The first is quality. Local models are one beat behind the closed frontier, sometimes two; the gap has narrowed dramatically and it is not zero, and it shows most on hard reasoning, on taste, and on long multi-step coding. Do not argue about leaderboards. Measure it on your own work, then decide which jobs can live with the result.

The second is operations, covered in the checklist above: budget a person, at least part-time, or the hardware becomes an expensive space heater. The third is security, which the first topic introduced: secrets, file permissions, the open port, containers, patching and logs are now yours, and the vendor’s security team did not come with the download. Three specific failures are worth naming because everyone meets them.

A model that fits at a 4,000-token context and fails at 64,000 has hit the context cache, which is memory on top of the weights; set the context deliberately and test at the length you will use. A model that writes lovely prose and produces broken tool calls has usually met a harness whose tool schema it was never evaluated on, or a runtime using the wrong chat template; test the exact schema.

And a stack that works until the reboot or the update has unpinned versions; record the working combination and reproduce it before trying to improve it.

Go deeper3 panels · what goes wrong · 1 source

Quality: one beat behind

Sometimes two. The gap has closed a lot and it is not zero: hard reasoning, taste and long-horizon coding still show it. Measure it on your own work, not a leaderboard. Then decide which jobs can live with it.

Ops: the line item you forgot

Drivers, quants, context packing, “why is it broken after the reboot”. The checklist in the previous section is the price. Budget a human, part-time at least, or the machine becomes a very expensive space heater.

Security: now yours

Secrets, file permissions, exposed APIs, containers, patching, logs. The cloud vendor’s security team does not come with the download. Part X already showed what good looks like.

WHAT GOES WRONG → THE GUARDRAIL
It fits at a 4K context and falls over at 64K
→
The context cache is memory too. Set the context deliberately and test at that length.
Lovely prose, broken tool calls
→
Evaluate the exact tool schema. Some runtimes need a model-specific chat template; check it.
Works until the reboot, or the update
→
Pin every version. Record the working stack. Reproduce before you “optimise”.
Sources (1)
  1. https://www.hivenet.com/post/kv-cache-llm-gpu-memory-context-window
Questions to take back

Put a number on it.

Four questions about the numbers. Most people cannot answer the first, and that is the finding: you cannot make the local-versus-cloud decision without a token count. The second question is where the real savings usually are, and they do not require a GPU.

  1. How many tokens a month do you actually send to models today? Does anyone know? What would it cost at the cheap tier?
  2. Which job are you paying frontier prices for that a 9B model with the right document in the window could do?
  3. What does the person who would own the box cost: hours a week, times their rate, times about forty-eight weeks?
  4. If memory prices stay high for years, as Framework’s CEO expects, does that change whether you buy, rent, or wait?
04 / 05

What it is good for

The model board, the four jobs local models are actually good at, and the architecture that uses local for most things and the frontier for the rest.

Local 80 · frontier 20

This topic turns from “can I” to “should I, for what”.

04 · What you can do with it

The model board, checked October 2026. Names expire; the method won’t.

The one table of model names. It will go stale first; the selection method under it will not. Every entry is from the maker’s Hugging Face page or Ollama listing, October 2026. Qwen, from Alibaba, has the widest range: Qwen3.8-27B is a dense 27 billion parameter model under Apache 2.0 with a 256K context, the Qwen3.5 family runs from 0.8 to 397 billion parameters, and Qwen3.8-Flash-Next is a mixture-of-experts with 125 billion parameters and 6 billion active, under a Qwen community licence rather than Apache. DeepSeek-V4.1-Flash-1017, released 17 October 2026, is 763 billion parameters under MIT with a million-token context: frontier-class and lab-tier hardware. GLM-5.3-Flash from Z.ai is 320 billion total and 18 billion active, MIT, multimodal, aimed at coding and agents. Google’s Gemma 4 runs from effective 2B to a 31B dense model, Apache 2.0 with vision and a 256K context, one of the strongest small dense options for laptops. Mistral’s Ministral 3 line, 3, 8 and 14 billion, is Apache 2.0 with vision and built for edge devices.

OpenAI’s gpt-oss, 20B and 120B mixture-of-experts under Apache 2.0, dates from August 2025 and had no newer open release when checked; the 20B runs in 16 gigabytes.

The method is Part XI’s gates 1, 2, 3, 5 and 6, expanded for a box you own. Seven questions, in order. Task quality on your own test set. Licence, because a model you cannot legally use is not a candidate. Fit on the box you have. Tokens per second, measured rather than quoted. The context length you will actually use. Tool calling against your harness’s schema. And operational pain: who suffers when it breaks.

Names change monthly. The order does not.

Go deepertable · step diagram · 11 sources
Family (maker)Current examplesShapeLicenceNote
Qwen (Alibaba)Qwen3.8-27B · Qwen3.5 0.8B–397B · Qwen3.8-Flash-Next 125B-A6BDense 27B; MoE others; 256K contextApache 2.0 (27B, 3.5) · Qwen community (Flash-Next)Widest size range. The default first pull.
DeepSeekDeepSeek-V4.1-Flash-1017763B MoE; 1M contextMITFrontier-class open weights. Needs the lab tier.
GLM (Zhipu / Z.ai)GLM-5.3-Flash320B MoE, 18B active; multimodalMITCoding and agentic focus. 2× Spark class.
Gemma (Google)Gemma 4 E2B, E4B, 12B, 26B-MoE, 31BDense and small MoE; 256K; visionApache 2.0Strong small dense options for laptops.
MistralMinistral 3 (3B, 8B, 14B) · Mistral Small 4 119BSmall dense with vision; 256KApache 2.0 (Ministral 3)European lineage; edge-focused small models.
gpt-oss (OpenAI)gpt-oss-20b · gpt-oss-120bMoE: 21B/3.6B active; 117B/5B activeApache 2.020B runs in 16 GB. Aug 2025; no newer open release.
RULE

1 · Task quality

On your test set.

RULE

2 · Licence

Read the page.

RULE

3 · Fit

The box you have.

RULE

4 · Tokens/sec

Measured.

RULE

5 · Context

That you will use.

RULE

6 · Tool calling

Your schema.

RULE

7 · Ops pain

Who suffers.

Sources (11)
  1. https://huggingface.co/Qwen/Qwen3.8-27B
  2. https://huggingface.co/collections/Qwen/qwen35
  3. https://huggingface.co/Qwen/Qwen3.8-Flash-Next
  4. https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash-1017
  5. https://api-docs.deepseek.com/news/news261017
  6. https://huggingface.co/zai-org/GLM-5.3-Flash
  7. https://huggingface.co/google/gemma-4-31B-it
  8. https://ollama.com/library/gemma4
  9. https://huggingface.co/mistralai/Ministral-3-14B-Instruct-2512
  10. https://huggingface.co/openai/gpt-oss-20b
  11. https://ollama.com/library
04 · What you can do with it

Four jobs a local model is actually good at.

Four jobs justify a local model. The first is a private assistant on your own documents, the named-data case from the first topic made concrete: contracts, personnel files, the claims database go into the model’s window, and nothing leaves the machine. LM Studio does this out of the box; Part VI covers doing it properly, with retrieval, chunking and the ways it goes wrong.

The second is a cheap classifier or summariser in a workflow, rung two of Part IV’s ladder: one model step that tags a ticket, extracts fields, or summarises a call. With the facts supplied in the window, a 9 billion parameter model does this nearly as well as a frontier model, at near-zero token cost, and will run all night. The third is coding with a harness: a 27 to 31 billion parameter model behind the endpoint, with a coding harness from Part V pointed at it.

It is good for the repository that must not leave the building, for cheap iteration, and for learning what a harness does. It is not yet a frontier replacement on hard problems. Expect “useful assistant”, not “senior engineer”. The fourth is batch work: ten thousand documents to classify, a year of transcripts to summarise, a nightly report. Latency is irrelevant, volume is high, and the box is idle anyway. This is where the cost topic’s economics tilt toward local, if the alternative was frontier or mid-tier pricing. Against the cheap tier, run the arithmetic from the cost topic first.

Notice the pattern: messy input, facts supplied in the window, volume, and a human or a rule at the end. Same as every part of this series.

Go deeper4 panels

A private assistant on your documents

Contracts, HR files, the claims database: the named data from section 01. Documents go in the window, nothing leaves the machine. LM Studio does this out of the box; Part VI covers doing it properly (retrieval, chunking, what goes wrong).

A cheap classifier or summariser in a workflow

Part IV, rung 2: a fixed flow with one AI step. Tag the ticket, extract the fields, summarise the call. A 9B model with the facts in the window does this nearly as well as the frontier, at near-zero token cost, all night.

Coding with a harness, privately

A 27–31B model behind the endpoint, with a harness from Part V pointed at it. Good for the repo that must not leave, for cheap iteration, and for learning what harnesses do. Not yet a frontier replacement on hard problems.

Batch jobs

Ten thousand documents to classify, a year of transcripts to summarise, a nightly report. Latency does not matter, volume does, and the box is idle anyway. This is where the economics in section 03 actually tilt.

04 · What you can do with it

Local for the 80%. Frontier for the 20%. Log all of it.

The architecture this chapter closes on. A request arrives: a ticket, a document, a coding task, a batch. The harness, from Part V, wraps it with tools, memory, the loop and permissions. Then a router asks two questions, and it asks them in code rather than by asking a model: may this data leave the building, and can the local model do this job well enough?

The first is a policy lookup; the second is a rule you set from your test set, possibly with a cheap check on the local model’s output. The default answer sends the request to the local model, private and cheap, behind the one URL from the stack topic. The exception, the twenty percent that is hard, high-stakes, or that failed a check, goes to a frontier API, but only if the data rule allows, and the reason is logged.

Everything ends in an output and an audit trail: what ran, which model, which tools, which data left the box. Three properties make it grown-up rather than a diagram. The router is code, so the data rule is a wall rather than a prompt, the same principle Part IV applied to agent permissions. The audit trail means the question “which data left the building?” has an answer in a log.

And because both models sit behind the same shape of endpoint, swapping either one is a configuration change rather than a project. The percentages are a figure of speech: your test set tells you the real split.

Go deeperstep diagram
IN / OUT

Request

A ticket, a document, a coding task, a nightly batch.

CODE / TOOL

Harness

Tools, memory, the loop, permissions (Part V).

RULE

Router / policy

Two questions, in code: may this data leave the building? Can the local model do this job well enough?

MODEL

Local model

Private, cheap, fast. The default. Behind the one URL.

IN / OUT

Output + audit trail

What ran, which model, which tools, which data left the box.

Model judgesCode / tool actsLeaves the building
04 · What you can do with it

Three stories worth knowing.

Three stories, each attached to one of the bad reasons at the start of the chapter. The first belongs to “no API, no risk”: the 1,100 open Ollama servers from the start of the chapter. No vulnerability was exploited. People bound a service to a public interface and never closed the port. The second belongs to the same reason from the other direction: the two Hugging Face models with a reverse shell in their Pickle files.

The lesson: a weight file is code you run, so prefer formats that are not programs, such as safetensors or GGUF, keep the loader patched, and download from the maker’s own page. The third belongs to “the GPU is already paid for”. In 2026 AI datacentre demand for DRAM drove prices up sharply: NVIDIA’s 128 gigabyte DGX Spark went from about $4,000 at launch to $6,950 by October, Framework raised its 128 gigabyte desktop from $1,999 to $3,449, and the RTX 5090 sold for several times its $1,999 list price.

Framework’s CEO said in January he expected the shortage to last years. Hardware is a variable cost too.

Go deeper3 panels · 6 sources
Cisco Talos, 2025

A thousand open doors in ten minutes.

Researchers scanned the internet for Ollama servers and found over 1,100 reachable by anyone, a fifth of them serving models. No exploit was needed: a default setting and a port nobody closed. Idle ones still accepted model uploads.

“No API” is not “no attack surface”. Bind to localhost. Put a gate in front of the port.
ReversingLabs, 2025

The model file was the malware.

Two models on Hugging Face carried a reverse shell inside their PyTorch (Pickle) payload, packed so the platform’s scanner failed before it reached the bad part. Loading them would have handed a stranger a shell. Removed within a day.

A weight file is code you run. Prefer safetensors or GGUF; download from the maker’s own page.
The memory crunch, 2026

The GPU was not already paid for.

AI datacentre demand for DRAM pushed the 128 GB DGX Spark from about $4,000 to $6,950, the Framework Desktop from $1,999 to $3,449, and the RTX 5090 to several times its $1,999 list. Framework’s CEO expects the shortage to last years.

Hardware is a variable cost too. Price the box the week you buy it, and re-check this chapter’s board.
Sources (6)
  1. https://www.theregister.com/2025/09/02/exposed_ollama_servers_insecure_research/
  2. https://www.reversinglabs.com/blog/rl-identifies-malware-ml-model-hosted-on-hugging-face
  3. https://www.theregister.com/a/5300622
  4. https://www.pcworld.com/article/3031562/framework-raises-prices-yet-again-as-memory-costs-go-up.html
  5. https://frame.work/products/desktop-diy-amd-aimax300/configuration/new
  6. https://www.digitalcitizen.life/gpu-prices-surge-in-2026-as-nvidia-rtx-5090-reaches-7998-and-amd-graphics-cards-also-get-more-expensive/
Questions to take back

Which of the four jobs is yours?

Four questions about where this would actually help. The third usually reveals that no written data rule exists, which is the real blocker, and it is not a technical one.

  1. Which pile of documents would people ask questions of, if they were certain nothing left the building?
  2. Which workflow step today sends a cheap, repetitive task to a frontier model because that was the only model anyone had set up?
  3. If you drew the router diagram for a place you know, what would the data rule actually say? Could you write it as a list?
  4. What would the audit trail need to record for your compliance team to sign off on the 20% that leaves?
05 / 05

Use it Monday

Five steps, in order. Most people should stop after the third for a while, and that is fine.

Start boring

Five steps, in order, and deliberately cheap. The first three cost nothing but an afternoon, and most people should sit at step three for a month before buying anything.

On Monday

What I would do on Monday.

01

LM Studio first.

On the laptop you have. Pull a 9B model at 4-bit, chat, turn the wifi off. One hour. If this feels useless, stop here; you have learned something cheaply.

02

Make one model boring.

Pick one job from the four. Build a 50-case test set from real work. Run it. Record the model, quant, runtime, context and speed. Boring means it passes the same way every day.

03

Expose the endpoint. To one app.

Start the server on localhost. Point one tool at it: a script, a workflow step, a harness. Not the office network, not the internet. Watch it for a week.

04

Measure.

Tokens a month, tokens per second, test-set pass rate, hours spent. Four numbers. Compare the first against the cloud price table before anyone says “GPU”.

05

Decide.

Named data that must not leave → local, and buy the box the job needs. Volume against frontier prices → maybe. Neither → cloud, with the contract read. Hobby → say so.

The boring architecture wins: a stable endpoint, a measured model, explicit permissions, a frontier fallback, and a log.

The five, in fullprose version

Five steps, each cheaper than the one people usually start with, which is buying hardware. Step one: install LM Studio on the laptop you already have, pull a 9 billion parameter model at 4-bit, chat with it, and turn the wifi off. An hour, no spend. If it feels useless to you, stop, and you have learned that cheaply. Step two: make one model boring.

Choose one of the four jobs from the previous topic, build a test set of about fifty cases from real work, run it, and write down the model, the quant, the runtime, the context setting and the speed. Boring means it passes the same way every day, which is the property production needs and demos lack. Step three: expose the endpoint, on localhost, to exactly one application: a script, a workflow step, or a harness from Part V. Not the office network, not the internet.

Watch it for a week. Step four: measure four numbers. Tokens per month, tokens per second, test-set pass rate, and hours spent by the person looking after it. Put the first one against the cloud price table from the cost topic before anybody says the word GPU. Step five: decide, using the rule this chapter opened with. Named data that must not leave means local, and you buy the box the job needs. Serious volume against frontier prices means maybe, and the test set decides.

Neither means cloud, with the contract read. And if someone just wants a homelab, say so. Hobbies are allowed.

The names will be wrong in six weeks.
The architecture will not.

Weights you can hold. A quant you measured. A runtime you pinned. One URL your tools talk to. A rule that says which data stays home, and a log that proves it did.

That is the rabbit hole. The rest is a download.

Appendix · For the nerds

Quant formats, and the context cache that eats your memory.

Open the appendixfor the nerds · optional

Two things the chapter simplified. There were more, but these two decide how much memory you need. First, formats. GGUF is llama.cpp’s container and what LM Studio and Ollama mostly run; its quant names, such as Q4_K_M, encode the bits and the method, and the files are mixed precision inside, with the layers that matter most kept at higher bits. MLX is Apple’s own framework, with its own quantised builds listed separately by the runtimes.

EXL3, from the ExLlamaV3 project, allows fractional bits per weight, which is why recipes squeezing a 300 billion parameter mixture-of-experts model onto two DGX Sparks talk about 2.9 bits per weight, and the 700 billion class needs three or four; FP8 and NVFP4 are precisions that server GPUs compute in natively. Second, the context cache. A transformer stores, for every token in the window and every layer, the attention keys and values it computed, so it never recomputes them.

The size per token is the number of layers, times two for keys and values, times the number of key-value heads, times the head dimension, times the bytes per value. For a representative 32-layer model with 8 key-value heads and 128-dimensional heads at 16-bit that is 131,072 bytes per token, or 16 gibibytes at a 128K-token context; an 80-layer model with the same heads needs about 40.

One published example, and real models vary, but the shape is right: the cache scales with the context length you configure, not with how much you typed, and storing it at 8-bit or 4-bit halves or quarters it. This is the second term in fitting a model in a box. The weights were only the first.

GGUF

llama.cpp’s container; what LM Studio and Ollama mostly run. Quant names like Q4_K_M: 4-bit “K-quant”, medium. Mixed precision inside: important layers kept at higher bits. 1.5 to 8-bit variants exist.

MLX

Apple’s framework for its own chips. mlx_lm.convert -q quantises a Hugging Face model; Ollama and LM Studio list separate MLX builds (e.g. gemma4 31b-mlx, 19 GB). Fastest path on a Mac.

EXL3 · FP8 · NVFP4

NVIDIA-side formats. EXL3 (ExLlamaV3) allows fractional bits per weight, e.g. 2.5 or 2.9 bpw, used in aggressive recipes for big MoEs on small boxes. FP8/NVFP4 are server-GPU native precisions.

# KV (context) cache, per token, full-attention transformer
bytes_per_token = layers * 2 * kv_heads * head_dim * bytes_per_value

# representative 32-layer model, 8 KV heads, head_dim 128, BF16 (2 bytes)
32 * 2 * 8 * 128 * 2 = 131,072 bytes/token   # 128 KiB
131,072 * 131,072 tokens ≈ 16 GiB at a 128K context   # ~8 GiB at FP8

# 80-layer model, same heads: 320 KiB/token → ~40 GiB at 128K
Sources (5)
  1. https://github.com/ggml-org/llama.cpp
  2. https://github.com/ml-explore/mlx-lm
  3. https://ollama.com/library/gemma4
  4. https://huggingface.co/Mia-AiLab
  5. https://www.hivenet.com/post/kv-cache-llm-gpu-memory-context-window
Appendix · For the nerds

Version pinning, and recipes worth stealing.

Open the appendixfor the nerds · optional

One point worth keeping: the useful unit of local-AI knowledge is a recipe, not a model name. The code block above shows what one public recipe actually pins for running Qwen3.8-27B on a 16 gigabyte NVIDIA card: the engine, ExLlamaV3 at exactly version 1.6.0, which the kit refuses to run without; the driver generation and CUDA build; the Python and Node versions; the quant and context setting per memory size, 2.5 bits per weight at a 176K context as the 16 gigabyte default, 4.0 bits at 262K for 24 gigabytes and up; the cache precision; the endpoint; and measured quality and speed on named hardware, including the KL divergence figures used in the quantisation section and decode speeds of roughly 100 to 275 tokens per second on a single RTX 5090 depending on task. Those speed figures are the author’s own measurements and will not transfer to your box; the point is that they were measured and recorded.

The order of theft is: copy the pinned versions first, the launch flags second, and ignore anyone’s benchmark until you have run your own job. MiaAI_Lab’s GitHub organisation holds recipes for a range of hardware, from single consumer cards to multiple DGX Sparks, and its Hugging Face account holds the matching quantised files; the makers’ own Hugging Face pages, Qwen, deepseek-ai, zai-org, google, mistralai and openai, are where the original weights and licences live. Download from those, check the hash, pin the stack, and write it down.

# What one public recipe pins (Qwen3.8-27B on a 16 GB NVIDIA card)
engine      ExLlamaV3 v1.6.0      # refuses to start on other versions
driver      NVIDIA 570+           # CUDA build cu128 (or cu132)
python      3.11+   node 22.19+
quant       EXL3 2.5 bpw @ 176K context (16 GB default)
            EXL3 4.0 bpw @ 262K context (24 GB+)
kv cache    int4
endpoint    http://127.0.0.1:8888/v1   # OpenAI-compatible
quality     mean KL vs bf16: 6.0 bpw 0.007 · 4.0 bpw 0.05 · 2.0 bpw 0.35
speed       one RTX 5090, 4.0 bpw: ~100–275 tok/s decode depending on task (the top of that range with speculative decoding or batching)

github.com/MiaAI-Lab

Public recipes with pinned versions: Qwen3.8-27B one-click install for 16–32 GB NVIDIA cards; Qwen3.8-27B on SGLang for DGX Spark; DeepSeek-V4-Flash on 2× DGX Spark; GLM-5.3-Flash EXL3 on 2–4 Sparks; sparkDash monitoring.

huggingface.co/Mia-AiLab

The matching quants: EXL3 builds of DeepSeek-V4.1-Flash at 2.9–3.0 bpw, GLM-5.3-Flash at 4 bpw, MiniMax-M3.1-Flash and others. Plus the makers’ own pages: Qwen, deepseek-ai, zai-org, google, mistralai, openai.

Sources (3)
  1. https://github.com/MiaAI-Lab/Qwen3.8-27B-16gb-NVIDIA-GPUs-one-click-install
  2. https://github.com/MiaAI-Lab
  3. https://huggingface.co/Mia-AiLab