Index of every page on this site: llms.txt
All skills
fiveonecode avatar

/local-model-serving

@8f30014
Run it yourself

Select and run the right local LLM engine (MLX with speculative decoding vs llama.cpp) with the right settings for a task, and enforce the one-engine-at-a-time memory rule. Use whenever a task runs local inference against an OpenAI-compatible endpoint — evals, summarization, code review, content generation — or when choosing between local engines serving the same model.

  • 1 file
  • 5.4 KB
  • Updated 3 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/fiveonecode/agent-skills/local-model-serving

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈99 tokens for metadata: the name and description. ≈1.3k when used: this file.

Description uses 4.9% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈394 characters, or 4.9%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Local Model Serving

Use this skill whenever a task needs local LLM inference on this machine. It is engine- and model-generic: the measured numbers come from a Qwen3.8-27B-class dense model (8-bit, ~28-30 GB resident) on a 128 GB Apple Silicon Mac, but the decision rules and settings transfer to any model served by the same two engine families.

The Two Engine Families (same model, two backends)

MLX + speculative decoding (e.g. mlx-dspark) llama.cpp (e.g. LM Studio)
Model file MLX 8-bit (e.g. mlx-community/…-8bit) + drafter GGUF Q8_0 (e.g. lmstudio-community/…-GGUF)
Port e.g. http://127.0.0.1:8080/v1 e.g. http://127.0.0.1:1234/v1
Context model native (e.g. 262,144) model native
Thinking-off knob "enable_thinking": false "reasoning_effort": "none"
Short-context decode ~1.7-2.2× faster (measured) baseline
Long-context (100k+) slower (spec-decode verify rounds double the huge-KV cost) ~1.9× faster decode, ~linear prefill

Both are OpenAI-compatible (/v1/chat/completions), so the same client code works against either — only the base URL and the thinking-off parameter differ.

Drafters (DSpark, DFlash 2, and similar speculative-decoding heads) are modes of the MLX family, not a third engine. Do not install NVIDIA-only stacks (SGLang, vLLM) or a third MLX GUI to A/B a drafter. A better drafter can raise short-context decode; it does not remove the long-context crossover, because every verify round still walks the full KV. Use the drafter the local serving policy or helper names. llama.cpp may be LM Studio or llama-server; that is still the same family.

First: The Memory Rule (crash prevention)

Never run both engines with a model resident at the same time. On a 128 GB machine, two resident 28 GB models plus the OS drove the system into ~20-46 GB of swap and crushed both engines' throughput (a long run was aborted, another finished at half speed). The same exclusivity rule applies on a 64 GB machine that can fit only one ~28 GB model. Each engine fits alone; both do not.

  • Stop the other engine before starting one: lms unload <identifier> / lms unload all, or pkill -f "mlx-dspark serve" (or the equivalent for your server).
  • Wrap start/stop in a small helper that refuses the second engine unless it unloads the first — mechanical enforcement beats discipline.

Decision Rule

Prompt Engine Why
Short (≤ ~100k tokens), decode-heavy MLX + spec decode 1.7-2.2× faster decode, same quality
Long (≥ ~100k tokens) llama.cpp faster decode, ~linear prefill scaling, better retrieval at depth
Code review of huge diffs llama.cpp if local; prefer a cloud model for quality-critical 100k+ contexts; local 27B-class models miss subtle defect classes

Rule of thumb: short in, long out → MLX spec-decode; long in → llama.cpp.

Settings (pinned, per engine)

  • Context: use the model's native window (e.g. 262,144) unless the task explicitly needs less.
  • Thinking: pin it off unless the task is reasoning-specific. Default thinking produces reasoning-only/truncated output in structured pipelines. The knob name differs per engine — using the wrong one silently does nothing, so verify with a smoke call.
  • Reproducible runs (evals): temperature 0 (greedy), and compare runs only within one engine + quant — Q8_0 vs int8 and sampler differences shift scores.
  • Realistic generation (Qwen3.8 documented defaults): temp 0.7, top_p 0.80, top_k 20, presence_penalty 1.5.

Known Workload Mapping

Task Engine Notes
Eval / judge sweeps (many short prompts) MLX spec-decode pin the engine for the whole baseline
Summarization of short/mid text (strict JSON) MLX spec-decode, re-verify the schema first schema quirks differ per engine
Summarization of long documents (100k+) llama.cpp long-context winner
Code review of huge PRs cloud (or llama.cpp if local) token-hungry; local = minutes at best, hours worst-case
Content generation / filling objects MLX spec-decode decode-heavy short prompts — biggest win

Verify The Engine Is Actually Serving

Smoke-test before a batch run — confirm reachability and that thinking is off (the wrong knob is the classic silent failure):

curl -s http://127.0.0.1:<port>/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{"model":"<model-id>","messages":[{"role":"user","content":"Say OK"}],
       "max_tokens":8,"<thinking-off-knob>":<value>}'

Closeout

  • Unload when done (lms unload / stop the server process) so memory returns for the other engine or other workloads on the same machine.
  • If a run produced a new measurement or decision (quality delta, throughput, engine crossover), record it in your repository's knowledge base with the exact setup so it is reproducible — single-run anecdotes are signal, not proof.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 8f30014. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 3 months ago

README badge

README badge for fiveonecode/agent-skills/local-model-serving