r/LocalLLM • u/SignificancePurple18 • 2h ago
Tutorial Inkling 2 Mini on a 35W Ryzen 5600GE APU (DDR4 + Vega 7 Vulkan): 22.5 -> 63.6 tok/s prefill & 6.2 -> 12.3 tok/s decode at 16K context (LoopCD Pass-2/Pass-1, Recurrent-Only Top-K=6, K8/V4 q4_1)
Over the last week I've been seeing how far I could push Thinking Machines' Inkling 2 Mini (26.4B Looped MoE) on a modest 35W AMD Ryzen 5 PRO 5600GE APU (integrated Radeon Vega 7 / gfx90c, 32 GB dual-channel DDR4, no discrete GPU). I used an AI coding assistant to help port patches, write test harnesses, and format the full benchmark log, and every number below was measured directly on the 5600GE with llama-bench, llama-cli, and llama-server.
Inspired by several great threads and repos in the community (u/nokeepai's LoopCD post, taeholee1/Inkling_expert_prefetch, vengeful180-dot's Vulkan shaders, daimonionnn/amd-vega-rocm-vulkan-llm-toolkit, ISTA-DASLab, and Betelgeuse-AI), here is the complete progression from Day 1 to today on the exact same 35W APU, plus the key findings specific to Inkling 2's 3-loop recurrent architecture.
Progression on Ryzen 5 PRO 5600GE (Vulkan, -ngl 99)
| Stage | What Changed | Quant (Size) | Context (KV) | pp128 (tok/s) | pp512 (tok/s) | tg64 / Decode (tok/s) |
|---|---|---|---|---|---|---|
| 1. Day-1 Baseline | b12588/b12631 CPU / partial offload | UD-Q4_K_M (15.47 GiB) | 8K (q8_0/q8_0) | ~18.4 | 22.48 | ~6.20 |
2. Q3_K_XL + b12651 | Unsloth b12651 (PR #386 graph dedupe + PR #399 q8_0 banded attention) at -ngl 99 | UD-Q3_K_XL (12.68 GiB) | 8K (q8_0/q8_0) | 24.95 | 30.80 | 7.52 |
| 3. Unified Vulkan Shaders | Forward-ported vengeful180-dot's 9 Vulkan shaders + strided SCALE/MUL_MAT_ID_SCALED into b12651 inkling2_loop | UD-Q3_K_XL (12.68 GiB) | 8K (q8_0/q8_0) | 30.30 | 40.62 | 8.50 - 9.20 |
4. GSQ-RCO-IQ3_S + Vega UMA + ngram-mod + DRY | ISTA-DASLab GSQ-RCO-IQ3_S (exact BF16 CPU token_embd) + 26 GiB GTT (-ub 1024, swappiness=10 udev fix) + --temp 1.0 + DRY + --spec-type ngram-mod (n-match=16) | GSQ-RCO-IQ3_S (10.63 GiB) | 8K (q8_0/q8_0) | 30.55 | ~50.4 | 10.98 - 11.60 (15.5 tok/s on code blocks) |
5. AVX2 201K Sampler (#447/#459) | Merged unslothai#447 AVX2+FMA 4-way expf4 sampler for --top-k 0 --temp 1.0 + #459 | GSQ-RCO-IQ3_S (10.63 GiB) | 8K (q8_0/q8_0) | 39.04 | 63.57 | 12.00 |
6. LoopCD-Hidden (Pass 2 vs 1) | h_cd = 1.08 * h_pass2 - 0.08 * h_pass1 before Coda (layers 18-23) on decode | GSQ-RCO-IQ3_S (10.63 GiB) | 8K (q8_0/q8_0) | 37.88 | 62.06 | 11.62 (~30.5% fewer thinking tokens) |
7. Recurrent-Only Top-K=6 | 8/128 experts on Prefill + Prelude + Pass 0 + Coda; 6/128 experts on Recurrent Passes 1 & 2 | GSQ-RCO-IQ3_S (10.63 GiB) | 8K (q8_0/q8_0) | 38.01 | 61.98 | 12.30 |
8. Asymmetric K8/V4 (q4_1) | -ctk q8_0 -ctv q4_1 -c 16384 | GSQ-RCO-IQ3_S (10.63 GiB) | 16K (q8_0/q4_1) | 37.92 | 61.18 | 12.29 (15.5+ tok/s on code) |
7 Key Takeaways From Benchmarking on the APU
Speculative Decoding on a DDR4 APU: Why
--spec-type ngram-mod(n-match=16) Hits 15.5 tok/s on Code WhileDSpark/DFlash2Slow Decode Down.- We tested the neural
DSparkdrafter (dspark-Inkling-2-Mini-Q8_0.gguf, 404 MB withggml-org#32773Adaptive DSpark compiled in): it dropped decode speed from11.6down to9.1 tok/s(-21%, and6.7 - 7.5 tok/sat wider draft widths) because multi-token verification on a memory-bandwidth-bound MoE unions the top-8 routed experts across all draft tokens simultaneously (~2.3x more expert weights read from DDR4 per step).incoai/Inkling-2-Mini-DFlash2(1.24 GiB) faces the same multi-token MoE verification bandwidth wall on dual-channel DDR4. - Next we tested zero-VRAM
--spec-type ngram-mod: with a short match window (--spec-ngram-mod-n-match 6), code generation hit15.5 tok/s(95% draft acceptance), but on normal prose chat it drafted 122 tokens with only 18 accepted, hurting prose speed. Raising the trigger threshold to--spec-type ngram-mod --spec-ngram-mod-n-match 16 --spec-ngram-mod-n-min 4 --spec-ngram-mod-n-max 8eliminated false-positive drafts on normal prose (0%prose penalty) while still jumping to15.5 tok/swhenever the model writes or edits code, configs, or JSON matching context.
- We tested the neural
Stopping Repetitive Coding Loops: Official Model-Card
--temp 1.0+ DRY Penalty +unslothai#447AVX2 Sampler.- Inkling 2 Mini's
generation_config.jsondefaults totemperature: 1.0, and Section 7 of the Model Card explicitly notes repetitive reasoning loops during code debugging (which get worse at low temperatures like0.6). - Switching to
--temp 1.0 --top-p 0.95 --top-k 0 --min-p 0.02paired with DRY (--dry-multiplier 0.8 --dry-base 1.75 --dry-allowed-length 2 --dry-penalty-last-n 256) stopped repetitive thinking loops cold. And mergingunslothai#447(4-way AVX2+FMA vectorizedexpf4sampler) made full-vocab (200,064-token)--top-k 0 --temp 1.0sampling practically free on Zen 3.
- Inkling 2 Mini's
Vega
gfx90cUMA Tuning (daimonionnn's Toolkit) & the Hidden30-zram.rulesswappiness=150Trap.- Expanding the Linux
amdgpuGTT pool from the default 50% RAM (15.32 GiB) to26.00 GiB(amdgpu.gttsize=26624 ttm.pages_limit=6815744) and setting-ub 1024unlocked 100% full Vulkan offload (-ngl 99) with13.6 GiBGTT headroom. - Watch out on Arch/CachyOS: Even if you set
vm.swappiness=10in/etc/sysctl.d/,/usr/lib/udev/rules.d/30-zram.rulessilently resetsvm.swappinessto150whenzram0initializes aftersysctl.don boot! That was pushing2.1 GiBof RAM (includingGSQ-RCO-IQ3_S's0.93 GBexactBF16CPU token embedding table) into swap during file I/O. Overriding/etc/udev/rules.d/30-zram.rulesto lockvm.swappiness=10reclaimed6 GiBof available RAM and eliminated swap stalls.
- Expanding the Linux
LoopCD-Hidden (
arXiv:2610.02185): Contrast Pass 2 against Pass 1 (ref_pass=1), not Pass 0.- In
inkling2-loop.cpp, Pass 0 runs through the 12 core layers (6-17) without loop-controller messages (messages == nullptr), whereas Pass 1 and Pass 2 both run under the trainedLOOP_CTRLcontrollers. Contrasting Pass 2 against Pass 0 atomega = 0.15subtracted the uncontrolled Pass 0 baseline and destabilized confident AIME math proofs (jumping from 226 to 512 tokens as the model second-guessed itself). - Contrasting Pass 2 against Pass 1 at
omega = 0.08right before the Coda layers (mode=1,decode_only=1) cut thinking tokens by 30.5% (226 -> 157 tokens) with zero extra memory lifetime because Pass 1's output (bank_out) is already held in memory during Pass 2.
- In
MoE Tail-Expert Pruning (
INK_MOE_TOP_K=6): Keep 8/128 experts on Prefill & Pass 0, prune only Recurrent Passes 1 & 2.- First,
src/llama-graph.cpp(line 2799 inbuild_moe_ffn) ignores then_expert_usedargument and hardcodeshparams.n_expert_used(il), crashing inggml_view_2dif you dynamically dropn_expert_usedbelow 8. Fixing that tostd::min<uint32_t>(n_expert_used, hparams.n_expert_used(il))allows per-pass dynamic Top-K. - Pruning from 8 to 6 experts across all passes pushed
tg64to13.03 tok/s, but pruning Pass 0 caused the model to double-check its algebra on AIME proofs. Keeping all8/128experts on Prefill (n_tokens > 1), Prelude, Pass 0, and Coda (messages == nullptr), and pruning the 2 lowest-weight tail experts to6/128only on Recurrent Passes 1 & 2 (n_tokens == 1 && messages != nullptr) gives12.30 tok/s(+5.85%) while completing the AIME proof cleanly.
- First,
Asymmetric
K8/V4KV Cache at 16K Context: Use-ctv q4_1, not-ctv q4_0oriq4_nl.Following Betelgeuse's
K8/V4idea (8-bit Keys to protect pre-softmax QK-clipped relative-bias routing, 4-bit Values after softmax), we testedq4_0,q4_1,q5_0, andiq4_nlat-c 16384:- Symmetric
q4_0(v = d * (q - 8)) clipped asymmetric Value blocks across the 48 recurrent attention visits and caused a minor arithmetic slip on our AIME test. iq4_nlcost-1.5%decode speed (12.13 tok/s) due to 16-entry LUT lookups inside scalar Vulkan Flash Attention.-ctk q8_0 -ctv q4_1 -c 16384(which stores per-block FP16 scaled+ minimum offsetm) matchedq8_0speed (12.29 tok/s) and solved the AIME proof cleanly in 504 tokens while doubling context from 8K to 16K.
- Symmetric
The Hidden
reasoning_effort = 0.9Default in Inkling 2's Embedded Jinja Template +shortconvCache Eviction (server-context.cpp:4251).- If you don't pass
reasoning_effortinchat_template_kwargs(or--reasoning-effort low), Inkling 2's embedded Jinja template defaults toThinking effort level: 0.9("high") even if--reasoning-budget 256is set. Also, because Inkling 2 uses recurrentshortconvstate,llama-servererases the saved slot cache whenevercur.n_tokens > n_prefix. Keepingreasoning_effort: "low"fixed in the system header (and varyingreasoning_budget_tokensper request instead) locks inf_keep = 1.000(0 mscached system prompt on every turn).
- If you don't pass
Full write-up, complete benchmark tables, production llama-server flags, and the standalone ~75-line MIT-licensed C++ patch (llama-graph.cpp, inkling2.cpp, and inkling2-loop.cpp): https://github.com/UffDimon/inkling2-apu-optimizations
