Repository navigation
Description
Feature: speculative drafting on the inkling2_loop path (DSpark drafter)
What already exists (and is 90% of what's needed)
--draft-model already understands the DFlash/DFlash2 schema (dflash.* keys: block-diffusion drafter reading target hidden states, block verify, auto-conversion of safetensors checkpoints, hybrid ngram cascade, sampling-safe verify). Thinking Machines' dspark-Inkling-2-Mini-Q8_0.gguf (318 M, on unsloth/Inkling-2-Mini-GGUF) carries general.architecture = dflash — i.e. the same schema family, plus:
dflash.dspark.markov_rankdflash.target_layers(a layer subset for hidden-state taps)dflash.block_size,dflash.sample_from_anchor,dflash.has_confidence_headdflash.attention.causal+sliding_window_pattern(draft is partly non-causal)
Verified on-file: /home/kirill/models/unsloth/Inkling-2-Mini/dspark-Inkling-2-Mini-Q8_0.gguf, 402,278,560 B.
The gap
main.rs dispatches inkling2_loop to inkling2::chat::generate(&g, &prompt, n) — the decode loop is single-token greedy; the batched-verify machinery (verify_rows, draft-length negotiation, rollback) lives in gpu_model.rs behind the main engine. --draft-model/--mtp are silently unreachable from that path (serve.rs exposes drafts stats only for the main engine).
Why it matters disproportionately for this model
Inkling 2 Mini's loop shape (24 layers, 6-17 x3 = 48 layer-visits/token) makes one decoded token expensive: on an 8 GB card decode sits at the LPDDR roofline (~16-18 t/s) for every token, and 4/5 of it streams from RAM. A drafter that proposes a whole block in one pass converts roofline-bound tokens into one verify batch — on the 12 GB reference, llama.cpp measured mean accept-len 3.78 at 69.7% acceptance (short ctx); at 64K depth it still measured 2.24 (1.93x net). The loop is exactly where batched verify pays most: verify cost per extra row is the loop's marginal cost, drafting skips it entirely.
Suggested shape
- Extract the DFlash draft runtime (load, block propose from tapped hidden states) from the main-engine glue so it's callable per decode step.
- Give
inkling2::forwarda multi-row verify entry (its prefill chunk path already computes multi-token forwards layer-first; a K-row decode is a small chunk) + partial-accept rollback for the sliding-window + rel-bias cache and the loop's per-pass message state. - Wire
--draft-model(and the ngram cascade as a weightless fallback that works today on repeated agentic text) intoinkling2/chat.rsdecode.
The markov_rank/confidence_head/non-causal-attention keys may need schema additions in the loader; the block/anchor/verify skeleton should carry over unchanged.
Context
Measured on RTX 5060 Laptop 8 GB + Ryzen mobile: Inkling UD-Q4_K_XL Mainline_Support: decode 15.3-20.1, prefill 33-136 (chunk-dependent); engine is RustingStrata 1.2.6 @ bc3facb native build. llama.cpp oracle (b12588-mix, -cmoe --moe-cache-mib 1536) with DSpark measured net-negative on 8 GB (accept 2.51 < verify 2.8x) — but its verify there runs through the CPU-heavy path; on a GPU-resident decode state the verify economics are a different regime, which is exactly what this engine changes.
Activity
quant: Q4_0 and Q5_0 weights stay in their own format on the GPU and …
Merge pull request #65 from ybenyedder/feat/inkling2-complete: Inklin…
inkling2: a draft check batches the experts of the layers outside VRA…
Vasyl-Trefilov commentedon Nov 22, 2026
@FoMiN12 This is on
mainnow, through #65 by ybenyedder plus fixes on top.--draft-model <DSpark file>and--spec-type ...work oninkling2_loopingenerate,chat,serveandbench.--mtpand--mtp-modelare still ignored (the model has no MTP head), with a warning.How it works: the drafter proposes up to 15 tokens (3 a round for a DSpark file unless you set
--spec-draft-n-max), one GPU pass checks them (16 rows at most), and the state is cut back to the last accepted token. Drafts need the GPU path.Numbers on my card: RTX 3060 12 GB,
Inkling-2-Mini-IQ4_NL.gguf(17.6 GB, so 15 of 24 expert layers are in VRAM on CUDA and 16 on Vulkan),bench --pp 512 --tg 128, decode tok/s. "Merge" is #65 as it was merged; "now" has a follow-up that runs the draft check of the layers outside VRAM as one batch (it checked their rows one at a time before).--spec-type ngram-simple--draft-model dspark-Inkling-2-Mini-Q8_0.ggufThe bench text repeats, so the lookup has nearly every draft accepted; on normal text it drafts less. The DSpark file has 285 of 294 drafts accepted.
So on this card the DSpark file no longer costs speed, but on CUDA it only breaks even (in a second run it was 35.6 against 31.1 without drafts; the numbers move with what else the machine does). On Vulkan it is about a quarter faster. The limit is the model not fitting: in the 8 or 9 layers outside VRAM the rows of a check share few experts, so each checked row still pays for its own experts. More drafts a round did not help (
--spec-draft-n-max5, 7, 11, 15: the same tok/s). On a card that holds the whole model all layers check in one batch and I expect a larger gain, but I have no such card and no number for it. If you have 24 GB, abenchwith and without--draft-modelwould tell us.With
STRATA_FIXED_EXPERTS=1the text with the DSpark file is byte-identical to the text without drafts (70 tokens checked). Without it the expert split adapts, and the text can differ at a near tie, as it does between two runs without drafts.FoMiN12 commentedon Nov 22, 2026
@Vasyl-Trefilov @ybenyedder — thanks for #66's answer and for wiring all of this up so quickly. Here is the full drafter matrix measured on
44e63c5(the numbers below are that commit's), from the 8 GB 5060 rig of the issue body. I have a 24 GB card on another machine and will run the with/without--draft-modelbench some time later. The tip work (#72, the GEMM draft check, theinkling2-named files) landed while I was benching this — re-measuring the same grid on current master and will post the follow-up here.Every number:
Stack: Ubuntu 26.10, kernel 7.3.0-11; CUDA 13.5 (V13.5.37, native build, libs from
/usr/local/cuda); NVIDIA driver 620.70.06 (also the Vulkan driver for device 0); Mesa 26.2.4-1ubuntu1 RADV for device 1 (the engine's own header line:radv Mesa 26.2.4-1ubuntu1, device-coherent memory yes, cooperative matrix f16 yes int8 yes); engine44e63c5, binary sha256925e5b6ab191….Target is the
Mainline_Inkling-2-Mini-UD-Q4_K_XLfile from the issue; device 0 = the 5060, device 1 = the 780M iGPU (coherent UMA). "prose" = the engine's built-in bench text, "rep" = a 13.4 KB repetitive prompt (a JSON access-log ending in a request to continue the list in the same format — the agentic-repetition shape; under 4096 tokens, the bench repeats it to fill the prefill). Cell format:bench --pp 4096 --tg 128decode t/s, then (speedup over the no-draft row of that column, accepted/proposed drafts):--draft-model+ --spec-draft-n-max 7+ --spec-draft-n-max 15--spec-type suffix--spec-type ngram-simple--spec-type ngram-map-k--spec-type ngram-map-k4v--spec-type ngram-mod--spec-type ngram-cache--draft-model --spec-type suffixSame file,
bench --pp 512 --tg 128, for depth-512 reference:ngram-simple--draft-modelCell format: t/s (speedup vs the no-draft row of the same column, accepted/proposed drafts).
Prefill from the same 4096-token runs (prose/rep t/s, grouped — the pattern was uniform inside each group):
--draft-modelincl. n-max armsOne determinism question. On this build, with
--fixed-expertsand a short prompt: two undrafted runs are byte-identical to each other (so the flag holds and the run is deterministic), thengram-simpleoutput is byte-identical to undrafted, but--draft-modeloutput is byte-identical across itself while consistently differing from the undrafted output at around token 20 — a near-tie in a low-confidence region, so ULP-level reassociation on the verify pass flipping an argmax, presumably from the batched out-of-VRAM expert check. Does the 70-token byte check still pass at the current tip?ybenyedder commentedon Nov 22, 2026
@FoMiN12 Yes,
speculative_ngram_and_dspark_match_greedystill passes on currentmain(tested on Radeon 890M Vulkan). The divergence around token 20 with--draft-modelon partial-VRAMUD-Q4_K_XLis expected ULP rounding between batched verify and token-by-token decode at a near-tie logit — that's also why the test checks up to the first near-tie.FWIW on Radeon 890M Vulkan with
UD-IQ3_XXS(fits in VRAM with #72 graph capture): plain11.8 tok/s,--draft-model(default)17.2 tok/s(90.2% accepted),ngram29.8 tok/s(87.5% accepted).(Also, could you add me on TikTok? My username is
table5879🙏)Vasyl-Trefilov commentedon Nov 22, 2026
@ybenyedder gasdhdasghdghasghdashhadg, wtf, why do you need him on tiktok hahaha
ybenyedder commentedon Nov 22, 2026
@Vasyl-Trefilov Ifk I just want to add the people from the project pls add me too
Vasyl-Trefilov commentedon Nov 22, 2026
hahahha, okay
FoMiN12 commentedon Nov 23, 2026
Same grid, re-measured on
main@2a581f1(#72 graph capture, ≥7-row GEMM draft check,ccf4e2ddecoders, #75 softcap skip). Same rig, stack, and commands as my previous comment, engine binary sha2569e19f8818a4e…. One run per cell:bench --gpu --ctx 32768 --pp 4096 --tg 128 --reps 1,STRATA_DS_GPU_FRACTION=0.90.Upstream moves faster than I can test — the tip moved again while this comment sat. This is my last grid on this machine (5060 Laptop, 8 GB); the next one is on an RTX 3090 (24 GB).
Correction to my previous comment: its CUDA rep k4v cell (50.2) was a bad run, true value ≈39.8 — the 75/75 starvation shows on CUDA too.
--draft-model+ --spec-draft-n-max 7+ --spec-draft-n-max 15--spec-type suffix--spec-type ngram-simple--spec-type ngram-map-k--spec-type ngram-map-k4v--spec-type ngram-mod--spec-type ngram-cache--draft-model --spec-type suffixFormat: decode t/s (
--pp 4096 --tg 128), speedup vs no-draft, accepted/proposed. Hybrid cascade (--draft-model+ default lookup), same grid: CUDA 61.6 / 54.9, VK5060 43.1 / 42.1, VK780M 20.3 / 18.2 (prose / rep). Three cells re-run after an external process skewed their timing (acceptance identical): CUDA n-max-15 prose → 32.7, VK780M--draft-modelprose → 11.5, CUDA rep-k4v → 39.8; last row measured in the same gated batch.bench --pp 512 --tg 128(maintainer-reference shape):ngram-simple--draft-modelPrefill from the 4096-token runs (prose / rep t/s, grouped):
--draft-modelincl. n-max armsDiff vs
44e63c5: CUDA lookups +11-16% (GEMM draft check), everything else ±3%.FoMiN12 commentedon Nov 23, 2026
@ybenyedder well.... I don't even have TikTok currently. I used it maybe 5-6 years ago last time