Skip to content

[#11170][fix] Fix for mm placeholder counts#11461

Merged
2ez4bz merged 1 commit intoNVIDIA:mainfrom
2ez4bz:dev-mm-placeholder-counts
Feb 14, 2026
Merged

[#11170][fix] Fix for mm placeholder counts#11461
2ez4bz merged 1 commit intoNVIDIA:mainfrom
2ez4bz:dev-mm-placeholder-counts

Conversation

@2ez4bz
Copy link
Collaborator

@2ez4bz 2ez4bz commented Feb 12, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Improved multimodal content placeholder tracking in conversations—now handles per-message placeholder counts instead of global tracking, ensuring accurate insertion of multimodal placeholders across multiple messages.
  • Tests

    • Added regression tests for per-message multimodal placeholder counting across various message scenarios.

Description

  • Why?

As reported by #11170, when a single request contains multiple messages, and only a subset of those messages include multimodal data, the previous logic incorrectly adds placeholder tokens to subsequent messages that do not contain such data.

  • What?

This commit fixes this issue, and adds unit tests that would have caught this.

Test Coverage

  • Added unit test cases that would have caught this issue.

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

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

Details

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 the stage-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.

@2ez4bz 2ez4bz requested a review from a team as a code owner February 12, 2026 00:28
@2ez4bz 2ez4bz requested a review from hchings February 12, 2026 00:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

The changes modify multimodal placeholder tracking in the chat message processing pipeline. The add_data method now returns an optional placeholder string instead of implicitly returning None. Placeholder counting shifts from cumulative global tracking to per-message accumulation, with corresponding test coverage added.

Changes

Cohort / File(s) Summary
Multimodal Data Tracker
tensorrt_llm/inputs/utils.py
Updated add_data method signature to return Optional[str], propagating generated placeholder identifiers to callers instead of returning None.
Chat Message Processing
tensorrt_llm/serve/chat_utils.py
Refactored parse_chat_messages_coroutines to track multimodal placeholders per-message using msg_placeholder_counts dictionary instead of cumulative global counts. Captures returned placeholders from add_data calls and applies per-message counts when updating message content.
Per-Message Placeholder Tests
tests/unittest/llmapi/apps/test_chat_utils.py
Added TestMultimodalPlaceholderCounts class with parameterized test_per_message_counts method. Introduced module-level constants for model type (_MM_MODEL_TYPE), image placeholder, and video placeholder retrieved from MULTIMODAL_PLACEHOLDER_REGISTRY.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title '[#11170][fix] Fix for mm placeholder counts' clearly summarizes the main change: fixing a bug in multimodal placeholder counting logic, with specific reference to the issue number.
Description check ✅ Passed The description includes the required sections (Why, What, Test Coverage) and explains the issue, solution, and test additions. It follows the repository template structure appropriately.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
tests/unittest/llmapi/apps/test_chat_utils.py (1)

233-239: Module-level registry lookups are fragile if import order changes.

_IMG_PLACEHOLDER and _VIDEO_PLACEHOLDER are resolved at module import time. If the registry isn't fully populated when this test module is imported (e.g., due to lazy registration or import reordering), these will raise at collection time with a confusing error. Consider moving these into a fixture or a helper method.

That said, this is a minor robustness concern for a test file — fine to keep as-is if the registry is always populated at import.

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Collaborator

@venkywonka venkywonka left a comment

Choose a reason for hiding this comment

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

lgtm!

@2ez4bz
Copy link
Collaborator Author

2ez4bz commented Feb 12, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35752 [ run ] triggered by Bot. Commit: fff703b

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35752 [ run ] completed with state SUCCESS. Commit: fff703b
/LLM/main/L0_MergeRequest_PR pipeline #27613 completed with status: 'FAILURE'

⚠️ 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

* Why?

As reported by NVIDIA#11170, when a single request contains multiple
messages, and only a subset of those messages include multimodal data,
the previous logic incorrectly adds placeholder tokens to subsequent
messages that do not contain such data.

* What?

This commit fixes this issue, and adds unit tests that would have
caught this.

Signed-off-by: William Zhang <133824995+2ez4bz@users.noreply.github.com>
@2ez4bz 2ez4bz force-pushed the dev-mm-placeholder-counts branch from fff703b to e657e4b Compare February 12, 2026 17:05
@2ez4bz
Copy link
Collaborator Author

2ez4bz commented Feb 12, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35801 [ run ] triggered by Bot. Commit: e657e4b

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35801 [ run ] completed with state SUCCESS. Commit: e657e4b
/LLM/main/L0_MergeRequest_PR pipeline #27653 completed with status: 'FAILURE'

⚠️ 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

@2ez4bz
Copy link
Collaborator Author

2ez4bz commented Feb 12, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35839 [ run ] triggered by Bot. Commit: e657e4b

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35839 [ run ] completed with state SUCCESS. Commit: e657e4b
/LLM/main/L0_MergeRequest_PR pipeline #27680 completed with status: 'FAILURE'

⚠️ 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

@2ez4bz
Copy link
Collaborator Author

2ez4bz commented Feb 13, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35880 [ run ] triggered by Bot. Commit: e657e4b

Copy link
Collaborator

@yechank-nvidia yechank-nvidia left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the work!

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35880 [ run ] completed with state ABORTED. Commit: e657e4b
LLM/main/L0_MergeRequest_PR #27710 (Blue Ocean) completed with status: ABORTED

@2ez4bz
Copy link
Collaborator Author

2ez4bz commented Feb 13, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35927 [ run ] triggered by Bot. Commit: e657e4b

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35927 [ run ] completed with state SUCCESS. Commit: e657e4b
/LLM/main/L0_MergeRequest_PR pipeline #27745 completed with status: 'FAILURE'

⚠️ 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

@2ez4bz
Copy link
Collaborator Author

2ez4bz commented Feb 13, 2026

/bot run --disable-fail-fast

@2ez4bz 2ez4bz enabled auto-merge (squash) February 13, 2026 22:33
@tensorrt-cicd
Copy link
Collaborator

PR_Github #35944 [ run ] triggered by Bot. Commit: e657e4b

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35944 [ run ] completed with state SUCCESS. Commit: e657e4b
/LLM/main/L0_MergeRequest_PR pipeline #27759 completed with status: 'SUCCESS'

@2ez4bz 2ez4bz merged commit 4debf15 into NVIDIA:main Feb 14, 2026
5 checks passed
peihu-nv pushed a commit to peihu-nv/TensorRT-LLM that referenced this pull request Feb 19, 2026
* Why?

As reported by NVIDIA#11170, when a single request contains multiple
messages, and only a subset of those messages include multimodal data,
the previous logic incorrectly adds placeholder tokens to subsequent
messages that do not contain such data.

* What?

This commit fixes this issue, and adds unit tests that would have
caught this.

Signed-off-by: William Zhang <133824995+2ez4bz@users.noreply.github.com>
Signed-off-by: peihu-nv <259410613+peihu-nv@users.noreply.github.com>
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.

4 participants