Skip to content

fix(vision): RF-DETR, Muse Glimmer and Mage-VL-Cowork parity fixes - #3460

Merged
inureyes merged 3 commits into
lablup:mainfrom
Jaeyeong-CHOI:fix/3236-vision-parity-fixes
Nov 27, 2026
Merged

inureyes merged 3 commits into
lablup:mainfrom
Jaeyeong-CHOI:fix/3236-vision-parity-fixes

Conversation

@Jaeyeong-CHOI

Copy link
Copy Markdown
Contributor

Summary

Closes #3236.

Four vision-side fixes that mlx-vlm landed for families mlxcel already ships, in one PR as the issue asks: RF-DETR's projector LayerNorm eps and mask resize, Muse Glimmer's position-table axis order on non-square grids, loading microsoft/Mage-VL-Cowork, and f32 LayerNorm/GELU in the Mage ViT. Each item's reproduction test failed on main, and reverting any one production change fails its own test and no other. Item 3 needed one change beyond the issue text: Cowork loaded, but decoded through its embedding matrix until a Mage-VL config without tie_word_embeddings was read as untied (see "Where this differs from the issue text").

With the change, on Spark2 (GB10, CUDA):

  • RF-DETR seg masks from mlxcel detect match mlx-vlm e8035ae3 pixel for pixel (0 differing pixels on all four masks; main: 341, 398, 37 and 46 of 307,200). Raw logits against the same reference are within 3.6e-4 (base) and 6.1e-4 (seg); main is at 3.8e-3 and 4.4e-3.
  • Mage-VL-Cowork loads. Main fails with Unsupported model type: llava_onevision2. With the card's system prompt the greedy reply is <think>…</think>, Action: Click the Save button in the dialog., <tool_call>{"name": "computer_use", "arguments": {"action": "screenshot"}}</tool_call>, which is the same tool call mlx-vlm produces for the same request. A teacher-forced trace against mlx-vlm f32 disagrees on top-1 at 1 of 87 positions, none decided.
  • Muse Glimmer: on two non-square images the teacher-forced perplexity gap to mlx-vlm goes from +9.5% to −4.0% and from +9.5% to +4.6%. Decided disagreements are 0 in both arms, so the issue's --decided 2 gate does not separate them.
  • Mage ViT f32 LayerNorm/GELU: unit tests show the half-precision paths round differently. On real checkpoints on CUDA the effect sits inside the rounding class: no decided disagreements in either arm, and the logit deltas move in both directions. See "Verification limits".

