Repository navigation
fix: close remaining vision resize and frame-sampling parity gaps - #3490
Merged
Merged
Conversation
Frame indices in uniform_indices, evenly_spaced_indices, Gemma 4 uniform_sample_frames and Inkling pair anchors now round half to even, as numpy and Python round do, so a tie samples the same frame as the reference. The Qwen2-VL family, dots.ocr and Hunyuan-VL smart_resize drop the one-factor floor from the first rounding step, so a thin edge that rounds to 0 takes the min_pixels branch like transformers (10x1000 at factor 28 is 28x560). The result is floored at one factor only when min_pixels is 0. The qwen2_vl 200:1 cap trim now also runs after the min_pixels branch. ERNIE 4.5 VL follows the processing_ernie4_5_vl.py its checkpoints ship: it keeps the first-step floor and now clamps ratios past 200:1 as that file does, in u64 arithmetic. Hunyuan-VL rescales a zero edge as one pixel in saturating u64 instead of overflowing. Validated with the focused processor and multimodal::video tests, clippy and fmt. Closes #3478
inureyes
marked this pull request as ready for review
November 27, 2026 05:21
Member
Author
|
Merge-time validation by the orchestrator, on top of the focused tests in the PR body.
|
5 of 6 tasks
1 task done
inureyes
added a commit
that referenced
this pull request
Nov 28, 2026
## Summary
Adds the bilingual technical reports that were skipped when these three PRs merged on 2026-11-27:
- `TECHNICAL_REPORTS/3489-jiff-1x-strftime-now-20261127.{en,ko}.md` (#3489, jiff 1.0.3 and the `strftime_now` format and zone)
- `TECHNICAL_REPORTS/3490-vision-resize-frame-parity-20261127.{en,ko}.md` (#3490, resize and frame-sampling parity)
- `TECHNICAL_REPORTS/3491-qwen35-mtp-drafter-yarn-20261127.{en,ko}.md` (#3491, YaRN in the Qwen 3.5 MTP drafter)
Each report records the decisions the PR encodes (for example why ERNIE follows the checkpoint's `processing_ernie4_5_vl.py` rather than transformers or mlx-vlm, and why the drafter YaRN table is installed by the binary crate's loader) and what remains unverified.
## Test plan
Docs only. Remote CI was cancelled by maintainer decision.
- [x] Facts cross-checked against the merged diffs, PR bodies and the local validation output
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.
Summary
Closes the four resize and frame-sampling parity gaps left after #3464 and #3466. Each fix lands in the existing preprocessing function, so only the inputs named below change.
uniform_indices,evenly_spaced_indicesand Gemma 4uniform_sample_framesnow round half to even, asnp.linspace(...).round()does (uniform_indices(6, 3)is[0, 2, 5]). Inklingpair_adjacent_frame_indicesswitched too: its reference formula (issue feat(vision): Inkling native video ingestion through adjacent-frame temporal pairs #1323) uses Pythonround, so 12 frames in 5 pairs anchor at[0, 2, 5, 8, 10].min_pixelsbranch (10x1000 at factor 28 is now 28x560, as transformers gives, not 28x1008). The final result is floored at one factor only for themin_pixels == 0case, where the reference returns a zero edge (commented). In qwen2_vl the >200:1 cap trim now also runs after themin_pixelsbranch, because a thin edge can now reach that branch with a long side over a small cap.baidu/ERNIE-4.5-VL-28B-A3B-PT,-Thinking, and the validatedmlx-community/ERNIE-4.5-VL-28B-A3B-Thinking-4bit) shipsprocessing_ernie4_5_vl.py(Ernie4_5_VLImageProcessorthroughauto_map). That file is now the reference. It matches neither transformers nor mlx-vlm exactly. It keeps the first-step one-factor floor, which mlx-vlm also has and transformers lacks, so item 2 does not apply to ERNIE and 10x1000 stays 28x1008. It does not truncate beforeceil, which matches transformers and the current code: 4x15 gives 56x112 here and 28x112 in mlx-vlm. Past 200:1 it clamps the ratio instead of raising, so that clamp is now ported: 10x3000 goes from 28x2996 to 28x5600. The arithmetic now uses u64 soh * wcannot overflow.smart_resize(0, 10)returns 192x1632 instead of overflowing.max(factor, round_by_factor(..)).Changed expectations
No existing expectation changed. Each old test input gives the same result under the transformers or checkpoint reference: the zero-edge tests still give (28, 196) and (56, 56), and the ERNIE tie and out-of-bounds tests match the checkpoint code. The only edit to an existing test is in the
load_videodecode test (video_tests.rs), where the expected-index helper now rounds half to even. Index 12 becomes 24, which is still inside the color tolerance.Every new expected value was computed with the Python reference: transformers 5.16.1
smart_resizefor qwen2_vl, dots (qwen2_vl bounds) and hunyuan_vl, the checkpoint'sprocessing_ernie4_5_vl.pyfor ERNIE, and numpy for the frame indices. Each test's doc comment shows the arithmetic. The ERNIE thin-image and 4x15 tests pass on main by design, because the checkpoint code agrees with the current arithmetic there. The ratio-clamp test fails on main.Test plan
Remote CI was cancelled by maintainer decision. Local validation only:
cargo fmt --all -- --checkcargo clippy -p mlxcel --lib --tests --features metal,accelerate -- -D warningscargo test -p mlxcel --lib --profile test-fast --features metal,acceleratefiltered tovision::processors::{qwen2_vl,dots_ocr,ernie4_5_vl,hunyuan_vl,gemma4}andmultimodal::video: qwen2_vl 14, dots_ocr 6, ernie4_5_vl 8, hunyuan_vl 4, gemma4 21 (1 ignored), multimodal::video 57 (11 ignored, ffmpeg-fixture gated) passed, 0 failedCloses #3478