KEMBAR78
[TRTLLM-6780][fix] Add multimodal data to dummy requests during memory profiling by johncalesp · Pull Request #7539 · NVIDIA/TensorRT-LLM · GitHub
Skip to content

Conversation

@johncalesp
Copy link
Collaborator

@johncalesp johncalesp commented Sep 4, 2025

Summary by CodeRabbit

  • New Features

    • Added --enable_chunked_prefill option to the serve command to toggle chunked prefill.
    • Improved profiling for vision/multimodal models by generating dummy multimodal contexts, leading to more accurate KV cache capacity estimation and GPU memory reporting.
  • Tests

    • Added a unit test to verify KV cache memory is reduced when multimodal profiling is enabled.

Description

Take into account memory consumption of vision part for VLM's

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

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

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.

@xinli-sw
Copy link

xinli-sw commented Sep 9, 2025

Could you also create or modify a unit test that invokes _create_dummy_context_requests ?

@johncalesp johncalesp changed the title JIRA Ticket: [TRTLLM-6780] [TRTLLM-6780][Fix] Add multimodal data to dummy requests during memory profiling Sep 9, 2025
@johncalesp johncalesp changed the title [TRTLLM-6780][Fix] Add multimodal data to dummy requests during memory profiling [TRTLLM-6780][fix] Add multimodal data to dummy requests during memory profiling Sep 9, 2025
@johncalesp
Copy link
Collaborator Author

johncalesp commented Sep 15, 2025

@xinli-sw @vadiklyutiy @benchislett Can you take another look when you get a chance? I also added a unit test

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.

Thanks for the work! Left some design questions.

@johncalesp johncalesp force-pushed the add-mm-dummy-req branch 3 times, most recently from 7511010 to 5d8a9ff Compare September 18, 2025 18:16
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.

Thx for addressing what I mentioned. I am adding one more comment regarding the design.

@johncalesp
Copy link
Collaborator Author

@yechank-nvidia I rebase after your changes and I run into some issues.
In the file tensorrt_llm/_torch/pyexecutor/model_engine.py at line 1688:

mrope_position_ids = torch.cat(mrope_position_ids,
                                           dim=-1).pin_memory()

During profiling with mm data dummy reqs, I get this error:

  File "/code/tensorrt_llm/tensorrt_llm/_torch/pyexecutor/model_engine.py", line 1689, in _prepare_tp_inputs
    dim=-1).pin_memory()
            ^^^^^^^^^^^^
RuntimeError: cannot pin 'torch.cuda.LongTensor' only dense CPU tensors can be pinned
[09/22/2025-20:51:35] [TRT-LLM] [E] Encountered an error in forward function: cannot pin 'torch.cuda.LongTensor' only dense CPU tensors can be pinned

I can get around it by moving all to cpu before pinning:

mrope_position_ids = torch.cat(mrope_position_ids,
                                           dim=-1).cpu().pin_memory()

Also If I stress test (num reqs > 100) , I get this error:

File "/code/tensorrt_llm/tensorrt_llm/_torch/pyexecutor/model_engine.py", line 1688, in _prepare_tp_inputs
    mrope_position_ids = torch.cat(mrope_position_ids,
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument tensors in method wrapper_CUDA_cat)
[09/22/2025-20:43:43] [TRT-LLM] [E] Encountered an error in forward function: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument tensors in method wrapper_CUDA_cat)

I think someone also notice it and left a comment on your PR saying: The tensor ctx_mrope_position_ids might be on the CUDA device, while gen_mrope_position_ids remains on the CPU device.
I'll try to take a look later

@johncalesp johncalesp marked this pull request as ready for review September 23, 2025 19:28
@johncalesp johncalesp requested review from a team as code owners September 23, 2025 19:28
@johncalesp
Copy link
Collaborator Author

/bot run

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 23, 2025

📝 Walkthrough

Walkthrough

