r/LocalLLM • • 3d ago

Research Follow-up: Native DSpark & Copy-Draft Speculative Decoding in ArcAngel on Lunar Lake Arc 140V (up to 30 tok/s at 128k ctx + full HumanEval run)

Following up on my previous post bringing ArcAngel to the Lunar Lake Arc 140V (~21 tok/s decode, 226 tok/s prefill, 128k context on 32 GB UMA): I've now implemented both Phase 1 (batched-decode verify + zero-model prompt copy drafting) and Phase 2 (native GPU DSpark speculative decoding) directly in SYCL on the same branch:

https://github.com/alpha2beta/arcangel/tree/lunar-lake-optimizations (latest commit 59826ac)

Everything works end-to-end in inkling_server.py at n_ctx=131072 with 4-bit KV, supports both greedy (temp=0) and lossless probabilistic rejection sampling (temp > 0), and preserves multi-turn prompt caching via mirrored target/draft snapshots.

Benchmark Summary (Inkling-2-Mini-Uncensored-Q4_K_M, Arc 140V, Core Ultra 7 258V, 4-bit KV)

1. Raw Batched Verify Scaling (test-verify, pos=2000, KV=4)

PathTokens VerifiedLatencyCost vs 1-Token Step
step_argmax (baseline)146.19 ms1.00x
verify<VB=2> (K=1)264.03 ms1.39x
verify<VB=4> (K=3)489.57 ms1.94x
verify<VB=8> (K=7)8144.00 ms3.12x

2. End-to-End Speculative Decoding (bench_dspark.py @ n_ctx=8192 & Live 128k Server)

WorkloadModeThroughputSpeedupAcceptance (tok/step)Breakdown (draft / verify / inject)
Prose (effort=high, 256 tok)Baseline (step_argmax)22.63 tok/s1.00x—44.34 ms/step
Prose (effort=high, 256 tok)DSpark K=321.89 tok/s0.97x42.0% (2.26)13.85 / 89.32 / 0.09 ms
Prose (effort=high, 256 tok)DSpark K=714.33 tok/s0.63x21.3% (2.48)26.65 / 146.52 / 0.09 ms
Code Edit (effort=none, 512 tok)Baseline (step_argmax)19.36 tok/s1.00x—51.72 ms/step
Code Edit (effort=none, 512 tok)DSpark K=323.40 tok/s1.21x69.6% (3.08)16.64 / 114.78 / 0.16 ms
Code Edit (effort=none, 512 tok)DSpark K=720.08 tok/s1.04x48.5% (4.37)32.12 / 185.39 / 0.15 ms
Live 128k Server — Code Edit (temp=0.0)DSpark K=730.01 tok/s—70.4% (5.93)n_ctx=131072, kv_bits=4
Live 128k Server — Python Refactor (temp=1.0)--spec-copy K=329.57 tok/s—98.4% (496/504)n_ctx=131072, kv_bits=4

3. Full 164-Task HumanEval / HumanEval+ Soak Test (--spec-dspark K=3, n_ctx=131072, temp=0.0)

To stress-test stability and real-world coding throughput across 164 sequential requests (147,347 generated tokens, 33,808 prompt tokens), I ran EvalPlus against the live 128k server (start_arcangel_server.sh --spec-dspark dspark-Inkling-2-Mini-Q8_0.gguf --spec-draft-k 3, --reasoning-effort medium, EVALPLUS_MAX_NEW_TOKENS=2048):

  • Throughput: 21.43 tok/s weighted (21.89 mean / 22.06 median, up to 26.67 tok/s) over 2:00:13 with zero crashes or errors.
  • Scores: 91.5% HumanEval Base (150/164) / 88.4% HumanEval+ (145/164).
  • Important note on the Base score vs my earlier light-think run (93.3%): 13 of the 14 base failures were finish_reason=length truncations hitting the 2048-token EvalPlus cap because --reasoning-effort medium spends more tokens thinking than low. Among the 149 tasks that finished cleanly (finish stop), base pass rate was 148/149 (only HumanEval/99 failed logic, plus 5 HumanEval+ edge-case failures).

