by alesha-pro
97 tested hypotheses on making huge MoE LLMs fast on consumer GPUs (4x RTX 3090 + experts in RAM): what worked, what failed and why. A playbook for people and a ready skill for coding agents.
# Add to your Claude Code skills
git clone https://github.com/alesha-pro/inference-optimization-playbookGuides for using ai agents skills like inference-optimization-playbook.
inference-optimization-playbook is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by alesha-pro. 97 tested hypotheses on making huge MoE LLMs fast on consumer GPUs (4x RTX 3090 + experts in RAM): what worked, what failed and why. A playbook for people and a ready skill for coding agents. It has 129 GitHub stars.
inference-optimization-playbook's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/alesha-pro/inference-optimization-playbook" and add it to your Claude Code skills directory (see the Installation section above). inference-optimization-playbook ships a SKILL.md manifest, so compatible agents can discover and load it automatically.
inference-optimization-playbook is primarily written in Python. It is open-source under alesha-pro on GitHub, so you can review or fork the full source.
Yes. AgentsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh inference-optimization-playbook against similar tools.
No comments yet. Be the first to share your thoughts!
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
A map of real experiments on speeding up LLM inference on consumer GPUs: what was tried, on which model, what the numbers were, what the decision was and why. All paths below are relative to the directory this file is in.
A static hot set worked on DeepSeek and Qwen and gave little gain on GLM and MiniMax. The cheapest way to serve a miss also flipped between models on the same hardware. Find the closest case to the user's setup, then check the conditions on each result before applying it.
protocol/situation-card.md for the case in front of you: model, hardware, engine and placement, workload, current numbers. Unknown fields are the first things to find out, and the card says how. It ends with a tag line such as #offload #weak-skew #cpu-lane #multi-gpu #agent.playbook/00-start-here.md. Answer its 7 questions by regime, or enter by symptom. Each answer points to 1-2 chapters. Read the first lines of a chapter: every chapter says when to read it and when to skip it.ledger/hypotheses.md by your tags to see what was already tried under your conditions, with the verdict, the reason and a "revisit when". Then open the closest case from the traits table in cases/README.md.protocol/experiment-rules.md: ceiling first, one change, controls on both sides, thresholds written in advance, a stop rule.Read the chapters that match the bottleneck.
grep "#weak-skew" ledger/hypotheses.md # results on models with weak routing skew
grep "#offload" ledger/hypotheses.md | grep "#tp" # tensor parallel with experts in RAM
grep "#drafter" ledger/hypotheses.md | grep "❌" # drafter ideas that failed
grep -n -i "prefetch\|numa" ledger/hypotheses.md # by keyword
Both are standard-library Python, no install.
| Tool | Question it answers | Input |
|---|---|---|
tools/route_sim.py |
Is routing skewed? Does a static hot set beat a random one at my VRAM budget? How far is a live cache from the best possible one? | a router trace in JSON Lines |
tools/fit_cost.py |
Which term of token time is larger, the constant part or the misses? What is the ceiling with no misses? | a CSV of 3 or more runs |
tools/README.md has the formats. Both have --demo.
| The user's problem | Read |
|---|---|
| Will offload be fast at all, how many experts fit, where does token time go, what is the ceiling | playbook/01-cost-model.md |
| Misses in decode: CPU or PCIe, memory tiers | playbook/02-serving-a-miss.md |
| Which experts to keep in VRAM, profiles, domains | playbook/03-expert-profile-and-placement.md |
| Cache policy, capacity, warming, predicting experts | playbook/04-live-expert-cache.md |
| 2-4 GPUs: layer split vs TP vs EP, exchange between cards, padding | playbook/05-multi-gpu.md |
| RAM channels, NUMA, thread count, pinning | playbook/06-cpu-and-ram.md |
| Slow prompt reading, chunk size, DMA, CUDA graphs | playbook/07-prefill.md |
| Drafters, MTP, acceptance, window policy, drafter training | playbook/08-speculative-decoding.md |
| Which quant, hybrids, KL noise floor | playbook/09-quants.md |
| Dropping, masking or merging experts | playbook/10-pruning-and-merging.md |
| Agent turns are slow, prompt cache misses, A → B → A | playbook/11-sessions-and-prompt-cache.md |
| Load time, THP stalls, a table too big for RAM, lent-VRAM vision | playbook/12-loading-and-big-tables.md |
| Vocabulary projection cost | playbook/13-output-head.md |
| Building a reference, replay, why a benchmark lied | playbook/14-benchmarking-and-traps.md |
| Did the change keep quality, should this build ship | playbook/15-quality-and-release-gates.md |
| A new model from zero | protocol/new-model-checklist.md |
| A term is unclear | glossary.md |
#weak-skew was not tested on weak skew.Decode of an offloaded MoE costs constant + misses per token × cost of one miss. So there are 4 levers: fewer misses at the same VRAM (profile, live cache), more experts in VRAM (fewer bits, smaller buffers), a cheaper miss (CPU lane, faster RAM, better CPU code), and a smaller constant (kernels, exchange, drafter). Fit the model first and work on the larger term. Prefill is a different regime: almost every expert is needed per chunk, so the lever is bytes moved over PCIe per token. Agent workloads are a third regime: most time is generation and short re-reads, so caches and snapshots matter more than cold prefill speed.
Most measurements cover 1 active request on the rig in cases/README.md. For throughput on the user's setup, run the engine's benchmark or replay their sessions.
When the map has no answer, say so. Use the closest mechanism to design the cheapest test that would answer the question, then run it if you can and report the result.
My field notebook for tuning LLM inference on consumer GPUs. The ledger covers 138 tested hypotheses across 7 model cases, with the verdict, measurements and test conditions for each. I publish it as a read-only reference for people tuning local inference and as a skill for coding agents.
My rig measurements use 1-4 RTX 3090 cards (24 GB each). The cases cover expert offload to RAM and models or quants that fit in VRAM, including Inkling 2 Mini on 1 card and Ling-3.2-air R3 on 3-4 cards. Engines include Strata, Maya forks, an exllamav3 fork, llama.cpp and vLLM. Rig details and model cases
| Model and setup | What changed | Result |
|---|---|---|
| DeepSeek V4.1 Flash, 4 cards | DMA from pinned RAM for all formats, prompt layer skipping, automatic chunking | 32K prefill rose from 430 to 2,199 tok/s |
| DeepSeek V4.1 Flash, Zen 2 CPU | Disabled the PDEP path at build time | Time per cold expert dropped from 1.6 to 0.44 ms |
| Hy4 Flash, 1 card | Loaded each needed expert once per block of up to 57,600 tokens, with 2,048-token attention tiles | The full build raised 57,587-token prefill from 415.6 to 1,510.2 tok/s |
| Hy4 Flash, 2 cards | Ran cold experts on the CPU while the GPUs ran hot experts | Short code decode rose from 24.6 to 70.4 tok/s |
| Qwen3.8-Flash-Next, 1-2 cards | DFlash2 drafter | Decode gained 44-46% over plain decode |
| Qwen3.8-Flash-Next, Russian | Cyrillic draft vocabulary | Draft acceptance rose from 32% to 54% |
| MiniMax-M3.1-Flash | Gathered attention K/V into VRAM once per chunk | 3.3x faster 64K prefill |
| GLM-5.3-Flash, 2.05 bpw in VRAM, 4 cards | Switched from layer split to tensor parallel | Decode rose from 48.3 to 66-68 tok/s |
| Inkling 2 Mini, 1 card | Resident experts, 1 CUDA graph per token, tensor cores for experts and attention | The final build reached 128.7 tok/s after 47 prompt tokens with a 344K window, and 62.3 tok/s after 340K tokens |
| Ling-3.2-air R3, 4 cards, FP16 KV | Restored stage pipelining with every expert in VRAM | 32K prefill rose from 2,230 to 5,439 tok/s. Plain decode reached 124.4 tok/s |
| Ling-3.2-air R3, 2 cards, INT8 KV | Enabled adaptive blk.42 MTP |
Warm decode after a 2K prompt rose from 120.31 to 143.8 tok/s |
O_DIRECT under 8 and 24 GiB memory caps.The cheapest way to serve an expert miss flipped between models on the same rig. Use the placement, hardware and workload tags to find a result that applies to your setup. Chapters 01-15 end with steps for testing the mechanism on another model.
| You want to | Open |
|---|---|
| Describe your case and get its tags | protocol/situation-card.md |
| Find your place by regime or by symptom | playbook/00-start-here.md |
| Check if an idea was already tried under your conditions | ledger/hypotheses.md |
| See how it went on a model like yours | cases/ |
| Run an experiment so the result means something | protocol/experiment-rules.md |
| Bring up a new model from zero | protocol/new-model-checklist.md |
| Look up a term | glossary.md |
playbook/ start page and 15 chapters by mechanism
00 the map: entry by regime and by symptom, 15 findings
01 cost model: time = constant + misses × cost of a miss, ceilings
02 where to serve a miss: CPU lane vs PCIe copy
03 hot experts: profile, domain, placement
04 live expert cache
05 several GPUs: layer split, TP, EP, all-reduce
06 CPU and RAM: channels, NUMA, threads
07 prefill and re-reading the prompt
08 speculative decoding
09 quants: bits vs experts in VRAM
10 pruning and merging experts
11 sessions, KV and the prompt cache in agent work
12 loading, page cache, THP, big tables on NVMe, lent-VRAM vision
13 the output head
14 how to benchmark, and the traps
15 quality and release gates
ledger/ every hypothesis: verdict, numbers, why, "revisit when", condition tags
cases/ the rig, a traits table and 7 model case files
protocol/ situation card, experiment rules, new-model checklist, rig experiment log format
tools/ route_sim.py (skew and cache simulator), fit_cost.py (time model fit)
SKILL.md entry point for agents
AGENTS.md internal notebook maintenance rules
The repo root is a skill directory: SKILL.md, plain markdown and 2 standard-library Python scripts.
Clone it where your agent looks for skills, for example:
git clone https://github.com/alesha-pro/inference-optimization-playbook ~/.claude/skills/inference-optimization-playbook
or into .agents/skills/ or .claude/skills/ of a project. Then ask the agent things like:
Without skills support, point the agent at the repo and tell it to read SKILL.md first.
The agent fills a situation card, gets a tag line such as #offload #weak-skew #cpu-lane #multi-gpu #agent, and filters the ledger with it:
grep "#weak-skew" ledger/hypotheses.md
python3 tools/route_sim.py --demo uniform --fraction 0.3
Most measurements are for 1 active request. The tools estimate routing, cache behavior and token time from inputs you supply. Use your engine's benchmark or session replay to measure throughput.
Unlabeled results come from measured runs. Labels mark simulations (sim), calculations (calc), microbenchmarks (micro), external measurements (ext) and single runs (1 run). When a later test changes a verdict, I keep the earlier result next to the new one.
MIT license. @superalesha