Skip to content

[Idea]: Inkling 2 Mini speed and VRAM gaps against llama.cpp, Strata and PolyStrata #101

Backlog

Description

@sayampy

What problem would this solve?

I went through the current upstream trees of llama.cpp (0ce7f213, 24 Nov), Strata (0.2.21, 24 Nov) and PolyStrata (23 Nov) with Inkling 2 Mini in mind, and compared them with RustingStrata's current main (4b3f44bf). RustingStrata already covers a lot here: chunked GPU prefill, q8/q4/q2 KV, CUDA graphs, profile-driven expert swaps, batched host expert matvecs (#80), mainline DSpark on the GPU, and the new HIP backend. These are the specific things that still seem to be missing, with the upstream evidence next to each one. All numbers are from the other engines' own PRs and docs on their own cards, not from a RustingStrata A/B.

Area What I found in the other engines What I can see here
Prefill attention tensor-core QKᵀ and P·V, query chunking, packed-K/V reuse chunk attention scores still run on the host (docs/BENCHMARKS.md:264)
Decode launches clip + KV store fused to 2 launches, small-M GEMV straight from S_K, doorbell kernels merged fused ink_clip on CUDA exists; the small-M slot GEMV and host-expert launch merge don't appear in the Inkling path
Expert residency 64→128 slot refill, pinned full mirror, scratch lent back to the cache, adaptive pinned RAM tier budget is still split into weight fraction + expert headroom + growing KV (forward.rs:463, device.rs:293)
Drafting q4 draft KV, adaptive pause, graph-rebuild accounting, INT8 Markov fold graphs and GPU markov_w2 exist; a fixed short window, cheap fold and acceptance-based pause don't appear
Small-card preset attn requant q5_0, loop BF16, fp8/q8_0 KV with measured quality cost q8/q4/q2 KV exists; the attention/loop rounding preset doesn't

A few of the upstream notes that caught my eye:

  • Fewer ops per token and per prompt tile. llama.cpp PR #32948 keeps normalised mix() stacks across loop passes and merges the two controller norms: kernels/token 6487→6071, tg128 40.44→41.37 tok/s, pp512 832→860, same bits. Its PR #32883 chunks the query batch so the mask scratch is reused — at ub 2048 on Inkling 2 Mini, pp goes 938.5→946.2 tok/s and tg 47.44→49.82 while the MoE cache hit rate stays near 95%. Strata PR #7033 moves complete 2,048-position K/V history tiles out of the prefill query loop: 32K prefill 1,325.4→1,379.6 tok/s.
  • Decode kernels that avoid full dequant or extra launches. PolyStrata PR #284 uses a one-warp-per-row GEMV for cached experts (IQ4_NL 43.0→44.0 tok/s, bit-identical); PR #288 merges the doorbell's tiny kernels into 2 per layer (−192 to −236 launches/token, +1.9–4.3% decode); PR #295 fuses clip, head norms and KV stores on HIP (8→2 launches, +3.4–3.9%). Strata PR #6958 reads S_K weights directly at M≤16 (44→64 tok/s on SQ-15).
  • Keeping more experts resident on small cards. PolyStrata PR #299 refills 128 instead of 64 experts after long prompts — the first 16 tokens after a 32K prompt are 15–16% faster. PR #316 lends prompt scratch back to the expert cache with a drafter (+113–116 experts on an 8 GB card), and PR #317 grows the drafter's attention cache with the conversation (+97–103 experts at 128K). Strata issue #6978 describes an adaptive pinned RAM tier (prototype +16.5% combined decode). llama.cpp PR #32777 ranks looped MoE layers ahead of single-pass ones when fitting weights into VRAM.
  • Drafting that stays cheap. llama.cpp PR #32773 measures q4 draft KV, the ~25 ms graph-rebuild cost and adaptive pausing: fixed 4-token drafts 80.2 tok/s vs 47.6 without drafts on code at 184K, while 7-token windows collapse to ~17. Strata issue #6959 also found greedy DSpark worth pausing when drafts are mostly rejected. PolyStrata PR #311 folds the INT8 Markov head and argmax in one kernel (215→42 µs per draft, bit-exact token picks).
  • A documented small-card profile. PolyStrata's Inkling 2 page lists --attn-requant q5_0 --loop-bf16 --tail-skip 4 --kv fp8/q8_0 for cards that cannot hold every expert: on an RTX 4070 Laptop 8 GB, 37.8→47.7 tok/s after a short prompt and 41.8→50.0 after 4,526 tokens, with the same top-1 token 98.0% of the time. Its backend notes spell out the 48-slot / 40 sliding-window layout that matches the loop handling here.
  • VRAM ideas still in flight. llama.cpp PR #32768 shares global KV across loop passes while keeping per-pass conv state: q4_0 at 262K goes 2.29→1.17 GiB. PolyStrata PR #290 keeps a pinned full expert mirror, and Strata PR #6983 brings FP8 KV to Metal — two directions I could not find an equivalent for here.

Proposed improvement

The directions that seem open, based only on the above:

  • A matrix-core prefill attention path for Inkling 2 (QKᵀ and P·V), plus reuse of packed global K/V history between query blocks.
  • A cheaper decode path when experts are on the host: small-M direct GEMV and fewer tiny kernels around routing, down and conv.
  • One VRAM budget covering weights, KV, graphs and expert slots, with faster post-prompt refill and scratch/drafter KV that give memory back to the cache.
  • Draft verification that keeps graph shapes stable (short fixed window), a cheaper Markov fold and an acceptance-based pause.
  • An opt-in small-card preset for attention/loop rounding and 8-bit KV, with its quality numbers written down.
  • The pinned-RAM expert mirror and loop-aware layer placement as separate switchable ideas.

Alternatives and tradeoffs

  • Several numbers above are from open or draft PRs on cards much larger cards. Also the same kernels were slower on some Turing and AMD cards in those very PRs.
  • The small-card settings are lossy: --attn-requant q5_0 gave 95.6% same-top-1 in PolyStrata's own table, and --tail-skip 4 skips 9–27% of expert picks on 8 GB cards. A strict-quality mode matters here.
  • RustingStrata already has graph capture, hybrid CPU/GPU experts and quantized KV, so the overlap is real; the useful part is the specific measurements and where the bytes go, not the whole upstream implementation.

Activity

  1. Vasyl-Trefilov commented on Nov 24, 2026

    @Vasyl-Trefilov
    Member

    holly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions