/inferencekit:proving-correctnessfrom inferencekit
Verifies model correctness and quality after engine, kernel, precision, or backend changes. Selects exact, task, or perceptual checks for text, image, audio, video. Run before performance claims.
Ships in inferencekit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A speedup only counts if the engine still computes the same model. Engines almost never agree bit for bit, so "same" is defined per kind of change, against a noise floor of correct-but-different arithmetic. optimizing-inference runs the full workflow per candidate engine and at milestones; inside the change loop each change gets only the fast check below.
Use when:
N* is being claimed (quality must hold at that load level too).Do not use when:
GPU approval: reference and candidate runs occupy GPUs; run only with budget.approved: true in intake.yaml or an explicit yes to a stated cost.
Read the run's quality choice. Exact requires equality on its declared deterministic/seeded outputs; legacy lossless distribution agreement alone is insufficient. Balanced/speed tracks use their registered task/perceptual budget, so rounding differences are not an automatic rejection. Model changes need separate permission and separate reporting.
Use modality-appropriate structural integrity and task quality: text accuracy/distributions, image semantics/readability, speech content/completion/speaker, video temporal consistency. Other tasks need a registered adapter; do not substitute GSM8K or token identity. Missing listening/viewing remains UNPROVEN. The text procedures below apply only where their inputs and claims match.
For TTS, register the acceptance policy before capture with quality audio-policy, then run quality audio on final configuration records and saved PCM (protocol). For changed outputs, quality audio-scorers pins local models and quality audio-score produces ASR/naturalness/voice observations (setup). Score after timing; WER/CER and MOS predictors do not replace required listening.
| Kind of change | Examples | Fidelity | Pass rule |
|---|---|---|---|
| Pure refactor | moving code, launch restructuring, a switch that is off, prefill tiles that keep the K order | lossless | byte identity (ladder below) |
| Equivalence | CUDA graphs, fusion, the same precision in another engine or attention kernel | lossless | no regression beyond the A/A noise floor |
| Exact byte cut | lossless weight re-encoding, an exact bound-pruned lm_head | lossless | its proof recipe (byte-cuts.md: weights decode bit-equal; pruned token = full token every step; logprob requests take the full head), rare_tokens, then equivalence |
| Exact speculation | MTP or EAGLE heads, a same-tokenizer draft model, n-gram lookup, with standard verification | lossless | the spec_exact gate at temperature 0; under sampling, the accept/resample check and quality sampling (sampled exactness); then equivalence |
| Declared numerics change | 16-bit activations where the checkpoint quantises them; a KV dtype the task lists | lossless only if the task allows it; declared in the engine's numerics, labelled "numerics changed" | quality against the reference no worse than the baseline's, within the noise floor |
| Numeric | an FP8 KV cache the checkpoint does not declare, lower-precision attention maths | lossy | no regression beyond the noise floor plus a pre-registered margin |
| Approximation | 4-bit weights, lossy speculative decoding, weight or expert pruning, a truncated vocabulary | lossy | a pre-registered margin agreed with the user; otherwise it is a different model |
fidelity: lossless (the intake default) allows only the lossless rows. fidelity: lossy adds the others, each judged against the intake's quality.budget and reported on its own track, as speed at a stated quality cost. A task's own precision rule overrides this plugin's default. Full rules: fidelity.md.
For images, TTS and STT, an explicitly authorized numerical change uses the registered modality checks rather than LLM token/logprob gates. Relative degradation budgets belong in quality.budget.relative, with a matching modality and quality.protocol / quality.protocol_sha256 binding. A valid intake leaves external quality proof UNPROVEN. Different pixels, PCM, generated codes or rounding are diagnostic observations, not automatic quality failures for that numerical-change track. Pure refactors still use the declared exactness checks. Nonfinite values, invalid shapes, unsafe accesses, broken own-output/native integrity and omitted cases remain failures. A quality budget alone does not authorize architecture pruning or another model.
With explicit quality.acceptance: perceptual_and_task_noninferiority, image/TTS promotion requires the bound task checks and fresh blinded perceptual evidence. Numerical similarity (including image LPIPS/SSIM) is diagnostic, not an independent rejection gate; do not add dummy bounds. TTS ASR/VAD/speaker proxies do not replace listening. Missing perceptual evidence remains UNPROVEN. Retain old numerical failures under their original rules and reassess a baseline's eligibility prospectively under the new acceptance policy.
For an image or speech numerical change, use one short fixed public modality correctness/quality screen under the agreed protocol. Full registered quality and balanced timing remain milestone/final promotion requirements; they are not required for every intermediate kernel. Retain failed screens and all cases, and label any historical output reuse exploratory. No numerical candidate is promoted from exact-output diagnostics alone.
For LLM candidate changes, against the previous build, greedy, on a handful of fixed prompts: a pure refactor or exact change keeps the greedy tokens identical; a numerics change (any change to the arithmetic) keeps next-token and logprob agreement, flips only at near-ties (inferencekit correctness --reference <prev.jsonl> --candidate <new.jsonl>); a fail drops the change. Inputs: one {"tokens": [...], "logprobs": [...]} line per prompt from each build's server (a bench decode id compares tokens only). For a numerics change, --min-prefix-agreement below 1 (written down first) and --logprob-tol <t>; at each first divergence, the top-2 gap from the previous build's top-20 logprobs must be below the A/A control's largest flip margin, or the change drops (margin test). The A/A floor, trajectory score, GSM8K, sampling and byte-identity ladder below are the full proof: milestones and published claims only (state.md).
inferencekit prompts verify --set <dev|path>), the same token ids for every engine. Why: changing prompts changes the result.quality.reference): a vLLM server running the model in BF16 for an FP8 engine (quality score needs vLLM's prompt_logprobs). Why: distance to a better reference is the quality signal; two candidates agreeing with each other proves little. None: below.--baseline), ideally twice (--baseline-repeat, e.g. after a relaunch). Why: it sets the noise floor; no tolerance may be invented.--margin-agreement, --margin-kl, --margin-nll). Why: the tool's defaults (0.02 / 0.02 nats / 0.05 nats) are loose placeholders, ten times looser than a same-precision KL margin.Quality:
- [ ] 1. Classify the change (table above); pre-register the rule and margin
- [ ] 2. Reference (vLLM, BF16) up: quality trajectory --label reference, then --label reference-r2
(restart your own reference server in between; a remote endpoint cannot be restarted:
run back to back and say so) -> the A/A floor's trajectories
- [ ] 3. Per engine, its exact speed config up: quality trajectory --label <engine> -> ev_traj_<engine>
- [ ] 4. quality score --trajectories <dir> (once per engine) --baseline <reference dir> [--baseline-repeat]
with the pre-registered margins -> ev_qs (verdict per engine vs the floor, paired CI over prompts)
- [ ] 5. Every disagreement: position + reference margin; any above the control's max -> investigate / FAIL
- [ ] 6. quality gsm8k --concurrency 0 on every engine: all 1,319 for a claim, the final candidate
or a scored commit; --limit 100 at the light milestone checks (only screens);
candidates with --paired-with <baseline run> (McNemar) -> ev_gsm
- [ ] 6b. Sampling in the claim? quality sampling on each engine, the baseline too (draws vs own logprobs) -> ev_samp;
plus the accept/resample check (speculation) or per-step support check (pruned head)
- [ ] 7. Long context in the claim? quality niah at the lengths claimed (optional otherwise)
- [ ] 8. Pure refactor? Byte-identity ladder instead, control first
- [ ] 9. Fill the fixed table; verdict per check
# A/A floor: the reference's own greedy run (vLLM serving the model in BF16)
inferencekit quality trajectory --base-url http://127.0.0.1:8001 --model <ref-name> --prompts <set.jsonl> \
--label reference --run-dir runs/<id> --top-logprobs 20
# each engine, at its exact speed configuration
inferencekit quality trajectory --base-url http://127.0.0.1:8000 --model <served-name> --prompts <set.jsonl> \
--label vllm-tuned --run-dir runs/<id> --top-logprobs 20 --engine-kind vllm # -> runs/<id>/quality/vllm-tuned
inferencekit quality score --trajectories runs/<id>/quality/vllm-tuned --reference-url http://127.0.0.1:8001 \
--reference-model <ref-name> --baseline runs/<id>/quality/reference [--baseline-repeat runs/<id>/quality/reference-r2] \
--margin-agreement <pre-registered> --margin-kl <pre-registered> --margin-nll <pre-registered> # -> ev_qs
inferencekit quality gsm8k --base-url http://127.0.0.1:8000 --model <served-name> --run-dir runs/<id> --label baseline \
--concurrency 0 # 0: sized from the server
inferencekit quality gsm8k --base-url http://127.0.0.1:8000 --model <served-name> --run-dir runs/<id> --label vllm-tuned \
--concurrency 0 --paired-with runs/<id>/quality/gsm8k/baseline.jsonl # McNemar vs the baseline
inferencekit quality sampling --help # sampled exactness (below)
inferencekit correctness --reference ref_hf.jsonl --candidate <ev_bench> # token agreement: the per-change fast check vs the previous build (or the older HF-reference method)
inferencekit report <ids...> --format md
MCP tools: quality_trajectory, quality_score, quality_gsm8k, quality_niah, check_correctness, report (in OpenCode, which ends an MCP call after 120 s, run quality through the CLI, detached with a log). Flag spellings: inferencekit quality <op> --help. Scoring, the noise floor and pass rules in detail: references/quality.md.
Each engine generates its own greedy continuation through its serving (decode) path, the code users run, with the top-20 logprobs per step. The reference (vLLM) is teacher-forced on that sequence and scores every position: top-1 match, KL on the top-k supports (an approximation), the reference's log-probability of the engine's token, and the first divergence from the reference's own greedy run. The A/A floor is the reference's own trajectory scored the same way, so it already holds the gap between decode path and one-pass scoring. Prompt-logprob ("score mode") endpoints exercise only prefill kernels.
Lossless means the same sampling distribution, not only the same greedy token. The teacher-forced check holds the engine's log-probabilities to the reference's; inferencekit quality sampling shows the sampler draws from the distribution they give under the request's temperature, top-k and top-p (seeded first-token draws against the top-20 log-probabilities; mean TV beyond sampling noise, bootstrap CI over prompts; references/quality.md section 6). PASS when the CI's upper end is inside the pre-registered margin, FAIL when its lower end is above it, UNPROVEN otherwise or when not run.
It checks only the first generated token (max_tokens 1, produced by prefill), so a change that acts only in decode steps is not exercised. Speculation also needs a unit check of the accept/resample step against the target distribution (synthetic p and q, many draws, TV or chi-square inside a pre-registered bound). A pruned head needs the per-step support check in byte-cuts.md, or the first token must also go through the pruned head. Without one of these the sampled claim is UNPROVEN.
Floating-point addition is not associative: tiling, split-K, reduction order, FMA contraction, online softmax and shape-dependent heuristics each give a slightly different, equally valid result, and after one flip greedy outputs diverge. With the early engine almost no prompt matched the reference exactly for any engine (the reference's own second attention path included) while per-step agreement stayed inside the floor. Exact-match rates are a poor quality signal.
Climb in order; stop at the first failing rung (references/byte-identity-ladder.md):
cuobjdump -sass).inferencekit quality gsm8k: the same problems, format and answer extraction for every engine, greedy, accuracy with a Wilson CI; --paired-with <the baseline's results JSONL or evidence id> adds McNemar's exact test. A claim uses all 1,319 items (the default); a --limit subset only screens (the first 100 detect only about 10-point effects). --concurrency 0 sizes concurrency from the server. The first run on a host downloads the pinned test split (419 KB) into ~/.cache/inferencekit/gsm8k/: unset HF_HUB_OFFLINE for it, or place the file with the curl command the error prints (references/gsm8k-parity.md; the older token-agreement method: references/token-agreement.md).
With quality.reference: none, compare with the baseline engine run twice, restarted between (the A/A floor); label results "vs baseline, no reference".
--paired-with baseline; the A/A pair gives the noise-only discordant count.quality score reference: it bounds drift from the incumbent, not quality.quality trajectory -> runs/<id>/quality/<label>/<prompt-id>.json + index.json and a kind=quality_trajectory record (observed); quality score -> runs/<id>/quality/score.json and a derived record: per engine, per position bucket and input bucket, with a PASS / FAIL / UNPROVEN verdict against the floor; quality gsm8k -> kind=quality_task (per-problem outcomes, not only accuracy); correctness -> kind=correctness.| Check | Engine (config) | Value [CI95] | Noise floor (A/A) [CI95] | Margin (pre-registered) | Verdict | Evidence |
|---|---|---|---|---|---|---|
| Top-1 agreement vs reference (decode path, tie-inclusive) | % | % | pp | |||
| Mean / p99 KL (top-20 approx.) | ||||||
| Disagreements above the control's max margin | count | must be 0 | PASS / FAIL | |||
| GSM8K (1,319), McNemar vs baseline | x / n, p | |||||
| Sampled distribution (mean TV vs baseline; speculation: + accept/resample check), if sampling is claimed | ||||||
| NIAH at lengths claimed (optional) | NOT RUN if skipped | |||||
| Byte ladder rung reached (refactors) | 1-4 | control identical? |
What SKILL.md sets; muted values are Claude Code's defaults
9 skills in this plugin
/benchmarkingMeasure end-to-end inference latency, throughput, memory and cost against tuned baselines with balanced rounds and quality evidence. Use for engine/config comparisons and performance claims. Route text, image, audio and video to their own client timers and protocols; isolate device measurements./evaluating-quantizationChoose a compressed model format by measuring memory, complete-request speed and task/perceptual quality on the exact target hardware. Use for quantization, lower precision or fitting a model on cheaper hardware. Respect the chosen quality policy and separate model-change permissions./inference-triageRoute inference performance questions for text, image, audio, video and other models to the cheapest useful evidence: latency, throughput, memory, hardware cost or quality. Use when unsure where to start; select tools for NVIDIA, AMD, Apple Silicon or CPU and preserve resource authorization./optimizing-inferenceOptimize a model for faster responses, more requests, less memory or cheaper hardware. Ask simple quality and budget questions, research current implementations, tune the strongest supported baseline, investigate compiler/kernel bottlenecks and prove end-to-end results. Covers text, image, audio and video with modality-specific checks; accepts an intake or written brief./optimizing-kernelsProfile-driven loop for building or patching inference engines and kernels on NVIDIA, AMD, Apple Silicon or CPU. Use after baseline tuning and profiling to close a measured bottleneck with one change, a correctness check and an end-to-end screen. Covers custom engines, fusion, attention, matrix kernels and memory traffic; routes to the hardware's supported tools./profilingFinds where inference time goes and why a kernel is slow on NVIDIA, AMD ROCm, Apple Metal and CPUs, routing to vendor timelines then supported kernel analysis; nsys only or the PyTorch profiler when GPU counters are blocked. Use for "where does the time go", "why is decode/prefill slow", "GPU idle", "launch overhead", "which kernel", "is this kernel memory-bound", "nsys", "ncu", "torch profiler", "profile". Never proves a speedup.npx claudepluginhub kittenml/inferencekit --plugin inferencekitOther plugins' skills for the same job