Adds a dummy-inputs builder for multimodal Qwen2VL, exposes BaseDummyInputsBuilder, and integrates profiling_stage_data through PyExecutor into KvCacheCreator. KV-cache profiling can create multimodal dummy requests and records computed memory back into profiling data. Introduces a serve CLI flag enable_chunked_prefill and a new memory profiling unit test.

Changes

Cohort / File(s) Summary
Qwen2VL dummy input support
tensorrt_llm/_torch/models/modeling_qwen2vl.py
Added numpy/PIL imports; Qwen2VLInputProcessorBase now also derives from BaseDummyInputsBuilder; implemented get_dummy_text/images/prompt; stored model_path; Qwen2VLModelBase now tracks original_arch.
KV-cache profiling and MM dummy requests
tensorrt_llm/_torch/pyexecutor/_util.py
KvCacheCreator.init gains profiling_stage_data; added _create_dummy_mm_context_request; _create_dummy_context_requests can choose MM path based on original_arch; configure_kv_cache_capacity writes max_gpu_total_bytes back to profiling data.
PyExecutor creation propagation
tensorrt_llm/_torch/pyexecutor/py_executor_creator.py
create_py_executor now accepts profiling_stage_data; forwards it to KvCacheCreator and ChainDrafter when enabled.
Serve CLI flag for chunked prefill
tensorrt_llm/commands/serve.py
Added --enable_chunked_prefill flag; get_llm_args includes enable_chunked_prefill in llm_args; serve propagates it.
Inputs API exposure
tensorrt_llm/inputs/__init__.py
Exposed BaseDummyInputsBuilder in public API.
Inputs registry base class
tensorrt_llm/inputs/registry.py
Added BaseDummyInputsBuilder with abstract get_dummy_prompt(input_seq_len, mm_data).
Unit test for memory profiling
tests/unittest/llmapi/test_memory_profiling.py
New test validates KV-cache memory differs when MM profiling requests are enabled vs disabled for a VL model.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant CLI as serve CLI
  participant Args as get_llm_args
  participant Exec as create_py_executor
  participant KVC as KvCacheCreator
  participant Model as Qwen2VL* InputProcessor
  participant Prof as profiling_stage_data

  User->>CLI: serve --enable_chunked_prefill [optional]
  CLI->>Args: build llm_args (includes enable_chunked_prefill)
  Args-->>CLI: llm_args
  CLI->>Exec: create_py_executor(llm_args, profiling_stage_data)
  Exec->>KVC: KvCacheCreator(..., profiling_stage_data)
  Note over KVC: Configure KV-cache capacity
  KVC->>Model: original_arch / dummy MM prompt (if vision/mm)
  Model-->>KVC: dummy multimodal context
  KVC->>Prof: set max_gpu_total_bytes
  KVC-->>Exec: KV-cache configured
  Exec-->>CLI: PyExecutor ready
Loading
sequenceDiagram
  autonumber
  participant Prof as profiling_stage_data
  participant KVC as KvCacheCreator
  participant Ctx as _create_dummy_context_requests
  participant MMCtx as _create_dummy_mm_context_request

  Prof-->>KVC: provided (optional)
  KVC->>Ctx: build context requests
  alt Model is multimodal/vision
    Ctx->>MMCtx: create dummy MM request
    MMCtx-->>Ctx: MM context
  else
    Ctx-->>KVC: text-only context
  end
  KVC->>Prof: write max_gpu_total_bytes
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.81% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title concisely and accurately summarizes the primary change—adding multimodal data to dummy requests used during memory profiling for vision-language models—and follows the repository ticket/type convention.
Description Check ✅ Passed The PR description follows the repository template and states the issue and high-level solution, but the Test Coverage section is empty and the description lacks specifics about which tests were added and what they validate.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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
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: 3

Caution

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

⚠️ Outside diff range comments (3)
tensorrt_llm/_torch/pyexecutor/py_executor_creator.py (2)

