[None][chore] Small cleanups to MultimodalModelMixin#15322
Conversation
📝 WalkthroughWalkthroughThis PR simplifies the multimodal encoder contract by changing from returning a ChangesMultimodal Encoder Contract Simplification
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/unittest/_torch/multimodal/test_multimodal_mixin.py (1)
69-70: 📐 Maintainability & Code Quality | ⚡ Quick winCoverage misses the cacheable tensor path.
make_raw_multimodal_param()omitsmultimodal_runtime.total_embeds_in_request, so this test only exercises the early-return path inget_multimodal_embeddings()and the "skip validation" branch inMultimodalModelMixin._validate_embeddings(). Please add cases intests/unittest/_torch/multimodal/test_multimodal_mixin.pythat populate runtime metadata and assert both successful cache/gather of tensor-returning encoders and aValueErroron row-count mismatch.As per coding guidelines, changes under
tests/**should explicitly call out whether coverage is sufficient and identify concrete follow-up files.Also applies to: 107-138
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unittest/_torch/multimodal/test_multimodal_mixin.py` around lines 69 - 70, The test helper make_raw_multimodal_param() currently omits multimodal_runtime.total_embeds_in_request so tests only hit the early-return branch of get_multimodal_embeddings() and the "skip validation" branch of MultimodalModelMixin._validate_embeddings(); update the unit tests to (1) add cases that populate MultimodalParams.multimodal_runtime.total_embeds_in_request with the expected row count, (2) verify that tensor-returning encoders are cached/gathered correctly (exercise the cacheable tensor path in get_multimodal_embeddings and the gather logic), and (3) add a failing case where total_embeds_in_request mismatches actual returned rows and assert a ValueError from _validate_embeddings; target the tests around make_raw_multimodal_param(), get_multimodal_embeddings, and MultimodalModelMixin._validate_embeddings so coverage includes both successful cache/gather and row-count mismatch branches.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tensorrt_llm/_torch/models/modeling_multimodal_mixin.py`:
- Around line 285-290: The current early-return accepts mixed runtime metadata
and causes inconsistent slicing; change the check around the existing "if
runtime is None or runtime.total_embeds_in_request is None:" so you instead
inspect all multimodal_params' runtime/total_embeds_in_request: if every param
lacks runtime.total_embeds_in_request, keep the debug log and return; if some
params have it and some don't, raise an error (ValueError) immediately to fail
fast; update the code path in the same function (referencing multimodal_params,
runtime, total_embeds_in_request and find_input_mm_embeds) to implement this
all-or-none validation.
---
Nitpick comments:
In `@tests/unittest/_torch/multimodal/test_multimodal_mixin.py`:
- Around line 69-70: The test helper make_raw_multimodal_param() currently omits
multimodal_runtime.total_embeds_in_request so tests only hit the early-return
branch of get_multimodal_embeddings() and the "skip validation" branch of
MultimodalModelMixin._validate_embeddings(); update the unit tests to (1) add
cases that populate MultimodalParams.multimodal_runtime.total_embeds_in_request
with the expected row count, (2) verify that tensor-returning encoders are
cached/gathered correctly (exercise the cacheable tensor path in
get_multimodal_embeddings and the gather logic), and (3) add a failing case
where total_embeds_in_request mismatches actual returned rows and assert a
ValueError from _validate_embeddings; target the tests around
make_raw_multimodal_param(), get_multimodal_embeddings, and
MultimodalModelMixin._validate_embeddings so coverage includes both successful
cache/gather and row-count mismatch branches.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 1f1f4bf9-dd79-43d1-87a6-8a1c8794089d
📒 Files selected for processing (4)
tensorrt_llm/_torch/models/modeling_mistral.pytensorrt_llm/_torch/models/modeling_multimodal_mixin.pytensorrt_llm/_torch/models/modeling_multimodal_utils.pytests/unittest/_torch/multimodal/test_multimodal_mixin.py
733542c to
1247439
Compare
|
/bot run |
|
PR_Github #54019 [ run ] triggered by Bot. Commit: |
|
PR_Github #54019 [ run ] completed with state
|
|
/bot run |
|
PR_Github #54090 [ run ] triggered by Bot. Commit: |
|
PR_Github #54090 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
👎 Promotion blocked, new vulnerability foundVulnerability report
|
Signed-off-by: William Zhang <133824995+2ez4bz@users.noreply.github.com>
f283e2a to
796222d
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #54904 [ run ] triggered by Bot. Commit: |
|
PR_Github #54904 [ run ] completed with state
|
Summary by CodeRabbit
Refactor
Tests
Description
Test Coverage
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.