Logo Inference Optimisation

Inference Optimisation

Tổ chứcPhổ biến
sybil-solutions
inference-optimisation

Hill-climb the serving speed of a local LLM on any hardware (NVIDIA, AMD, Intel, Apple, unified-memory laptops, multi-GPU) and any quantization (GGUF, EXL2/EXL3, AWQ/GPTQ, FP8, MLX, BF16): single-user and concurrent decode tok/s, speculative decoding, prefill tok/s, KV cache size, startup time and TTFT, under a memory cap and with full-context stability. Computes the theoretical ceiling first, runs noise-controlled A/B experiments, keeps a ledger, and qualifies the winner before publishing it. Use when asked to optimise, tune, speed up, benchmark or hill-climb a model server (vLLM, SGLang, llama.cpp, ExLlama/TabbyAPI, MLX, TensorRT-LLM...), to find the maximum possible tok/s on a machine, or to publish a tuned recipe. Triggers: hill climb, tok/s, decode speed, prefill speed, MTP, EAGLE, draft model, speculative decoding, KV cache, TTFT, startup time, theoretical maximum.

Tổng quan

Nhà phát hànhsybil-solutions
Kho mãinference-optimisation-skill
Tên kỹ nănginference-optimisation
Sao
3K
Bản fork
286
Tệp đi kèm
12
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 12 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được sybil-solutions công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Inference Optimisation trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/sybil-solutions/inference-optimisation-skill/tree/main/skills/inference-optimisation
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/sybil-solutions/inference-optimisation-skill.git /tmp/inference-optimisation-skill
mkdir -p .claude/skills
cp -r /tmp/inference-optimisation-skill/skills/inference-optimisation .claude/skills/inference-optimisation
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Inference Optimisation trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Inference Optimisation ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Inference Optimisation với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Inference optimisation (hill-climbing a model server)

You improve how fast a model server runs on one machine, with evidence. The loop is:

  1. Measure the baseline.
  2. Calculate the ceiling.
  3. Change one thing.
  4. Measure it against controls.
  5. Keep it or reject it, and write down why.
  6. Repeat until the remaining gap needs work out of scope, then qualify and publish.

Detailed references, read when needed:

  • references/ceilings.md: how to compute theoretical maxima. It includes a worked example.
  • references/methodology.md: measurement pitfalls and statistics.
  • references/levers.md: levers by area, ordered by typical payoff, with measured evidence.
  • references/gotchas.md: engine- and hardware-specific traps.
  • references/publishing.md: qualification gates, pinning, poster and report.
  • scripts/: an engine-agnostic harness. It has a bench, ceiling calculator, memory watchdog, serialized queue and ledger.

0. Before touching anything

  • Write down the targets and constraints the user gave. Ask only if one is missing and it changes what you do.
    • Metrics that matter: c1 decode, cN decode, prefill at several lengths, TTFT, startup.
    • Memory cap.
    • Context length that must stay stable.
    • Which quality changes are allowed: lossless only, or labelled lossy trades such as int8 prefill.
  • Inventory the machine:
    • accelerator, memory type and size, and whether memory is unified;
    • driver, engine version, model, quantization, current launch command.
  • Measure, don't trust spec sheets:
    • real memory bandwidth (device copy);
    • real matmul throughput (large GEMM);
    • clocks under load.
  • Read any existing experiment log for this machine and model. Never rerun a rejected experiment without a new reason.
  • Create the working directory:
    • PLAN.md: a timestamped log of every experiment, with numbers, verdict and reason.
    • THEORY.md: the ceilings.
    • ledger.jsonl: one line per run, from the harness.
    • configs/: one JSON per run.
    • best-config.json.

1. Ceilings first

Compute the theoretical maximum for each metric before optimising (scripts/ceiling.py, references/ceilings.md):

  • Decode is memory-bandwidth bound. Count the bytes read per emitted token:
    • dense weights;
    • active experts: top-k ÷ experts × expert bytes;
    • LM head;
    • KV read at the working context.
    • Divide by measured bandwidth.
    • Speculative decoding divides the target's bytes by the accepted length. It also adds the draft's bytes, and the draft's LM head is often the biggest part.
  • Prefill is compute bound. FLOPs per token ≈ 2 × active params, plus attention at about 4 × layers × hidden × position. Divide by ~50% of measured peak for a practical ceiling.
  • TTFT floor: one forward pass plus tokenize and schedule.
  • Startup floor: weight read from disk or page cache plus allocation, assuming JIT and graph caches persist.
  • KV: bytes per token per layer × the layers that actually have KV (hybrid models have few). That gives how many full-length sequences fit under the memory cap.

Report progress as a percentage of the practical ceiling. If the user's target is above the ceiling, say so early, with the arithmetic.

