You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(vision): DeepSeek-OCR CLIP encoder parity is off the mlx-vlm reference on CUDA #3563
sam_and_clip_encoders_match_reference in tests/deepseekocr_encoder_parity.rs (gated on models/deepseek-ocr-4bit, vision weights bf16) fails on GB10 (spark-102, sm_121, CUDA) at tests/deepseekocr_encoder_parity.rs:88 with CLIP absmean 0.130644 off reference.
SAM passes (reference 0.04304, tol 0.002). CLIP's reference is 0.14356 with tol 0.005, so the gap is about 0.013 (roughly 9%), well outside bf16 drift.
It fails identically on main at the previous MLX pin (fc344c98, commit bb0c8b3) and at the new pin 5a48f9cc (#3517), so it predates the pin bump. It surfaced during the #3517 GB10 gate (make verify-test-cuda). Not yet checked: the Metal result, and when it started on CUDA. The test file was last changed by #651 (initial) and #2682 (quantized vision parameter loading hardening).
Since SAM matches and CLIP does not, the gap is in the CLIP path (ClipEncoder::from_weights(&weights, "vision_model", ClipConfig::default(), 64, 4), src/vision/encoders/deepseekocr_clip.rs) or the SAM-to-CLIP handoff on CUDA.
cargo test -p mlxcel --features cuda --profile test-fast --test deepseekocr_encoder_parity -- --test-threads=1
Acceptance Criteria
Determine whether the test passes on Metal (CUDA-only vs. both backends)
Root cause found, by bisect or a per-layer diff against mlx-vlm using the reference script the test header names (ref_dsocr_enc2.py)
Fixed so the test passes on GB10 with the existing tolerance; do not widen the tolerance without a diagnosed numeric reason
Root cause: the test's expected CLIP absmean (0.14356) described the old erf GELU MLP. Since #3456 the encoder has used mlx-vlm's quick GELU, so the model was right and the reference was stale. No inference change and no tolerance change.
Measured on GB10 with checkpoint revision 4958b6b:
The erf variant sits about 2.6 times outside the unchanged 0.005 tolerance, so the test still rejects the old activation. The contributor's per-layer diff in #3578 tracks mlx-vlm at blocks 1, 6, 12, 18 and 24. The test's pointer to the missing scratchpad script now points to scripts/deepseekocr_encoder_reference.py, and the checkpoint lookup honors MLXCEL_REQUIRE_MODELS=1. The contributor reported a passing make verify-test-cuda run that included this test.
Not done: the Metal run of this test. The change only touches the expected value and the activation is backend-independent, so we are closing without it.
Activity
fix(vision): make the DeepSeek-OCR encoder reference runnable and gated
test(vision): refresh the DeepSeek-OCR CLIP reference for quick GELU (#…
inureyes commentedon Nov 30, 2026
Resolved by #3578 (
2292469c).Root cause: the test's expected CLIP absmean (0.14356) described the old erf GELU MLP. Since #3456 the encoder has used mlx-vlm's quick GELU, so the model was right and the reference was stale. No inference change and no tolerance change.
Measured on GB10 with checkpoint revision
4958b6b:The erf variant sits about 2.6 times outside the unchanged 0.005 tolerance, so the test still rejects the old activation. The contributor's per-layer diff in #3578 tracks mlx-vlm at blocks 1, 6, 12, 18 and 24. The test's pointer to the missing scratchpad script now points to
scripts/deepseekocr_encoder_reference.py, and the checkpoint lookup honorsMLXCEL_REQUIRE_MODELS=1. The contributor reported a passingmake verify-test-cudarun that included this test.Not done: the Metal run of this test. The change only touches the expected value and the activation is backend-independent, so we are closing without it.