Skip to content

feat(inkling2): DFlash2 speculative decoding, M<=16 verify tree, M5 Max fusions, and App co-download - #403

Merged
Brooooooklyn merged 4 commits into
mainfrom
feat/inkling2-dflash2-perf
Nov 24, 2026
Merged

Brooooooklyn merged 4 commits into
mainfrom
feat/inkling2-dflash2-perf

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Contributor

Summary

Brings Splash-class 200+ tok/s decode performance to Inkling-2-Mini on Apple M5 Max 128 GB out of the box (zero custom env vars), adds full DFlash2 (incoai/Inkling-2-Mini-DFlash2) speculative decoding + M <= 16 Verify Tree / SAM Lookup support across both GGUF (UD-Q4_K_M / UD-Q4_K_XL) and Original SafeTensors (NVFP4 + MXFP8 + BF16), and wires automatic companion co-download in the App and CLI wizard.

flowchart LR
    A["Inkling-2-Mini Load"] --> B{"DFlash2 Companion?<br/>(&lt;modelDir&gt;/draft/ or autoDraftModelPath<br/>or inkling-2-mini-dflash2/)"}
    B -- Yes --> C["DFlash2 5L Draft + M<=16 Verify Tree & SAM<br/>(zero-sync 1D chain + adaptive SAM tree)"]
    B -- No / Corrupt Auto --> D{"Bundled DSpark?<br/>(mtp.safetensors / dspark-*.gguf)"}
    D -- Yes --> E["DSpark Fallback (~3.1 tok/cyc)"]
    D -- No --> F["Pure AR Fallback"]
Loading

Key Changes

  1. DFlash2 Core & Inkling-2-Mini Speculative Decoding

    • Added post-edge softcap (final_logit_softcapping = 30.0, selector_softcap_mode = "after_correction") to Metal/CUDA mlx_dflash2_selector_edges, active-vs-codebook vocab split (200058 vs 201024), final-norm tap capture (layer 48), optional mask_embedding.safetensors, compiled embedded draft path, and fixed ctx >= 2048 ring-wrap contract (> 2056) in mlx_dflash2_attention.cpp.
    • Added crates/mlx-core/src/models/inkling2/dflash2.rs (Inkling2TargetView, Inkling2Dflash2Context, Inkling2VerifyTreeMode::Auto adaptive zero-sync 1D chain / M = 8..16 SAM Verify Tree routing) and wired it through whole-turn and scheduled lanes, execution_plan(), and resolve_params().
    • Added autoDraftModelPath (auto_draft_model_path) soft-fallback external companion hint so corrupt/incompatible auto-discovered external companions warn and fall back cleanly to bundled DSpark or AR, while explicit draftModelPath keeps strict hard-error semantics.
  2. M <= 16 Verify Tree Metal Kernels & Zero-Rollback Path Commit

    • Compile-time template <bool HasTree> paged attention (paged_attention_inkling2.h), single-tile _r16 MPP verify kernels (paged_prefill_attention_inkling2.h), tree causal taps across all 4 ShortConv streams (k, v, attn_post, mlp_post), and in-place ascending-order inkling2_paged_kv_path_commit with pre/post encoder barriers and ShortConv tape path commit.
  3. M5 Max Target Fusions & Out-of-the-Box Runtime Defaults

    • Bound MoE weights via set_input_array_with_budget (eliminating 56–68 CB splits/step and MAX_ACTIVE_TASKS=10 stalls; host_graph_build 6.18 → 0.51 ms/tok).
    • Replaced 96 redundant GPU barriers around KV pool writes with set_buffer + register_output_array.
    • Fused 40-core qr_clip + sconv + kv_prep_paged, o_proj + attn_post_conv + residual, and loop_ctrl 3-way QKV norm split, cutting total MLX ops/step from ~850–900 to ~380–430 (< 500 default CB limit).
    • Defaulted MLX_INKLING2_Q8_SIMD_MAX_M=0 (NAX lm_head + dense Q8 on M5+) and SWA_MPP_VERIFY (4 <= M <= 16, ctx >= 512), eliminated q_staged temp allocs, and made all 3 persistent Metal scratch arenas thread_local with enc.retain_inputs(owner) + teardown/cache-clear hooks.
  4. App Catalog, Server Host & CLI Co-Download

    • Added INKLING2_DFLASH2 (incoai/Inkling-2-Mini-DFlash2, autoInstall: true) to Inkling-2-Mini in packages/agent/src/catalog.ts covering all 3 builds (UD-Q4_K_XL, UD-Q4_K_M, Original).
    • Generalized companion lookup & download handling across packages/lm, packages/dashboard (server + UI Models & Onboarding pages), packages/server/src/host/index.ts, and packages/cli wizard.