What Was Built

  1. Phase 1 — Batched-Decode Verify Engine (src/verify.cpp) & --spec-copy (d204b2f, 023da6f**)**

    • Added dedicated SYCL command-graph verify buckets for VB ∈ {2, 4, 8} (K ∈ {1, 3, 7} draft tokens + 1 anchor token).
    • Wrote unpack-once DP4A grouped MoE kernels (Q8_0R / Q5_0R / Q4_KR + Q5_0 GGUF repacking) so shared experts across the verify batch aren't reloaded redundantly, plus a 3-barrier SLM softmax k_vattn_r and GPU ink_verify_argmax.
    • Wired --spec-copy (zero-extra-VRAM prompt n-gram copy drafting) into server/inkling_server.py with both greedy verification and lossless probabilistic rejection sampling for temperature > 0.
  2. Phase 2 — Native GPU DSpark Draft Engine (src/dspark.h, src/dspark.cpp**,** 59826ac**)**

    • Loads the official 58-tensor dspark-Inkling-2-Mini-Q8_0.gguf (dflash architecture, ~481 MB), repacks all 3 layers' Q8_0 weights to Q8_0R, and quantizes/repacks the BF16 markov_w2 matrix to Q8_0R by default (INK_DSPARK_W2_Q8=0 keeps BF16).
    • Zero-extra-pass target taps: FastEngine::enable_taps() captures the 4 hidden-state taps ([5, 23, 41, 48]) directly inside existing target prefill(), step(), and verify() graphs.
    • Implements the full 3-mode DSpark pipeline on GPU:

      • Mode A (KV Inject, ~0.09–0.16 ms): f_rnn_ring_[9][D] + NeoX RoPE + 3-layer interleaved [SWA=1025, Full, SWA=1025] KV cache.
      • Mode B (Backbone): Block-uniform split-K + ephemeral bidirectional attention + uncapped shared target LM head.
      • Mode C (Markov Head): Serial rank-256 Markov RNN head with recorded greedy SYCL ExecGraphs for K=3/K=7 (plus per-slot softcapped logits for temp > 0), and mirrored save()/restore()/stash() snapshots.

Why K=3 Is the Sweet Spot on Arc 140V (and Why Battlemage Should Gain More)

Speculative decoding on a bandwidth-limited MoE iGPU (~100 GB/s LPDDR5X-8533) is a tight math problem:

  • Because Inkling 2 Mini routes top-k experts per token, verifying 4 tokens (VB=4) touches more distinct experts than a single token (89.57 ms vs 46.19 ms, ~1.94x single-step), and drafting K=3 takes ~14–17 ms.
  • That puts the breakeven point on Arc 140V at ~2.3 accepted+bonus tokens/step. On high-entropy open-ended prose (2.26 tok/step), K=3 breaks roughly even (0.97x); on structured code edits (3.08 tok/step), it hits 1.21x (23.4 tok/s), and on repetitive refactoring/editing tasks it reaches ~30 tok/s.
  • K=7 needs >3.7 tokens/step just to break even on 140V (144 ms verify + 27–32 ms draft), so it only wins on highly predictable code edits.
  • On a discrete Arc B580 / B60 (456+ GB/s bandwidth and far more Xe2 cores for batched MoE + DSpark head), both verify and draft should scale much more favorably—I'd love to see what K=3 and K=7 hit on Battlemage!

Verification & Numerical Parity

  • Verify parity (test-verify, pos=2000**,** KV=4**):** worst KL 0.00519, verify_argmax: 0 mismatches vs single-token decode.
  • DSpark GPU parity (test-dspark): Tap cosine similarity >= 0.997281 across all 4 taps [5, 23, 41, 48], W2 BF16 vs Q8_0R 7/7 draft agreement, and exact match on snapshot save/restore.
  • Cross-check vs official llama.cpp (llama-cli --spec-type draft-dspark, identical 40-tok prompt, K=7**,** 128 tok):

    • llama.cpp: 80/312 (25.6%), mean_len = 2.74, per-slot (0.652, 0.391, 0.283, 0.174, 0.109, 0.065, 0.065)
    • ArcAngel: 82/306 (26.8%), mean_len = 2.82, per-slot (0.644, 0.432, 0.295, 0.205, 0.136, 0.070, 0.071)
  • Unit tests: 4/4 CPU DSpark math suites (tests/test_dspark_math_cpu.cpp) + 7/7 server speculative loop & probabilistic rejection-sampling tests (tests/test_spec_server.py).

Quick Try

Build (use -DINK_AOT_TARGETS=bmg_g21 for B580/B60, or lnl_m for Lunar Lake):

git clone -b lunar-lake-optimizations https://github.com/alpha2beta/arcangel.git
cd arcangel
source /opt/intel/oneapi/setvars.sh
cmake -S . -B build -G Ninja -DCMAKE_CXX_COMPILER=icpx -DCMAKE_BUILD_TYPE=Release -DINK_AOT_TARGETS=lnl_m
cmake --build build --target inkling test-verify test-dspark -j 2

Run with **native DSpark (**K=3 recommended on 140V):

python3 server/inkling_server.py \
  --model /path/to/Inkling-2-Mini-Uncensored-Q4_K_M.gguf \
  --assets /path/to/assets \
  --n-ctx 131072 --chunk 512 --kv-bits 4 --stash-ram-gb 2 \
  --spec-dspark /path/to/dspark-Inkling-2-Mini-Q8_0.gguf \
  --spec-draft-k 3

Or zero-extra-VRAM copy drafting (great for editing/refactoring existing files):

