Repository navigation
[https://nvbugs/5596377][fix] Fix mm dummy calculation - #8498
Conversation
📝 WalkthroughWalkthroughThe changes refactor dummy prompt generation for multimodal models by removing a text helper method and reimplementing prompt logic to iteratively adjust image resolution to fit token constraints. Related dummy context request infrastructure is updated to directly use the new prompt generation method with optional mrope configuration support. Test data references are migrated from remote URLs to local paths. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant PyExecutor
participant InputProcessor
participant Model
rect rgb(200, 220, 240)
note over PyExecutor: Old Path (Removed)
Client->>PyExecutor: _create_dummy_mm_context_request()
PyExecutor->>InputProcessor: input_processor_with_hash path
InputProcessor-->>PyExecutor: multimodal_input/multimodal_data
end
rect rgb(220, 240, 220)
note over PyExecutor: New Path
Client->>PyExecutor: _create_dummy_mm_context_request()
PyExecutor->>InputProcessor: get_dummy_prompt(input_seq_len)
alt prompt available
InputProcessor-->>PyExecutor: dummy_mm_prompt
PyExecutor->>Model: input_processor.get_prompt_token_ids()
Model-->>PyExecutor: prompt_token_ids + multimodal_data
else prompt unavailable
InputProcessor-->>PyExecutor: None
PyExecutor->>PyExecutor: fallback to text-only prompt
alt mrope enabled
PyExecutor->>PyExecutor: include mrope_config
end
end
PyExecutor-->>Client: GenerationRequest with updated fields
end
sequenceDiagram
autonumber
participant Caller
participant GetDummyPrompt
participant ImageResolution
rect rgb(220, 240, 220)
note over GetDummyPrompt: New Iterative Resolution Tuning
Caller->>GetDummyPrompt: get_dummy_prompt(input_seq_len)
GetDummyPrompt->>ImageResolution: img_max_dim = input_seq_len
loop Halve dimensions until fit or exhausted
ImageResolution->>ImageResolution: create multimodal input with current resolution
ImageResolution->>ImageResolution: generate prompt tokens with prompts=[""]
alt token count ≤ input_seq_len
ImageResolution-->>GetDummyPrompt: test_mm_prompt (success)
GetDummyPrompt-->>Caller: return test_mm_prompt
else token count exceeds
ImageResolution->>ImageResolution: halve width/height
end
end
GetDummyPrompt-->>Caller: None (no suitable resolution)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Rationale: The changes span three distinct areas with varying complexity. The first file involves a non-trivial logic rewrite (iterative resolution tuning) requiring careful verification of token fitting behavior. The second file contains infrastructure rework with conditional branching and fallback paths that demand attention to control flow. The third file consists of homogeneous string replacements with minimal risk. Combined heterogeneity and moderate logic density across files justifies a moderate effort assessment. Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
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/models/modeling_qwen2vl.py (2)
1-1: Missing NVIDIA Apache-2.0 header (2025).Add the standard header at file top.
Same header block as suggested in tests file.
291-315: Starting dummy image size = input token limit risks OOM and long loops. Clamp to model-aware max.Using
img_max_dim = input_seq_lencan create gigantic images (e.g., 16K×16K) before preprocessing, wasting memory and time. Start from a safe, model-config bound (e.g., vision_config image size) and then halve.Proposed fix:
- img_max_dim = input_seq_len # TODO: Find better starting resolution + # Start from a safe, model-aware upper bound to avoid OOM from huge dummy images + max_hw = (getattr(self.model_config.vision_config, "image_size", None) + or getattr(self.model_config.vision_config, "max_image_size", None) + or 1024) + img_max_dim = int(min(max_hw, max(64, input_seq_len)))Optional follow-up (binary search to reduce iterations) available if you want.
tensorrt_llm/_torch/pyexecutor/_util.py (1)
1-1: Missing NVIDIA Apache-2.0 header (2025).Add the standard header at file top.
Same header block as suggested earlier.
🧹 Nitpick comments (5)
tests/unittest/llmapi/apps/_test_openai_chat_multimodal.py (2)
71-75: Use pure pathlib composition instead of os.path.join.Cleaner and OS-agnostic; avoid mixing os.path with Path.
Example (apply to all occurrences):
- test_data_root = Path( - os.path.join(llm_models_root(), "multimodals", "test_data")) + test_data_root = Path(llm_models_root()) / "multimodals" / "test_data"Also applies to: 127-129, 188-190, 244-246, 301-303
247-249: Confirmencode_base64_content_from_urlhandles local paths.The helper name suggests remote URLs; ensure it accepts plain file paths. If not, inline a file read.
Fallback snippet:
- image64 = encode_base64_content_from_url(image_url) + # Fallback if local paths aren’t supported by the helper: + # from base64 import b64encode + # image64 = b64encode(Path(image_url).read_bytes()).decode("ascii")tensorrt_llm/_torch/models/modeling_qwen2vl.py (1)
303-305: Empty text prompt is fine; consider annotating intent.A brief comment like “image-only prompt” improves maintainability.
tensorrt_llm/_torch/pyexecutor/_util.py (2)
155-161: Minor: semantics ofinput_seq_lenvsremaining_tokens.You clamp
input_seq_len = min(max_num_tokens, input_seq_len)and then drive the loop byremaining_tokens = max_num_tokens. That’s fine, but a short comment explaining the intent (pack multiple requests to fill max_num_tokens) would help future readers.
180-186: Non-crypto RNG is OK here; consider reproducibility.
random.randintis fine for dummy profiling. If you want deterministic runs, seed or switch totorch.randintwith a fixed RNG.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
tensorrt_llm/_torch/models/modeling_qwen2vl.py(2 hunks)tensorrt_llm/_torch/pyexecutor/_util.py(1 hunks)tests/unittest/llmapi/apps/_test_openai_chat_multimodal.py(6 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/_torch/models/modeling_qwen2vl.pytests/unittest/llmapi/apps/_test_openai_chat_multimodal.pytensorrt_llm/_torch/pyexecutor/_util.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/_torch/models/modeling_qwen2vl.pytests/unittest/llmapi/apps/_test_openai_chat_multimodal.pytensorrt_llm/_torch/pyexecutor/_util.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/_torch/models/modeling_qwen2vl.pytests/unittest/llmapi/apps/_test_openai_chat_multimodal.pytensorrt_llm/_torch/pyexecutor/_util.py
🧬 Code graph analysis (1)
tensorrt_llm/_torch/pyexecutor/_util.py (3)
tensorrt_llm/_torch/models/modeling_qwen2vl.py (1)
get_dummy_prompt(290-315)tensorrt_llm/inputs/registry.py (1)
get_dummy_prompt(50-52)tensorrt_llm/_torch/pyexecutor/model_engine.py (1)
use_mrope(390-398)
🪛 Ruff (0.14.0)
tensorrt_llm/_torch/pyexecutor/_util.py
181-181: Standard pseudo-random generators are not suitable for cryptographic purposes
(S311)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Pre-commit Check
🔇 Additional comments (1)
tests/unittest/llmapi/apps/_test_openai_chat_multimodal.py (1)
74-85: Local filesystem paths inimage_url/video_urlmay not be valid URLs.OpenAI-style payloads usually expect http(s) or data: URIs. Your RemoteOpenAIServer may support local paths, but please confirm to keep tests portable.
If unsupported, load bytes and use data: URIs (you already do that once) or prefix with file:// where accepted.
I can help switch all cases to data: URIs for consistency if needed.
Also applies to: 130-147, 191-203, 247-260, 312-316
|
/bot run |
|
PR_Github #21893 [ run ] triggered by Bot. Commit: |
|
PR_Github #21893 [ run ] completed with state |
|
/bot run |
|
PR_Github #22248 [ run ] triggered by Bot. Commit: |
|
/bot run |
|
PR_Github #22251 [ run ] triggered by Bot. Commit: |
|
PR_Github #22248 [ run ] completed with state |
|
PR_Github #22251 [ run ] completed with state |
|
/bot run |
|
PR_Github #22270 [ run ] triggered by Bot. Commit: |
|
PR_Github #22270 [ run ] completed with state |
|
/bot run |
Signed-off-by: yechank <[email protected]>
Signed-off-by: yechank <[email protected]>
Signed-off-by: yechank <[email protected]>
Signed-off-by: yechank <[email protected]>
Signed-off-by: yechank <[email protected]>
Signed-off-by: yechank <[email protected]>
Signed-off-by: yechank <[email protected]>
753878c to
1b2121b
Compare
|
/bot run |
|
PR_Github #22694 [ run ] triggered by Bot. Commit: |
Signed-off-by: yechank <[email protected]>
|
/bot run |
|
PR_Github #22712 [ run ] triggered by Bot. Commit: |
|
PR_Github #22694 [ run ] completed with state |
|
PR_Github #22712 [ run ] completed with state |
|
/bot run |
|
PR_Github #22724 [ run ] triggered by Bot. Commit: |
|
PR_Github #22724 [ run ] completed with state |
|
/bot run |
|
PR_Github #22741 [ run ] triggered by Bot. Commit: |
|
PR_Github #22741 [ run ] completed with state |
Re-pin flashinfer-prims-ts-moe from FlashInfer main 855eece4 to 637f9c53, which adds FlashInfer NVIDIA#8497 (faster MXFP4 x MXFP8 MoE GEMMs: deeper-pipelined tile configs, 64-byte K-block weights and an opt-in fused FC2 finalize) and NVIDIA#8498. The integration patch applies unchanged, and the new launch arguments are optional, so the op keeps the unfused finalize. NVIDIA#8497 renumbers the tactics. Key the autotuner cache on a digest of the vendored config mapper and tables instead of a hand-kept version string, so tuned tactics from other config tables are not replayed. Signed-off-by: qgai <[email protected]>
Re-pin flashinfer-prims-ts-moe from FlashInfer main 855eece4 to 637f9c53, which adds FlashInfer NVIDIA#8497 (faster MXFP4 x MXFP8 MoE GEMMs: deeper-pipelined tile configs, 64-byte K-block weights and an opt-in fused FC2 finalize) and NVIDIA#8498. The integration patch applies unchanged, and the new launch arguments are optional, so the op keeps the unfused finalize. NVIDIA#8497 renumbers the tactics. Key the autotuner cache on a digest of the vendored config mapper and tables instead of a hand-kept version string, so tuned tactics from other config tables are not replayed. Signed-off-by: qgai <[email protected]>
Summary by CodeRabbit
Release Notes
Breaking Changes
get_dummy_textmethod from input processor.Improvements