What changed

  1. RF-DETR (Use eps=1e-6 in the RF-DETR projector LayerNorms Neywa-Labs/mlx-vlm#2709, fix(server): refuse special-purpose IPv6 ranges in media URL policy #2713)
    • src/vision/detection/rfdetr/layers.rs: ConvNorm::from_weights loads its bn LayerNorm at eps 1.0e-6 (was 1.0e-5). This covers every projector cv1, cv2 and bottleneck conv; ConvNorm has no other user in RF-DETR (pp_doclayout_v3 and rt_detr_v2 have their own ConvNorm).
    • src/vision/detection/rfdetr/projector.rs: the final norm projector.stages.0.1 at 1.0e-6.
    • src/vision/detection/rfdetr/predictor.rs: decode_masks resizes the selected mask logits with resize_bilinear_nhwc(.., (height, width), false, false) instead of resize_bicubic_nhwc, keeping the f32 cast and the > 0 threshold.
    • The other RF-DETR norms (backbone 1e-6, decoder and enc_output_norm 1e-5, segmentation 1e-6) are unchanged.
    • Test-only accessors ConvNorm::norm_eps and Projector::norm_eps (#[cfg(test)]).
  2. Muse Glimmer (Fix Muse Glimmer vision position embedding order Neywa-Labs/mlx-vlm#2746): src/vision/encoders/muse_glimmer_pos.rs bilinear_indices_and_weights binds let (h, w) = (w, h); inside the per-grid loop. The outer loop walks the grid width against table_h and the inner loop the grid height against table_w, which is upstream's meshgrid(.., indexing="xy") order. Token count is unchanged; muse_2d_rope is not touched.
  3. Mage-VL-Cowork (Add native Mage-VL-Cowork support Neywa-Labs/mlx-vlm#2636)
    • src/models/detection.rs: "mage_vl" | "llava_onevision2" => ModelType::MageVLM.
    • src/models/registry.rs: llava_onevision2 added to ModelType::MageVLM's aliases.
    • src/loading/vlm_mage_vl.rs: remap_mage_vl_weight_key maps visual.* to vision_tower.* after the model.visual. arm.
    • src/loading/vlm_mage_vl.rs: mage_vl_text_config fills in tie_word_embeddings when text_config does not state it: the top-level boolean if there is one, otherwise false. Not in the issue; see below.
    • The processor path needed nothing: Cowork's preprocessor_config.json has the same min_pixels / max_pixels / image_mean / image_std keys and values as Mage-VL's, and vision_config (temporal_patch_size: 1, layer_norm_type: "layer_norm", hidden 1024, 16 heads, use_head: false) passes MageVlVisionConfig::validate.
  4. Mage ViT f32 LayerNorm and GELU (ae763da4): src/vision/encoders/mage_vl.rs gains private layer_norm_f32 (casts input, weight and bias to f32, runs the fast layer norm through a temporary LayerNorm, casts back to the input dtype) and gelu_f32 (f32 upcast, mlxcel_core::gelu, cast back). They are used at layernorm_pre, layer_norm1, layer_norm2, the merger's ln_q, and the SigLIP MLP and merger GELUs. Mage-ViT has no layernorm_post (use_head: false is refused at load), so there are four norm sites, not five. The weights stay in their loaded dtype, and mlxcel_core::layers::LayerNorm is not changed.

Docs: CHANGELOG.md (Unreleased / Fixed), the Mage-VL entry in docs/supported-models.md (Cowork), and row V42 of docs/gelu-call-sites.md (new line numbers, gelu_f32). No shared helper gained a caller, so no Used by: annotation changed; check_used_by.py passes.

Where this differs from the issue text

  • Cowork's tied head (new). The issue lists lm_head.weight among the keys that "already pass through unchanged". They do, but Cowork's config states tie_word_embeddings nowhere, and the shared Qwen3 ModelArgs default it to true, so the loaded model ignored lm_head and decoded through embed_tokens. In the checkpoint the two differ (max |diff| 0.177, mean 0.0078). Transformers' Qwen3Config and mlx-vlm's Mage-VL TextConfig both default to untied, and microsoft/Mage-VL states false. Before this change the loaded Cowork model produced repetitive text that drifted into Chinese ("…changes belong belonging belong belonging…") on every greedy and sampled request, and a teacher-forced trace against mlx-vlm disagreed on top-1 at 42 of 87 positions (13 of 54 decided), perplexity 84.8 against the reference's 6.0. After it: 1 of 87, 0 decided, 5.97. Without this, item 3's acceptance ("a well-formed <tool_call> reply") was not met.
  • The mask-resize test input. The issue suggests [[-1, 1], [1, -1]]. Upsampled to 4x4, both bicubic and bilinear keep its sign pattern, so it thresholds to the same plane either way (computed, and checked on main: the test passed). The test uses [[-1, 3.2], [3.2, -1]], which differs at four pixels, and it asserts that the bicubic plane differs from the bilinear one, so a future change of input cannot make it vacuous.
  • The Mage tests cover bf16 as well as f16. On CUDA the tower runs in bf16 by default (CUDA keeps bf16 unless MLXCEL_CUDA_F16_NORMALIZE is set), and Mage-VL-8bit keeps a bf16 tower on every backend because the checkpoint is quantized. With f16 only, the GELU test showed that mlxcel_core::gelu already rounds once from f32: its f32 constants promote a half input. bf16 is different on CUDA. The CUDA overlay src/lib/mlxcelverse/overlays/cuda/mlx/dtype.cpp promotes bf16 with f32 to bf16, so on CUDA a bf16 GELU ran entirely in bf16 (for example gelu(-5) came out as -0 where the f32-rounded value is about -1.4e-6). The GELU test asserts that today's path differs only for bf16 on CUDA, the one case where it can differ; on Metal and for f16 that path already matches.
  • The bf16 LayerNorm test input. A spread under one on rows at 150 to 430 rounds away in bf16 (step 1 to 2 there), which makes each row nearly two-valued; on that input today's bf16 path matched the f32 reference everywhere. The bf16 case uses a spread of 8, still far below the offset.

Verification

Spark2: NVIDIA GB10 (sm_121), Linux aarch64, pinned toolchain, --features cuda, --profile test-fast, MLX_ENABLE_TF32=0 MLXCEL_SDPA_DETERMINISTIC=1. Base f74dd84eb923f42a95d212f5bbd666a00bcb914f. Tested tree 15de7a6d084959bf150269c26201d4017505a039, the tree of the commit.

  • cargo fmt --all -- --check
  • cargo clippy --locked --workspace --all-targets --features cuda -- -D warnings
  • python3 scripts/ci/check_used_by.py, bash scripts/ci/check_used_by_test.sh, python3 scripts/insert_apache_header.py --check, python3 scripts/ci/check_env_var_docs.py, python3 scripts/ci/check_kernel_dtype_keys.py, python3 scripts/ci/check_cross_repo_refs.py
  • The new and extended tests and the related sets below.
  • make verify-test-cuda with a private 0700 TMPDIR: 17,193 passed, 1 failed, 517 ignored over 197 test result lines (35 min). The tree was the tested tree before and after. The one failure is models::deepseek_v32::rope_tests::prefill_and_decode_cache_yarn_rotated_keys_past_the_original_context (cached k_pe at positions 16..24 must be YaRN-rotated (max diff 1.6620973)), the known CUDA failure on main (fix(cuda): MLX CUDA RoPE gives every row of a broadcast input the same rotation, failing make verify-test-cuda on main #3442, fix in fix(cuda): rotate broadcast RoPE inputs in a dense output #3443). The same test, run alone from a build of unmodified f74dd84eb, fails with the same message and the same max diff 1.6620973. The library target has 13,192 tests on main and 13,200 here.

Tests

Test File main fix
projector_norms_use_eps_1e6 rfdetr/tests.rs fail (1e-5 != 1e-6) pass
mask_resize_is_bilinear_half_pixel rfdetr/tests.rs fail (cubic plane) pass
position_table_uses_xy_meshgrid_order muse_glimmer_pos.rs fail (corner 0 [0, 1, 2, 3, 8, 9, 10, 11]) pass
square_grid_position_table_is_unchanged muse_glimmer_pos.rs pass (guard) pass
hub_and_converted_keys_remap_to_one_layout (extended) vlm_mage_vl_tests.rs fail (visual.merger.mlp.0.weight kept) pass
text_config_without_a_tie_flag_is_untied vlm_mage_vl_tests.rs not run on main; fails under the mutation that restores the tied default pass
llava_onevision2_detects_as_mage_vl detection_tests.rs fail (Unsupported model type: llava_onevision2) pass
mage_layer_norm_rounds_once_from_f32 mage_vl_tests.rs fail (f16 bits differ at 1 ulp) pass
mage_gelu_rounds_once_from_f32 mage_vl_tests.rs fail (bf16 on CUDA) pass

"main" is f74dd84eb with the tests added and a #[cfg(test)] shim that maps layer_norm_f32 / gelu_f32 to today's LayerNorm::forward / mlxcel_core::gelu. The main run used the first version of the two Mage tests (f16 only). The bf16 rows were added after it, so on main the GELU test failed only its "today must differ" assertion; the bf16 failure is shown by the mutation below. The Glimmer expected arrays are the output of upstream's numpy code on those grids.

Mutation: each production change reverted on its own, tests kept, lib test binary rebuilt each time.

Reverted Failing tests
nothing none
RF-DETR eps (both sites) projector_norms_use_eps_1e6
RF-DETR bilinear resize mask_resize_is_bilinear_half_pixel
both RF-DETR changes both of the above
Glimmer (h, w) swap position_table_uses_xy_meshgrid_order
llava_onevision2 detection arm llava_onevision2_detects_as_mage_vl
visual. remap arm hub_and_converted_keys_remap_to_one_layout
untied default (unwrap_or(true)) text_config_without_a_tie_flag_is_untied
layer_norm_f32 body -> ln.forward(x) mage_layer_norm_rounds_once_from_f32 (f16)
gelu_f32 body -> mlxcel_core::gelu(x) mage_gelu_rounds_once_from_f32 (bf16)

Related sets on the fix tree (cargo test -p mlxcel --lib -- FILTER --test-threads=1): rfdetr 25 passed, 2 ignored; muse_glimmer 122; mage 961 passed, 41 ignored; detection_tests 113; registry 73; interpolate 18. On main the same filters failed only on the new tests.

Real checkpoints

All on Spark2, one model process at a time under a memory watchdog (stop below 25 GiB available or above an RSS bound). 66 watched runs, none stopped; the lowest available memory seen was 83.0 GiB and the largest process-group RSS 4.9 GiB (on GB10 unified memory CUDA allocations need not show in RSS, so the available-memory floor is the main guard). Reference: mlx-vlm e8035ae3 (mlx 0.32.4, CUDA), which contains #2709, #2713, #2746 and #2636.

Checkpoint Revision
mlx-community/rfdetr-base-fp32 eddb85a12c5996074fac2f2e769ca5e947bd80d3
mlx-community/rfdetr-seg-small-fp32 a7a2375b4ca7b2ef0427af91b55d8176ca647b35
microsoft/Mage-VL-Cowork 6fbe7f91da477c1c73790dbb1f08d001b8626be1
mlx-community/Mage-VL-8bit 40dc28d825dfaf0dfdea374f39539475d5ee35f2
mlx-community/Muse-Glimmer-30B-4bit 3e7677d7a40d348a3daba263a2b1c0aa41910710

RF-DETR. The committed fixtures in tests/fixtures/rfdetr were generated with mlx-vlm 4319ef2c, before #2709 / #2713. Re-running that predictor at e8035ae3 with the two fixes reverted in-process reproduces them (identical masks, logits within 5.7e-4), so they are a pre-fix reference. New references were captured at e8035ae3 as is ("post") and with the two fixes reverted ("pre"), same cats.png input. real_tests.rs asserts a ROCm backend, so the numbers below come from an evidence-only copy of it (not in this PR) that prints the metrics and feeds the reference's own input tensor (processor output was byte-identical in every run):

Arm vs mlx-vlm post-fix base logits max base boxes max seg logits max seg mask-logits max seg masks, differing px (of 307,200)
fix 3.62e-4 2.03e-4 6.11e-4 8.30e-3 0, 0, 0, 0
eps reverted 3.82e-3 3.33e-3 4.42e-3 6.05e-2 0, 0, 0, 0
resize reverted 3.62e-4 2.03e-4 6.11e-4 8.30e-3 398, 37, 341, 46
both reverted (main) 3.82e-3 3.33e-3 4.42e-3 6.05e-2 398, 37, 341, 46

Against the pre-fix reference the picture inverts (main: base logits 1.98e-4, masks 0 px; fix: 3.74e-3, 398/37/341/46 px). In every arm the selected queries, labels and NMS survivors match the reference, with scores within 5.4e-6.

The issue's command, mlxcel detect -m rfdetr-seg-small-fp32 -i cats.png --format json --masks-dir …: fix masks equal the mlx-vlm post-fix masks exactly (IoU 1.000000 on all four); main's are 0.994565, 0.992694, 0.991578 and 0.979860. Main and fix print the same detections and labels on cats.png and on a 1280x720 resize of it for both checkpoints (confidence differences at most 1.8e-4). Seg masks on the wide image differ by 1,020 / 1,170 / 128 / 120 pixels between the arms.

Mage-VL-Cowork. mlxcel generate -m Mage-VL-Cowork --image screenshot.png -p "Click the Save button." -n 256 on a synthetic 1280x800 editor screenshot with a "Save changes to report.txt?" dialog: main exits with Error: Unsupported model type: llava_onevision2, as does mlxcel-server. With the fix it loads in 1.5 s (8.22 GB resident) and describes the dialog and the blue Save button, all in the reasoning channel (no system prompt, so no tool format). Through mlxcel-server with the model card's verbatim MAGE_HYBRID_SYSTEM_PROMPT and Task: Click the Save button in the dialog. (2,122 prompt tokens, the same count mlx-vlm renders):

  • greedy: reasoning, then content Action: Click the Save button in the dialog., and the token stream (from logprobs) ends in <tool_call>\n{"name": "computer_use", "arguments": {"action": "screenshot"}}\n</tool_call>. mlx-vlm greedy on the same request emits the same <tool_call> line after a differently worded reasoning paragraph. Without tools in the request the server leaves tool_calls unset; with the two functions passed as tools it returns finish_reason: tool_calls and computer_use with {"action": "screenshot"}.
  • sampled at the card's temperature 0.7, top_p 0.8, seeds 0, 1 and 2: three coherent replies, each ending with an Action: line (129 to 163 tokens, finish_reason: stop).

Teacher-forced trace (MLXCEL_TRACE_IMAGE, prompt Click the Save button., 87 forced tokens of a card-style reply) against mlx_vlm_image_logit_trace.py --float32 --mlxcel-prompt, prompt ids identical (1,017):

Arm top-1 disagreement decided (gap >= 2) logit delta p50 / p90 / max perplexity (ref 5.9737)
tied head (before the untied default) 42 / 87 13 / 54 1.652 / 4.769 / 12.604 84.785
fix 1 / 87 0 / 54 0.067 / 0.292 / 0.646 5.970
fix with item 4 reverted 0 / 87 0 / 54 0.081 / 0.255 / 1.108 5.966

Mage-VL-8bit (no-regression check; main loads it): Describe the image., 128 greedy tokens. On the 1280x720 image main and fix produce the same text. On cats.png (640x480) they diverge at character 38 (pink couch vs red couch). Trace on cats.png against mlx-vlm f32 (prompt ids identical, 325):

Arm top-1 disagreement decided logit delta p50 / p90 / max perplexity (ref 1.4876)
main 3 / 128 0 / 64 0.084 / 0.196 / 0.365 1.4857
fix 1 / 128 0 / 64 0.120 / 0.281 / 0.483 1.4779

The 1280x720 trace has no reference arm: mlx-vlm makes 880 image tokens and mlxcel 920, and the script refuses the pair. That difference is outside this PR; see "Verification limits".

Muse Glimmer (Describe the image.). Reference without --float32: the 30B checkpoint dequantized to f32 is about 120 GB, more than the host, so the reference runs the 4-bit weights natively. mlx-vlm renders 2 more prompt tokens than mlxcel (1,259 vs 1,257 and 454 vs 452), so the reference scores mlxcel's ids (--mlxcel-prompt). Greedy text differs between main and fix from about the 40th character on both images.

Image Arm top-1 disagreement decided logit delta p50 / p90 / max perplexity vs ref
1280x720 (59 positions) main 2 0 / 39 0.125 / 0.563 / 1.125 7.219 vs 6.593 (+9.5%)
fix 1 0 / 39 0.125 / 0.375 / 0.875 6.327 (−4.0%)
640x480 (63 positions) main 1 0 / 41 0.250 / 0.625 / 1.813 5.608 vs 5.122 (+9.5%)
fix 3 0 / 41 0.188 / 0.438 / 0.875 5.356 (+4.6%)

Verification limits

  • Item 4 on real checkpoints. On CUDA the f32 LayerNorm/GELU change does not show up as a reference improvement. Cowork with item 4 reverted is as close to mlx-vlm f32 as with it (0 vs 1 undecided flips; p90 lower, max higher). On Mage-VL-8bit cats.png the fix has fewer undecided flips (1 vs 3) but larger logit deltas (p90 0.28 vs 0.20). The unit tests show the rounding difference exists in both half types; on these traces it sits below the decoder's own bf16 noise. Metal was not run, so the f16 tower path (Metal, unquantized checkpoint) was not measured on a real model.
  • Muse Glimmer improves perplexity and the largest logit delta on both images, but the issue's gate (--decided 2) is 0 in both arms, and on cats.png the fix has more undecided top-1 flips (3 vs 1). The reference ran the 4-bit weights, not f32.
  • RF-DETR reference is mlx-vlm, not PyTorch rfdetr; upstream's "3.46 -> 5.4e-3 vs PyTorch" was not reproduced here (no torch on the host). The eps change moves mlx-vlm-referenced logits by about 3.5e-3, not by 3.46.
  • Cowork's tool call is action: screenshot in both mlxcel and mlx-vlm greedy, not a click on Save; the pass criterion is a well-formed <tool_call>, which both meet. The screenshot is synthetic. Under greedy the server stops after the call with finish_reason: stop and no tool_calls field unless tools is passed (existing server behaviour, not changed here).
  • Not run: Metal and ROCm (real_tests.rs is the ROCm-only parity test and was not run as committed); the video path; tensor parallelism.
  • Found, not fixed: Qwen2VLProcessor::smart_resize (src/vision/processors/qwen2_vl.rs) rounds with f64::round, half away from zero; transformers and mlx-vlm use Python round, half to even. A 1280x720 image gives a 736x1280 grid here and 704x1280 upstream (920 vs 880 Mage-VL image tokens). This affects every family on that processor and is a separate issue.
  • main moved to ed7f31e46 (two commits) while this was tested; git merge-tree reports no conflict, and the tests were not re-run on the new base.

@inureyes inureyes added status:review Under review type:bug Bug fixes, error corrections, or issue resolutions priority:medium Medium priority area:models Model architectures, weights, loading, metadata modelsize:medium 4-bit checkpoint 10-50GB; comfortable on a 128GB dev box modeltype:vlm Vision-language model labels Nov 27, 2026
Four vision-side fixes mlx-vlm landed for families mlxcel already ships.

- RF-DETR: the projector's ConvX LayerNorms (every C2f cv1, cv2 and
  bottleneck conv, stored as `bn`) and the final projector norm load at
  eps 1e-6, rfdetr's channel LayerNorm default, instead of nn.LayerNorm's
  1e-5 (Neywa-Labs/mlx-vlm#2709). Segmentation mask logits are upsampled with
  resize_bilinear_nhwc(.., align_corners false, no antialias) and kept at
  `> 0`, as rfdetr's PostProcess does, instead of bicubic
  (Neywa-Labs/mlx-vlm#2713). The other RF-DETR norms already matched and are
  unchanged.
- Muse Glimmer: the reference samples the learned position table with
  meshgrid(pos_h, pos_w, indexing="xy"), so height and width swap roles in
  bilinear_indices_and_weights (Neywa-Labs/mlx-vlm#2746). The flattened order
  changes with them, so every non-square grid gets different embeddings;
  square grids are unchanged. The vision RoPE is not touched.
- Mage-VL-Cowork: microsoft/Mage-VL-Cowork declares
  model_type "llava_onevision2" and stores the tower under bare `visual.*`.
  Detection and the registry aliases map it to Mage-VL, and
  remap_mage_vl_weight_key rewrites `visual.` to `vision_tower.`
  (Neywa-Labs/mlx-vlm#2636). Its preprocessor_config.json has the same
  pixel bounds and normalization keys as Mage-VL's. Its config states
  tie_word_embeddings nowhere, and its lm_head differs from embed_tokens
  (max |diff| 0.177). Transformers' Qwen3 config and mlx-vlm's Mage-VL
  config default to untied, the shared Qwen3 args to tied, so
  mage_vl_text_config now fills in the top-level flag or false. Without
  this the loaded model decoded through the embedding matrix.
- Mage ViT: layernorm_pre, layer_norm1, layer_norm2 and the merger's ln_q
  go through layer_norm_f32 (f32 input, weight and bias, one rounding back
  to the activation dtype), and the MLP and merger GELUs through gelu_f32
  (f32 upcast, one rounding), as upstream's tower does since ae763da4. The
  weights stay in their loaded dtype. The shared kernel in f16 or bf16
  rounds the normalized value before the affine. The bridge GELU widens a
  half input through its f32 constants, but the CUDA build promotes bf16
  with f32 to bf16, so on CUDA a bf16 activation ran the whole GELU in bf16.

Tests: projector eps and the bilinear mask path for RF-DETR, the xy
position-table order and an unchanged square grid for Muse Glimmer, Cowork
detection, key remap and the untied default, and Mage LayerNorm/GELU
rounding against an f32 reference in f16 and bf16. The mask test uses [[-1, 3.2], [3.2, -1]]
rather than [[-1, 1], [1, -1]], which thresholds to the same plane under
both resizes.

Closes lablup#3236
@Jaeyeong-CHOI
Jaeyeong-CHOI force-pushed the fix/3236-vision-parity-fixes branch from e3d915d to 9f2116e Compare November 27, 2026 02:42
@Jaeyeong-CHOI

Copy link
Copy Markdown
Contributor Author

Rebased onto 2b34a2f7a (9f2116eae) after #3456 merged. The only conflict was CHANGELOG.md, where both PRs add an entry under "Fixed"; both are kept. The source files of this PR are unchanged from e3d915d8e. I did not rerun the CUDA gate or the checkpoints on this base.

lablup#3456 moved the DeepSeek-OCR CLIP MLP activation from line 100 to line 106 of `deepseekocr_clip.rs`. This PR refreshes the line references of `docs/gelu-call-sites.md` row V42, so V54 is brought up to date in the same pass to keep the inventory consistent with the code after both land.

Refs lablup#3236, Refs lablup#3460
@inureyes

Copy link
Copy Markdown
Member

Hardening review

Target PR: #3460. Linked issue: #3236.

Findings

Each change was checked against mlx-vlm 466069f5 (references/mlx-vlm):

  • RF-DETR: rfdetr/vision.py builds the projector ConvNorm.bn and the final norm with nn.LayerNorm(.., eps=1e-6); the other norms (backbone 1e-6, decoder 1e-5, segmentation 1e-6) match what the PR leaves alone. generate.py _resize_masks documents and implements F.interpolate(mode="bilinear", align_corners=False) then > 0, which is resize_bilinear_nhwc(.., false, false) plus the existing threshold.
  • Muse Glimmer: muse_glimmer/vision.py _position_embeddings swaps height and width (meshgrid(.., indexing="xy")) before computing the bilinear grid, which is the PR's let (h, w) = (w, h). The RoPE path uses indexing="ij" upstream and is correctly left unchanged.
  • Mage-VL-Cowork: upstream maps llava_onevision2 to mage_vl (utils.py), remaps visual.* to vision_tower.* (mage_vl.py), and both TextConfig and ModelConfig default tie_word_embeddings to False, so the untied fallback matches. A config that omits the flag and also lacks lm_head now fails to load with a missing-weight error, as it would in mlx-vlm.
  • Mage ViT: upstream LayerNorm casts input, weight and bias to float32 and casts back; its GELU is nn.gelu(x.astype(float32)).astype(x.dtype), exact erf. layer_norm_f32 / gelu_f32 reproduce both at all four norm sites and both GELU sites. LayerNorm weights are dense in the quantized checkpoints too, so the quantized path is covered.
  • Security: no new request-controlled sizes. Performance: the f32 casts add a few elementwise ops per tower layer, once per image, none on the decode path.
  • Gap fixed (631d5bbca): after fix(vision): match DeepSeek-OCR CLIP and SAM encoder numerics #3456 merged, docs/gelu-call-sites.md row V54 pointed at deepseekocr_clip.rs:100; the call is now at :106. Updated so the inventory matches the code. Also merged origin/main (with fix(vision): match DeepSeek-OCR CLIP and SAM encoder numerics #3456 and fix(vision): match the Unlimited-OCR processor crop limit and prompt #3473); CHANGELOG.md, docs/gelu-call-sites.md and docs/supported-models.md merged without conflict and keep all three entries.

Validation (Mac Studio M3 Ultra, Metal, merged tree)

Remote CI was cancelled by maintainer decision; the merge relies on the local checks below.

  • cargo fmt --all -- --check: pass
  • python3 scripts/ci/check_used_by.py: OK
  • cargo clippy -p mlxcel -p mlxcel-core --all-targets --features metal,accelerate -- -D warnings: pass
  • cargo test -p mlxcel --lib --profile test-fast --features metal,accelerate -- <filter> --test-threads=1: rfdetr 25 passed / 2 ignored, mage_vl 30, muse_glimmer 122, detection_tests 113, llava_onevision2 1, registry 73, all passed.
  • No RF-DETR, Mage-VL, Mage-VL-Cowork or Muse Glimmer checkpoint is present on this host, so the PR's GB10 mask, trace and generation results were not reproduced here. The bf16-on-CUDA GELU case is only reachable on CUDA.

@inureyes
inureyes merged commit 03692be into lablup:main Nov 27, 2026
28 of 33 checks passed
@inureyes inureyes added this to the 0.9 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:models Model architectures, weights, loading, metadata modelsize:medium 4-bit checkpoint 10-50GB; comfortable on a 128GB dev box modeltype:vlm Vision-language model priority:medium Medium priority status:review Under review type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(vision): RF-DETR, Muse Glimmer and Mage-VL-Cowork parity fixes

2 participants