Repository navigation
feat(vlm): support MiniCPM-V 4.7 dense and MoE checkpoints - #3657
Merged
Merged
Conversation
…mul guard Add a dedicated `MiniCPM-V 4.7` section header and upstream URL to `NOTICE` (resolved during rebase onto `main`), add the full upstream GitHub URL and `NOTICE` pointer to `src/vision/minicpmv4_7_rope.rs`, use `checked_mul` for grid-size validation, and update `Used by:` annotations in `src/vision/encoders/minicpmv4_6.rs`. Validated with `cargo test --profile test-fast --lib -- minicpm` (72 passed), `cargo fmt --check`, and real Metal checks on `mlx-community/MiniCPM-V-4.7-1B-4bit` and `models/minicpm-v-4.6-mxfp4` (both accurately OCR'd `GOT OCR two point zero renders this page`). Refs lablup#2398, lablup#3657
inureyes
force-pushed
the
feat/minicpm47-canvas
branch
from
December 2, 2026 00:41
ba6c0a3 to
740a027
Compare
Member
Implementation Hardening SummaryAudited PR #3657 against issue #2398 across MiniCPM-V 4.7 detection, canvas M-RoPE, vision encoder/merger configuration, and preemption state binding. Findings & Fixes
Validation
|
3 tasks done
inureyes
added a commit
that referenced
this pull request
Dec 2, 2026
Parallel `cargo test --features cuda --lib -- --test-threads=4` aborted in most runs with "invalid memory registered when calling <op>::eval_gpu". The cause is a race in MLX's debug-only CUDA allocation tracker: `move_to_unified_memory` and `move_to_device_memory` freed the old pointer before calling `swap_allocation`, so another thread could be handed that address and track it, and the late swap then moved the live entry away and its next `verify_graph` aborted. A new overlay of `mlx/backend/cuda/allocator.cpp` (base 5a48f9cc) retargets the tracker before the free. Release and test-fast builds define NDEBUG and never ran this code, which is why the merge gates did not see it. MLX-evaluating lib tests now take `mlx_test_guard()` as their first statement, and `tests/mlx_test_guard_coverage.rs` gains a source scan that fails when a test reaches an eval or host readback before taking the guard. Helpers that took their own guard or the device lock were adjusted so nothing deadlocks. CI clippy now also lints examples (about one second of extra time). Main broke several times while this was open, and the branch carries the fixes the verification needed: the diffusing_interval settings classification, LLaVA-OneVision in FAMILY_ORDER, two clippy lints, the WebUI string fixture and bundle, and guards on tests added by #3654, #3657 and #3678. Validation: five consecutive 4-thread CUDA lib runs on GB10 passed (14080 passed, 0 failed each) where the base aborted; the guard scan, family_order, fmt, clippy with examples, the scripts/ci contract checks, the WebUI suite and contract check pass. OpenXLA feature compile fails with the same RUSTFLAGS quoting error as on main. Closes #3660
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.
Closes #2398.
Adds MiniCPM-V 4.7 dense and MoE loading. Image requests use canvas M-RoPE and retain their positions across preemption; text-only requests keep 1-D positions. The encoder selects the checkpoint’s downsample mode and 4.7 merger activation without changing the 4.6 default. The patch also updates a stale constructor in the logit-trace example so the verification harness builds.
Spark2 verification (NVIDIA GB10, CUDA)
The pre-change binary rejected
minicpmv4_7. I tested the 1B-4bit checkpoint at13caa569and the 35B-A3B-mxfp4 checkpoint at810419ddwith greedy generation, using the repository soccer photo, an OCR card, and two ordered shape images. Examples of visible answers:Both CLI and server ran with a 64-token cap first. Thinking consumed the entire budget on some prompts, including the photo. The visible results above use a 384-token cap; server requests set
chat_template_kwargs.enable_thinking=false.Teacher-forced comparison
Against two identical mlx-vlm 0.8.2 reference runs on Metal, the Rust 1B CUDA trace had identical prompt IDs and 0/17 top-token disagreements (0/16 where the reference gap was ≥2). Absolute logit differences on the reference choice: median 0.125, maximum 0.875; this is top-token parity, not identical logits. On the same input, replacing canvas with 1-D positions in the reference changed 4/16 decided tokens; switching both merger activations to erf changed 0/16.
The focused regression tests cover upstream canvas fixtures, malformed crop spans, packed 4-bit embeddings with fractional pixels, and per-sequence state. Independent source review checked position handling and found a missing exhaustive-test entry and upstream attribution; both are included here.
test result: ok. 72 passed; 0 failed; 2 ignored; 0 measured; 14199 filtered out; finished in 1.20s