Skip to content

[https://nvbugs/6157892] [fix] MistralCommonImageProcessor text-only path#13916

Open
evezhier wants to merge 1 commit intoNVIDIA:mainfrom
evezhier:fix/mistral-processor
Open

[https://nvbugs/6157892] [fix] MistralCommonImageProcessor text-only path#13916
evezhier wants to merge 1 commit intoNVIDIA:mainfrom
evezhier:fix/mistral-processor

Conversation

@evezhier
Copy link
Copy Markdown
Collaborator

@evezhier evezhier commented May 8, 2026

Summary by CodeRabbit

  • New Features
    • Image processor now supports text-only processing mode with images as an optional parameter, allowing flexible usage without requiring image input.

Description

Allows text-only path (images optional)for MistralCommonImageProcessor

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)

  • 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.

Signed-off-by: Olya Kozlova <okozlova@nvidia.com>
@evezhier evezhier requested review from a team as code owners May 8, 2026 19:38
@evezhier evezhier requested review from jdebache and symphonylyh May 8, 2026 19:38
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The MistralCommonImageProcessor.__call__ method signature was modified to make the images parameter optional by assigning a default empty list value. This change allows the processor to be called in text-only mode without requiring an explicit images argument.

Changes

Optional Images Parameter

Layer / File(s) Summary
Method Signature Update
tensorrt_llm/_torch/models/modeling_mistral.py
The images parameter in MistralCommonImageProcessor.__call__ is changed from required to optional with a default value of an empty list, enabling text-only processing mode.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description section is incomplete; it provides a brief summary but lacks detailed explanation of the issue, solution, and test coverage information. Provide more detailed context about the bug/issue being fixed, explain why making images optional is needed, and list specific test cases that validate the text-only path.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and specifically describes the main change: enabling a text-only path with optional images for MistralCommonImageProcessor.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tensorrt_llm/_torch/models/modeling_mistral.py (1)

1-1: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add/update NVIDIA copyright header in this modified file.

This file is modified in this PR and currently has no NVIDIA copyright header at the top.

As per coding guidelines: "All C++, Python, and other source files must contain NVIDIA copyright header with current modification year".

🤖 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 `@tensorrt_llm/_torch/models/modeling_mistral.py` at line 1, Add or update the
NVIDIA copyright header at the top of
tensorrt_llm/_torch/models/modeling_mistral.py (above the existing "import copy"
statement) so the modified file includes the required NVIDIA copyright header
with the current modification year; insert the standard multi-line header block
as used across the repo, ensuring it appears before any imports or code in the
module.
🤖 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_mistral.py`:
- Line 312: The method MistralCommonImageProcessor.__call__ uses a mutable
default parameter images=[], which can be shared across calls; change the
signature to use images=None and inside the method initialize it with images =
[] if images is None, updating any subsequent references to the parameter
accordingly (ensure no other logic depends on an empty-list default at function
definition time).

---

Outside diff comments:
In `@tensorrt_llm/_torch/models/modeling_mistral.py`:
- Line 1: Add or update the NVIDIA copyright header at the top of
tensorrt_llm/_torch/models/modeling_mistral.py (above the existing "import copy"
statement) so the modified file includes the required NVIDIA copyright header
with the current modification year; insert the standard multi-line header block
as used across the repo, ensuring it appears before any imports or code in the
module.
🪄 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: bc4f39f5-2abf-48cc-803a-c421816541ae

📥 Commits

Reviewing files that changed from the base of the PR and between f8572ab and e209560.

📒 Files selected for processing (1)
  • tensorrt_llm/_torch/models/modeling_mistral.py

return ncols * nrows + nrows

def __call__(self, text, images, **kwargs):
def __call__(self, text, images=[], **kwargs):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

python - <<'PY'
import ast
from pathlib import Path

path = Path("tensorrt_llm/_torch/models/modeling_mistral.py")
tree = ast.parse(path.read_text())

for node in ast.walk(tree):
    if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
        for default in node.args.defaults:
            if isinstance(default, (ast.List, ast.Dict, ast.Set)):
                print(f"{path}:{default.lineno} -> {node.name} has mutable default")
PY

Repository: NVIDIA/TensorRT-LLM

Length of output: 1960


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# List files to understand the structure
fd "modeling_mistral.py" --type f

Repository: NVIDIA/TensorRT-LLM

Length of output: 166


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check file size first
wc -l tensorrt_llm/_torch/models/modeling_mistral.py

# Read around line 312 to get context
sed -n '300,320p' tensorrt_llm/_torch/models/modeling_mistral.py

Repository: NVIDIA/TensorRT-LLM

Length of output: 789


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Run AST analysis to find all mutable defaults in the file
python - <<'PY'
import ast
from pathlib import Path

path = Path("tensorrt_llm/_torch/models/modeling_mistral.py")
tree = ast.parse(path.read_text())

mutable_defaults = []
for node in ast.walk(tree):
    if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
        for i, default in enumerate(node.args.defaults):
            if isinstance(default, (ast.List, ast.Dict, ast.Set)):
                mutable_defaults.append({
                    'line': default.lineno,
                    'function': node.name,
                    'type': type(default).__name__
                })
        # Also check kw_defaults for keyword-only args
        for i, default in enumerate(node.args.kw_defaults):
            if default and isinstance(default, (ast.List, ast.Dict, ast.Set)):
                mutable_defaults.append({
                    'line': default.lineno,
                    'function': node.name,
                    'type': type(default).__name__
                })

if mutable_defaults:
    for item in mutable_defaults:
        print(f"Line {item['line']}: {item['function']} has mutable default ({item['type']})")
else:
    print("No mutable defaults found")
PY

Repository: NVIDIA/TensorRT-LLM

Length of output: 109


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Get broader context to see the class name
sed -n '280,320p' tensorrt_llm/_torch/models/modeling_mistral.py | grep -E "^class |def __call__"

# Also check for the class definition
grep -n "class.*ImageProcessor" tensorrt_llm/_torch/models/modeling_mistral.py | head -5

Repository: NVIDIA/TensorRT-LLM

Length of output: 153


Fix mutable default argument images=[] in MistralCommonImageProcessor.__call__.

Line 312 uses images=[], which creates a shared mutable default across invocations. Change to images=None with conditional initialization.

Proposed fix
-    def __call__(self, text, images=[], **kwargs):
+    def __call__(self, text, images=None, **kwargs):
+        if images is None:
+            images = []
         mm_items = []
🧰 Tools
🪛 Ruff (0.15.12)

[warning] 312-312: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)

🤖 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 `@tensorrt_llm/_torch/models/modeling_mistral.py` at line 312, The method
MistralCommonImageProcessor.__call__ uses a mutable default parameter images=[],
which can be shared across calls; change the signature to use images=None and
inside the method initialize it with images = [] if images is None, updating any
subsequent references to the parameter accordingly (ensure no other logic
depends on an empty-list default at function definition time).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant