Local LLM runtimes
Ollama's daemon, LM Studio's desktop app and llama-server run open-weight models on one machine behind a localhost API. Interviewers ask when that beats a hosted API on privacy and cost.
on this pageshowhide
guide
overview
~1 minLocal model runtimes load an open-weight language model on a machine you control and serve it behind an HTTP endpoint on localhost. Interviewers bring them up when a role involves data that must not leave the building, an offline or air-gapped environment, steady inference volume where per-token pricing adds up, or simply a developer laptop running a coding assistant. The probe is judgement more than syntax: when local beats a hosted API and when it does not, what the runtime decided on your behalf, where the model's memory actually went, and which parts of a familiar client stop working once its base URL points at your own box. The subject has three sections, and they stack rather than compete. [llama.cpp](/topics/ai-llama-cpp) is the engine underneath: the GGUF file format, quantization, the compute backends and its own llama-server. [Ollama](/topics/ai-ollama) wraps local inference in a background daemon with a pull-and-tag model registry, Modelfiles that bake settings into a named model, and native plus compatibility HTTP APIs. [LM Studio](/topics/ai-lm-studio) wraps llama.cpp or Apple's MLX in a desktop app, with a headless daemon, the `lms` CLI and SDKs for scripted use. Each wrapper inherits the engine's constraints and then adds defaults of its own, which is where most surprises come from. Learn the file format and quantization first, because nearly every memory, speed and quality question in the wrappers traces back to them. Then take the wrapper your team uses, and finish with the server topics, where most senior questions sit: sharing one model, exposing it beyond localhost, and what a compatible API leaves out.
primer
A few ideas carry the whole hub; with them in place, most questions below read as applications rather than trivia. - **Memory decides almost everything.** A model runs fast only when its weights and its context cache fit in accelerator memory. Whatever does not fit spills to system RAM and the CPU, and throughput falls off steeply. Weights scale with parameter count times bits per weight; the context cache scales with context length times concurrent requests. Most "why is it slow" and "why won't it load" questions come down to that sum. - **Quantization trades quality for fit.** Storing weights at 4 or 5 bits instead of 16 is what lets a mid-sized model run on a laptop. The loss is uneven across schemes and tensors, and it compounds when you round weights that were already rounded, so where a build came from matters as much as its label. - **The file carries the model's contract.** A GGUF bundles the weights with what a runtime needs to talk to them: architecture, tokenizer, chat template. When output rambles, prints role markers or ignores a system prompt, suspect the template before the model. - **Defaults are decisions someone made for you.** Context length, GPU layers, idle unload timers, how many models stay resident, how parallel requests divide memory: each runtime picks these, picks them differently, and has changed them between releases. A strong answer names the default, says what it optimizes for, and pins it when the behaviour matters. - **A compatible API is a subset.** OpenAI- and Anthropic-shaped routes let existing SDKs work after a base-URL change, but unsupported fields can be ignored quietly and omitted ones can receive different defaults. The native route exists for the controls the compatible one cannot express. - **Localhost is the security boundary.** Out of the box, these servers assume one trusted user on the same machine. Binding to a network interface without authentication turns a developer tool into an open inference endpoint, and a model name that routes to a hosted service defeats the privacy reason for running locally at all.
- Open-weight model
- A model whose trained weights are published for download, so it can run on your own hardware, usually under a licence that sets the terms of use.
- GGUF
- The single-file model format llama.cpp and the tools built on it load, holding the tensors plus metadata such as architecture, tokenizer and chat template.
- Quantization
- Storing weights at fewer bits than they were trained in, cutting memory and often raising speed at some cost in output quality.
- K-quant
- A family of llama.cpp quantization types, named like Q4_K_M, that quantize weights in blocks with their own scales; the suffix marks a size and quality variant.
- GPU offload
- Placing some or all of a model's layers in accelerator memory; layers that do not fit run on the CPU from system RAM, far more slowly.
- KV cache
- Per-token attention state kept during generation so earlier tokens are not recomputed; its size grows with context length and with the number of concurrent requests.
- Context length
- The number of tokens a loaded model can attend to at once. Runtimes often load a model below its trained maximum to save memory.
- Chat template
- The rules that render a list of role-tagged messages into the exact text format a model was trained on, special tokens included.
- Parallel slot
- One concurrent request a server can process. Slots share the loaded weights, but each needs its own portion of the context cache.
- Keep-alive or idle TTL
- How long a runtime keeps an unused model in memory before unloading it; the first request after an unload pays the full load time.
- Compatibility endpoint
- A route shaped like a hosted provider's API so existing SDKs work by changing the base URL; it usually implements only part of that API.
- Modelfile
- Ollama's recipe that starts from a base model and fixes parameters, a system prompt and a prompt template, then builds them into a new named model.
The three sections form a stack, and most debugging means finding which layer made the decision you are looking at. **The file is the bottom layer.** A GGUF build fixes the weights' precision and carries the tokenizer and chat template, so a poor quant or a missing template travels with the file into whichever runtime loads it. LM Studio's MLX builds are the one parallel track: a different format for a different engine, tied to Apple hardware. **The engine turns the file into tokens.** [llama.cpp](/topics/ai-llama-cpp) decides how layers split between GPU and CPU, how the context cache is allocated and which hardware backend does the math. The available backends are largely fixed when the engine is compiled, which is one reason the same file can run very differently under two builds. Its [bindings](/topics/ai-llama-cpp-bindings) let a program embed the engine in its own process instead of calling a server. **The wrappers manage lifecycle.** [Ollama](/topics/ai-ollama) and [LM Studio](/topics/ai-lm-studio) add what the engine leaves to you: finding, downloading and storing models, choosing load settings, keeping a model resident or unloading it when idle, and loading on demand when a request names a model that is not in memory. Their settings end up as engine parameters, so a wrapper question often reduces to which engine setting a given default produced. **The server is the contract with clients.** All three expose a native route plus routes shaped like the OpenAI and Anthropic APIs. Coding assistants, agent frameworks and retrieval pipelines usually target a compatible route so they can switch between local and hosted models; the native route is where runtime-specific controls live.
- GGUF Format and Quantization →
The file format and quant levels underlie every memory, speed and quality trade-off the wrappers expose, so learn what a build label promises first.
- GPU Offload and Memory →
Where memory goes in practice: GPU offload, context size, parallel requests and idle unloading, seen through the tool most people install first.
- HTTP Routes & Compat Gaps →
How existing SDKs reach a local model, and which hosted-API features the compatibility routes leave out.
- llama-server and Endpoints →
The engine's own server shows the knobs the wrappers hide: slots, context division, structured output and what to change before sharing it.
- Server Routes & Access →
A second wrapper's answer to the same problems, including on-demand loading, eviction and authentication for network access.
Sizing a model by its weight file alone and forgetting the context cache, which grows with context length and with every parallel request.
Reading a partial CPU/GPU split as a minor slowdown; layers left in system RAM usually dominate generation speed.
Assuming a compatible endpoint honours every field the hosted API does; unsupported parameters can be ignored quietly and omitted ones can get different defaults.
Blaming the model for rambling output or leaked role markers before checking which chat template the runtime actually applied.
Pulling a floating tag such as
lateston several machines and expecting identical builds instead of pinning a size and quant explicitly.Shrinking an already-quantized download to a smaller quant instead of starting again from a 16-bit source, which compounds the rounding loss.
Binding a local server to a network interface with no authentication on the assumption that the office network is trusted.
Promising that prompts never leave the machine without checking whether any configured model name routes to a hosted service.
Comparing two setups whose implicit defaults differ (GPU layers, context length, flash attention) and blaming the runtime for the gap.
Most questions in this hub turn on one of a few recurring choices, and naming the one you are making is usually the core of a good answer. - **Local versus hosted.** Local keeps data on hardware you control, works offline and has no per-token bill. You pay in hardware, operations and model quality, since open-weight models that fit on one machine generally trail the largest hosted ones. Privacy constraints, steady predictable load and experimentation favour local; peak quality, bursty demand and zero maintenance favour hosted. - **Wrapper versus engine.** Ollama and LM Studio make reasonable choices for a single user quickly. llama.cpp directly gives you every knob and new features first, at the cost of setting them yourself. - **Server versus in-process.** A shared server lets many clients use one loaded model and keeps a crash from taking the caller down with it. Embedding the engine removes the network hop and exposes lower-level control, but ties the model's lifetime to one process. - **Fewer bits versus quality.** A smaller quant fits a larger model, a longer context or more parallel requests in the same memory; past some point the loss shows up as weaker reasoning and formatting slips. A larger model at a lower quant can beat a smaller one at a higher quant, and only a test on your own task settles which. - **Convenience versus reproducibility.** Automatic fitting, floating tags and on-demand loading are pleasant on a laptop and a source of drift on a shared server, where they are better pinned.
explore
- Ollama20 questions
- Model Registry and Pull5 questions
- Modelfile Customization5 questions
- HTTP Routes & Compat Gaps5 questions
- GPU Offload and Memory5 questions
- LM Studio17 questions
- Downloads and Load Settings5 questions
- Server Routes & Access6 questions
- lms CLI and SDKs6 questions
- llama.cpp18 questions
- GGUF Format and Quantization6 questions
- llama-server and Endpoints6 questions
- Bindings and Compute Backends6 questions
questions
page 2 of 2In Ollama, what changes when an indexer moves from /api/embeddings to /api/embed, and what does /api/embed do with over-long inputs?
basics
~20 s/api/embed takes input as a string or list and returns one L2-normalized vector per item under embeddings; /api/embeddings took one prompt and returned a raw vector. Over-long inputs are silently cut unless truncate is false.
When does a client need Ollama's native /api/chat rather than /v1/chat/completions, and how do you read its streamed response?
basics
~20 sUse /api/chat when a request needs Ollama's own controls directly: per-request options such as num_ctx, think levels, or a JSON schema in format. It streams by default as newline-delimited JSON; the last object has done: true and the timings.
A GGUF that runs fast under llama-server crawls on the CPU and rejects long prompts through llama-cpp-python's Llama(model_path=...); which defaults explain it, and what do you set?
basics
~10 sllama-cpp-python 0.3.36's Llama defaults to n_gpu_layers=0, n_ctx=512 and flash_attn=False, while llama-server 0.5.0 picks GPU layers, the model's own context and flash attention automatically. Set n_gpu_layers=-1, an explicit n_ctx and flash_attn=True.
llama-quantize refuses with "requantizing from type ... is disabled" when you shrink a downloaded Q4_K_M GGUF to Q2_K — why, and what should you do instead?
basics
~20 sllama-quantize refuses already-quantized tensors, because rounding Q4_K_M weights again stacks a second error on the first. Quantize from a 16-bit GGUF instead, converted from the original checkpoint or published as BF16; --allow-requantize is a last resort.
After moving to llama.cpp 0.5.0, llama-server starts with less context than the model supports — what is --fit doing, and how do you take control?
basics
~20 s--fit, on by default in llama.cpp 0.5.0, shrinks the unset context, then the unset GPU layer count, until each device keeps a 1024 MiB margin. Pin -c or -ngl, raise the -fitc floor, adjust -fitt, or pass --fit off.
A parser reading JSON from llama-server's /v1/chat/completions started failing overnight — which request fields and server settings do you check first?
basics
~10 sCheck finish_reason first: length means max_tokens or the slot's context cut the JSON off. Then check response_format: json_object without a schema allows any object, and a json_schema type needs its schema nested in json_schema.schema.
A coding extension on LM Studio's server alternates a chat model, an autocomplete model and an embedding model, and every switch waits for a reload — why, and what do you change?
basics
~20 sAuto-Evict, on by default, keeps at most one JIT-loaded model, so each request for a different model unloads the previous one first. Turn Auto-Evict off if memory holds all three, or load them explicitly, which Auto-Evict leaves alone.
Before switching on LM Studio's Serve on Local Network so a second office machine can use the server, what do you configure and why?
basics
~20 sServe on Local Network exposes a server that by default needs no authentication, so first switch on Require Authentication (LM Studio 0.4.0+), issue each client its own API token with only the permissions it needs, and leave Enable CORS off.
After raising OLLAMA_NUM_PARALLEL from 1 to 4 on a shared Ollama box, `ollama ps` shows a 14B model at 41%/59% CPU/GPU — why, and what do you change?
basics
~10 sOllama loads a model with num_ctx times OLLAMA_NUM_PARALLEL tokens of context, so four slots roughly quadruple context memory and push layers off the GPU. Lower num_ctx, set OLLAMA_KV_CACHE_TYPE=q8_0, or reduce parallelism.
A community GGUF imported into Ollama 0.35 with `FROM ./model.gguf` runs past its answer or prints role markers — how do you find and fix its prompt template?
basics
~20 sCheck which template Ollama used: create may have matched the GGUF to a close-but-wrong built-in template, or the file has none. Write the model's format as a Go TEMPLATE with matching PARAMETER stop lines and re-run ollama create.
On an Ollama 0.35 box meant to keep every prompt local, how can a model name still send prompts to ollama.com, and how do you forbid it?
basics
~20 sIn Ollama 0.35.0 a tag ending in :cloud or -cloud runs on ollama.com: the local daemon forwards the request there once you are signed in. Set OLLAMA_NO_CLOUD=1 or disable_ollama_cloud in server.json and restart to forbid it.
Against Ollama 0.35's /v1/chat/completions, an agent sending tool_choice 'required' and n=3 gets one choice and prose replies — why, and what else differs silently?
basics
~10 sOllama 0.35's /v1/chat/completions does not support tool_choice, n, logit_bias or user and drops them without an error. It also sends temperature and top_p of 1.0 when omitted and has no context-size field.
In llama.cpp 0.5.0, an old launch script's --mlock and --no-mmap flags are rejected; what replaced them, and what does each --load-mode value do?
basics
~20 sllama.cpp 0.5.0 replaced both with -lm / --load-mode: auto (the default, mmap unless a device cannot), none, mmap, mlock, mmap+mlock or dio. --no-mmap becomes none; --mlock becomes mmap+mlock, or mlock when mapping was off too.
How do you ship a very large llama.cpp GGUF as shards with llama-gguf-split, and how do llama.cpp tools load the shards afterwards?
basics
~20 sRun llama-gguf-split --split-max-size 40G model.gguf model, which writes model-00001-of-0000N.gguf and the rest, then point llama.cpp tools at the 00001 shard. The loader finds the others by name in the same directory. --merge rebuilds one file.
How do you make LM Studio's /v1/chat/completions return JSON matching a schema, and what should the client still check?
basics
~20 sSend response_format with type json_schema and the schema under json_schema.schema; LM Studio constrains GGUF models with llama.cpp grammars and MLX models with Outlines. The JSON still arrives as a string in choices[0].message.content, so parse and validate it.
LM Studio's server offers /v1/chat/completions, /v1/responses, /v1/messages and the native /api/v1/chat — what decides which one a client should call?
basics
~20 sCall the route the client's SDK already speaks: /v1/chat/completions or /v1/responses for OpenAI SDKs, /v1/messages for Anthropic ones. Use native /api/v1/chat for LM Studio-only features such as per-request context length, but it takes no custom tools.
In LM Studio, how are the inference engines shipped and updated separately from the app, and when does that bite?
basics
~20 sLM Studio packages its engines (llama.cpp, MLX) as separate runtimes, downloadable and hot-swappable without an app update since LM Studio 0.3.0. One runtime is selected per model format, and an outdated or CPU-only runtime explains missing features or GPU use.
In lmstudio-python, why can lms.llm("your-model", config={"contextLength": 16384}) return a model running at a smaller context, and how do you guarantee yours?
basics
~20 slms.llm(key) gets an already-loaded instance of that model if one exists and only loads when none does, so its config and ttl are ignored for an existing instance. Use load_new_instance() with the config, or unload first, then check get_load_config().
After upgrading to Ollama 0.35, an ADAPTER line and `ollama create -q q4_K_M` on a GGUF both fail — what changed, and what replaces each?
basics
~20 sSince Ollama 0.34.1 ollama create rejects ADAPTER ("LoRA adapters are no longer supported"), so merge the adapter into the weights first. --quantize works only on safetensors imports (int4, int8, nvfp4, mxfp4, mxfp8); a GGUF must be quantized before import.
Why does `ollama push mymodel` fail with "not authorized to push to this namespace", and how do you publish it for teammates?
basics
~10 sAn unqualified name lands in the library namespace, which you do not own. Add Ollama's public key to your ollama.com account, rename with ollama cp mymodel myuser/mymodel, push that name, and teammates pull myuser/mymodel.
Pointing an Anthropic-SDK coding tool at a local Ollama 0.35 server, what do you configure, and which Messages API features stop working?
basics
~10 sSet the base URL to http://localhost:11434 with a placeholder token and a local model name. Ollama's /v1/messages handles messages, streaming, tools and thinking, but not tool_choice, count_tokens, prompt caching, batches, PDFs or image URLs.
Two llama.cpp builds of the same GGUF differ threefold in llama-bench; how do you read pp512 against tg128 and isolate the cause?
basics
~20 spp512 is prompt-processing speed over a 512-token prompt and tg128 is generation speed over 128 tokens, both in tokens per second. Check the backend, ngl and build fields first, then rerun both builds with identical explicit flags, sweeping one parameter.
With llama-quantize, how do you keep chosen tensors at higher precision in a Q4_K_M build, and what does the file's quant label then tell its users?
basics
~20 sPass --output-tensor-type and --token-embedding-type for those two tensors and --tensor-type name=type (a regex, repeatable) for others, using ggml tensor types such as q6_K or q8_0. The label stays Q4_K_M, so only the tensor table shows the overrides.
In lmstudio-python, what does model.act() handle that a hand-rolled tool loop over LM Studio's OpenAI-compatible endpoint makes you write, and what stays your job?
basics
~20 smodel.act() turns typed, documented Python functions into tool definitions, runs prediction rounds, executes requested tools in your process and feeds results back until the model stops calling tools; round limits, parallelism, error policy and side-effect safety stay yours.
With Ollama 0.35.0, what does OLLAMA_KV_CACHE_TYPE=q8_0 change, what must be enabled for it to work, and which models does it affect?
basics
~20 sOLLAMA_KV_CACHE_TYPE=q8_0 stores the KV cache at 8 bits, about half the memory of the default f16. It only works with flash attention enabled, which Ollama 0.35.0 does automatically where supported, and it applies to every model on the server.
showing 31–55 of 55