2. Ground rules (non-negotiable)

  1. One change per experiment. Give each its own config file. Derive new configs from the current best.
  2. Control for noise. Run-to-run noise is typically ±5–10%.
    • Take ≥6 decode samples per run and use the median.
    • Run controls on both sides of each candidate: control, candidate, control.
    • Accept only if the candidate beats both neighbouring controls on its target metric and regresses nothing by more than ~3%.
    • Repeat any single surprising win.
  3. Keep the environment fixed. Stay on AC power, on a fixed performance profile, with an idle host and no other GPU jobs.
    • Make the harness refuse to run otherwise.
    • Record the state at the end of each run, and void the run if it changed.
    • Restore any profile you changed when you finish, and tell the user.
  4. Run one GPU job at a time. Serialize them with a lock (scripts/queue.sh).
    • Never use pkill -f/pgrep -f patterns that can match your own shell.
    • Detach long queues (setsid nohup … &) so they survive agent restarts.
  5. Enforce the memory cap with a watchdog that kills the run.
    • On unified memory, GPU allocations do not show in cgroup counters or MemAvailable. Measure driver residency (e.g. drm-resident-* in /proc/<pid>/fdinfo, nvidia-smi, or ioreg/vm_stat on Apple) plus process anonymous memory.
  6. Stability gates. A config is only "best" after it passes:
    • a long-context retrieval run, with needles in a ~50% then ~100% context document, found exactly;
    • a soak with concurrent full-length requests, if the KV pool is sized for N users;
    • a greedy output equivalence check, if the change claims to be lossless.
  7. Never force-kill a server mid-batch. Abort requests, wait for the drain, then stop with a timeout. A forced stop mid-prefill has caused GPU driver faults.
  8. Verify outputs, not just speed. Flag degenerate or looping output, failed requests and an idle GPU. A suspiciously fast result is usually broken output.
  9. Log everything in PLAN.md, including failures and why they failed. Negative results are the most reusable output.
  10. Secrets: never ask twice for a credential the user already saved. Never print it, and never copy it or its path into anything published.

3. The loop

baseline → profile → pick the lever with the largest (ceiling gap × likelihood) → config → A/B with controls
   ↑                                                                                         ↓
   └──────── update best-config + PLAN.md + ledger ←──── accept / reject with reason ←───────┘

Lever order

Cheapest first; see references/levers.md for evidence.

  1. Persistent JIT, compile and graph caches (startup −50–70%). Also use eager safetensors loading instead of mmap where it is slow.
  2. Decode graphs (CUDA/XPU graphs): often 2× c1 on their own.
  3. Speculative decoding:
    • Choose the method (built-in MTP, EAGLE, a draft model, n-gram).
    • Sweep draft length per concurrency and context; the best length differs.
    • Prune the draft LM head's vocabulary.
    • Keep sampling on the GPU.
    • Make sure verify runs with decode-style attention.
  4. Concurrency and KV sizing:
    • Set max running requests and the KV pool to N × context.
    • For hybrid SSM/GDN models, size the state slots. They, not KV, often cap concurrency.
    • Explicitly enable prefix caching and confirm cached_tokens > 0.
  5. Prefill:
    • Tune chunk size; it trades throughput against decode stalls.
    • Use a faster attention library.
    • Use int8/fp8 prefill GEMMs as a labelled quality trade.
    • Avoid padding cliffs in grouped MoE GEMMs.
  6. Kernel thread and tile sizes: defaults are often tuned for a bigger card.
  7. Kernel work: profile, read the ISA, fix the dominant kernel. Do this only after config levers plateau.

When a lever fails

  • If kernel-count reductions (fusion) give nothing under graphs, the time is inside the main kernels. Stop fusing.
  • If higher acceptance doesn't give higher tok/s, the draft costs too much. Measure per-step time.
  • If a weird result appears, suspect the measurement first: tokens counted per streamed chunk, prompt length not measured with the real tokenizer, cache hits, thermal state, or the battery.

Plateau

Declare a plateau when three consecutive levers land inside noise. Write a STATUS section in PLAN.md with:

  • best numbers vs baseline vs ceiling;
  • what limits further gains, with evidence;
  • a ranked list of the remaining levers and their estimated cost.

Then keep the loop alive at a slower cadence if the user said "don't stop", or hand back.

4. Qualify and publish

See references/publishing.md.

  • Pin weights by revision, engine by image digest or source commit, and kernels by commit. Build the published artifact from those pins in a clean checkout, never from a dirty tree.
  • Run the acceptance gates on the clean build: load, chat, reasoning, tools round-trip, a long-context needle, and speed.
  • Then A/B the clean build against your best image to prove they match.
  • Report which numbers come from which harness. Gate numbers (e.g. thinking on, first 30 s) and hill-climb numbers (thinking off, medians) are not comparable.

5. Reporting to the user

  • Start with a table: metric, baseline, now, ceiling, how it was measured (median of N, cold or warm, which harness).
  • Then: what got the gains, why it stops here, the known limitations, and the system state you changed (power profile, running servers, uncommitted code, branches that must not be deleted).
  • Say plainly what was not verified.
  • When asked to free the GPU: drain, stop the server, confirm no processes and an idle clock, and end any loop.

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Inference Optimisation làm được gì?

Hill-climb the serving speed of a local LLM on any hardware (NVIDIA, AMD, Intel, Apple, unified-memory laptops, multi-GPU) and any quantization (GGUF, EXL2/EXL3, AWQ/GPTQ, FP8, MLX, BF16): single-user and concurrent decode tok/s, speculative decoding, prefill tok/s, KV cache size, startup time and TTFT, under a memory cap and with full-context stability. Computes the theoretical ceiling first, runs noise-controlled A/B experiments, keeps a ledger, and qualifies the winner before publishing it. Use when asked to optimise, tune, speed up, benchmark or hill-climb a model server (vLLM, SGLang,...

Vì sao nên dùng Inference Optimisation trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Inference Optimisation là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Inference Optimisation trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/sybil-solutions/inference-optimisation-skill/tree/main/skills/inference-optimisation. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Inference Optimisation?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Inference Optimisation với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Inference Optimisation với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Inference Optimisation có miễn phí không?

Có. Kỹ năng này được sybil-solutions phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