Skip to content

feat(dflash): allow MiniCPM-V 4.7 as a DFlash/DSpark target - #4737

Merged
jundot merged 1 commit into
jundot:mainfrom
ChristianPraiss:feat/dflash-minicpmv4_7
Oct 24, 2026
Merged

jundot merged 1 commit into
jundot:mainfrom
ChristianPraiss:feat/dflash-minicpmv4_7

Conversation

@ChristianPraiss

@ChristianPraiss ChristianPraiss commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Allow MiniCPM-V 4.7 (minicpmv4_7) as a DFlash/DSpark target on the VLM engine.

Today the admin DFlash toggle refuses this model:
DFlash supports Qwen3, Qwen3.5/3.6, Laguna, MiMo V2, GLM-5.3, Gemma 4 and Muse Glimmer models (model_type='minicpmv4_7', engine='vlm').
The gate keys on the top-level model_type; MiniCPM-V 4.7 is a VLM wrapper (minicpmv4_7) whose text backbone is qwen3_5_moe_text, a family that is already supported. MiniCPM-V 4.7 itself has loaded since 0.7.1 (#4527, #4529).
OpenBMB publishes a matching DSpark draft: openbmb/MiniCPM-V-4.7-35B-A3B-DSpark (Apache-2.0, 778 MB, Qwen3DSparkModel, dflash_config with projector_type: dspark).

Changes (3 files, +41/-2):

  • omlx/utils/model_loading.py: add "minicpmv4_7" to _DFLASH_BATCHED_MODEL_TYPES["vlm"] and name MiniCPM-V 4.7 in the dflash_compatibility() message. Nothing else keys on the model type: omlx/speculative/dflash/* has no model-type keys, and engine_pool, the admin routes and model_loading all go through dflash_batched_supported() / dflash_compatibility().
  • docs/experimental/dflash_mlx_integration.md: supported-targets table row.
  • tests/test_dflash_model_types.py (new): the allow-list and its message. Run against copies of the code: 4 of 7 cases fail without the change, all 7 pass with it.

Related: #4508, #4525, mlx-vlm #2499 (merged, added the model) and mlx-vlm #2506 (draft, opt-in SIMD verification and DSpark for MiniCPM 1B and 35B-A3B).

Validation

Hardware and software: MacBook M4 Max, 36 GB, macOS 26.5.2; oMLX 0.7.1 release app (bundled mlx-vlm 0.7.8).
This change was validated on the 0.7.1 release, not on a build of current main: the allow-list entry was applied in memory in a separate instance (port 7001, fresh base path, default model settings; the instance ran with --memory-guard off because the default guard rejected the 22 GB load on that fresh configuration), nothing in the app was modified. The allow-list block and message on main (2ecf137) are identical to 0.7.1.

Model: mlx-community/MiniCPM-V-4.7-35B-A3B-mxfp4; draft: openbmb/MiniCPM-V-4.7-35B-A3B-DSpark as published. Settings: dflash_enabled=true, dflash_draft_model=<local path of the draft>; the log shows DFlash drafter loaded ... block=9 ... layers=[3,11,19,27,35] and "attached", with no "loading without DFlash" line and no traceback.

Decode, same instance, model reloaded between runs: 5 fixed prompts (code, prose explanation, translation, ...), 400 new tokens each, greedy (temperature 0), thinking off, one request at a time:

plain DFlash/DSpark
mean tok/s over the 5 prompts, first run 72.7 124.6 (1.71x)
mean tok/s, warm re-run 72.7 109.9 (1.51x)
per-prompt tok/s 72.2-72.9 76-194 (first run), 68-185 (warm)
accepted tokens per cycle (omlx log) n/a 4.65, 6.25, 2.33, 3.54, 2.90

Other checks with DFlash on (each run once):

  • Concurrency: 2 concurrent requests 96 and 80 tok/s (about 176 aggregate) against about 118 aggregate for plain; 3 concurrent about 175 aggregate. No crash, no fallback to plain decode.
  • Vision: a single image request ran at 105 tok/s with a correct description; two image requests plus one text request at the same time all returned HTTP 200 (about 51 tok/s each).
  • Tool call: returned structured tool_calls in both modes. Streaming was used by the 4k smoke request.
  • Cold ~4k random-word prompt: prefill 1514 -> 1384 tok/s (about 9% slower, single sample); decode 70.2 -> 73.5 tok/s (no gain on that filler prompt).

Correctness: a 5-prompt temperature-0 comparison gives 14 of 15 text fields identical; the "math" answer diverges at character 151 (coherent, similar length). Plain mode also differs between a solo request and the same prompt inside a 2-way batch, so I read this as batched-verify numerics on mxfp4 rather than a DSpark problem, but I have not proven it. For comparison, mlx-vlm's own speculative loop on the same target and draft was bit-identical on all 5 prompts (67.3 -> 112.3 tok/s, 1.67x, 2.58 accepted tokens per round).

Not tested: contexts above ~4k; prefix-cache reuse with DFlash on; combination with Affine/TurboQuant KV compression or MoE expert offload; temperature above 0; chips other than M4 Max (the _SPEC_CAPS_TARGET_TYPES path is for other GPU generations); a build of current main; the new unit tests under pytest in a full checkout (I ran their bodies against copies of the code with a minimal stand-in for pytest.mark.parametrize).

Reproduction: enable DFlash for the model with the draft path above, send greedy 400-token requests with DFlash off and on, and compare tok/s and the accepted-tokens line in the log. A script that drives mlx-vlm directly and the raw result files are available on request.

AI assistance: this change and its validation were prepared with AI assistance and run on my hardware; I take responsibility for it.

Checklist

  • I read CONTRIBUTING.md.
  • I understand every change in this PR and can explain it in review.
  • For UI or UX changes, I attached before and after screenshots. (not applicable: no UI change)

Allow MiniCPM-V 4.7 (minicpmv4_7) as a DFlash/DSpark target on the VLM engine.
The gate keys on the top-level model_type; MiniCPM-V 4.7 is a VLM wrapper whose
text backbone (qwen3_5_moe_text) is already supported. Adds the allow-list
entry, names the model in the dflash_compatibility() message, a docs table row
and a unit test for the allow-list.

@jundot jundot left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked this against the mlx-vlm version oMLX pins. The MiniCPM-V 4.7 language model is a subclass of the Qwen3.5 MoE one, so DFlash runs through the same verify and rollback path that already works for Qwen3.5 MoE.

One small thing I'll fix on main after this is the runtime patch scope table, so a MiniCPM-V 4.7 load only applies the Qwen3.5 patches. LGTM, merging.

@jundot
jundot merged commit 1d7e3e8 into jundot:main Oct 24, 2026
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.

2 participants