-
Notifications
You must be signed in to change notification settings - Fork 1.8k
enh: Lift expectation of single image per sample in Gemma3 VLM #6195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enh: Lift expectation of single image per sample in Gemma3 VLM #6195
Conversation
Warning Rate limit exceeded@brb-nv has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 30 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughAudio modality support is added to the multimodal input utilities, including audio loading functions and placeholder handling for the new "phi4mm" model group. The Gemma3 vision-language model's preprocessing is updated to allow multiple images and add debug prints. Test code for Gemma3 is updated to use a weight mapper during model loading. Changes
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (6)
tensorrt_llm/_torch/models/modeling_gemma3vl.py (3)
48-51
: Remove commented-out validation code.Since the single image restriction is being lifted, this commented-out validation code should be removed rather than left as comments for cleaner code maintenance.
Apply this diff to remove the commented code:
- # if images and len(images) != 1: - # print(f"RECEIVED MORE THAN ONE IMAGE FOR PROCESSING. len(images): {len(images)}.") - # for img_idx, img in enumerate(images): - # print(f"[Gemma3InputProcessor::_preprocess] img_idx: {img_idx}, img.shape: {img.shape}")
65-69
: Consider removing debug print statements for production code.While helpful for development, these commented-out debug print statements should be removed before merging to maintain clean code.
Apply this diff to remove the commented debug prints:
- # for img_idx, pixel_value in enumerate(pixel_values): - # print(f"[Gemma3InputProcessor::_preprocess] pixel_idx: {img_idx}, pixel_value.shape: {pixel_value.shape}") - - # print(f"[Gemma3InputProcessor::_preprocess] input_ids: {input_ids}, pixel_values: {pixel_values}") -
202-205
: Remove debug print statements from production code.These debug print statements should be removed before merging to avoid cluttering production logs and maintain code cleanliness.
Apply this diff to remove the debug prints:
- print(f"[Gemma3VLM::forward] pixel_values concat shape: {torch.cat(pixel_values).shape}") image_features = self._get_image_features( pixel_values=torch.cat(pixel_values)) - print(f"[Gemma3VLM::forward] image_features shape: {image_features.shape}")tensorrt_llm/inputs/utils.py (3)
441-441
: Remove debug print statement from production code.This debug print should be removed before merging to avoid cluttering production logs.
Apply this diff to remove the debug print:
- print(f"[default_multimodal_input_loader::convert_to_conversation_message] prompts: {prompts}, media: {media}, modality: {modality}")
483-487
: Remove debug instrumentation from production code.These debug print statements should be removed before merging for cleaner production code.
Apply this diff to remove the debug prints:
- idx = 0 for prompt, media in zip(prompts, media): - print(f"[default_multimodal_input_loader::apply_chat_template] idx: {idx}, prompt: {prompt}, media: {media}") conv = convert_to_conversation_message(prompt, media, modality) - print(f"[default_multimodal_input_loader::apply_chat_template] conv: {conv}")
507-511
: Remove debug prints and unnecessary counter variable.The debug prints and the
idx
counter variable should be removed for production code.Apply this diff to remove the debug instrumentation:
- idx += 1 - - print(f"[default_multimodal_input_loader::inputs] inputs[-1]: {inputs[-1]}") - # for img_idx, img in enumerate(inputs[-1]["multi_modal_data"]["image"]): - # print(f"[default_multimodal_input_loader::inputs] img_idx: {img_idx}, img.shape: {img.shape}")
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
tensorrt_llm/_torch/attention_backend/flashinfer.py
(2 hunks)tensorrt_llm/_torch/models/modeling_gemma3vl.py
(2 hunks)tensorrt_llm/bench/benchmark/utils/asynchronous.py
(1 hunks)tensorrt_llm/inputs/utils.py
(3 hunks)tests/unittest/_torch/modeling/test_modeling_gemma3.py
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Pre-commit Check
🔇 Additional comments (7)
tensorrt_llm/bench/benchmark/utils/asynchronous.py (1)
50-52
: LGTM! Enhanced error reporting improves debugging.The change from a generic error message to including the actual exception details will significantly improve debugging capabilities when tasks fail during inference.
tensorrt_llm/_torch/attention_backend/flashinfer.py (2)
300-309
: Excellent cache management improvement for attention plan wrappers.The logic correctly distinguishes between plan parameters with and without custom attention masks. Removing entries with non-trivial
attention_mask_data
from the cache is the right approach since these are specific to individual forward passes and shouldn't persist for subsequent calls.
435-435
: Minor comment punctuation fix.Good catch on the comment formatting.
tensorrt_llm/_torch/models/modeling_gemma3vl.py (1)
53-57
: Excellent update to support multiple images per sample.The changes correctly remove the single image restriction and pass the full list of images to the processor, aligning perfectly with the PR objective.
tests/unittest/_torch/modeling/test_modeling_gemma3.py (3)
13-14
: Good addition of AttentionMetadata import for type checking.The import addition supports the new test helper method's type annotations.
218-230
: Excellent test coverage for attention plan cache management.This helper method provides thorough validation of the new cache-flushing behavior:
- Verifies that plan parameters with custom masks exist after forward pass
- Confirms they are properly flushed after calling
prepare()
The test correctly validates the cache management improvement introduced in the FlashInfer backend.
346-346
: Good integration of cache verification test.The test helper is appropriately called after the forward pass to verify the cache management behavior.
61b0837
to
2cfb277
Compare
Signed-off-by: Balaram Buddharaju <[email protected]>
2cfb277
to
c34706d
Compare
/bot run |
PR_Github #12355 [ run ] triggered by Bot |
PR_Github #12355 [ run ] completed with state |
…A#6195) Signed-off-by: Balaram Buddharaju <[email protected]>
…A#6195) Signed-off-by: Balaram Buddharaju <[email protected]>
…A#6195) Signed-off-by: Balaram Buddharaju <[email protected]> Signed-off-by: Shreyas Misra <[email protected]>
…A#6195) Signed-off-by: Balaram Buddharaju <[email protected]> Signed-off-by: Ransiki Zhang <[email protected]>
Description
Currently, there's a limitation placed on having a single image per sample in Gemma3 VLM. This MR lifts it.
Images tested come from here: http://vision.stanford.edu/aditya86/ImageNetDogs/menu_frame.html
Formatted output looks like this:

Also, attaching stdout from terminal for reference.
multi_image_per_sample.txt
Test Coverage
GitHub Bot Help
/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...
Provide a user friendly way for developers to interact with a Jenkins server.
Run
/bot [-h|--help]
to print this help message.See details below for each supported subcommand.
run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]
Launch build/test pipelines. All previously running jobs will be killed.
--reuse-test (optional)pipeline-id
(OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.--disable-reuse-test
(OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.--disable-fail-fast
(OPTIONAL) : Disable fail fast on build/tests/infra failures.--skip-test
(OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.--stage-list "A10-PyTorch-1, xxx"
(OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.--gpu-type "A30, H100_PCIe"
(OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.--test-backend "pytorch, cpp"
(OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.--only-multi-gpu-test
(OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.--disable-multi-gpu-test
(OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.--add-multi-gpu-test
(OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.--post-merge
(OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx"
(OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".--detailed-log
(OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.--debug
(OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in thestage-list
parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.For guidance on mapping tests to stage names, see
docs/source/reference/ci-overview.md
and the
scripts/test_to_stage_mapping.py
helper.kill
kill
Kill all running builds associated with pull request.
skip
skip --comment COMMENT
Skip testing for latest commit on pull request.
--comment "Reason for skipping build/test"
is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.reuse-pipeline
reuse-pipeline
Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.