Repository navigation
core/picture: patches, the processor geometry out of qwen_vl (torchvision resize and fused normalization as options) - #1584
Merged
Conversation
This was referenced Oct 29, 2026
Open
Merged
…ut of qwen_vl smart_resize, the pixel bounds and the merge-order patchify move to core/picture/patches.zig over a Patches value (patch geometry, bounds, rescale, mean and std). core/qwen_vl/geometry.zig keeps its API as a thin wrapper over Config.patches(), so every caller and Qwen-VL's bits stay as they were. Two options for processors on transformers' torchvision backend, both off by default: resize = .torch (its antialiased uint8 bicubic, already in picture/resample) and fused = true, which normalizes as (x - mean / rescale) / (std / rescale) in float32. patches_test.zig checks them against transformers 5.19's Lfm3VlImageProcessor on five synthetic pictures (sha256 of pixel_values), and shows that Pillow's resize or the unfused normalization each miss those bits.
ashhart
force-pushed
the
core-picture-patches
branch
from
October 29, 2026 23:42
1325da3 to
1c298e4
Compare
Owner
|
Thank you @jschmied. This is in TensorFold 1.2.0, released today: https://github.com/ashhart/TensorFold/releases/tag/v1.2.0 It landed with your commits under your own name, so you're listed as a TensorFold contributor, and it's credited to you in the release notes and the changelog. |
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.
core/qwen_vl/geometry.zigis the processor geometry every Qwen-VL-style tower needs (smart_resize, pixel bounds, merge-order patches), but it lives under a Qwen name and takes Qwen'sConfig. LFM3-VL's processor uses the same geometry (patch 16, merge 2, temporal 2), so this moves it tocore/picture/patches.zigbefore the LFM3-VL CUDA tower (#1491, CUDA side) uses it.What
core/picture/patches.zig:Patches(patch geometry, pixel bounds, rescale, mean, std), plussmartResize,bounds,prepare,prepareRgbandpatchify, moved unchanged. The smart_resize test moves with them.core/qwen_vl/geometry.zigkeeps its API as a thin wrapper over the newConfig.patches(). Every caller (Flash-Next, qwen27, qwen3_5,vision/qwen_cuda.zig) is untouched, and its remaining tests pass through the wrapper.resize = .torch: its antialiased uint8 bicubic, already inpicture/resample.zig;fused = true: normalizes as(x - mean / rescale) / (std / rescale)in float32, the wayTorchvisionBackend.rescale_and_normalizefuses it. The default rescales first and differs by up to 1 ulp.Verification
patches_test.zigruns both options against transformers 5.19.0'sLfm3VlImageProcessor(torchvision 0.29.0) on five synthetic pictures, one upscaled, one wide, a downscaled 2000 x 3000 and two near-square. It compares the sha256 ofpixel_valuesand the grid, and all five are bit-equal.zig build test: RC 0, no errors. Lean shows nothing new.Not checked here: whether a Qwen-VL processor on current transformers also takes the torchvision path. If it does, the Qwen-VL ports would want these options too. I'll open that as a separate question.