Repository navigation
Description
System Info
General bug
Who can help?
No response
Information
- The official example scripts
- My own modified scripts
Tasks
- An officially supported task in the
examplesfolder (such as GLUE/SQuAD, ...) - My own task or dataset (give details below)
Reproduction
Issue 1: Length Mismatch Between mrope_position_ids and position_ids
There is a potential out-of-bounds risk caused by inconsistent length assumptions between position_ids and mrope_position_ids.
In the following code:
self.mrope_position_ids_cuda[:, :, :total_num_tokens].copy_(
mrope_position_ids[:, :, :total_num_tokens],
non_blocking=True
)total_num_tokens is derived from position_ids. However, there is no guarantee that
mrope_position_ids.shape[-1] >= total_num_tokens.
If mrope_position_ids.shape[-1] < total_num_tokens, the slicing operation on
mrope_position_ids[:, :, :total_num_tokens] will result in an out-of-bounds access (or an invalid copy), leading to undefined behavior or runtime errors.
In short, total_num_tokens is implicitly assumed to be valid for both tensors, but this assumption does not always hold.
Issue 2: Incorrect Accumulation of image_pad Across Messages
When a single request contains multiple messages, and only a subset of those messages include multimodal (image) data, the current logic incorrectly propagates image_pad tokens to subsequent messages that do not contain images.
https://github.com/NVIDIA/TensorRT-LLM/blob/main/tensorrt_llm/serve/chat_utils.py#L268
Example:
- A request contains 3 messages
- Only 2 messages actually include image data
Due to cumulative handling of multimodal placeholders, an image_pad token is still inserted for the third message, even though it has no associated image.
As a result:
- The number of
image_padtokens becomes inconsistent with the actual number of multimodal inputs. - Multimodal metadata and placeholder tokens are no longer aligned.
This cumulative behavior causes a mismatch between the multimodal data count and the image_pad markers in the serialized input.
I have proposed a solution for the issues described above and validated it using my own datasets. The fix resolves the observed inconsistencies and works correctly in all tested cases.
Lihui-Gu@a405252
However, I am not fully confident that the changes are universally correct or aligned with the intended design, so I would appreciate feedback on whether this approach is reasonable and safe under all expected scenarios.
Expected behavior
See Reproduction
actual behavior
See Reproduction
additional notes
NULL
Before submitting a new issue...
- Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.
Activity
[-][Bug]:[/-][+][Bug]: Length Mismatch Between mrope_position_ids and position_ids & Incorrect Accumulation of image_pad Across Messages[/+]zheyuf commentedon Feb 1, 2026
Hi @Lihui-Gu, thanks for raising this issue! I see you already have a proposed fix. Could you open a Pull Request so we can have an engineer review the changes and run the CI?
No worries about being unsure of the "universal" correctness — our CI testing and review process will help confirm that the logic is safe and fits the architecture.
chang-l commentedon Feb 2, 2026
cc. @2ez4bz
yechank-nvidia commentedon Feb 2, 2026
Thanks for raising this issue.
For both issues, yes, I think we are lacking in considering mixture of text + mm requests when first implemented. I saw your #11179 and seems first fix is correct. But need to think more about the second case's fix.
Will continue to add more comment on that PR. Thanks!
Nekofish-L commentedon Feb 3, 2026
Issue 2 is the same as #7929.
[NVIDIA#11170][fix] Fix for mm placeholder counts
[NVIDIA#11170][fix] Fix for mm placeholder counts
2ez4bz commentedon Feb 12, 2026
@Lihui-Gu could you share details on how to repro issue 1? I would like to understand the exact scenarios under which it manifests itself. 🙏
[#11170][fix] Fix for mm placeholder counts (#11461)
[NVIDIA#11170][fix] Fix for mm placeholder counts (NVIDIA#11461)
github-actions commentedon Apr 14, 2026
Issue has not received an update in over 14 days. Adding stale label.
github-actions commentedon Apr 28, 2026
This issue was closed because it has been 14 days without activity since it has been marked as stale.