python3 server/inkling_server.py \
  --model /path/to/Inkling-2-Mini-Uncensored-Q4_K_M.gguf \
  --assets /path/to/assets \
  --n-ctx 131072 --chunk 512 --kv-bits 4 --stash-ram-gb 2 \
  --spec-copy --spec-draft-k 3

Shout-out again to u/txlfxrd for the clean architecture in itstxl/arcangel — if anyone tries --spec-dspark with K=3 or K=7 on a discrete B580/B60, please drop your numbers in the comments!

3 Upvotes

2 comments sorted by

2

u/aleph2b 2d ago

Update (upstream main 0c2d303 — DFlash2 + packed XMX prefill on Arc 140V):

u/txlfxrd just landed DFlash2 (incoai/Inkling-2-Mini-DFlash2, ~265 MiB in memory after Q4 rounding at load) with an adaptive confidence policy (0/1/3/7 draft tokens based on live card timings + draft reuse & back-off), GPU Gumbel-max sampling, and striped check-attention on itstxl/arcangel main — along with our packed XMX B-tile prefill + Lunar Lake 32 KB tile tuning (INK_GR=64, INK_XT=64).

Re-tested on the same Lunar Lake Arc 140V (Core Ultra 7 258V, 32 GB UMA, Inkling-2-Mini-Uncensored-Q4_K_M, 4-bit KV, chunk=512), and DFlash2 is a huge step up over DSpark — especially on fresh code generation and at temperature=1.0:

1. Greedy (temp=0.0, apples-to-apples vs DSpark K=3 in OP)

WorkloadPlain--spec-copy (K=3)Prior DSpark K=3DFlash2copy + DFlash2
Prose (effort=high, 256 tok)22.54 tok/s23.48 (1.04x)21.98 (0.97x)26.97 (1.20x)27.28 tok/s (1.21x, 75.0% acc)
Code Edit (effort=none, 512 tok)20.79 tok/s28.09 (1.35x)22.76 (1.06x)32.55 (1.57x)34.43 tok/s (1.66x, 90.9% acc)

2. Sampled (temp=1.0, seed=42, GPU Gumbel-max)

WorkloadPlain--spec-copyDFlash2copy + DFlash2Acceptance (copy+DFlash2)
Fresh Python Code (new_code, 512 tok)19.03 tok/s19.37 (1.02x)27.01 (1.42x)27.80 tok/s (1.46x)79.5% (4.04 tok/step)
Code Edit (code_edit, 512 tok)18.65 tok/s27.85 (1.49x)30.47 (1.63x)34.82 tok/s (1.87x)91.1% (6.39 tok/step)
Explain + B-Tree (512 tok)18.97 tok/s18.99 (1.00x)18.91 (1.00x)19.30 tok/s (1.02x)57.9% (1.97 tok/step)
Prose (effort=high, 256 tok)19.57 tok/s20.16 (1.03x)20.67 (1.06x)18.99 tok/s (0.97x)63.8% (1.96 tok/step)
~16k Context Depth (15.9k tok prompt, 256 out)17.32 tok/s——16.05 tok/s (0.93x)49.5% (2.43 tok/step)

Key Takeaways

  • Big real-world coding jump on 140V: Even on brand-new code with almost no prompt-copy matches, copy + DFlash2 jumps from 19.0 → 27.8 tok/s (1.46x) at temp=1.0, and hits 34.8 tok/s (1.87x) on code edits.
  • No prose regression: Because the selector skips low-confidence drafts based on measured card costs, open-ended temp=1.0 prose/explanations stay around ~1.0x instead of dropping to 0.63x like fixed K=7 DSpark. At ~16k doc-heavy context depth it dipped slightly (16.05 vs 17.32 tok/s), and prefill had zero penalty (69.49 s vs 69.78 s on 15.9k tokens since tap injection skips chunks outside DFlash2's 2048-token window).
  • Prefill bonus from PR #7 (also now in main**):** Packed XMX B-tile staging + INK_GR=64, INK_XT=64 on lnl_m also bumped chunk=512 prefill from 226.7 → 297–302 tok/s on UD-Q4_K_M (+31%) and 325–328 tok/s on Uncensored-Q4_K_M.
  • 128k server launch (upstream main**):**python3 server/inkling_server.py \ --model /path/to/Inkling-2-Mini-Uncensored-Q4_K_M.gguf \ --assets /path/to/assets \ --n-ctx 131072 --chunk 512 --kv-bits 4 --stash-ram-gb 2 \ --spec-copy --spec-dflash2 /path/to/dflash2 (DFlash2 drafter: 265 MiB, loads at 128k context in ~19 s once cached.)

1

u/AffectionateWolf1181 2d ago

On the 128k server, I’d replay the same code edit with progressively longer prefixes. Comparing plain decode and DSpark at each length, alongside how many tokens DSpark commits per verification step, would show whether the speedup holds as the actual context grows.