|
Download README.md from Lanilen/Inkling-2-Mini-Draft-Kit: direct link, hf CLI and curl.
- Browser
- Download file 18.4 kB
-
https://huggingface.co/Lanilen/Inkling-2-Mini-Draft-Kit/resolve/main/README.md
- Command line
-
hf download hf://Lanilen/Inkling-2-Mini-Draft-Kit/README.md
-
curl -L -o README.md https://huggingface.co/Lanilen/Inkling-2-Mini-Draft-Kit/resolve/main/README.md
18.4 kB
| license: mit | |
| tags: | |
| - inkling-2-mini | |
| - speculative-decoding | |
| - dspark | |
| - draft-model | |
| - llama.cpp | |
| # Draft Kit for Inkling 2 Mini | |
| **This is not a language model, and it does nothing on its own.** It is a set of small files that make | |
| [Inkling 2 Mini](https://huggingface.co/thinkingmachines/Inkling-2-Mini)'s own DSpark drafter faster in speculative | |
| decoding: a drafting dictionary and two learned draft exits, one for greedy drafts and one for sampled drafts. The | |
| target model verifies every drafted token over its whole vocabulary, so **the output is exactly the model's own**: | |
| these files change how fast the answer arrives, never what it says. | |
| | everyday requests, answers in tok/s, temp 0 | review | notes | | |
| |---|---|---| | |
| | **1920X + R9700** (the model whole on the GPU): no drafter / shipped drafter / with this kit | 65.4 / 76.1 / **96.4** | 65.5 / 80.4 / **96.7** | | |
| | **14600KF + RTX 4070 Ti 12 GB** (experts in RAM, hot spare cache): no drafter / shipped / this kit | 36.5 / 43.1 / **55.3** | 36.0 / 47.9 / **59.0** | | |
| | **1920X + one RX 480 8 GB** (2016; experts in RAM, hot spare cache; 2026-11-27, files v1): no drafter / shipped / this kit | 14.6 / 15.9 / **22.0** | 14.6 / 19.4 / **22.4** | | |
| | the same at Inkling's temp 1.0 (top-p 1, top-k 0), medians of ten passes | review | notes | | |
| |---|---|---| | |
| | **1920X + R9700**: no drafter / shipped / kit with greedy drafts (files v1) / **kit v2, sampled drafts** | 60.4 / 54.3 / 72.1 / **80.9** | 60.5 / 59.5 / 77.9 / **83.4** | | |
| | **14600KF + RTX 4070 Ti**: no drafter / shipped / kit with greedy drafts / **kit v2, sampled drafts** | 35.7 / 36.6 / 47.2 / **49.4** | 35.4 / 40.2 / 52.9 / **52.3** | | |
| **The speed barely depends on the text or the sampling any more.** The shipped drafter verifies four drafts every | |
| step; on text it predicts badly most are rejected, and at temperature 1.0 it is slower than no drafter on the R9700's | |
| review. The kit stops the drafts it expects rejected, and version 2 samples its drafts at temperature 1.0 and stops | |
| them with an exit trained on sampled drafts. At temperature 1.0 the review (hard to draft) runs at 0.97 of the notes' | |
| speed on the R9700 and 0.94 on the RTX 4070 Ti (shipped drafter: 0.91 on both), and the kit keeps 84β86% (R9700) and | |
| 89% (RTX 4070 Ti) of its temperature-0 speed (shipped: 71β74% and 84β85%). On the RTX 4070 Ti the greedy kit's | |
| temperature-1.0 speed swings between runs (45.5β47.2 / 48.5β52.9 in two runs), version 2's repeats within 0.5% | |
| (49.4 / 52.3β52.6): against the greedy kit, +4.6β8.5% on the review and β1.1 to +8.3% on the notes. Its steps cost | |
| 45β47 ms (the experts the cache misses run on the CPU) against the R9700's 28 ms, so a token more a step is worth less | |
| there. | |
| **Every arm runs the same file the same way.** Each row compares the drafting arms on one GGUF as stored, with every | |
| routed expert computed, the KV cache in F16, the same server and the same requests, through the same launcher (Local | |
| Coder, which passes Inkling's chat options: reasoning off): the only difference between the columns is the drafting. | |
| The RTX 4070 Ti rows are with a minimal desktop on the card (0.1 GB), an 8000 MiB cache and pinned experts | |
| (`--load-mode none`). Version 2 of this card showed 59.7 / 63.6 for the RTX 4070 Ti at temperature 0: that run used a | |
| direct `llama-server` command with reasoning on, whose answers draft better; the same engine gives 58.4 / 62.1 that way | |
| today, and its steps cost 7β13% more than through the launcher. | |
| | | | | |
| |---|---| | |
| | **For the model** | [thinkingmachines/Inkling-2-Mini](https://huggingface.co/thinkingmachines/Inkling-2-Mini), with its DSpark drafter (unsloth's `dspark-Inkling-2-Mini-Q8_0` from [unsloth/Inkling-2-Mini-GGUF](https://huggingface.co/unsloth/Inkling-2-Mini-GGUF)) | | |
| | **Measured with** | [unsloth/Inkling-2-Mini-GGUF](https://huggingface.co/unsloth/Inkling-2-Mini-GGUF) `Mainline_Support/UD-Q4_K_XL` as stored (the dense tensors at Q8_0, the experts in the release's NVFP4), every routed expert computed, the KV cache in F16 | | |
| | **Works with** | the [Polaris llama.cpp fork](https://github.com/Lanilen/llama.cpp) (branch `polaris`): the dictionary and the greedy exit from `c52c9eaf6` (2026-11-27); the sampled exit, and sampled drafts by default, from `c96e591b1` (2026-11-29). Its [Inkling 2 Mini guide](https://github.com/Lanilen/llama.cpp/blob/polaris/docs/inkling2-mini.md#the-draft-kit-a-dictionary-and-a-learned-exit) has the measurements | | |
| | **Version** | files 2 (2026-11-29: + the exit for sampled drafts); this card 3 (2026-11-29) | | |
| ## The files | |
| | file | flag | what it is | | |
| |---|---|---| | |
| | `inkling2-dict-24k.txt` | `--spec-draft-dict` | the dictionary's fixed core: the 24,576 most frequent tokens of Inkling's answers, one token id a line | | |
| | `inkling2-families-1024.txt` | `--spec-draft-dict-families` | each token's family (line *i*: token *i*'s), 1,024 clusters of the output head's rows: an answer token outside the dictionary loads its family | | |
| | `inkling2-exit-v1.txt` | `--spec-draft-exit-model` | the exit for greedy drafts (temperature 0): a LightGBM model (300 trees, 33 inputs) of the chance a drafted token is accepted, in place of a fixed stop | | |
| | `inkling2-exit-v1-check.txt` | | 2,000 rows of its 33 inputs and the expected output, to check an implementation against | | |
| | `inkling2-exit-sampled-v1.txt` | `--spec-draft-exit-model-sampled` | new in files v2: the exit for sampled drafts (temperature above 0), the same kind of model trained on rejection sampling's acceptance | | |
| | `inkling2-exit-sampled-v1-check.txt` | | 2,000 rows of its inputs and the expected output | | |
| | `SHA256SUMS` | | | | |
| ## Using it | |
| Add to the server's drafter options (the drafter at 4 tokens a draft): | |
| ``` | |
| -md dspark-Inkling-2-Mini-Q8_0.gguf --spec-type draft-dspark --spec-draft-n-max 4 -ngld 99 \ | |
| --spec-draft-dict inkling2-dict-24k.txt --spec-draft-dict-families inkling2-families-1024.txt \ | |
| --spec-draft-exit-model inkling2-exit-v1.txt \ | |
| --spec-draft-exit-model-sampled inkling2-exit-sampled-v1.txt -bs | |
| ``` | |
| `-bs` (backend sampling: the target's sampling on the GPU) is part of the measured setup; on the fork from 2026-11-28 it | |
| no longer slows prompts. With `-bs` and the sampled exit, a request at a temperature above 0 gets **sampled drafts**: | |
| the drafter samples its tokens and the target accepts or rejects them by rejection sampling, which keeps the model's | |
| own distribution and accepts more drafts than matching an argmax (on the R9700 at temperature 1.0, 55.7% β 66.9% of | |
| the review's drafts). A request at temperature 0 drafts greedily and the first exit decides, exactly as before. | |
| `--spec-draft-sampling greedy` turns sampled drafts off. A named exit model takes precedence over | |
| `--spec-draft-p-min` (the server warns when both are given); a sampled draft with neither an exit of its own nor a | |
| `p-min` would run to `--spec-draft-n-max` every step, so the fork drafts greedily in that case. The server's log names | |
| the mode when it starts. | |
| ## What each part is worth | |
| The 35 varied prompts (code, prose, maths, chat, four other languages), the R9700, UD-Q4_K_XL whole, two runs an arm. | |
| Each part was measured in its own A/B against the setup before it: | |
| | | temp 0 | temp 1.0 | | |
| |---|---|---| | |
| | the shipped drafter with its probability stop (4 drafts, p β₯ 0.8) | 76.1 tok/s | 64.4 tok/s | | |
| | + the dictionary | +5.1% | +4.8% | | |
| | + the learned exit, in place of the stop | +1.9% | +2.2% | | |
| | + `-bs` | +5.4% | +4.5% | | |
| | + sampled drafts (with the 0.8 stop for them) | (greedy at temp 0) | +3.5% | | |
| | + the sampled exit, in place of that stop | (greedy at temp 0) | +0.7% | | |
| On the everyday requests the last two rows are larger: sampled drafts +8.0% / +2.6% (review / notes) over greedy | |
| drafts, and the sampled exit +1.2% / +3.4% over the stop. | |
| The dictionary rows were measured with a 32k frequency core; the shipped 24k core with families runs within 0.3% of | |
| it on these prompts. At temperature 0 that dictionary gives the same answer as the full vocabulary on 34 of 35 | |
| prompts (the 35th differs where different drafts change the target's batch shapes); a dictionary holding the whole | |
| vocabulary gives the same answers and the same drafts on 35 of 35. A translation set (25 translations of English | |
| answers into German, Spanish, Russian, Japanese and Chinese, and 10 "answer in X" requests) runs at 66.0 tok/s | |
| without a dictionary and 69.3 with the shipped one. | |
| ## How the dictionary works | |
| **Why it pays.** Inkling's vocabulary is 201,024 tokens, and a DSpark draft step does three things over all of them: | |
| the output head (201,024 rows of 2,304, Q8_0), the Markov head's vocabulary matmul (bf16, 200,058 Γ 256, once a drafted | |
| position) and the ARGMAX / TOP_K over the result. On the R9700 those were 53% of the drafter's 3.48 ms at 4 drafts. | |
| Drafting over K tokens instead costs about K / 200k of that. | |
| **What it costs.** Only a token the drafter would have drafted *and* the target would have accepted can be lost: the | |
| target still verifies over its full vocabulary and corrects any miss itself. On live drafts at temperature 0, a | |
| dictionary of the 32k most frequent answer tokens plus the answer so far keeps 98.5% of the accepted drafts (16k: | |
| 96.4%, 8k: 93.1%). More than half of the drafts it loses are a draft's first token. | |
| **The active set** is 34,816 slots in three parts: | |
| 1. **The fixed core** (`inkling2-dict-24k.txt`): the 24,576 tokens that appear in the most of Inkling's answers | |
| (document frequency over 662 conversations, the test prompts' conversations left out). | |
| 2. **A ring of 2,048 single tokens**: the prompt's tokens and every answer token (the target's corrections included) | |
| that is not in the core. The oldest leaves first. | |
| 3. **32 family blocks of 256 slots**, least recently used out. A family is a cluster of the target's output head | |
| rows: k-means into 1,024 clusters on the unit-normalized rows, reduced to 64 dimensions with PCA, using no text at | |
| all (median 175 tokens). A family's tokens outside the core are cut into pieces of 256. When the answer produces a | |
| token outside the dictionary, its piece loads into the least recently used block, and a token the drafter uses | |
| marks its block as recently used. A token sits in one slot at most. | |
| The ring and the blocks carry over between requests, so several parallel sequences don't reset each other's | |
| dictionary. | |
| **On the GPU.** The core's and the loaded tokens' rows of the output head (Q8_0) and of the Markov head (bf16, and its | |
| bias) are copied byte for byte into slot tensors next to the drafter. The draft graph computes the head's logits over | |
| the 34,816 slots only. The Markov chain also runs in slot space: its bias is added there, and its TOP_K / ARGMAX pick | |
| slots that a small id table maps back to token ids, so the chain's next input embedding and the draws carry real | |
| tokens. Free slots are masked to -inf and point at a sink token no dictionary can hold. Only the final logits are | |
| scattered back to the full vocabulary, once, for the sampler. A ring add writes at most 12 tensors, and a family load | |
| writes 6 (~0.75 MB). The drafter's graph goes from 3.04 to 1.54 ms on the R9700 at 4 drafts. Nothing is retrained: | |
| it applies to the drafter as shipped. | |
| **Why families, and not topics.** At equal budgets, families recover what a frequency list loses on text the | |
| dictionary's source barely has: Russian 78.2 β 93.7% of the tokens covered, Japanese 91.8 β 98.2%, Chinese | |
| 93.5 β 98.1%, German 84.9 β 89.9%, Spanish 87.0 β 91.3%. They cost nothing in-domain (97.6 β 98.0%) or on code | |
| and markdown. Dictionaries chosen by the prompt's topic (NMF topics, or clusters of the training prompts) did worse | |
| than one global list everywhere, because the useful units are lexical: a script, a language, a family of subwords. | |
| The prompt's own tokens add almost nothing on live text (about +9 tokens to a 32k dictionary). | |
| **Related work.** Drafting over a reduced vocabulary while the target verifies over the full one is an active idea. | |
| [FR-Spec](https://arxiv.org/abs/2502.14856) (Zhao et al.) constrains the draft to a static frequency-ranked subset, | |
| which is what the fixed core is. EAGLE-3's released drafters also draft over a fixed reduced vocabulary with a | |
| draft-to-target map, which DSpark shares (its Markov head's 200,058 tokens against the target's 201,024). | |
| [NanoSpec](https://arxiv.org/abs/2605.26444) (Chen et al.) builds a small active vocabulary from the context at each | |
| step. [DynaSpec](https://arxiv.org/abs/2510.13847) (Zhang et al.) routes each context to coarse token clusters with | |
| meta-classifiers and drafts over their union. [SpecVocab](https://arxiv.org/abs/2602.13836) (Williams et al., | |
| Findings of ACL 2026) selects a vocabulary subset at each step. This kit's combination is a frequency core, a | |
| per-request ring, and families of the target's own head rows loaded on a miss with LRU, all in a fixed slot layout, | |
| applied to a shipped drafter with no training. | |
| ## How the exits work | |
| A draft of up to 4 tokens is cut before the first token that the exit predicts will be rejected at a probability | |
| below 0.5. The first drafted token is always kept. Both exits are LightGBM (300 trees) over the same 33 inputs. | |
| **The greedy exit** (`inkling2-exit-v1.txt`) was trained on logs of greedy drafts and the target's verdicts on the | |
| 35-prompt collection at temperatures 0 and 1.0, held out by conversation. In the replay over those logs at temperature | |
| 0 it separates accepted from rejected drafts at an AUC of 0.864. | |
| **The sampled exit** (`inkling2-exit-sampled-v1.txt`) was trained on 72,088 steps of sampled drafts (432,528 | |
| decisions): the oracle collection's 746 requests at temperature 1.0 through Local Coder's launcher, drafts up to 7 | |
| long with no stop, on two R9700s. A sampled token is accepted by rejection sampling with probability min(1, p / q), | |
| where q is the drafter's probability of the token it drew and p the target's (after its sampling filters); the target | |
| computes p at every drafted position in the verify, so every position has that exact label, past the first rejection | |
| too. The model was trained on these soft labels (each row as a 1 with weight a and a 0 with weight 1 β a), so it is | |
| the same kind of model as the greedy exit. On held-out conversations its soft log loss is 0.544 against the greedy | |
| exit's 0.582 on the same sampled drafts. The greedy exit on sampled drafts lost to the plain 0.8 stop live (β0.3% on | |
| the 35 prompts, β1.2% / β2.6% on the everyday requests); the sampled exit beats that stop (+0.7%, +1.2% / +3.4%). | |
| **The 33 inputs** of a decision at drafted position *j* (0-based, *j* β₯ 1), in this order. The drafter's candidates | |
| are the ones its sampler keeps at that position, with their logits; *p* is their softmax. For a sampled draft they | |
| are the draw's top 10 candidates by logit, and the token's kind (9β14) is the drawn token's. | |
| | # | input | | |
| |---|---| | |
| | 0 | the top candidate's *p* | | |
| | 1 | its margin: *p*β β *p*β (0 with one candidate) | | |
| | 2 | the candidates' entropy | | |
| | 3 | the top logit | | |
| | 4 | the logit margin: *l*β β *l*β (10 with one candidate) | | |
| | 5 | the smallest top-1 *p* at positions 0..*j*β1 | | |
| | 6 | the sum of log(max(top-1 *p*, 1e-6)) over positions 0..*j*β1 | | |
| | 7 | the top-1 *p* at position *j*β1 | | |
| | 8 | *j* | | |
| | 9β14 | the drafted token's text: a newline in it, a leading space, a digit, a letter, punctuation (neither alphanumeric nor space; an invalid UTF-8 byte counts as punctuation), its length in characters | | |
| | 15 | the drafts accepted at the request's last step (3 before the first) | | |
| | 16 | their mean over the last 3 steps | | |
| | 17 | their mean over the last 8 steps | | |
| | 18 | their minimum over the last 3 steps | | |
| | 19β22 | the target's confidence: **0 in these versions** (zeroed in training too; given to the exit, it gained nothing in a replay of the logged drafts) | | |
| | 23 | the last draft's first top-1 *p* (0.9 before the first) | | |
| | 24 | inside a code fence: the count of ``` in the committed text is odd | | |
| | 25 | characters since the last newline, at most 200 | | |
| | 26β31 | the kind of the committed text's last 8 characters, as 9β14 (a single space before any text) | | |
| | 32 | 1 if the request samples at a temperature above 0, else 0 | | |
| The committed text is the request's answer after its first token. Each exit's check file has 2,000 rows of these 33 | |
| inputs followed by the model's output: an implementation should match them to about 1e-8 (the fork's evaluator | |
| matches LightGBM to 5e-10 on live decisions). | |
| ## Measured and not kept | |
| - **Longer drafts** (5 / 6 / 7 tokens) with the exit: β0.8 / β2.0 / β4.6% live on the R9700. A verified token past the 4th | |
| costs ~4.7 ms there, more than the extra accepted tokens save, and the drafter computes all its positions however | |
| early the exit stops it (+0.5 ms a step at 7). | |
| - **Three drafts instead of four:** +1.4β1.6% on the 35 prompts, β0.7% / β2.1% on the everyday requests: on long, | |
| predictable prose the fourth token is accepted often enough to pay for its verify. | |
| - **Extending a confident draft** (a second drafter pass of 2 or 3 tokens when the exit keeps a whole draft with | |
| P(all accepted) β₯ 0.85; 4 + 2 and 3 + 3): β0.1 to β3.8% live. Inkling's drafter gives the block's positions after | |
| the anchor learned mask embeddings, so the extra positions are the same guesses a longer block makes. | |
| - **A learned cap** (each step's draft length from the request's history): β1.1% at temperature 0, +1.1β1.3% at 1.0 | |
| with small margins. Not shipped. | |
| - **A learned exit at the first token** (drop the whole draft when its first token looks rejected; held-out AUC | |
| 0.854): +1.2% at temperature 0 and +1.6% at 1.0 on the 35 prompts, but β0.8% at both on 20 everyday-style | |
| requests (code reviews, document summaries). | |
| - **An entry gate** (skip the drafter on steps whose first token would fail, a third to almost half of them): before | |
| the drafter runs, the target's state (its taps of the last token, plus the next token's embedding) separates them at | |
| an AUC of only 0.75, against the drafter's 0.85. Live it lost 3.9β4.7% on the 35 prompts: a step that drafts nothing | |
| still costs 17.6 ms on the R9700 with the drafter loaded (plain decoding ~15.6 ms). | |
| - **Drafting a near-tie's runner-up as a second branch:** a verified token would have to cost 5β7x less than it does. | |