1-1: Add NVIDIA Apache-2.0 header.

Per repo guidelines, prepend the NVIDIA Apache-2.0 copyright header with current year at the top of this file.

Apply this diff:

+# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#     http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.

322-323: Fix logging bug: improper use of logging args will raise TypeError.

logger.info("...", attn_runtime_features) uses %-style formatting and will error since message has no placeholders.

Apply this diff:

-    logger.info("ATTENTION RUNTIME FEATURES: ", attn_runtime_features)
+    logger.info("ATTENTION RUNTIME FEATURES: %s", attn_runtime_features)
tensorrt_llm/_torch/models/modeling_qwen2vl.py (1)

1-1: Add NVIDIA Apache-2.0 header.

Per repo guidelines, prepend the NVIDIA Apache-2.0 copyright header with current year at the top of this file.

Apply this diff:

+# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#     http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
🧹 Nitpick comments (4)
tensorrt_llm/_torch/pyexecutor/_util.py (2)

163-164: Consider improving error message clarity

The current message could be more specific about which models are affected and what the impact might be on profiling accuracy.

Consider expanding the warning message:

-        input_processor = create_input_processor(model_name_or_path, tokenizer)
-        if not (hasattr(input_processor, "get_dummy_prompt")):
-            logger.warning("The input processor of the model does not have the method [get_dummy_prompt] implemented." \
-            "Profiling with the default input dummy context request. This may not take into account the memory consumption of " \
-            "the image encoder")
+        input_processor = create_input_processor(model_name_or_path, tokenizer)
+        if not (hasattr(input_processor, "get_dummy_prompt")):
+            logger.warning(f"Input processor for model '{model_name_or_path}' does not implement get_dummy_prompt(). " \
+            "Falling back to text-only dummy requests for profiling. " \
+            "This may underestimate memory consumption for vision-language models.")

215-223: Consider refactoring multimodal detection logic

The condition checking for both original_arch attribute and MODEL_CLASS_VISION_ENCODER_MAPPING could be extracted for clarity and reuse.

Consider extracting the multimodal model detection:

+    def _is_multimodal_model(self) -> bool:
+        """Check if the model is a multimodal/vision model."""
+        return (hasattr(self._model_engine.model, "original_arch") and 
+                MODEL_CLASS_VISION_ENCODER_MAPPING.get(
+                    self._model_engine.model.original_arch, None) is not None)
+
     def _create_dummy_context_requests(
             self, input_seq_len: int) -> List[trtllm.Request]:
         requests = []
-        if hasattr(self._model_engine.model,
-                   "original_arch") and MODEL_CLASS_VISION_ENCODER_MAPPING.get(
-                       self._model_engine.model.original_arch, None):
+        if self._is_multimodal_model():
             requests = self._create_dummy_mm_context_request(input_seq_len)
tensorrt_llm/_torch/pyexecutor/py_executor_creator.py (1)

34-38: Duplicate import of is_mla; remove ambiguity.

Both . _util and .config_utils export is_mla. Pick one to avoid accidental shadowing.

Apply this diff to keep the config_utils version:

-from ._util import (KvCacheCreator, _adjust_torch_mem_fraction,
-                    create_py_executor_instance, instantiate_sampler, is_mla)
+from ._util import (KvCacheCreator, _adjust_torch_mem_fraction,
+                    create_py_executor_instance, instantiate_sampler)
 from .config import PyTorchConfig, _construct_checkpoint_loader
-from .config_utils import is_mla
+from .config_utils import is_mla
tensorrt_llm/_torch/models/modeling_qwen2vl.py (1)

294-298: Avoid repeating the same PIL instance N times.

Minor: create distinct Image objects to sidestep accidental in‑place mutations affecting all entries.

Apply this diff:

-    def get_dummy_images(self, max_width: int, max_height: int,
-                         num_images: int):
-        image = Image.new("RGB", (max_width, max_height), color=255)
-        return [image] * num_images
+    def get_dummy_images(self, max_width: int, max_height: int,
+                         num_images: int) -> List[Image.Image]:
+        return [
+            Image.new("RGB", (max_width, max_height), color=255)
+            for _ in range(num_images)
+        ]
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1738c3 and b8d42c3.

📒 Files selected for processing (7)
  • tensorrt_llm/_torch/models/modeling_qwen2vl.py (6 hunks)
  • tensorrt_llm/_torch/pyexecutor/_util.py (5 hunks)
  • tensorrt_llm/_torch/pyexecutor/py_executor_creator.py (2 hunks)
  • tensorrt_llm/commands/serve.py (5 hunks)
  • tensorrt_llm/inputs/__init__.py (2 hunks)
  • tensorrt_llm/inputs/registry.py (1 hunks)
  • tests/unittest/llmapi/test_memory_profiling.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{h,hpp,hh,hxx,cpp,cxx,cc,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Use only spaces, no tabs; indent with 4 spaces.

Files:

  • tensorrt_llm/inputs/registry.py
  • tests/unittest/llmapi/test_memory_profiling.py
  • tensorrt_llm/inputs/__init__.py
  • tensorrt_llm/commands/serve.py
  • tensorrt_llm/_torch/pyexecutor/_util.py
  • tensorrt_llm/_torch/pyexecutor/py_executor_creator.py
  • tensorrt_llm/_torch/models/modeling_qwen2vl.py
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: Python code must target Python 3.8+.
Indent Python code with 4 spaces; do not use tabs.
Maintain module namespace when importing; prefer 'from package.subpackage import foo' then 'foo.SomeClass()' instead of importing the class directly.
Python filenames should be snake_case (e.g., some_file.py).
Python classes use PascalCase names.
Functions and methods use snake_case names.
Local variables use snake_case; prefix 'k' for variables that start with a number (e.g., k_99th_percentile).
Global variables use upper SNAKE_CASE prefixed with 'G' (e.g., G_MY_GLOBAL).
Constants use upper SNAKE_CASE (e.g., MY_CONSTANT).
Avoid shadowing variables from an outer scope.
Initialize all externally visible members of a class in the constructor.
Prefer docstrings for interfaces that may be used outside a file; comments for in-function or file-local interfaces.
Use Google-style docstrings for classes and functions (Sphinx-parsable).
Document attributes and variables inline so they render under the class/function docstring.
Avoid reflection when a simpler, explicit approach suffices (e.g., avoid dict(**locals()) patterns).
In try/except, catch the most specific exceptions possible.
For duck-typing try/except, keep the try body minimal and use else for the main logic.

Files:

  • tensorrt_llm/inputs/registry.py
  • tests/unittest/llmapi/test_memory_profiling.py
  • tensorrt_llm/inputs/__init__.py
  • tensorrt_llm/commands/serve.py
  • tensorrt_llm/_torch/pyexecutor/_util.py
  • tensorrt_llm/_torch/pyexecutor/py_executor_creator.py
  • tensorrt_llm/_torch/models/modeling_qwen2vl.py
**/*.{cpp,cxx,cc,h,hpp,hh,hxx,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Prepend the NVIDIA Apache-2.0 copyright header with current year to the top of all source files (e.g., .cpp, .h, .cu, .py).

Files:

  • tensorrt_llm/inputs/registry.py
  • tests/unittest/llmapi/test_memory_profiling.py
  • tensorrt_llm/inputs/__init__.py
  • tensorrt_llm/commands/serve.py
  • tensorrt_llm/_torch/pyexecutor/_util.py
  • tensorrt_llm/_torch/pyexecutor/py_executor_creator.py
  • tensorrt_llm/_torch/models/modeling_qwen2vl.py
🧠 Learnings (5)
📚 Learning: 2025-08-26T09:37:10.463Z
Learnt from: jiaganc
PR: NVIDIA/TensorRT-LLM#7031
File: tensorrt_llm/bench/dataclasses/configuration.py:90-104
Timestamp: 2025-08-26T09:37:10.463Z
Learning: In TensorRT-LLM, the `get_pytorch_perf_config()` method returns `self.pytorch_config` which can contain default `cuda_graph_config` values, so `llm_args` may already have this config before the extra options processing.

Applied to files:

  • tensorrt_llm/commands/serve.py
  • tensorrt_llm/_torch/models/modeling_qwen2vl.py
📚 Learning: 2025-08-11T20:09:24.389Z
Learnt from: achartier
PR: NVIDIA/TensorRT-LLM#6763
File: tests/integration/defs/triton_server/conftest.py:16-22
Timestamp: 2025-08-11T20:09:24.389Z
Learning: In the TensorRT-LLM test infrastructure, the team prefers simple, direct solutions (like hard-coding directory traversal counts) over more complex but robust approaches when dealing with stable directory structures. They accept the maintenance cost of updating tests if the layout changes.

Applied to files:

  • tensorrt_llm/_torch/models/modeling_qwen2vl.py
📚 Learning: 2025-07-22T09:22:14.726Z
Learnt from: yechank-nvidia
PR: NVIDIA/TensorRT-LLM#6254
File: tensorrt_llm/_torch/pyexecutor/model_engine.py:1201-1204
Timestamp: 2025-07-22T09:22:14.726Z
Learning: In TensorRT-LLM's multimodal processing pipeline, shared tensor recovery using `from_shared_tensor()` is only needed during the context phase. Generation requests reuse the already-recovered tensor data and only need to call `strip_for_generation()` to remove unnecessary multimodal data while preserving the recovered tensors. This avoids redundant tensor recovery operations during generation.

Applied to files:

  • tensorrt_llm/_torch/models/modeling_qwen2vl.py
📚 Learning: 2025-08-26T09:37:10.463Z
Learnt from: jiaganc
PR: NVIDIA/TensorRT-LLM#7031
File: tensorrt_llm/bench/dataclasses/configuration.py:90-104
Timestamp: 2025-08-26T09:37:10.463Z
Learning: In TensorRT-LLM's bench configuration, the `get_pytorch_perf_config()` method returns `self.pytorch_config` which is a Dict[str, Any] that can contain default values including `cuda_graph_config`, making the fallback `llm_args["cuda_graph_config"]` safe to use.

Applied to files:

  • tensorrt_llm/_torch/models/modeling_qwen2vl.py
📚 Learning: 2025-08-11T13:58:57.678Z
Learnt from: tomeras91
PR: NVIDIA/TensorRT-LLM#6796
File: tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py:201-201
Timestamp: 2025-08-11T13:58:57.678Z
Learning: When a PR is intended for pure code movement/refactoring (moving code from one file to another), avoid suggesting code changes including linting fixes, as the goal is to keep the code exactly as it was in the original location.

Applied to files:

  • tensorrt_llm/_torch/models/modeling_qwen2vl.py
🧬 Code graph analysis (5)
tensorrt_llm/inputs/registry.py (1)
tensorrt_llm/_torch/models/modeling_qwen2vl.py (1)
  • get_dummy_prompt (299-312)
tests/unittest/llmapi/test_memory_profiling.py (3)
tensorrt_llm/_torch/pyexecutor/py_executor_creator.py (1)
  • create_py_executor (210-693)
tensorrt_llm/llmapi/llm_args.py (4)
  • DynamicBatchConfig (792-814)
  • SchedulerConfig (818-836)
  • CudaGraphConfig (108-165)
  • TorchLlmArgs (2126-2550)
tensorrt_llm/executor/postproc_worker.py (1)
  • enabled (48-49)
tensorrt_llm/inputs/__init__.py (1)
tensorrt_llm/inputs/registry.py (1)
  • BaseDummyInputsBuilder (45-52)
tensorrt_llm/_torch/pyexecutor/_util.py (3)
tensorrt_llm/_torch/model_config.py (2)
  • ModelConfig (110-582)
  • from_pretrained (405-445)
tensorrt_llm/inputs/registry.py (3)
  • create_input_processor (421-450)
  • create_input_processor_with_hash (453-569)
  • get_dummy_prompt (50-52)
tensorrt_llm/_torch/models/modeling_qwen2vl.py (1)
  • get_dummy_prompt (299-312)
tensorrt_llm/_torch/models/modeling_qwen2vl.py (2)
tensorrt_llm/inputs/registry.py (4)
  • BaseDummyInputsBuilder (45-52)
  • BaseMultimodalInputProcessor (55-188)
  • InputProcessor (22-42)
  • get_dummy_prompt (50-52)
tensorrt_llm/inputs/utils.py (1)
  • default_multimodal_input_loader (450-613)
🔇 Additional comments (18)
tensorrt_llm/commands/serve.py (3)

89-89: Parameter consistency: enable_chunked_prefill added properly

The new parameter enable_chunked_prefill follows the existing pattern and is correctly propagated through the function signature and the returned dictionary.

Also applies to: 133-133


290-293: LGTM: CLI option follows established patterns

The new --enable_chunked_prefill flag is properly defined with appropriate type, default value, and help text.


303-304: Verify chunked prefill compatibility with attention backends and quantization

  • Repository already contains compatibility checks and notes — see tensorrt_llm/llmapi/llm.py (raises ValueError when backend == "pytorch" and chunked prefill isn't enabled), tensorrt_llm/_torch/pyexecutor/py_executor_creator.py (checks attn_backend == "FLASHINFER_STAR_ATTENTION" together with enable_chunked_context), and tests/integration/defs/accuracy/test_llm_api_pytorch.py (comment: "chunked prefill is not supported for fp8 and nvfp4").
  • Ensure the new serve.py parameter is forwarded into get_llm_args / LLM initialization, verify consistency between enable_chunked_prefill and enable_chunked_context, and add runtime validation or documentation if chunked prefill is incompatible with certain quantization modes or attention backends.
tensorrt_llm/_torch/pyexecutor/_util.py (3)

51-60: LGTM: Proper handling of profiling stage data parameter

The new profiling_stage_data parameter is correctly added as a keyword-only argument and properly stored as an instance variable.


425-428: LGTM: Profiling data properly updated with memory metrics

The code correctly updates the profiling stage data with the computed max_gpu_total_bytes when profiling data is provided.


152-211: Comprehensive multimodal dummy request generation — verified

Confirmed: get_dummy_prompt is implemented (tensorrt_llm/_torch/models/modeling_qwen2vl.py), create_input_processor and create_input_processor_with_hash exist (tensorrt_llm/inputs/registry.py), and vision-encoder registration/mapping (MODEL_CLASS_VISION_ENCODER_MAPPING / register_vision_encoder) is present — no changes required.

tensorrt_llm/inputs/registry.py (1)

45-53: Well-designed base class for dummy input generation

The BaseDummyInputsBuilder base class is properly designed with:

  • Clear docstring explaining its purpose for profiling
  • Abstract method that raises NotImplementedError with a helpful message
  • Appropriate method signature for multimodal dummy prompt generation
tensorrt_llm/inputs/__init__.py (1)

3-3: LGTM: Proper API exposure of BaseDummyInputsBuilder

The new BaseDummyInputsBuilder class is correctly imported and added to __all__ for public API exposure.

Also applies to: 32-32

tests/unittest/llmapi/test_memory_profiling.py (1)

18-81: Well-structured test for memory profiling with multimodal requests

The test properly validates that:

  1. Memory profiling with multimodal requests (enable_mm_reqs=True) accounts for vision encoder memory
  2. The available KV cache memory is reduced when multimodal profiling is enabled
  3. Both profiling scenarios are properly cleaned up
tensorrt_llm/_torch/models/modeling_qwen2vl.py (7)

5-5: Import numpy: OK.

Needed for efficient random token generation.


8-8: Import PIL.Image: OK.

Required for dummy image synthesis.


30-35: Expose dummy-input and loader utilities: OK.

Imports align with the new BaseDummyInputsBuilder flow.


90-92: Extending Qwen2VLInputProcessorBase with BaseDummyInputsBuilder: OK.

Proper place to centralize dummy multimodal generation for profiling.


101-106: Persist model_path for loader: OK.

Needed by default_multimodal_input_loader.


299-313: Dummy prompt construction via default_multimodal_input_loader: OK.

Shape choice (3584x3584) matches max_pixels target; interface usage looks correct.


827-827: Persist original architecture: OK.

This unblocks downstream mappings that rely on the pre‑post_config architecture.

Please confirm MODEL_CLASS_VISION_ENCODER_MAPPING (or equivalent) now picks up original_arch as intended.

tensorrt_llm/_torch/pyexecutor/py_executor_creator.py (2)

216-217: create_py_executor: profiling_stage_data call sites verified — OK. Definition is in tensorrt_llm/_torch/pyexecutor/py_executor_creator.py; the only callers found are tests/unittest/llmapi/test_memory_profiling.py (they already pass profiling_stage_data). Signature is optional/backward‑compatible.


577-578: KvCacheCreator.init includes profiling_stage_data — resolved.
Verified in tensorrt_llm/_torch/pyexecutor/_util.py: def init(..., profiling_stage_data: Optional[dict])

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19718 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19718 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #14840 completed with status: 'FAILURE'

Signed-off-by: John Calderon <jcalderon@nvidia.com>
Signed-off-by: John Calderon <jcalderon@nvidia.com>
Signed-off-by: John Calderon <jcalderon@nvidia.com>
Signed-off-by: John Calderon <jcalderon@nvidia.com>
…s from modeling qwen

Signed-off-by: John Calderon <jcalderon@nvidia.com>
Signed-off-by: John Calderon <jcalderon@nvidia.com>
Signed-off-by: John Calderon <jcalderon@nvidia.com>
Signed-off-by: John Calderon <jcalderon@nvidia.com>
…-8B-FP16-vila/NVILA-8B-video-False]

Signed-off-by: John Calderon <jcalderon@nvidia.com>
…and A10-PyTorch-1.test_e2e.test_trtllm_serve_multimodal_example

Signed-off-by: John Calderon <jcalderon@nvidia.com>
Signed-off-by: John Calderon <jcalderon@nvidia.com>
Signed-off-by: John Calderon <jcalderon@nvidia.com>
Signed-off-by: John Calderon <jcalderon@nvidia.com>
Signed-off-by: John Calderon <jcalderon@nvidia.com>
Signed-off-by: John Calderon <jcalderon@nvidia.com>
@johncalesp
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #21490 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #21490 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #16223 completed with status: 'FAILURE'

@johncalesp
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #21497 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #21497 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #16229 completed with status: 'FAILURE'

@johncalesp
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #21499 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #21499 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #16231 completed with status: 'SUCCESS'
Pipeline passed with automatic retried tests. Check the rerun report for details.

@johncalesp
Copy link
Collaborator Author

@Funatiq thank your for your review and comments.
Is it possible to approve this PR and merge it ?

@Funatiq Funatiq merged commit 46ee7ac into NVIDIA:main Oct 16, 2025
5 checks passed
govind-ramnarayan pushed a commit to nv-auto-deploy/TensorRT-LLM that referenced this pull request Oct 21, 2025
…y profiling (NVIDIA#7539)

Signed-off-by: John Calderon <johncalesp@gmail.com>
Signed-off-by: John Calderon <jcalderon@nvidia.com>
Signed-off-by: john calderon <jcalderon@nvidia.com>
Signed-off-by: John Calderon <jcalderon@nvidia>
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.

6 participants