Skip to content

[Engine] feat: Implement Dflash2 for Inkling 2 Mini #339

Backlog

Description

@drakarah

https://huggingface.co/incoai/Inkling-2-Mini-DFlash2

From my own implementation in my edge-llm fork on an AGX Orin:

  • Hybrid decode on the 36 prompts:
    Drafter, K Decode tok/s Tokens per round
    DFlash2, K=3 39.57 3.21
    DFlash2, K=4 39.27 3.53
    DSpark, K=3 36.75 2.86
    Plain 25.99 1
  • That is +7.7% over DSpark at K=3 and +52% over plain.
  • A DFlash2 call costs about 2 ms more than DSpark's, at about 15 ms.

Edit: after optimizing the draft kernel work with K=4 --> 44.35tok/s

Hardware: AGX Orin 32GB unified memory, linux (jetpack 7.2).

Activity

  1. github-actions commented on Nov 25, 2026

    @github-actions

    Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

    • Add your graphics card with its VRAM, your RAM and your operating system.

    Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

    Details: CONTRIBUTING.md

  2. added
    needs-format
    and removed
    needs-format
    on Nov 25, 2026
  3. github-actions commented on Nov 25, 2026

    @github-actions

    Thanks, this follows the format now.

  4. VecSzn commented on Nov 25, 2026

    @VecSzn
    Collaborator

    Interesting numbers comparing DFlash2 against DSpark on Orin. Right now Inkling 2 Mini uses DSpark (--draft-model, enabled by default on Macs and full-VRAM NVIDIA cards in \�0.2.20-poly.5), and a PR is welcome if you want to contribute DFlash2 support.

  5. drakarah commented on Nov 25, 2026

    @drakarah
    ContributorAuthor

    I could but I can't test it properly, the discrete GPUs I have available only have 8gb vram and any drafter would slow it down due to having to fetch experts from ram, so making a proper performance comparison is going to be hard and skewed.

    So I could ask Claude to port drakarah/TensorRT-Edge-LLM@c18ec8c but I have no way of verifying.

    Hopefully someone else that can already run the dspark drafter can pick it up to make a fair comparison.

  6. cobra91 commented on Nov 26, 2026

    @cobra91
    Contributor

    Happy to help test and run fair A/B benchmarks (DFlash2 vs DSpark on v0.2.20-poly.5) whenever a branch or PR is ready!

    We have a Windows 11 test rig with an RTX 5080 16 GB (sm_120, where Inkling-2-Mini-UD-IQ3_XXS + DSpark fits 100% in VRAM at 237.99 tok/s on a 302-token prompt / 363.26 tok/s on a 16-token prompt) plus an RTX 4060 Ti 16 GB (sm_89, where UD-Q4_K_XL + DSpark runs 100% in VRAM via --layer-split 18 with #315). Ping me when you have a branch to benchmark.

  7. drakarah commented on Nov 26, 2026

    @drakarah
    ContributorAuthor

    Happy to help test and run fair A/B benchmarks (DFlash2 vs DSpark on v0.2.20-poly.5) whenever a branch or PR is ready!

    We have a Windows 11 test rig with an RTX 5080 16 GB (sm_120, where Inkling-2-Mini-UD-IQ3_XXS + DSpark fits 100% in VRAM at 237.99 tok/s on a 302-token prompt / 363.26 tok/s on a 16-token prompt) plus an RTX 4060 Ti 16 GB (sm_89, where UD-Q4_K_XL + DSpark runs 100% in VRAM via --layer-split 18 with #315). Ping me when you have a branch to benchmark.

    @cobra91 #358 It built on RTX4060 8GB here and forcing the drafter to work on 8GB made it run. I have no idea how it will perform compared to DSpark

    Instructions from Claude:

    1. Get the code and build

    git clone https://github.com/drakarah/PolyStrata
    cd PolyStrata
    git checkout feat/inkling2-dflash2 # commit 015a56c or later
    cd engine

    Build only the engine target. The full build also compiles test targets, and pinned_shared_test has a link error on this branch. That error hasn't been
    confirmed as pre-existing.

    • NVIDIA: cmake --preset cuda-compile -S . -B build -G Ninja && cmake --build build --target strata-poly
    • AMD: cmake --preset hip-compile -S . -B build -G Ninja && cmake --build build --target strata-poly

    Report whether the build succeeded, the backend, and the GPU. The HIP build hasn't been re-checked since the last changes, so a HIP build failure is
    useful information.

    1. Convert the DFlash2 drafter

    You need:

    • incoai/Inkling-2-Mini-DFlash2 from Hugging Face (config.json and model.safetensors)
    • The config of the target, thinkingmachines/Inkling-2-Mini (config.json only; no weights needed)
    python engine/third_party/strata-gguf-py/converter/convert_hf_to_gguf.py \
     <dir with incoai config.json + model.safetensors> \
     --target-model-dir <dir with thinkingmachines config.json> \
     --outtype bf16 \
     --outfile Inkling-2-Mini-DFlash2.gguf  
    

    Expected: about 81 tensors, about 990 MB, and a warning that the drafter writes no vocabulary. That warning is normal. The engine takes the tokenizer from the target file. Keep the log.

    1. Get the DSpark drafter for the comparison

    Use the DSpark file for the same Inkling 2 Mini target that your build's setup uses, for example dspark-Inkling-2-Mini-Q8_0.gguf. Record its exact file name and hash.

    1. Run each drafter with the same prompt

    Use the same target GGUF for both runs. Run each configuration three times and take the median. Change only the draft file and the window size.

    baseline: no drafter
    strata-poly --model <Inkling target>.gguf --tokens <ids> --max-new 256 --no-draft --window 4

    DFlash2, K=4 (4-token window, drafter guesses 3)
    strata-poly --model <Inkling target>.gguf --tokens <ids> --max-new 256 \ --draft-model Inkling-2-Mini-DFlash2.gguf --window 4

    DSpark, K=4
    strata-poly --model <Inkling target>.gguf --tokens <ids> --max-new 256 \ --draft-model <dspark file>.gguf --window 4

    Also run K=3 (--window 3) for both drafters, to match the issue's fork numbers. --window N means the drafter guesses N−1 tokens per round.

  8. cobra91 commented on Nov 26, 2026

    @cobra91
    Contributor

    @drakarah Here are the A/B benchmark results on our Windows 11 test rig (ecdfa5b21 on feat/inkling2-dflash2), following your protocol.

    1. Environment & Build

    • Commit: ecdfa5b21 (drakarah/PolyStrata, feat/inkling2-dflash2)
    • Backend / GPU: CUDA 13.4 (-DCMAKE_CUDA_ARCHITECTURES="89;120"), Ninja Release (--preset cuda-compile), built target strata-poly ([120/120] strata-poly.exe succeeded cleanly)
    • Active GPU: NVIDIA GeForce RTX 5080 16 GB (sm_120, Windows 11, 100.0% experts in VRAM)

    2. GGUF Conversion & Hashes

    • convert_hf_to_gguf.py (--outtype bf16) on incoai/Inkling-2-Mini-DFlash2 + thinkingmachines/Inkling-2-Mini/config.json:
      • n_tensors = 81, total_size = 990.2M (Inkling-2-Mini-DFlash2.gguf)
      • Expected warning observed: WARNING:hf-to-gguf:DFlash: no tokenizer handler for Inkling2LoopForConditionalGeneration; the drafter writes no vocabulary
    Role Filename SHA256
    Target Inkling-2-Mini-UD-IQ3_XXS.gguf BD7EF0865ADF119B5183E45E741C629BAFA649769B33B5EBF689BB4BCC4690D6
    DFlash2 Inkling-2-Mini-DFlash2.gguf B8723CC8FB58BEB16F8444EAE1CF3A38CEFA54F1CBF05B05DB1DD44A7D32E996
    DSpark dspark-Inkling-2-Mini-Q8_0.gguf 2EC78510DA837E8FC3BE54A14757A0C5FBD2D8D9E85A0D92853FAFDF674F3773

    3. A/B Benchmarks (302-token prompt, --max-new 256 --kv fp8 --max-context 32768, 3 runs -> median)

    Configuration Run 1 / 2 / 3 Decode (tok/s) Median Decode Median Prefill Accepted / Guessed
    Baseline (--no-draft --window 4) 215.47 / 215.81 / 215.90 215.81 tok/s 981.1 tok/s 122 / 184 (66.3%)*
    DFlash2 K=4 (--window 4) 205.46 / 205.55 / 205.37 205.46 tok/s 803.2 tok/s 144 / 195 (73.8%)
    DSpark K=4 (--window 4) 266.77 / 267.28 / 267.61 267.28 tok/s 1435.6 tok/s 180 / 212 (84.9%)
    DFlash2 K=3 (--window 3) 200.92 / 200.89 / 184.54 200.89 tok/s 798.4 tok/s 143 / 179 (79.9%)
    DSpark K=3 (--window 3) 247.56 / 250.37 / 250.23 250.23 tok/s 1423.1 tok/s 160 / 180 (88.9%)

    *Note: --no-draft --window 4 on Inkling-2-Mini-UD-IQ3_XXS.gguf still reported 122 of 184 guessed tokens right (built-in / STRATA_BLOCK_GUESS path).

    Takeaways on RTX 5080

    • Both K=4 (267.28 vs 205.46 tok/s, +30.1%) and K=3 (250.23 vs 200.89 tok/s, +24.6%) are currently significantly faster with DSpark Q8_0 than with DFlash2 BF16, both in acceptance rate (84.9% vs 73.8% at K=4; 88.9% vs 79.9% at K=3) and in drafter/prefill overhead (1435.6 vs 803.2 tok/s prompt).
    • Happy to re-test if you push further optimizations or quantized DFlash2 support!
  9. cobra91 commented on Nov 26, 2026

    @cobra91
    Contributor

    @drakarah Follow-up A/B run (K=4, --window 4) on our RTX 4060 Ti 16 GB (sm_89, CUDA_VISIBLE_DEVICES=1, same binary ecdfa5b21, Inkling-2-Mini-UD-IQ3_XXS.gguf, 302-token prompt, --max-new 256 --kv fp8 --max-context 32768, 100.0% VRAM, 3 runs -> median):

    Configuration (RTX 4060 Ti) Run 1 / 2 / 3 Decode (tok/s) Median Decode Median Prefill Accepted / Guessed
    Baseline (--no-draft --window 4) 98.92 / 98.81 / 98.99 98.92 tok/s 719.1 tok/s 132 / 188 (70.2%)
    DFlash2 K=4 (--window 4) 87.43 / 87.44 / 87.43 87.43 tok/s 507.8 tok/s 175 / 220 (79.5%)
    DSpark K=4 (--window 4) 125.99 / 126.04 / 126.02 126.02 tok/s 821.9 tok/s 181 / 210 (86.2%)

    On sm_89 (288 GB/s), DFlash2 BF16 (990 MiB) achieves a higher acceptance rate (79.5%) than on sm_120 (73.8%), while DSpark Q8_0 remains +44.1% faster (126.02 vs 87.43 tok/s) due to lower drafter/prefill bandwidth cost.

  10. drakarah commented on Nov 27, 2026

    @drakarah
    ContributorAuthor

    I'll try to optimize, but i'm optimizing blindly.

    Llama.cpp also has a PR for Dflash2 ggml-org/llama.cpp#33049 saying it's faster so it should be possible, if comparing apples to apples (as in Q8 to Q8). I'll see what Claude can cook up

  11. drakarah commented on Nov 27, 2026

    @drakarah
    ContributorAuthor

    @cobra91 Claude optimized and implemented Q8 support

    Claude response:

    What I found

    On my card (RTX 4060, 8 GB, with the drafter forced on for the test), the BF16 drafter spent about 14.8 ms of GPU time per round. 85% of that was one slow generic BF16 matvec kernel (gemv_rows_kernel<unsigned short>). The BF16 file's prefill overhead came from the same kernel.

    What changed

    Branch feat/inkling2-dflash2, commit dc5468a08 or later, merged with the latest simplex/main.

    1. Q8_0 drafter. Same converter, --outtype q8_0. The two selector codebooks stay BF16, so the file is 623 MB.
      • Drafter time per round: 14.8 ms → 3.8 ms.
      • Extra prefill time over a 300-token prompt: about 320 ms → about 3 ms.
    2. Screened head. The head (the drafter's product with the target's output matrix, 469 MiB on Inkling 2 Mini) now scores every token from 2-bit copies and rescores the best 96 rows exactly, the same idea as DSpark's.
      • On by default when the output matrix is Q8_0 and every expert is in VRAM. STRATA_DS2_SCREEN=0 turns it off, =1 turns it on for a card that doesn't hold every expert.
      • Head time: 1.96 ms → 0.67 ms. A round is about 2.5 ms now.
    3. Top-16 selection split across blocks: 193 µs → 46 µs per round.
    Drafter GPU time per round (RTX 4060)
    BF16 file 14.8 ms
    Q8_0 file 3.8 ms
    Q8_0 file + screened head 2.5 ms

    What I checked

    About 360 rows over two real prompts, 256 tokens, screened head against the exact head:

    • The exact top candidate matched every time.
    • 96–98% of the exact top-16 were found.
    • Exact scores agreed to 1e-5.
    • Accepted guesses did not drop.

    What I did not measure

    • Tokens per second against DSpark on a card that holds every expert. That's the number I need from you.
    • Output equality with the undrafted run: two identical undrafted runs on my card already differ after 22–67 tokens, so I couldn't test it there.
    • HIP and SYCL builds, and DSpark regression.

    What I'd like you to run

    Same 302-token prompt, --max-new 256, --kv fp8, 3 runs, median.

    1. Convert the drafter:
      python engine/third_party/strata-gguf-py/converter/convert_hf_to_gguf.py <incoai drafter folder> \
        --target-model-dir <Inkling 2 Mini folder, config.json is enough> \
        --outtype q8_0 --outfile Inkling-2-Mini-DFlash2-Q8_0.gguf
      
      Expect about 623 MB and a warning that the drafter writes no vocabulary. That warning is normal.
    2. Run K=3 and K=4 (--window 3 and --window 4) with the Q8_0 DFlash2 file, and with DSpark, on the same build.
    3. Also try --window 5 and --window 6. The drafter is cheap enough now that a larger window may pay off.
    4. For one run, set STRATA_DS2_SCREEN=0 to see the head's effect.
    5. Please share the experts in VRAM line. The screen adds about 144 MB, which could push the last experts out on a tight card.

    For each run please report: decode tok/s, prefill tok/s, accepted/guessed, and the experts in VRAM line.

  12. cobra91 commented on Nov 27, 2026

    @cobra91
    Contributor

    Empirical benchmark on commit dc5468a08 (drakarah/feat/inkling2-dflash2) with Inkling-2-Mini-DFlash2-Q8_0.gguf (622.8 MB, converted with --outtype q8_0) on Windows 11:

    • Hardware: Mono RTX 5080 16 GB (CUDA_VISIBLE_DEVICES=0, sm_120)
    • Target model: Inkling-2-Mini-UD-IQ3_XXS.gguf (10.86 GiB, 3072/3072 experts in VRAM = 9.6 GiB, 100% VRAM)
    • Protocol: median of 3 runs, synthetic 302-token --tokens prompt, --max-new 256, --kv fp8, --max-context 32768
    Drafter --window STRATA_DS2_SCREEN Decode (tok/s) Prefill (tok/s) Accepted / Guessed Experts in VRAM
    DFlash2 Q8_0 3 1 (default) 304.42 1208.3 169 / 170 (99.4%) 3072/3072 (9.6 GiB)
    DFlash2 Q8_0 4 1 (default) 341.59 1247.0 190 / 191 (99.5%) 3072/3072 (9.6 GiB)
    DFlash2 Q8_0 5 1 (default) 361.32 1235.9 202 / 205 (98.5%) 3072/3072 (9.6 GiB)
    DFlash2 Q8_0 6 1 (default) 371.62 1237.3 207 / 210 (98.6%) 3072/3072 (9.6 GiB)
    DSpark Q8_0 3 — 308.40 1655.0 169 / 170 (99.4%) 3072/3072 (9.6 GiB)
    DSpark Q8_0 4 — 343.92 1668.5 190 / 191 (99.5%) 3072/3072 (9.6 GiB)
    DFlash2 Q8_0 4 0 341.96 1248.8 190 / 191 (99.5%) 3072/3072 (9.6 GiB)

    Notes:

    • On this repetitive synthetic prompt (99.5% accept), DFlash2 Q8_0 (341.59 tok/s at w=4) virtually matches DSpark Q8_0 (343.92 tok/s) and scales up to 371.62 tok/s at --window 6.
    • STRATA_DS2_SCREEN=0 (341.96 tok/s) vs default 1 (341.59 tok/s) shows parity at w=4 on RTX 5080, while DSpark keeps higher prefill (1668.5 vs 1247.0 tok/s).
  13. cobra91 commented on Nov 27, 2026

    @cobra91
    Contributor

    Follow-up on dc5468a08 with --window 7, 8 on RTX 5080 and the full RTX 4060 Ti 16 GB (sm_89) matrix (same protocol: median of 3 runs, synthetic 302-token --tokens prompt, --max-new 256, --kv fp8, 3072/3072 experts in VRAM = 9.6 GiB):

    RTX 5080 (--window 7, 8 extension)

    Drafter --window Decode (tok/s) Prefill (tok/s) Accepted / Guessed
    DFlash2 Q8_0 7 339.31 1168.7 213 / 213 (100.0%)
    DFlash2 Q8_0 8 350.26 1219.2 218 / 222 (98.2%)

    RTX 4060 Ti 16 GB (CUDA_VISIBLE_DEVICES=1, sm_89)

    Drafter --window Decode (tok/s) Prefill (tok/s) Accepted / Guessed
    DFlash2 Q8_0 3 134.88 790.8 169 / 170 (99.4%)
    DFlash2 Q8_0 4 157.48 793.5 190 / 191 (99.5%)
    DFlash2 Q8_0 5 169.41 791.8 202 / 205 (98.5%)
    DFlash2 Q8_0 6 170.30 789.0 203 / 206 (98.5%)
    DFlash2 Q8_0 7 184.65 796.1 212 / 215 (98.6%)
    DFlash2 Q8_0 8 191.19 789.7 217 / 220 (98.6%)
    DSpark Q8_0 3 135.93 889.6 169 / 170 (99.4%)
    DSpark Q8_0 4 158.75 887.8 190 / 191 (99.5%)

    On RTX 4060 Ti 16 GB, DFlash2 Q8_0 scales all the way to --window 8 (191.19 tok/s, +21% over w=4), whereas RTX 5080 peaks at --window 6 (371.62 tok/s).

  14. drakarah commented on Nov 27, 2026

    @drakarah
    ContributorAuthor

    @cobra91 forwarding Claude's reply:

    Thanks for the full matrix on the 5080 and the 4060 Ti. This reply covers both rounds, plus two commits I've pushed since.

    What the numbers say

    • At --window 3 and 4, Q8_0 DFlash2 is within about 1% of DSpark on decode on both cards (4060 Ti: 134.9 vs 135.9 and 157.5 vs 158.8 tok/s; 5080: 304.4 vs 308.4 and 341.6 vs 343.9).
    • STRATA_DS2_SCREEN makes no difference on the 5080 (341.6 vs 342.0), so the screened head doesn't matter on a card with that much bandwidth.
    • DFlash2 keeps gaining to --window 8 on the 4060 Ti (191.2 tok/s) but peaks at --window 6 on the 5080 (371.6), then drops at 7 and 8 (339.3, 350.3).

    Two caveats before anyone draws conclusions

    1. The accepted/guessed counts are identical for DFlash2 and DSpark (169/170 at --window 3, 190/191 at --window 4). That means prompt lookup (--lookup, default 3) is making the guesses on the repetitive synthetic prompt, so this table can't tell the two drafters apart, and decode speed is mostly set by the target model. The no-drafter baseline you posted earlier already accepts 70% (132/188) for the same reason.
    2. DSpark wasn't run above --window 4, so we don't know whether the scaling, or the drop at 7 and 8 on the 5080, is DFlash2-specific.

    Commits since dc5468a08 (branch feat/inkling2-dflash2)

    • 1a5ec9193: ds_commit2 read the drafter's feature taps with the wrong row stride. It only matters on a card that does not hold every expert (the engine then keeps two scratch layouts), so it shouldn't have affected your runs, where all 3072 experts are in VRAM. On my RTX 4060 8 GB, with the drafter forced on and --lookup 0, drafter-only acceptance went from 113/220 to 155/178 on a code prompt and from 40/121 to 115/165 on prose. The old code also wrote past a buffer on every decode step.
    • a61959b08: review fixes. A key/value ring that a very large --prompt-batch (over 2,112 tokens) could overrun, an out-of-range guard in the selector, and stricter checks on the drafter file (tap ids, softcap mode). No change expected on your cards, and existing Q8_0 files still load, so there's no need to reconvert.

    The prefill gap (still open)

    Your DFlash2 prefill is 793 vs 888 tok/s on the 4060 Ti (about 41 ms on 302 tokens) and 1247 vs 1668 on the 5080 (about 61 ms). It's bigger on the faster card, which points to a fixed cold-start cost, not compute. On my card the Q8_0 drafter adds only about 6 ms of GPU kernels to a 2,048-token prefill, and forcing eager CUDA module loading cut its prefill gap from 106 ms to 65 ms. That is one comparison of 5 runs each, so a lead only.

    What would settle it (same build, 3 runs each, median):

    1. Cold-start test: set CUDA_MODULE_LOADING=EAGER (Windows) before running, and compare DFlash2 Q8_0 vs DSpark prefill at --window 4 again. Or, if you can run the server, send the same prompt twice and compare the second request's prefill.
    2. Realistic prompt with lookup off: tokenize ~300 tokens of real code and ~300 of prose with the target's tokenizer.json:
      from tokenizers import Tokenizer
      t = Tokenizer.from_file("tokenizer.json")
      print(",".join(map(str, t.encode(open("prompt.txt").read()).ids[:302])))
      Pass the printed ids to --tokens and add --lookup 0, so every guess is the drafter's own.
    3. Matching rows with --lookup 0: a no-drafter baseline (--no-draft --window 4 --lookup 0), DSpark at --window 4 to 8, and DFlash2 Q8_0 at the same windows.
    4. Only if the cold-start test doesn't explain it: one nsys profile of the DFlash2 prefill:
      nsys profile --stats=true -o dflash2_prefill strata-poly ... --draft-model <Q8_0 file> --window 4 --max-new 1
      with the top 15 rows of cuda_gpu_kern_sum and the top 10 of cuda_api_sum.
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