Benchmarks (Apple M5 Max 40-core, 128 GB — Zero Custom Env Vars)

Inkling-2-Mini-UD-Q4_K_M.gguf (15.99 GiB + 420 MiB DFlash2)

Prompt Output AR (M=1) DFlash2 1D (M=8) DFlash2 Tree (M=8..16)
Math / Reasoning (127 ctx) 128 tok 64.1 tok/s 224.2 tok/s (3.50x, 6.35 tok/cyc, 28.3 ms/cyc, 128/128) 195.6 tok/s (3.05x, 128/128)
Code-Edit Agent (SAM) (1511 ctx) 128 tok 64.3 tok/s 175.4 tok/s (2.73x, 5.52 tok/cyc, 128/128) 218.9 tok/s (3.40x, 7.94 tok/cyc)
Math / Reasoning (127 ctx) 512 tok 63.5 tok/s 189.1 tok/s (2.98x, 5.55 tok/cyc, 29.4 ms/cyc) —
Code-Edit Agent (SAM) (1511 ctx) 512 tok 63.9 tok/s 160.1 tok/s 178.8 tok/s Hybrid (2.80x, 5.94 tok/cyc)
  • M=8 target forward (ctx=512): 32.25 → 27.68 ms (-4.58 ms)
  • M=16 verify forward (ctx=512): 51.84 → 41.18 ms (-10.66 ms)
  • Draft propose (5L DFlash2 vs 3L DSpark): 3.19 → 2.42 ms

Original SafeTensors (NVFP4 + MXFP8 + BF16, 17.75 GiB + 420 MiB DFlash2, 512 out tok)

Prompt AR (M=1) DFlash2 1D (M=8) DFlash2 Tree (M=8..16)
Math / Reasoning (127 ctx) 54.3 tok/s 160.7 tok/s (2.96x, 5.32 tok/cyc) 133.5 tok/s
Code-Edit Agent (SAM) (1511 ctx) 55.0 tok/s 140.2 tok/s (2.55x) 154.0 tok/s (2.80x, 5.81 tok/cyc)
2K Context Coding (2048 ctx) 53.3 tok/s 104.8 tok/s (1.97x) 132.6 tok/s (2.49x, 5.11 tok/cyc)
4-Prompt Avg 54.3 tok/s 119.1 tok/s (2.19x) 131.5 tok/s (2.42x, 4.91 tok/cyc)

Verification

  • cargo fmt --all -- --check & cargo clippy --locked --all-targets -- -D warnings: 0 warnings
  • cargo test --release -p mlx-paged-attn (239+ tests): passed
  • bridge_metallib_names (9/9), dflash2_selector_edges (4/4), inkling2_scratch_release (2/2): passed
  • models::inkling2:: (73/73), models::qwen3_5::dflash2:: (41/41), models::qwen3_5::verify_tree:: (26/26): 140/140 passed
  • Real-model production chat admission inkling2_dspark_greedy_parity (scheduled + whole-turn): passed
  • vp lint --type-aware --type-check (0 warnings, 0 errors), yarn build:ts, packages/dashboard/ui tsc + build, TS Vitest suites: passed

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 41f2795b-9d8d-48ed-9fe6-8833534356de

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T08:52:02.268436Z 3fbe268 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…ck, verify-tree routing, and sync index.d.cts
…ore VERIFY_ROWS=8, atomic KV commit, target-first materialization, and update wizard test
…rden exclusive reclaim (seq 0, SSD wait, SWA-scoped)
@Brooooooklyn
Brooooooklyn merged commit c0fbd98 into main Nov 24, 2026
11 checks passed
@Brooooooklyn
Brooooooklyn deleted the feat/inkling2-dflash2-perf branch November 24, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant