Decode with padded video masks for Qwen3 models#4461
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
187ab0b to
82a9c5a
Compare
82a9c5a to
ead0c93
Compare
|
🤖 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. |
There was a problem hiding this comment.
This Pull Request successfully introduces end-to-end decode support for padded and resized video inputs in Qwen3* multimodal models. It elegantly manages the propagation of video masks, handles post-projector token-mask downsampling, and correctly configures positional embedding interpolation under JIT compilation. The implementation is highly professional, clean, and backed by robust unit tests.
🔍 General Feedback
- Excellent Test Coverage: Great addition of comprehensive unit tests in
multimodal_utils_test.pyandqwen3_omni_layers_test.pyverifying mask downsampling and token-level embedding merging. - Flax and NNX Uniformity: Outstanding consistency in integrating the new multimodal features across both the Flax/Linen and NNX model execution paths.
- Future-proofing
VisionEncoder: Insrc/maxtext/layers/encoders.py(which is not modified in this PR),VisionEncoder.__call__currently only propagatesvideo_grid_thwto the underlying encoder ifinput_masksis notNone. Consider decoupling this check in a future PR to support unpadded videos that require grid information but do not use padding masks.
|
🤖 I'm sorry @hengtaoguo, but I was unable to process your request. Please see the logs for more details. |
1 similar comment
|
🤖 I'm sorry @hengtaoguo, but I was unable to process your request. Please see the logs for more details. |
b655517 to
cd774f5
Compare
cd774f5 to
ef76736
Compare
Description
E2E decode now works for padded/resized video input:
video_masks, video_grid_thwthrough MaxEngine and the vision encoder.Tests
Original video grid [5, 30, 28], tensor size [10, 480, 448]:
Padded video [5, 30, 28] -> [32, 32, 32], tensor size [64, 512, 512].
video_max_grid_t/h/w=32, attention_for_vit="autoselected"The output string is basically identical, and drifted after ~35 tokens generation. This could be caused by small numerical differences in ViT attention kernel using
dot_product vs autoselected.Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.