Skip to content

[TRTLLM-11272][fix] Account for the existing multimodal placeholder tokens in a text prompt#12827

Merged
2ez4bz merged 2 commits intoNVIDIA:mainfrom
moraxu:dev-mguzek-account-for-existing-placeholder-tokens
Apr 20, 2026
Merged

[TRTLLM-11272][fix] Account for the existing multimodal placeholder tokens in a text prompt#12827
2ez4bz merged 2 commits intoNVIDIA:mainfrom
moraxu:dev-mguzek-account-for-existing-placeholder-tokens

Conversation

@moraxu
Copy link
Copy Markdown
Collaborator

@moraxu moraxu commented Apr 8, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Fixed multimodal placeholder handling to prevent duplicate insertion when placeholders already exist in text prompts. The function now correctly identifies existing placeholders and only adds the necessary ones, improving reliability of multimodal input processing.

Description

Account for the existing multimodal placeholder tokens in a text prompt

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.

@moraxu moraxu requested a review from 2ez4bz April 8, 2026 06:52
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

A utility function in tensorrt_llm/inputs/utils.py was enhanced to prevent duplicate placeholder insertion by checking for existing occurrences in the text prompt and calculating the needed count as the difference between required and existing placeholders.

Changes

Cohort / File(s) Summary
Placeholder Deduplication
tensorrt_llm/inputs/utils.py
Updated add_multimodal_placeholders to iterate through mm_placeholder_counts.items(), count existing placeholder occurrences in text_prompt, compute needed placeholders as max(0, count - existing), and early-return unchanged prompt when no insertion is required. Expanded docstring to document this subtraction behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete. While it includes a brief summary matching the title, the 'Test Coverage' and 'PR Checklist' sections are largely empty without specific test information or explicit completion of required checklist items. Add specific test cases that verify the placeholder deduplication logic and mark checklist items as completed to confirm adherence to coding guidelines and testing requirements.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: accounting for existing multimodal placeholder tokens in text prompts, matching the file-level changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

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

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.

🧹 Nitpick comments (1)
tensorrt_llm/inputs/utils.py (1)

548-553: Add regression tests for the new subtraction behavior.

The logic change looks correct, but please add targeted tests for: existing == count, existing > count, and mixed placeholder keys in one prompt to lock this behavior in.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tensorrt_llm/inputs/utils.py` around lines 548 - 553, Add unit tests for the
placeholder-subtraction logic around mm_placeholder_counts and text_prompt:
create tests exercising (1) existing == count (no placeholders added), (2)
existing > count (no negative additions and no removals), and (3) a mixed prompt
containing multiple different placeholder keys to ensure combined counts are
handled correctly; each test should call the function that builds placeholders
(referencing mm_placeholder_counts, text_prompt, and placeholders) and assert
the returned text_prompt or resulting placeholders list matches the expected
behavior for those three scenarios.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tensorrt_llm/inputs/utils.py`:
- Around line 548-553: Add unit tests for the placeholder-subtraction logic
around mm_placeholder_counts and text_prompt: create tests exercising (1)
existing == count (no placeholders added), (2) existing > count (no negative
additions and no removals), and (3) a mixed prompt containing multiple different
placeholder keys to ensure combined counts are handled correctly; each test
should call the function that builds placeholders (referencing
mm_placeholder_counts, text_prompt, and placeholders) and assert the returned
text_prompt or resulting placeholders list matches the expected behavior for
those three scenarios.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2c150b1c-49b2-4703-a774-7c369c61c04e

📥 Commits

Reviewing files that changed from the base of the PR and between 0b5289f and 980c86f.

📒 Files selected for processing (1)
  • tensorrt_llm/inputs/utils.py

@2ez4bz
Copy link
Copy Markdown
Collaborator

2ez4bz commented Apr 8, 2026

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42376 [ run ] triggered by Bot. Commit: 980c86f Link to invocation

Copy link
Copy Markdown
Collaborator

@2ez4bz 2ez4bz left a comment

Choose a reason for hiding this comment

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

Can you add a unit test for the scenario this fixes?

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42376 [ run ] completed with state SUCCESS. Commit: 980c86f
/LLM/main/L0_MergeRequest_PR pipeline #33155 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@2ez4bz
Copy link
Copy Markdown
Collaborator

2ez4bz commented Apr 8, 2026

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42395 [ run ] triggered by Bot. Commit: 980c86f Link to invocation

