Repository navigation
feat(inkling): DSpark speculative decoding with a cost-aware draft depth (#650 P2a) - #728
Merged
Merged
Conversation
… conv states, tap features, folded Markov head (#650 P2a) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012cicguZMN3jhNGmf5327oh
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012cicguZMN3jhNGmf5327oh
…t drafts through DSpark (#650 P2a) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012cicguZMN3jhNGmf5327oh
…s per verify cost; cached second turn drafts too (#650 P2a) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012cicguZMN3jhNGmf5327oh
…he depth policy picks within it (#650 P2a) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012cicguZMN3jhNGmf5327oh
goodmai
force-pushed
the
feat/inkling-dspark
branch
from
November 23, 2026 09:24
6a942bc to
5eb43ad
Compare
This was referenced Nov 23, 2026
goodmai
added a commit
that referenced
this pull request
Nov 23, 2026
…g safety, DSpark config guards, compiled 1-row rewind, HF-aligned YaRN factor (#750) * fix(rope,inkling): staging follows its source's file set and sweeps abandoned temporaries; MTP drafter from the staged config; DSpark block_size within the conv rewind, strictly increasing taps, null mtp_config; compiled 1-row steps keep conv windows; chunked drafter prefill (review) * chore(fork): pin e9feb1e — HF-aligned YaRN attention factor, exact-trim precondition; test the attention-factor rules (review)
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#650 P2a: speculative decoding for Inkling 2 with the DSpark drafter that ships in the checkpoint's
mtp.safetensors(0.32B, block of 8).--mtpnow drafts on Inkling 2 Mini.Fork (
goodmai/mlx-swift-lm, branchbasalt-650-dspark, pin 70d0190 → seePackage.swift):ConvolutionStatesCache, ported from upstream Add Inkling 2 Mini and Small ml-explore/mlx-swift-lm#821: short-conv states that rewind inside their last write. It stays snapshot-only for prompt caches (isTrimmableisfalse); only a speculative round, which asksisTrimmable(after:), rewinds it.AppendOnlyRoundStrategy) instead of refusing it.MTPDraftDepthPolicy: a drafter that proposes its whole block in one call setsdraftWidthCost, and each round verifies the depth with the most expected tokens per unit of verify cost. It keeps a decaying acceptance estimate per draft position, so it drafts deep on code and shallow on prose.nilkeeps the chained rule Qwen and Nemotron use.basalt:
Inkling2DSparkDraftModel: the upstream DSpark port, against ourStatefulMTPDrafterModelAPI. Its Markov head is folded into the target'slm_headat load, dequantizing a quantized head.Inkling2Modelemits the drafter's features under the MTP flag: the residual entering visits 5/23/41 and the final hidden state (mtp_config.target_layer_ids). Long prompts are prefilled in 512-token chunks, and only the last row's logits are computed.Inkling2WindowKVCachekeeps the round's rows past its window, so a rejected suffix trims back exactly. Conv states useConvolutionStatesCache..mtpadded to the Inkling 2 capability row. Without it, the plan dropped--mtpfor Inkling 2 even with the drafter loaded.--mtp-blockdefaults to a block drafter's own block (8 for DSpark). Qwen and Nemotron keep 4.Measured
Inkling-2-Mini-oQ3e-mtp on an Apple M4 Pro with 24 GB, release build, GPU lock, CI idle. Commit f8b07b9 (identical code to this head for these runs; the head only changes the
--mtp-blockdefault). 256 tokens, decode tok/s. Log:logs/dspark_bench-2026-11-23T071050Z.log.--mtp-block 4--mtp-block 8(new default)--mtpfalls back, same output--mtpis now even with plain decoding (−0.8% at T = 0.7).mtpPromptLimit), and a prompt cache restored from disk. That cache comes back as a plainArraysCache, cannot stage a round, and decodes without drafts (logged once).Parity (#228)
InklingDSparkTestsruns oninkling2Loop, with a window of 8, 10 visits and conv states:SuccessorDrafter) and random-init DSpark drafts both give the plain decoder's tokens, greedy and seeded at T = 0.7;Tests
InklingDSparkTests(9 tests). It covers the rewind parity above, conv-state trimming, tap features and chunked prefill, the sidecar load and head fold, DSpark parity, engine parity, cached second-turn parity, and the depth policy.InklingDSparkTests|MTP|ServeConfigFile|Nemotron: 76 tests in 18 suites pass.Inkling|PromptCache|Hybrid|Batched|KVCache: pass.swift test --parallelon this Mac: another session's CI run started mid-run. That gave time-limit failures in the compose/on-demand suites and a NIO writer crash.FeatureMatrixTestsandPreemptibleTrainingTestspass alone. CI on this PR is the full run.check_no_new_commentsandcheck_size_limits --impact: clean.Part of #650.
🤖 Generated with Claude Code
https://claude.ai/code/session_012cicguZMN3jhNGmf5327oh