Add video-scaling function for SFT padding#4353
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
hengtaoguo
force-pushed
the
hengtaoguo-sft-video
branch
from
July 5, 2026 04:22
5eead93 to
d586be8
Compare
Contributor
|
🤖 Hi @hengtaoguo, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
Contributor
There was a problem hiding this comment.
This PR introduces video rescaling functionality (scale_to_fit_video_grid) to proactively prevent sequence shape crashes during padding by enforcing the video_max_grid_h/w constraints. The test additions are well thought out and the fix for audio_end token appending is correct.
🔍 General Feedback
- The core implementation of aspect-ratio preserving downscaling is solid and functionally sound.
- There are a few edge cases related to floating point precision and consistency of the image scaling factor between the intermediate and final steps of the preprocessing pipeline that should be addressed.
- Great job adding the unit tests to explicitly verify the grid limits and downscaling behavior!
hengtaoguo
force-pushed
the
hengtaoguo-sft-video
branch
from
July 6, 2026 18:27
1b7817d to
f2c6658
Compare
hengtaoguo
marked this pull request as ready for review
July 6, 2026 18:37
hengtaoguo
requested review from
A9isha,
NicoGrande,
NuojCheng,
RissyRan,
SurbhiJainUSC,
abhinavclemson,
aireenmei,
bvandermoon,
darisoy,
dipannita08,
gagika,
gobbleturk,
igorts-git,
jiangjy1982,
khatwanimohit,
richjames0,
shralex,
suexu1025,
vipannalla and
xibinliu
as code owners
July 6, 2026 18:37
abhinavclemson
approved these changes
Jul 6, 2026
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.
Description
Scale-to-fit before padding in video preprocessor and fix audio-in-video sequence serialization. This PR serves as the groundwork for varied-size video SFT:
smart_resize()preprocessing step in Qwen3-Omni image preprocessor to proportionally downscale videos exceedingmax_h/w_pixels(resolving downstream shape crashes during batch padding) while preserving aspect ratio as closely as possible..test_scale_to_fit_video_before_paddingto verify correct aspect-ratio preserving downscaling and successful padding setup.add_extra_tokens_for_qwen3_omniwhere<|audio_pad|>(151675) was appended at the end of the interleaved video-audio sequence instead of<|audio_end|>(151670).Tests
Example: Video of (220, 896) is resized to (128, 512) by new
smart_resize: divisible by factor 32 and didn't exceed max canvas 512, preserving the aspect ratio as closely as possible:Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.