@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 8, 2026

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42413 [ run ] triggered by Bot. Commit: 88bd14c Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42413 [ run ] completed with state SUCCESS. Commit: 88bd14c
/LLM/main/L0_MergeRequest_PR pipeline #33183 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 9, 2026

/bot run

2 similar comments
@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 9, 2026

/bot run

@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 9, 2026

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42588 [ run ] triggered by Bot. Commit: 88bd14c Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42588 [ run ] completed with state SUCCESS. Commit: 88bd14c
/LLM/main/L0_MergeRequest_PR pipeline #33314 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 10, 2026

/bot run

1 similar comment
@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 10, 2026

/bot run

@moraxu moraxu force-pushed the dev-mguzek-account-for-existing-placeholder-tokens branch from 88bd14c to a23ad14 Compare April 13, 2026 17:51
@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 13, 2026

/bot run

1 similar comment
@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 13, 2026

/bot run

moraxu added 2 commits April 15, 2026 08:56
Signed-off-by: Michal Guzek <mguzek@nvidia.com>
Signed-off-by: Michal Guzek <mguzek@nvidia.com>
@moraxu moraxu force-pushed the dev-mguzek-account-for-existing-placeholder-tokens branch from a23ad14 to 40c0669 Compare April 15, 2026 15:57
@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 15, 2026

/bot run

2 similar comments
@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 15, 2026

/bot run

@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 15, 2026

/bot run

@brb-nv
Copy link
Copy Markdown
Collaborator

brb-nv commented Apr 15, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #43965 [ run ] triggered by Bot. Commit: 40c0669 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #43965 [ run ] completed with state SUCCESS. Commit: 40c0669
/LLM/main/L0_MergeRequest_PR pipeline #34408 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 17, 2026

/bot run

4 similar comments
@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 17, 2026

/bot run

@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 17, 2026

/bot run

@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 17, 2026

/bot run

@2ez4bz
Copy link
Copy Markdown
Collaborator

2ez4bz commented Apr 17, 2026

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44073 [ run ] triggered by Bot. Commit: 40c0669 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44073 [ run ] completed with state FAILURE. Commit: 40c0669
/LLM/main/L0_MergeRequest_PR pipeline #34503 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 18, 2026

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44135 [ run ] triggered by Bot. Commit: 40c0669 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44135 [ run ] completed with state SUCCESS. Commit: 40c0669
/LLM/main/L0_MergeRequest_PR pipeline #34562 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 19, 2026

/bot run

1 similar comment
@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 19, 2026

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44145 [ run ] triggered by Bot. Commit: 40c0669 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44145 [ run ] completed with state SUCCESS. Commit: 40c0669
/LLM/main/L0_MergeRequest_PR pipeline #34572 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 19, 2026

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44152 [ run ] triggered by Bot. Commit: 40c0669 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44152 [ run ] completed with state SUCCESS. Commit: 40c0669
/LLM/main/L0_MergeRequest_PR pipeline #34579 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@2ez4bz
Copy link
Copy Markdown
Collaborator

2ez4bz commented Apr 19, 2026

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44165 [ run ] triggered by Bot. Commit: 40c0669 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44165 [ run ] completed with state FAILURE. Commit: 40c0669
/LLM/main/L0_MergeRequest_PR pipeline #34592 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@2ez4bz
Copy link
Copy Markdown
Collaborator

2ez4bz commented Apr 19, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44223 [ run ] triggered by Bot. Commit: 40c0669 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44223 [ run ] completed with state FAILURE. Commit: 40c0669
/LLM/main/L0_MergeRequest_PR pipeline #34646 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@moraxu
Copy link
Copy Markdown
Collaborator Author

moraxu commented Apr 20, 2026

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44268 [ run ] triggered by Bot. Commit: 40c0669 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44268 [ run ] completed with state SUCCESS. Commit: 40c0669
/LLM/main/L0_MergeRequest_PR pipeline #34689 completed with status: 'SUCCESS'

CI Report

Link to invocation

@2ez4bz 2ez4bz merged commit 08bc122 into NVIDIA:main Apr 20, 2026
5 checks passed
@2ez4bz
Copy link
Copy Markdown
Collaborator

2ez4bz commented Apr 20, 2026

first try

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

Labels

Multimodal Label for issues & PRs regarding Multimodal related objects

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants