Skip to content

feat(hy4,qwen4_exp,dashboard): Hy4-flash vision & DFly2-B6, Qwen4 4L perf/parity, Work-mode images, and barrier KV eviction - #435

Merged
Brooooooklyn merged 14 commits into
mainfrom
feat/hy4-flash-dfly2-b6
Nov 29, 2026
Merged

Brooooooklyn merged 14 commits into
mainfrom
feat/hy4-flash-dfly2-b6

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Contributor

Summary

End-to-end speculative decoding, vision (mmproj), multi-lane Metal kernel optimization, Dashboard Work-mode image attachments, and exclusive-barrier KV reclamation across Hy4-flash, Qwen 3.8 Flash Next, Qwen 3.8 27B, and Inkling-2-Mini.

flowchart LR
  subgraph Models["Native Engine & Metal Kernels"]
    HY4["Hy4-flash<br/>• DFly2-B6 speculative decoding<br/>• GGUF mmproj vision + 3D M-RoPE<br/>• Image prefix cache + ViT skip<br/>• Exclusive-barrier KV eviction"]
    Q4["Qwen 3.8 Flash Next<br/>• GGUF mmproj + image prefix cache<br/>• AOT dense NAX + grouped MoE<br/>• Batched GDN/QSA + DFlash2<br/>• 0.0-ULP 1L GDN parity<br/>• Barrier decode/verify KV eviction"]
    Q3["Qwen 3.8 27B & Inkling-2-Mini<br/>• Image prefix cache + ViT skip<br/>• Multimodal DFlash2 & DSpark<br/>• BF16 sampler & sync fixes"]
  end
  subgraph App["LM, CLI, Agent & Dashboard"]
    TS["Model discovery, catalog & CLI<br/>• Hy4-flash mmproj + DFly2-B6<br/>• Qwen4 mmproj discovery"]
    UI["Dashboard Work Mode<br/>• Direct image attachments<br/>• Per-family image caps"]
  end
  HY4 --> TS
  Q4 --> TS
  Q3 --> TS
  TS --> UI
Loading

Key Changes

1. Hy4-flash: DFly2-B6 + GGUF Vision (mmproj-Hy4-flash-bf16.gguf) + Barrier KV Reclamation

  • DFly2-B6 (crates/mlx-core/src/models/hy_v4_flash/dfly2/): 3-layer Eagle/DFly2 speculative drafter (block_size = 6) integrated with paged KV cache, lock-free Engram batching, WINDOW_SLACK = 6, and multimodal verify.
  • GGUF Vision (vision.rs, media.rs, indexer.rs, persist_codec.rs):
    • SigLIP2-So400m ViT (27 blocks, exact erf GELU, bilinear-interpolated 128×128 position embeddings) + rmsnorm_mlp_adapter (mm.pre_norm → 2×2 s=2 Conv2d → GELU → 1×1 Conv2d → row-end v.image_newline).
    • Interleaved [12, 10, 10] 3D M-RoPE in GPT-J pair order with hybrid 1D/3D multi-chunk prefill (pure-text chunks stay on fused 1D Metal kernels with causal rope_delta), Indexer pooled-key 3D M-RoPE + open_pos / recent_group_pos rollback ring persisted in HY4S v3.
    • Image prefix caching + ViT skipping, zero-copy header-only planning (expandedPromptTokenCount), lazy mmproj load with open-fd fingerprint re-verification, zero-transfer Engram bypass + lookahead filtering on masked image rows, and supportsImages() / expandedPromptTokenCount() NAPI exports.
  • TS / Catalog / CLI (packages/lm, packages/agent, packages/cli): Auto-discovery of mmproj-Hy4-flash-*.gguf and hy4-flash-dfly2-b6 (Metal-only draft gating preserving Windows/Linux SPARK builds), catalog globs + sizes, and projector download tests.
  • Exclusive-Barrier KV Reclamation (owner.rs, sched.rs): LRU idle-owner KV eviction on prefill, warm continuation, and decode/verify block boundaries with host-headroom-capped partial grow while preserving history-only SessionContinue owners and published prefix checkpoints.

2. Qwen 3.8 Flash Next (qwen4_exp): 4L > 1L Metal Optimizations + Vision + Barrier Decode KV Reclamation

  • Zero-JIT Metal & Batching (crates/mlx-sys/src/metal/qwen4/, crates/mlx-core/src/models/qwen4_exp/):
    • AOT qwen4_q8_nax_m16 dense NAX (routing M = 1..16 directly to m16, skipping narrow N < 1024 / (N == 1024 && R <= 8)), grouped MoE, batched deferred-fold GDN & paged QSA, compiled batched DFlash2, AlignConstant4 (0 dispatches on aligned R = 1..4), and batched unquantized small projections (count >= 5, eliminating 3,840 serial matmuls/wave).
    • Compile-time QWEN4_*_RUN(A) switch (active) in dense_decode.metal.inc & mixer_act_decode.metal.inc eliminating register spills (-14 ms/cyc wall, -16.7 ms GPU on 1L SPEC).
    • Restored 4/4 exact 1L AR greedy parity (0.0 ULP state_out diff) via metal::fast::log in gdn_verify_batch.metal.
    • Bounded WaveCostModel priors & per-width observation tracking; paged QSA command-buffer memory budget scaling.
  • Multimodal & Prefix Persistence: GGUF mmproj vision, image prefix caching + ViT skipping, pinned prefill breaks, idle release draining, media prefix persistence, and exclusive-barrier decode & DFlash2 verify KV reclamation (paged.rs, mod.rs, decoder/draft_cycle/mod.rs).

3. Dashboard Work-Mode Image Input (packages/dashboard, docs/dashboard.md)

  • Enabled direct kind: 'image' attachments in Work mode whenever modelRow?.images === true.
  • Enforced per-family conversationImagesMax(family) (4 for Flash Next, 64 otherwise) in both UI blockers and chat service, plus recheckModel() preflight race guard.

Benchmarks & Live E2E Results (Apple M5 Max, 128 GiB)

Standalone Real-Weights Benchmarks

Model Workload Baseline This PR Parity / Notes
Qwen 3.8 Flash Next (UD-Q4_K_XL + DFlash2, 48/48 direct banks, 4L) 1L AR warm (128 tok avg) 54.07 tok/s 58.47–58.99 tok/s (+9.1%) 4/4 exact 1L AR parity
1L SPEC warm (128 tok avg) ~68–75 tok/s 83.03–84.22 tok/s (math 110.4, 1.43×) -14.0 ms/cyc wall (-16.7 ms GPU)
4L greedy (512 tok wall / steady dec) 30.82 → 81.33 93.5–95.6 aggTok/s (141.9 steady) -65% dispatches/wave (85.8 ms/wave)
4L sampled topK=0 (512 tok wall / steady) 57.66 → 82.09 88.7–92.0 aggTok/s (131–137 steady) +55% to +60% wall over baseline
Hy4-flash (Q4_K_M + mmproj + DFly2-B6) Cold screenshot → Warm Turn 2 → Cross-owner — 46.7 → 52.8 tok/s (τ = 3.90, 158 ms hit TTFT) Pixel-exact OCR, 576/597 ViT-skipped hit, exact 128-tok AR match
Qwen 3.8 27B (UD-Q4_K_XL + DFlash2) 1L / 4L greedy / 4L sampled — 35.6 / 55.8 / 57.2 aggTok/s exactMatchSolo = 4/4 (2.78× AR)
Inkling-2-Mini (DFlash2 / Bundled DSpark) 4L greedy / 4L DSpark — 71.1–81.6 / 87.7 aggTok/s exactMatchSolo = 4/4, Inline AR = 4/4

Live mlx agent Multi-Subagent E2E With Image Input (napi-rs Security Audit)

Model Exit Turns Gen Tokens Active Agg Decode Peak Per-Lane Avg τ Errors
Hy4-flash (Q4_K_M, 100% Direct MoE 85.2 GiB, mmproj + DFly2-B6) 0 574 244,106 32.7 tok/s (1L: 28.5 → 4L+: 44.4) 52.0 tok/s 2.71 0
Qwen 3.8 Flash Next (UD-Q4_K_XL, mmproj, 95k+ concurrent ctx) 0 185 180,794 31.1 tok/s (1L: 26.4 → 3L: 49.3) 59.0 tok/s AR 0

Verification

  • cargo fmt --all -- --check: PASS
  • cargo clippy -p mlx-core --lib --tests -- -D warnings: PASS (0 warnings)
  • cargo test -p mlx-core --lib models::hy_v4_flash::: 464 passed, 0 failed (32 vision & barrier KV tests)
  • cargo test -p mlx-core --lib models::qwen4_exp::: 514 passed, 0 failed
  • yarn build:native + tsc -b tsconfig.json + yarn --cwd packages/dashboard build + yarn lint: PASS (0 warnings, 0 errors)
  • vp test run (dashboard, lm, agent/catalog, cli/wizard, cli/download-projector, agent-wizard): 6,940+ passed, 0 failed (plus chat-mode-page.test.ts 81/81 re-verified after PR feat(dashboard): Arc Pro ModelPicker, smooth auto-scroll, and sidebar shift fixes #433 rebase)

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-28T22:46:19.933217Z
We couldn’t complete this review. Comment @codex review to try again.
d086715 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.

@coderabbitai

coderabbitai Bot commented Nov 28, 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: f8c88928-3497-4852-9933-6df732c476e3

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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Brooooooklyn
Brooooooklyn merged commit b4853c3 into main Nov 29, 2026
21 checks passed
@Brooooooklyn
Brooooooklyn deleted the feat/hy4-flash-dfly2-b6 branch November 29, 2026 01:45
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