# Inkling-2-Mini 26.4B looped MoE at 64k on llama.cpp

A 17.6 GB looped MoE on a 12 GB card: the experts of the loop core (layers 6-17, read three times per token) on the GPU, the rest in RAM, on stock llama.cpp master at ub 1024. 32.9 tok/s decode and 568 tok/s prefill at 8k (17.5 and 39 with every expert in RAM).

- Recipe id: `inkling-2-mini`  ·  status: measured  ·  updated 2026-11-30
- Model: [Inkling-2-Mini](https://huggingface.co/thinkingmachines/Inkling-2-Mini) (26.4B looped MoE, 24 layers, 128 experts (8 active); layers 6-17 run 3 times per token; image input)
- Weights: GGUF IQ4_NL, 17.6 GB, from https://huggingface.co/ggml-org/Inkling-2-Mini-GGUF, file `Inkling-2-Mini-IQ4_NL.gguf`, revision `db61c5b4`
- Engine: [llama.cpp](https://github.com/ggml-org/llama.cpp) master f6d944f6d (stock, no patches); patches: none for the default; INK_BUILD=r2inkfix runs the round-2 build, master 225a5345b + inkling-2-mini/patches/0001 and 0002 (F16 relative-bias mask), which the quant options and the 128k profile were measured on; CUDA 12.9
- Hardware: NVIDIA GeForce RTX 3060 12 GB, 62 GB RAM, Intel Core i5-12500, NVMe SSD
- Context: 65,536 tokens
- Placement: VRAM: all dense weights and the experts of loop-core layers 6-17 (6.4 GiB). RAM: the experts of layers 0-5 and 18-23, mmap'd.
- Contributor: [David Hatley](https://github.com/davidghatley)

## Run it

From `inkling-2-mini/` in a clone of https://github.com/davidghatley/3060-recipes:

```sh
INK_NO_GPU_RUN=1 ./serve.sh
```

API: OpenAI-compatible on port 8085

Key flags: `-ngl 99 --fit off`, `-ot 'blk\.([0-5]|1[89]|2[0-3])\.ffn_.*_exps=CPU'`, `-c 65536 -np 1 -t 6`, `-b 2048 -ub 1024`, `-fa on -ctk q8_0 -ctv q8_0`, `--jinja --reasoning-format deepseek`

The script itself (`inkling-2-mini/serve.sh`, machine paths shown as `$MODELS`, `$SCRATCH`, `~`; set them to where your weights and builds live):

```sh
#!/usr/bin/env bash
# Inkling-2-Mini on llama-server: loop-core experts on the GPU, the rest in RAM, 64k context. See PLAN.md / RESULTS.md.
# Build: stock llama.cpp master f6d944f6d (2026-11-29), no patches; see README.md, "Round 4". INK_BUILD=r2inkfix runs the
# round-2 build instead (master 225a5345b + patches/0001 and 0002, the F16 relative-bias mask that made 64k fit there, ub 128).
# Every knob has an INK_* env override; extra args are passed to llama-server.
set -euo pipefail
D=$MODELS/inkling-2-mini
# Quant options other than the default were gated on the round-2 build, so they keep it unless INK_BUILD says otherwise.
case "${INK_QUANT:-iq4nl}" in
  iq4nl) d_model=$D/Inkling-2-Mini-IQ4_NL.gguf; d_build=master ;;            # the default (ggml-org IQ4_NL)
  nvfp4) d_model=$D/own/Inkling-2-Mini-NVFP4.gguf ;;         # the checkpoint's own NVFP4 experts: ~3x lower KLD, ~7% slower
  iq2xxs) d_model=$D/unsloth/Mainline_Support/Inkling-2-Mini-UD-IQ2_XXS.gguf; d_place=gpu ;;   # 2-bit, fits whole on the GPU: fastest, lowest quality (RESULTS.md, Round 2)
  iq3xxs) d_model=$D/unsloth/Mainline_Support/Inkling-2-Mini-UD-IQ3_XXS.gguf; d_place=wide ;;  # 3-bit: layers 3-19 on the GPU; +7% decode, +42% prefill, KLD 3.3x IQ4_NL
  q2kxl) d_model=$D/unsloth/Mainline_Support/Inkling-2-Mini-UD-Q2_K_XL.gguf; d_place=gpu; d_ub=64 ;;  # 2-bit, whole on the GPU, ub 64 to fit 64k
  *) echo "INK_QUANT must be iq4nl, nvfp4, iq3xxs, q2kxl or iq2xxs (or set INK_MODEL)" >&2; exit 2 ;;
esac
# INK_PROFILE=128k was gated on the round-2 build as well (6-15 layout, ub 64, no op offload); it keeps that build too.
[ "${INK_PROFILE:-64k}" = 128k ] && d_build=r2inkfix
# INK_SPEC=dflash2: incoai's DFlash2 drafter (Inkling-2-Mini-DFlash2 @ 4f9088ea, converted to Q8_0 locally, README.md),
# 2 draft tokens, backend sampling, draft ubatch 16. It needs llama.cpp master from 55d482814 (#33073) on, so it always
# runs on the master build. INK_DRAFT, INK_DRAFT_N, INK_DRAFT_UB override. Measured in RESULTS.md, "Round 3" and "Round 4".
SPEC_ARGS=()
case "${INK_SPEC:-none}" in
  none) ;;
  dflash2)
    [ "${INK_BUILD:-master}" = master ] || { echo "INK_SPEC=dflash2 needs INK_BUILD=master" >&2; exit 2; }
    d_build=master; d_spec_ub=128
    SPEC_ARGS=(--spec-draft-model "${INK_DRAFT:-$MODELS/inkling-2-mini-dflash2/local/Inkling-2-Mini-DFlash2-Q8_0.gguf}"
               --spec-type draft-dflash2 --spec-draft-n-max "${INK_DRAFT_N:-2}" --spec-draft-ngl 99
               --spec-draft-n-ubatch "${INK_DRAFT_UB:-16}" -bs) ;;
  *) echo "INK_SPEC must be none or dflash2" >&2; exit 2 ;;
esac
case "${INK_BUILD:-${d_build:-r2inkfix}}" in
  master)   d_bin=$SCRATCH/llama.cpp/master-f6d944f6d/bin            # stock, #32740 compact bias merged: ub 1024 fits at 64k
            # ub 1024 by default; with the drafter ub 128 (ub 512 fails on the first request, PLAN #63); with INK_MMPROJ ub 512
            # (ub 1024 + projector runs out of VRAM on the first image, PLAN #62)
            if [ -n "${d_spec_ub:-}" ]; then d_ub=$d_spec_ub; elif [ -n "${d_ub:-}" ]; then :; elif [ -n "${INK_MMPROJ:-}" ]; then d_ub=512; else d_ub=1024; fi ;;
  r2inkfix) d_bin=$SCRATCH/llama.cpp/r2inkfix-19c41d2ff/bin ;;       # 225a5345b + F16-mask patches; ub 128 is what fits at 64k
  *) echo "INK_BUILD must be master or r2inkfix (or set INK_BIN)" >&2; exit 2 ;;
esac
BIN=${INK_BIN:-$d_bin}
MODEL=${INK_MODEL:-$d_model}
export LD_LIBRARY_PATH="$SCRATCH/envs/llama-build-cuda/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
# experts may be mmap'd from RAM: gpu_run's memcap counts page cache, 20 GB would bind
export GPU_RUN_MEM=${GPU_RUN_MEM:-44G}

# Expert placement (-ot). Layers 6-17 are the loop core and run 3x per token, so their experts go on the GPU first.
# INK_PROFILE=128k: core layers 16-17 back to RAM (6-15 on the GPU), ub 64, no op offload (a core layer in RAM + op offload
# gives NaN, PLAN #7 and #18). Use the default 6-17 layout for speed up to 64k, and this one only for 128k.
# The 128k boundary on this build with ~0.95 GB of the card on the desktop (PLAN #31/#32, RESULTS "The 128k boundary"):
#   6-15 ub 64   runs (124k prompt, needles 3/3)        6-15 ub 128/192/256   do not load
#   6-16 ub 64   loads, OOM on the first request         6-16 ub 128           does not load
# On master + PR #32740: 6-15 ub 256 and 6-16 ub 128 both run a 104k prompt (INK_BIN=<that build> INK_OT=... INK_UBATCH=...).
EXTRA=()
if [ "${INK_PROFILE:-64k}" = 128k ]; then
  : "${INK_OT:=blk\.([0-5]|1[6-9]|2[0-3])\.ffn_.*_exps=CPU}" "${INK_CONTEXT:=131072}" "${INK_UBATCH:=64}"
  EXTRA=(--no-op-offload)
fi
case "${INK_PLACEMENT:-${d_place:-core}}" in
  cpu)  d_ot='exps=CPU' ;;                                          # baseline: every routed expert in RAM (needs --no-op-offload, see PLAN #7)
  core) d_ot='blk\.([0-5]|1[89]|2[0-3])\.ffn_.*_exps=CPU' ;;       # core 6-17 experts on GPU, the rest in RAM
  wide) d_ot='blk\.([0-2]|2[0-3])\.ffn_.*_exps=CPU' ;;             # layers 3-19 on GPU (fits with UD-IQ3_XXS at 64k)
  gpu)  d_ot='' ;;                                                  # everything on the GPU (only the 2-bit quants fit)
  *) echo "INK_PLACEMENT must be cpu, core, wide or gpu (or set INK_OT)" >&2; exit 2 ;;
esac
OT=${INK_OT:-$d_ot}
OT_ARGS=(); [ -n "$OT" ] && OT_ARGS=(-ot "$OT")
KV=${INK_KV:-q8_0}
UB=${INK_UBATCH:-${d_ub:-128}}            # master: ub 1024 (prefill ~3.8x ub 128, PLAN #59); r2inkfix: the F16 mask caps it at 128
# INK_LOAD_MODE=none (master): +15% prefill at 8k, -0.6% decode, 4.4 s instead of 1.4 s to start (PLAN #64); default mmap
LM_ARGS=(); [ -n "${INK_LOAD_MODE:-}" ] && LM_ARGS=(--load-mode "$INK_LOAD_MODE")
MMPROJ_ARGS=()
[ -n "${INK_MMPROJ:-}" ] && MMPROJ_ARGS=(--mmproj "$INK_MMPROJ")
CACHE_ARGS=()
[ "${INK_MOE_CACHE_MIB:-0}" != 0 ] && CACHE_ARGS=(--moe-cache-mib "$INK_MOE_CACHE_MIB" --moe-cache-cpu-share "${INK_MOE_CACHE_SHARE:-0.95}")

# INK_NO_GPU_RUN=1: start llama-server directly (already inside a gpu_run session, or a box without the shared GPU queue)
RUN=("$HOME/anime-pipeline/tools/gpu_run" --need "${INK_NEED:-10000}" --wait "${INK_WAIT:-3600}")
[ -n "${INK_NO_GPU_RUN:-}" ] && RUN=()
exec "${RUN[@]}" \
  "$BIN/llama-server" -m "$MODEL" --alias inkling-2-mini "${MMPROJ_ARGS[@]}" \
  -ngl 99 "${OT_ARGS[@]}" "${CACHE_ARGS[@]}" "${SPEC_ARGS[@]}" --fit off \
  -c "${INK_CONTEXT:-65536}" -np 1 -t "${INK_THREADS:-6}" \
  -b "${INK_BATCH:-2048}" -ub "$UB" "${LM_ARGS[@]}" \
  -fa on -ctk "$KV" -ctv "$KV" --jinja --reasoning-format deepseek \
  --temp 1.0 \
  --host 127.0.0.1 --port "${INK_PORT:-8085}" "${EXTRA[@]}" "$@"
```

## Measured results

| Metric | Conditions | Value | Stock | Ceiling | Source |
|---|---|---|---|---|---|
| decode | coding answer, empty context (round-2 build: 29.0) | 32.9 tok/s | 29.0 |  | [inkling-2-mini/RESULTS.md:392](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L392) |
| decode | after 32k of context (round-2 build: 23.6) | 29.0 tok/s | 23.6 |  | [inkling-2-mini/RESULTS.md:393](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L393) |
| prefill | 8k prompt (round-2 build: 144.1) | 568 tok/s | 144.1 |  | [inkling-2-mini/RESULTS.md:395](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L395) |
| prefill | 32k prompt, measured on a busy host (round-2 build: 122.9) | 470-481 tok/s |  |  | [inkling-2-mini/RESULTS.md:396](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L396) |
| needles | at 32k and at 62k | 3/3, 3/3 found |  |  | [inkling-2-mini/RESULTS.md:397](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L397) |
| vram_peak | after a 62k prompt, whole card | 11587 MiB |  |  | [inkling-2-mini/RESULTS.md:401](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L401) |
| quality | KL divergence vs Q8_0, wikitext-2 (NVFP4 repack: 0.0029) | 0.0087 KLD |  |  | [inkling-2-mini/RESULTS.md:399](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L399) |
| decode | option: UD-IQ2_XXS, whole model on the GPU (KLD 10.7x IQ4_NL) [round-2 build] | 41.4 tok/s |  |  | [inkling-2-mini/RESULTS.md:25](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L25) |
| prefill | option: UD-IQ2_XXS, 8k prompt [round-2 build] | 295 tok/s |  |  | [inkling-2-mini/RESULTS.md:25](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L25) |
| decode | option: 128k profile, empty / after 124k [round-2 build] | 26.4 / 14.6 tok/s |  |  | [inkling-2-mini/README.md:42](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/README.md#L42) |
| decode | option: DFlash2 drafter (INK_SPEC=dflash2, ub 128), coding answer; same build without it | 40.8 tok/s | 33.0 |  | [inkling-2-mini/RESULTS.md:351](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L351) |
| decode | option: DFlash2 drafter, coding answer after 32k; same build without it | 33.4 tok/s | 29.0 |  | [inkling-2-mini/RESULTS.md:352](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L352) |
| decode | option: DFlash2 drafter, prose answer; same build without it | 35.1 tok/s | 33.0 |  | [inkling-2-mini/RESULTS.md:353](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L353) |
| decode | option: DFlash2 drafter, coding eval at temperature 0 (median, 8/8 passed); same build without it | 47.5 tok/s | 32.9 |  | [inkling-2-mini/RESULTS.md:354](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L354) |
| needles | option: DFlash2 drafter, at 32k and at 62k | 3/3, 3/3 found |  |  | [inkling-2-mini/RESULTS.md:356](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L356) |
| vram_peak | option: DFlash2 drafter, after a 62k prompt | 11.8 GB |  |  | [inkling-2-mini/RESULTS.md:357](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L357) |
| prefill | option: INK_LOAD_MODE=none, 8k prompt (decode 32.7) | 651.6 tok/s | 568.9 |  | [inkling-2-mini/RESULTS.md:410](https://github.com/davidghatley/3060-recipes/blob/main/inkling-2-mini/RESULTS.md#L410) |

## Caveats

- Older master (up to 225a5345b) gives NaN prompts when a loop-core layer's experts are in RAM with op offload on, and cannot run 64k with IQ4_NL without the two patches. Both are fixed in f6d944f6d.
- Image input at 64k needs ub 512 (serve.sh sets it with INK_MMPROJ); ub 1024 with the projector runs out of memory on the first image.
- 128k needs the 6-15 layout at ub 64 without op offload; measured on the round-2 build, which INK_PROFILE=128k selects.
- A layout that loads within about 0.4 GB of the card's limit fails on its first request.
- The 2-bit files pass needles and the coding eval; only KLD shows how far they are from the full model.
- The DFlash2 drafter option takes 0.65 GB more VRAM and fits at 64k only with --spec-draft-n-ubatch 16 and ub 128.
- Decode after 32k on the default was measured at ub 128 on the same build; the ub 1024 runs of it fell on a busy host and are void.

## Findings from this recipe

- [A layout that loads within 0.4 GB of the card's limit dies on its first request](https://davidghatley.github.io/3060-recipes/findings/a-load-is-not-a-run.md)
- [Automatic --fit placement loses 40-63% against the hand-written expert regex](https://davidghatley.github.io/3060-recipes/findings/auto-fit-placement-vs-regex.md)
- [Byte-count ceilings overstate what an all-GPU layout can reach](https://davidghatley.github.io/3060-recipes/findings/byte-ceilings-overstate-all-gpu-layouts.md)
- [The desktop session holds about 0.95 GB of the card and that decides several fits](https://davidghatley.github.io/3060-recipes/findings/desktop-holds-a-gigabyte-of-vram.md)
- [128k context on Inkling fits only with core layers 6-15 on the GPU and ub 64](https://davidghatley.github.io/3060-recipes/findings/inkling-128k-on-12gb.md)
- [With spare VRAM at 32k, the MoE cache adds 10-12% and the DSpark drafter a median 14-20%](https://davidghatley.github.io/3060-recipes/findings/inkling-moe-cache-and-dspark-at-32k.md)
- [Looped layers with experts in RAM give NaN prompts when op offload is on](https://davidghatley.github.io/3060-recipes/findings/op-offload-nan-looped-layers-in-ram.md)
- [Unmerged llama.cpp PR 32740 gives 2.5x prefill on Inkling at 64k on this card](https://davidghatley.github.io/3060-recipes/findings/pr-32740-on-a-12gb-card.md)
- [Unsloth's smaller Inkling quants are faster, and only KLD shows what they cost](https://davidghatley.github.io/3060-recipes/findings/unsloth-inkling-quant-ladder.md)
- [Running Inkling's loop fewer than 3 times drops accuracy to near chance for little speed](https://davidghatley.github.io/3060-recipes/findings/fewer-loop-passes-collapse-accuracy.md)
- [On Inkling the compute buffer, not the weights, decides what fits in 12 GB](https://davidghatley.github.io/3060-recipes/findings/compute-buffer-not-weights-sets-fit.md)
- [Casting Inkling's relative-bias mask to F16 cuts the compute buffer by 24%](https://davidghatley.github.io/3060-recipes/findings/f16-bias-mask-patch.md)
- [On a looped MoE, put the loop core's experts on the GPU before anything else](https://davidghatley.github.io/3060-recipes/findings/loop-core-experts-on-gpu-first.md)
- [Loop passes 2 and 3 dropped per-expert scales and broke NVFP4 GGUFs](https://davidghatley.github.io/3060-recipes/findings/loop-scale-bug-nvfp4-experts.md)
- [Repacking Inkling's own NVFP4 experts into a GGUF is about 3x closer to Q8_0 than IQ4_NL](https://davidghatley.github.io/3060-recipes/findings/nvfp4-repack-of-trained-experts.md)
- [Inkling's speed-up comes from flags alone and the patches only make 64k fit](https://davidghatley.github.io/3060-recipes/findings/speed-comes-from-flags-not-patches.md)
- [On an i5-12500 RAM read bandwidth peaks at 6 threads and so does decode](https://davidghatley.github.io/3060-recipes/findings/ram-bandwidth-saturates-at-six-threads.md)

## Credits

- Thinking Machines: The model behind the loop-core placement recipe; our NVFP4 repack copies the checkpoint's own 4-bit experts. (https://huggingface.co/thinkingmachines/Inkling-2-Mini)
- ggml-org: Flint-Q4_K_M.gguf and Inkling-2-Mini-IQ4_NL.gguf are the files the two recipes serve; the Q8_0 files are the KLD references. (https://huggingface.co/ggml-org/Flint-GGUF)
- llama.cpp (ggml-org and contributors): The engine for Flint, the 3D coder and Inkling-2-Mini, and the base of the Kintsugi fork. (https://github.com/ggml-org/llama.cpp)
- Unsloth: The Mainline_Support files are the max-speed options of the Inkling recipe (41.4 tok/s whole-on-GPU); UD-Q3_K_XL was the smaller-expert test on Flint. (https://huggingface.co/unsloth/Inkling-2-Mini-GGUF)
- pcuenca: #32694 is why the model runs on llama.cpp at all; #32752 is one of two open PRs we measured that make 64k fit without our patches. (https://github.com/ggml-org/llama.cpp/pull/32694)
- danielhanchen: Made NVFP4 GGUFs work on stock master, so our round-1 loop-scale patch was dropped. (https://github.com/ggml-org/llama.cpp/pull/32704)
- mtclinton: The upstream record of the op-offload NaN our placement matrix measures. (https://github.com/ggml-org/llama.cpp/issues/32710)
- pwilkin: #32740 measured here at 2.5x prefill at 8k, 2.9x at 62k and +20% decode at 62k; #32218 is the drafter support behind our DSpark test. (https://github.com/ggml-org/llama.cpp/pull/32740)
- Izento: With --fit-target 0 it is the only automatic placement that matched our hand-written one. (https://github.com/ggml-org/llama.cpp/pull/32777)
- Oxsilaris06: Part of the DSpark build we tested at 32k. (https://github.com/ggml-org/llama.cpp/pull/32773)
- apolinario: Scored the loop-pass experiment (3 passes 40.13, 2 passes 4.95, 1 pass 2.59). (https://github.com/apolinario/decision-index)
- multimodalart: The reference index our loop-pass scores are placed against. (https://huggingface.co/spaces/multimodalart/jev-decision-index)
- 0xSero / Sybil Solutions: The tuning method behind the Flint and Inkling recipes; its q8_0 KV gotcha is one we confirmed on Flint. (https://github.com/sybil-solutions/inference-optimisation-skill)
- Hugging Face: Every model, quant and drafter in these recipes is fetched from the Hub at a pinned revision and checked against the API's sha256; the base model's MTP tensors were fetched with HTTP range requests. (https://huggingface.co)
- NVIDIA: Every recipe runs on CUDA on this card; cuBLAS SGEMV is our VRAM bandwidth probe (342 GB/s), nvidia-smi dmon is the telemetry, and Inkling's experts ship in NVFP4. (https://www.nvidia.com/en-us/geforce/graphics-cards/30-series/rtx-3060-3060ti/)
- inco.ai: The opt-in drafter of the Inkling-2-Mini recipe (INK_SPEC=dflash2), converted to a Q8_0 GGUF here: 40.8 tok/s against 33.0 on a coding answer at 64k. (https://huggingface.co/incoai/Inkling-2-Mini-DFlash2)
- z-lab: Measured against MTP on the 3D coder: fastest while writing code (163 tok/s), not used because acceptance falls to 4-7% while reasoning. (https://huggingface.co/z-lab/Qwen3.5-4B-DFlash)

## Reproductions

None yet. Ran it on your own 3060? Report your numbers: https://github.com/davidghatley/3060-recipes/issues/new?template=reproduction.yml

## Machine-readable

- https://davidghatley.github.io/3060-recipes/recipes/inkling-2-mini/recipe.json
- Folder with scripts and raw runs: https://github.com/davidghatley/3060-recipes/tree/main/inkling-2-mini
- Full results log: https://raw.githubusercontent.com/davidghatley/3060-recipes/main/inkling-2-mini/RESULTS.md

## Full write-up (README)

Serving [thinkingmachines/Inkling-2-Mini](https://huggingface.co/thinkingmachines/Inkling-2-Mini) on the RTX 3060 12 GB with llama.cpp.
It is a 26.4B MoE (128 experts, 8 active) with image input. Its layers 6–17 form a loop core that runs three times per token.

The 17.6 GB GGUF does not fit in 12 GB, so experts have to live in RAM. This recipe is about which ones:
- every core-layer expert is read three times per token;
- so the 6.4 GiB of core experts go on the GPU, and the rest stay in RAM.

Numbers and quality are in [RESULTS.md](RESULTS.md). The experiment log is [PLAN.md](PLAN.md), the ceilings are in [THEORY.md](THEORY.md), and the raw data is in `runs/`.

### Result

| Single user, 64k context | Stock master, experts in RAM | **This recipe** |
|---|---:|---:|
| Decode, coding answer | 17.5 tok/s | **32.9 tok/s (1.88×)** |
| Decode at 32k context | | 29.0 tok/s |
| Prefill, 8k prompt | 39 tok/s | **568 tok/s (14.6×)** |
| Prefill, 32k prompt | | 470–481 tok/s (busy host) |
| Needles at 32k / 62k | | 3/3, 3/3 |
| KL divergence vs Q8_0 (wikitext) | 0.0085 | 0.0087 |

Measured on stock llama.cpp master f6d944f6d at ub 1024, 2026-11-30 ("Round 4" at the end of this file and of RESULTS.md). The round-2 build (225a5345b + two patches: 29.0 tok/s, 144 / 123 tok/s prefill) is `INK_BUILD=r2inkfix`. Other quants, 128k and the faster options are in the next table.

Two things in older master mattered for this model; both are fixed in f6d944f6d (2026-11-30):

- **Prompts came out NaN** (up to 225a5345b) when a loop-core layer's experts were in RAM and op offload was on, for any batch of 32 tokens or more, including `-ot exps=CPU` and image prompts ("????"). On f6d944f6d every row of `tools/nanprobe.sh` is finite. See RESULTS.md, "The op-offload NaN" and "Round 4".
- **64k did not run on a 12 GB card with IQ4_NL** on 225a5345b without the two patches in `patches/`. On f6d944f6d the compact-bias PR #32740 is merged, and 64k runs at ub 1024 with no patches.

### Which config

Pick by what you need. All rows are one user, measured on this card with the desktop holding 0.95 GB of it. Decode is a capped coding answer, prefill a cold prompt, KLD is against Q8_0 on wikitext (lower is closer to the full model).

| You want | Run | Decode, empty / after 62k | Prefill, 8k / 62k prompt | Needles | KLD |
|---|---|---:|---:|---|---:|
| **The default: 64k, best balance** | `./serve.sh` | **32.9** / 29.0 after 32k | **568** / 470–481 (32k prompt) | 3/3 at 32k and 62k | 0.0087 |
| **Faster decode, same output: DFlash2 drafter** | `INK_SPEC=dflash2 ./serve.sh` | **40.8** / 33.4 after 32k (chat 35.1) | 151 / 146 (32k prompt) | 3/3 at 32k and 62k | 0.0085 |
| **Max speed** | `INK_QUANT=iq2xxs ./serve.sh` | **41.4** / 26.1 | **295** / 160 | 3/3 at 32k and 62k | 0.091 |
| Speed, less quality lost | `INK_QUANT=iq3xxs ./serve.sh` | 31.0 / 21.6 | 205 / 129 | 3/3 at 32k and 62k | 0.028 |
| 2-bit, a little closer than iq2xxs | `INK_QUANT=q2kxl ./serve.sh` | 39.9 / 25.6 | 255 / 147 | 3/3 at 32k and 62k | 0.072 |
| **Best quality** | `INK_QUANT=nvfp4 ./serve.sh` | 27.4 / 19.3 | 126 / 98 | 3/3 at 32k and 62k | 0.0029 |
| **128k context** | `INK_PROFILE=128k ./serve.sh` | 26.4 / 14.6 after 124k | 85 / 56 (124k prompt) | 3/3 at 124k | 0.0085 |
| A little more decode at 32k | `INK_CONTEXT=32768 INK_MOE_CACHE_MIB=768 ./serve.sh` | 31.9 / 25.8 after 30k | 153 / 132 (30k prompt) | 3/3 at 30k | 0.0085 |
| Fast prefill on 225a5345b + #32740 (superseded: #32740 is merged, and the default row has it) | `INK_BIN=<master + #32740>/bin INK_UBATCH=512 ./serve.sh` | 29.6 / 24.2 | **361** / **297** | 3/3 at 32k and 62k | 0.0085 |

All eight coding tasks pass on the seven rows that were run through them: the first six and the #32740 row.

- **The drafter row runs on the same build as the default (stock master f6d944f6d), at ub 128.** That build gives 33.0 tok/s on the same flags without it, so the drafter's own share is 33.0 → 40.8 on a coding answer (+24%), 29.0 → 33.4 after 32k (+15%) and 33.0 → 35.1 on prose (+6%). See "DFlash2 drafter" below.

- **Core layers 6–17 on the GPU (the default) is the layout for speed, up to 64k.** Use the 6–15 layout (`INK_PROFILE=128k`) only when you need more than 64k: it gives up two core layers and op offload.
- The two 2-bit files are the only ones that fit on the card whole. They are the fastest and clearly the furthest from the full model (KLD 0.091 and 0.072 against 0.0085). The needle and coding gates do not show that difference; KLD does.
- The #32740 row is the round-2 measurement of that PR on 225a5345b (`$SCRATCH/llama.cpp/pr32740-3afe9c3c8/bin`). The PR has since merged; f6d944f6d includes it.

#### The 128k boundary on a 12 GB card

IQ4_NL, q8_0 KV, `--no-op-offload`, with 0.95 GB of the card held by the desktop. "Runs" means a real request with a prompt of more than 100k tokens completed and all 3 needles were found. Details and the load-time buffers are in RESULTS.md.

| Core layers with experts on the GPU | ubatch | Shipped build | master + #32752 | master + #32740 |
|---|---:|---|---|---|
| 6–15 (`INK_PROFILE=128k`) | 64 | **runs** (124k prompt, 3/3) | loads; not run | loads; not run |
| 6–15 | 128 | does not load | loads, fails on the first request | loads; not run |
| 6–15 | 192 | does not load | does not load | loads; not run |
| 6–15 | 256 | does not load | does not load | **runs** (104k and 124k prompts, 3/3 each) |
| 6–16 | 64 | loads, fails on the first request | loads; not run | loads; not run |
| 6–16 | 128 | does not load | does not load | **runs** (104k prompt, 3/3) |
| 6–17 (the 64k default layout) | 128 | not tried (6–15 already does not load) | not tried | loads, fails on the first request |

- With op offload on, nothing loads at 128k on any build, and that placement gives NaN output anyway.
- A layout that only just loads is not safe: the first request needs more memory than the load.
- **Community-reported, same card** (build and settings unknown): 6–15 at ub 128 runs 128k at 20 tok/s, 6–16 fails at ub 128, ub 192 works and ub 256 fails. We reproduced the speed (20.0 tok/s after 104k tokens, on #32740) and the 6–16 failure on three of four builds. We did not reproduce ub 128 or ub 192 working on the shipped build. The pattern fits master with #32752 on a card with no desktop on it; that is an inference from buffer sizes, not something we could test.

### Use it

```bash
## 1. weights (pinned): ggml-org/Inkling-2-Mini-GGUF @ db61c5b4 -> $MODELS/inkling-2-mini/
##    Inkling-2-Mini-IQ4_NL.gguf, mmproj-Inkling-2-Mini-Q8_0.gguf (optional), Inkling-2-Mini-Q8_0.gguf (KLD reference)
## 2. engine: stock llama.cpp master f6d944f6d, CUDA build for sm_86 (INK_BUILD=r2inkfix: 225a5345b + patches/0001, 0002)
git clone https://github.com/ggml-org/llama.cpp && cd llama.cpp && git checkout f6d944f6d
##    (round-2 build: git checkout 225a5345b && git am /path/to/3060-recipes/inkling-2-mini/patches/000[12]-*.patch)
cmake -B build -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=86 && cmake --build build -j --target llama-server
##    (this box: $SCRATCH/llama.cpp/master-f6d944f6d; the round-2 build is $SCRATCH/llama.cpp/r2inkfix-19c41d2ff)
## 3. serve (through gpu_run, OpenAI-compatible on 127.0.0.1:8085)
./serve.sh
```

**Which commit and which patches (2026-11-22; since 2026-11-30 the default is stock master f6d944f6d, see "Round 4" at the end).** The recipe is measured on llama.cpp master **225a5345b** (build 12627).
- `patches/0001` and `0002` (F16 relative-bias mask) are needed for 64k with IQ4_NL, and for nothing else. At 32k, and for every speed number, stock master is enough.
- The loop-scale patch from round 1 is not needed since **690b87d88** (upstream #32704). NVFP4 GGUFs work on stock master from that commit.
- `patches/0003` is only for the loop-pass experiment in `eval/`.
- Open upstream PRs #32740 and #32752 each make 64k fit without our patches. When one merges, the answer becomes "none". RESULTS.md has both measured.
- The patches for the round-1 pin 29b52d398 are in `patches/old-29b52d398/`.

Without `gpu_run` (any box with one 12 GB card), either `INK_NO_GPU_RUN=1 ./serve.sh` or plain llama-server:

```bash
llama-server -m Inkling-2-Mini-IQ4_NL.gguf --alias inkling-2-mini -ngl 99 --fit off \
  -ot 'blk\.([0-5]|1[89]|2[0-3])\.ffn_.*_exps=CPU' \
  -c 65536 -np 1 -t 6 -b 2048 -ub 1024 -fa on -ctk q8_0 -ctv q8_0 \
  --jinja --reasoning-format deepseek --temp 1.0 --host 127.0.0.1 --port 8085
```

`-t 6` is the number of performance cores here. This line is for master f6d944f6d or later; on 225a5345b use `-ub 128` and the two patches for 64k, or `-c 32768`.

The defaults in `serve.sh` are:

- IQ4_NL, with the experts of layers 0–5 and 18–23 in RAM (`-ot 'blk\.([0-5]|1[89]|2[0-3])\.ffn_.*_exps=CPU'`) and everything else on the GPU;
- q8_0 KV, `-ub 1024 -b 2048` (ub 512 with `INK_MMPROJ`, ub 128 with `INK_SPEC=dflash2` or `INK_BUILD=r2inkfix`), 64k context, one slot, `-fa on`, 6 threads, on stock master f6d944f6d;
- `GPU_RUN_MEM=44G`, because the RAM experts are mmap'd and gpu_run's memory cap counts page cache.

Overrides:

- `INK_QUANT=nvfp4`: our repack with the checkpoint's own NVFP4 experts. KLD is ~3× lower, and it runs 5.5% slower (27.4 tok/s).
- `INK_QUANT=iq3xxs`, `q2kxl`, `iq2xxs`: Unsloth's dynamic 3-bit and 2-bit files. They are the mainline-layout files from the `Mainline_Support/` folder of unsloth/Inkling-2-Mini-GGUF @ 45fd0876, renamed from `.gguf_file` to `.gguf` under `$MODELS/inkling-2-mini/unsloth/Mainline_Support/`. The files in that repo's root do not load. Each quant sets its own layout: `iq3xxs` keeps layers 3–19 on the GPU, the 2-bit files put everything on the GPU, and `q2kxl` uses ub 64. Numbers are in the table above.
- `INK_MOE_CACHE_MIB=768` with `INK_CONTEXT=32768`: keeps the hottest RAM experts in VRAM, +10% decode. There is no room for it at 64k.
- `INK_MMPROJ=$MODELS/inkling-2-mini/mmproj-Inkling-2-Mini-Q8_0.gguf`: image input. At 64k `serve.sh` then uses ub 512 (ub 1024 with the projector runs out of memory on the first image; "Round 4").
- `INK_CONTEXT`, `INK_KV`, `INK_UBATCH`, `INK_PLACEMENT=cpu` (the baseline; add `--no-op-offload`), `wide` (layers 3–19 on the GPU) or `gpu` (no experts in RAM), `INK_OT`, `INK_PORT`.
- `INK_SPEC=dflash2`: speculative decoding with inco.ai's DFlash2 drafter (below). `INK_DRAFT_N` (default 2), `INK_DRAFT` (GGUF path) and `INK_DRAFT_UB` (default 16) override.
- `INK_NO_GPU_RUN=1`: start llama-server directly, without the shared GPU queue.
- `INK_PROFILE=128k`: 128k context. Core layers 16–17 move to RAM, with ub 64 and no op offload. Needles are 3/3 at 124k; decode is 26.4 tok/s empty and 14.6 at 124k (RESULTS.md, "The 128k boundary").

Reasoning depth is a chat-template argument: `"chat_template_kwargs": {"reasoning_effort": "low"}`. The values are none, minimal, low, medium, high (the default), xhigh and max. Cap `max_tokens`: at high effort the model can reason for a long time.

### DFlash2 drafter (opt-in)

[incoai/Inkling-2-Mini-DFlash2](https://huggingface.co/incoai/Inkling-2-Mini-DFlash2) (@ 4f9088ea) is a 0.5B block-diffusion drafter: it reads four of the target's hidden states and proposes a block of tokens, which the target then verifies in one batch. Verification keeps the target's output; the drafter only changes the speed.

- **It needs llama.cpp master from 55d482814 (#33073) on.** The round-2 build has the DFlash2 code but its Inkling graph does not hand the drafter its features. `INK_SPEC=dflash2` runs on stock master **f6d944f6d** (the default build since round 4) at ub 128, and refuses `INK_BUILD=r2inkfix`.
- **Two draft tokens, not seven.** Acceptance falls fast with draft length (prose: 51% at 2, 27% at 5), and every extra verified token makes the target read more of the experts that live in RAM. n = 3, 4 and 5 are slower than no drafter on prose.
- **It costs 0.65 GB of VRAM** (11.8 GB on the card after a 62k prompt, desktop included), and only fits at 64k with the drafter's ubatch at 16 (`--spec-draft-n-ubatch 16`). The Q4_K_M drafter saves 40 MiB more and accepts a little less.
- The uncensored AtomicChat file (`../inkling-2-mini-uncensored/`) takes the same drafter at 48k: 42.4 tok/s against 32.4.
- Prefill is unchanged, needles are 3/3 at 32k and 62k, and the coding eval passes 8/8. At temperature 0 (the coding eval) the gain is larger: a median 47.5 tok/s against 32.9, all 8 tasks in 88 s instead of 143.

Convert it yourself (the repo ships safetensors only); the converter needs the original Inkling checkpoint for the tokenizer and the shared embedding norm:

```bash
python -I llama.cpp/convert_hf_to_gguf.py Inkling-2-Mini-DFlash2/ \
  --target-model-dir Inkling-2-Mini/ --outtype q8_0 \
  --outfile Inkling-2-Mini-DFlash2-Q8_0.gguf
```

On top of the llama-server line above, the drafter adds:

```bash
  --spec-draft-model Inkling-2-Mini-DFlash2-Q8_0.gguf --spec-type draft-dflash2 \
  --spec-draft-n-max 2 --spec-draft-ngl 99 --spec-draft-n-ubatch 16 -bs
```

### Building the NVFP4 GGUF

`tools/repack_nvfp4.py TEMPLATE.gguf HF_DIR OUT.gguf [--verify Q8_0.gguf] [--layers 6-17]`. It needs the original safetensors (19.5 GB, without the MTP files) and runs on the CPU in a few minutes.

It copies every tensor from the IQ4_NL GGUF. The NVFP4 experts of layers 0–19 are replaced with the checkpoint's bytes:
- the E2M1 nibbles and E4M3 sub-block scales, bit-for-bit;
- a per-expert F32 `.scale`, equal to amax / outer denominator;
- with the w13 rows de-interleaved into llama.cpp's gate/up order.

`--verify` dequantises the result and compares it with the Q8_0 GGUF; the worst tensor differs by 0.6% relative L2.

### Tools

| Script | What it does |
|---|---|
| `tools/srvtest.py` | server speed and sanity: cold prefill, capped coding decode at a context depth, needles; appends to `runs/ledger.jsonl` |
| `tools/serverrun.sh` | start `serve.sh` with overrides, wait for health, run a test (`INK_TEST`), stop cleanly |
| `tools/bench.sh`, `summarize.py` | one llama-bench run through gpu_run with `nvidia-smi dmon` telemetry |
| `tools/bufprobe.sh` | load the server at several context/ubatch settings and record the KV and compute buffers |
| `tools/kld.sh` | KL divergence vs Q8_0 on wikitext-2 and CPython source |
| `tools/codeeval.py` | 8 Python tasks run against asserts |
| `tools/smoke.py` | chat, arithmetic, code, and one generated image |
| `tools/repack_nvfp4.py` | the NVFP4 repack above |
| `tools/gguf_sizes.py` | per-tensor sizes of a GGUF |
| `tools/gguf_layers.py` | expert bytes and quant types per layer of a GGUF |
| `tools/nanprobe.sh` | the op-offload NaN matrix: llama-perplexity over placements, op offload on and off, ubatch 31 / 32 |
| `tools/gpu_batch.sh` | run a script of several tests inside one `gpu_run` session |

### Credits

- llama.cpp, for the engine and the Inkling 2 Mini support (#32694); ggml-org, for the GGUFs and the imatrix.
- Unsloth, for the dynamic 2-bit and 3-bit GGUFs and the DSpark drafter GGUF.
- The authors of llama.cpp PRs #32704, #32740, #32752 and #32777 and of the analysis in issue #32710, which round 2 builds on and measures.
- Thinking Machines, for Inkling 2 Mini.
- inco.ai, for the Inkling-2-Mini DFlash2 drafter; the DFlash authors (z-lab); and the authors of llama.cpp #32218 and #33073, which let llama.cpp run it on Inkling.
- The tuning method comes from 0xSero's [inference-optimisation-skill](https://github.com/sybil-solutions/inference-optimisation-skill): ceilings first, one change at a time with controls, and output gated as well as speed.
- The flint recipe in this repo, for the experts-in-RAM tooling.

### Round 4 (2026-11-30): stock master is the default build

`serve.sh` now runs stock llama.cpp master **f6d944f6d** (no patches) at ubatch 1024. Same layout, KV and context as before; only the build and the ubatch changed. RESULTS.md, "Round 4", has the gate.

| 64k, IQ4_NL | Round-2 build (225a5345b + patches), ub 128 | **master f6d944f6d, ub 1024** |
|---|---:|---:|
| Decode, coding answer, empty / after 32k | 29.0 / 23.6 tok/s | **32.9 / 29.0 tok/s** |
| Prefill, 8k / 32k prompt | 144.1 / 122.9 tok/s | **568 / 470–481 tok/s** |
| Needles 32k / 62k, coding eval, KLD wiki | 3/3, 3/3, 8/8, 0.0085 | 3/3, 3/3, 8/8, 0.0087 |

- **Build:** `git checkout f6d944f6d`, then the same `cmake` line as above, without `git am` (this box: `$SCRATCH/llama.cpp/master-f6d944f6d`). The compact-bias PR #32740 is merged there, so the attention mask no longer grows with ubatch and 64k fits without our patches.
- **The op-offload NaN is fixed** on this build: a core layer's experts in RAM with op offload on now give finite output.
- **Plain llama-server:** the line under "Use it" (now `-ub 1024`) needs this build or later.
- **Image input:** `INK_MMPROJ=...` now runs at 64k. `serve.sh` drops to ub 512 when it is set, because ub 1024 with the projector runs out of memory on the first image.
- **`INK_SPEC=dflash2`** is unchanged: same build, ub 128, 40.8 tok/s (ub 512 with the drafter fails on the first request).
- **`INK_LOAD_MODE=none`:** +15% prefill (652 against 568 tok/s at 8k), −0.6% decode, 4–5 s to start instead of 1.4 s. Opt-in.
- **`INK_BUILD=r2inkfix`** runs the round-2 build (225a5345b + `patches/0001`, `0002`) at ub 128. `INK_QUANT=nvfp4|iq3xxs|q2kxl|iq2xxs` and `INK_PROFILE=128k` were measured on that build and still select it; the numbers in "Which config" other than the default row are from it.
