agentleFS
markoblogomarkoblogo/abvx-agent-skills/skills/local-inference-tuning/SKILL.md

local-inference-tuning

Skill16 starsChanged 5 months agoMITView on GitHub

Select and tune a local LLM inference engine for the user's hardware. Use when setting up or auditing local/private model serving, choosing between MLX, llama.cpp, Ollama, and vLLM, estimating model fit, deciding cache/storage policy, tuning batching and KV cache flags, running smoke benchmarks, or exposing an OpenAI-compatible local endpoint.

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. About 0 are common, 12 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈12

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill to design a local inference setup that fits the actual machine, model format, storage policy, and target workflow.

    line 12
  2. Distinctive:

    Use compact commands. On macOS, prefer:

    line 29
  3. Distinctive:

    If a lower-overhead engine already meets the goal, do not introduce a heavier stack.

    line 50
  4. Distinctive:

    prefer 3B-4B 4-bit models as daily local fallback.

    line 65
  5. Distinctive:

    treat 7B 4-bit as possible but pressure-sensitive.

    line 66
  6. Distinctive:

    avoid long-context serving and high concurrency unless memory pressure is low.

    line 67
  7. Distinctive:

    Before downloading or converting a model, state where model and cache files will live.

    line 71
  8. Distinctive:

    Do not put multi-GB model downloads on the system disk if the user has designated an external or work volume.

    line 75
  9. Distinctive:

    Avoid global shell profile changes unless explicitly requested.

    line 77
  10. Distinctive:

    Do not delete existing local models without explicit approval.

    line 78
  11. Very specific:

    If an engine hardcodes ~/.cache/<engine>, use a narrow symlink to the approved volume and document it.

    line 89
  12. Distinctive:

    Verify in this order:

    line 128
  13. Distinctive:

    If memory pressure warning appears, lower concurrency and cache before increasing model size.

    line 138
  14. Very specific:

    Never expose the server on 0.0.0.0 without auth review.

    line 151

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Local Inference Tuning

Use this skill to design a local inference setup that fits the actual machine, model format, storage policy, and target workflow.

This skill may inspect hardware and local model inventory. Do not remove models, download large weights, change global package manager config, expose network services beyond loopback, or write to system-wide config unless the user explicitly approves.

Hardware Audit

Collect the minimum useful facts:

  • OS and architecture;
  • CPU / SoC / GPU;
  • RAM or unified memory;
  • available accelerators: Metal, CUDA, ROCm, Vulkan, CPU-only;
  • free disk on the approved model/cache volume;
  • thermal class if visible: desktop, laptop, fanless laptop;
  • existing engines: Ollama, llama.cpp, MLX, vLLM, LM Studio, Docker;
  • existing local models and formats: GGUF, MLX, safetensors, Ollama manifests.

Use compact commands. On macOS, prefer:

sysctl -n machdep.cpu.brand_string
sysctl -n hw.memsize
system_profiler SPHardwareDataType
system_profiler SPDisplaysDataType
df -h
ollama list

Engine Selection

Choose the engine by hardware and model format:

  • MLX / Rapid-MLX: best default for Apple Silicon and MLX-format models. Prefer when the user wants an OpenAI-compatible local endpoint, batching, prompt/prefix cache, and Apple GPU kernels.
  • llama.cpp / llama-cpp-python: best fallback for GGUF models, especially existing Ollama blobs or fully local files. Use Metal on Apple Silicon, CUDA on NVIDIA, CPU only as fallback.
  • Ollama: best simple model manager and casual local endpoint. Keep when ease of use matters more than fine-grained batching/KV tuning.
  • vLLM: best for NVIDIA CUDA servers with enough VRAM and concurrent serving workloads. Do not choose for Apple Silicon laptops.
  • TensorRT-LLM: specialized NVIDIA deployment path; only use when the user has server NVIDIA hardware and deployment maturity.

If a lower-overhead engine already meets the goal, do not introduce a heavier stack.

Model Fit Estimate

Estimate before downloading:

  • model parameter count and quantization;
  • on-disk size;
  • expected working set;
  • KV cache growth with context length, batch size, and concurrent sequences;
  • whether the model fits with OS headroom;
  • whether storage policy allows the download location.

For Apple Silicon laptops, keep a meaningful unified-memory reserve. Treat fanless 16 GB machines conservatively:

  • prefer 3B-4B 4-bit models as daily local fallback;
  • treat 7B 4-bit as possible but pressure-sensitive;
  • avoid long-context serving and high concurrency unless memory pressure is low.

Storage And Cache Policy

Before downloading or converting a model, state where model and cache files will live.

Rules:

  • Do not put multi-GB model downloads on the system disk if the user has designated an external or work volume.
  • Set Hugging Face and engine cache env vars per project or per command.
  • Avoid global shell profile changes unless explicitly requested.
  • Do not delete existing local models without explicit approval.

Useful env vars:

HF_HOME=/Volumes/Work/AI/huggingface
HF_HUB_CACHE=/Volumes/Work/AI/huggingface/hub
MLX_CACHE_DIR=/Volumes/Work/AI/mlx
XDG_CACHE_HOME=/Volumes/Work/AI/cache

If an engine hardcodes ~/.cache/<engine>, use a narrow symlink to the approved volume and document it.

Tuning Profile

Produce a profile with:

  • engine and model;
  • model alias served to clients;
  • bind host and port;
  • max concurrent sequences and request queue cap;
  • prefill and completion batch sizes;
  • context or max token limits;
  • KV cache dtype or quantization;
  • prefix/prompt cache settings;
  • chunked prefill settings for agent prompts;
  • GPU memory utilization or memory reserve;
  • fallback profile for reasoning or high-quality checks.

For Apple Silicon + Rapid-MLX, prefer:

  • loopback-only bind: 127.0.0.1;
  • low concurrency on 16 GB machines;
  • prefix cache enabled;
  • radix index where available;
  • int4 KV cache for speed/memory fallback work;
  • int8 KV cache for harder reasoning if quality matters more;
  • chunked prefill for long agent prompts;
  • conservative GPU memory utilization on fanless laptops.

For llama.cpp, prefer:

  • Metal enabled on Apple Silicon;
  • n_gpu_layers=-1 when it fits;
  • n_ctx no larger than needed;
  • moderate n_batch and smaller n_ubatch on memory-constrained laptops;
  • mmap on, mlock off by default.

Smoke Bench

Verify in this order:

  1. Engine health check.
  2. Model list or model info.
  3. Single-prompt smoke benchmark.
  4. OpenAI-compatible /v1/models.
  5. Short /v1/chat/completions.
  6. Cache location check.
  7. Memory pressure check.

If memory pressure warning appears, lower concurrency and cache before increasing model size.

Endpoint Recipe

Return copy-paste commands for:

  • environment loading;
  • server start;
  • /v1/models test;
  • chat completion test;
  • client configuration model id;
  • shutdown.

Never expose the server on 0.0.0.0 without auth review.

Final Report

Report:

  • hardware summary;
  • selected engine and why;
  • rejected engines and why;
  • selected model and storage path;
  • tuned flags;
  • benchmark/smoke result;
  • endpoint URL and model id;
  • remaining risks;
  • explicit non-actions, such as models not removed or global config not changed.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.