Skip to content

[None][feat] Enable MM encoder cache on Qwen3.x and Gemma4 VLMs - #16662

Merged
2ez4bz merged 2 commits into
NVIDIA:mainfrom
2ez4bz:dev-encoder-cache-more-models
Jul 31, 2026
Merged

[None][feat] Enable MM encoder cache on Qwen3.x and Gemma4 VLMs#16662
2ez4bz merged 2 commits into
NVIDIA:mainfrom
2ez4bz:dev-encoder-cache-more-models

Conversation

@2ez4bz

@2ez4bz 2ez4bz commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Description

  • Why?

Repeated or chunked multimodal requests re-ran encoder work on supported
Qwen3.x and Gemma4 models, increasing latency and GPU utilization.
Duplicated model-specific multimodal plumbing also made this behavior
harder to maintain consistently.

  • What?

Refactor Gemma4 and Qwen3.x VLMs to reuse the multimodal base mixin and
shared encoder flow, removing duplicated multimodal boilerplate.

Enable cached encoder embeddings for supported models, preserve
model-specific behavior, exclude Qwen Image Bench from caching, and
document support.

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)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

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

Dev Engineer Review

  • Refactored Gemma4 and Qwen3.x VLM multimodal plumbing to reuse a shared MultimodalModelMixin/model base flow:
    • Gemma4MultimodalModelBase introduced and Gemma4ForConditionalGeneration updated to inherit it (centralizing multimodal encoding + LM integration hooks, and renaming token-id exposure to multimodal_token_ids).
    • Gemma4UnifiedForConditionalGeneration now inherits Gemma4MultimodalModelBase, removing the prior custom multimodal forward/fusion path and switching to encoder-free vision/audio feature extraction + shared multimodal fusion.
    • Mistral3VLM hook renamed/reshaped: get_language_model_forward_kwargsget_language_model_extra_forward_kwargs to align with the shared extra-forward-kwargs pattern.
    • Qwen3VLModelBase forward rewritten to use shared multimodal lifecycle methods (select_multimodal_params, after_active_multimodal_embeddings, _fuse_multimodal_embeddings, get_language_model_extra_forward_kwargs) and to enforce the new multimodal token-id property name (multimodal_token_ids).
  • Encoder-caching + cache prefetch behavior tightened/extended:
    • MultimodalModelMixin.multimodal_token_ids now defaults to None (instead of throwing), enabling the sentinel/OOV path in fuse_input_embeds.
    • MultimodalModelMixin.select_multimodal_params now filters params only when param.has_content() and the chunk has multimodal tokens (via multimodal_runtime/num_mm_tokens_in_chunk rules).
    • Cross-iteration encoder prefetch now propagates request-specific multimodal item ordering (mm_item_order) into MultimodalParams.
    • PyTorchModelEngine._prepare_multimodal_indices now derives mm_token_ids via the mixin-style multimodal_token_ids first, falling back to legacy mm_token_ids.
  • Model-specific encoder-cache enablement:
    • supports_encoder_cache = True added for _Qwen3_5VLModel and Qwen3MoeVLModel.
    • Qwen Image Bench explicitly rebuilds multimodal config with encoder_cache_max_bytes = 0 to exclude it from caching.
  • Compatibility/error-handling changes to validate:
    • Gemma4 unified wrapper now hard-requires config.image_token_id (raises ValueError if missing).
    • Qwen3VLModelBase now directly requires mm_encoder for encoder-backed multimodal embedding; validates exactly one packed embedding tensor is returned.
    • Multimodal API call sites/tests updated to use encode_multimodal_inputs and shared multimodal selection helpers.
  • Documentation:
    • docs/source/models/supported-models.md updated to enumerate all architectures implementing MultimodalModelMixin that support multimodal encoder side-stream + embeddings cache (replacing the previous single-model statement).

QA Engineer Review

Test changes (files under tests/ touched)

  • tests/unittest/_torch/multimodal/test_mm_encoder_cross_iter_prefetch.py
    • Added _CacheStubModel (cache-capable stub), _make_cacheable_request(...).
    • Added CUDA tests:
      • test_cross_iter_prefetch_populates_and_reuses_persistent_cache
      • test_cross_iter_prefetch_mixed_cache_hit_and_miss_encodes_only_miss
      • test_cross_iter_prefetch_cache_model_preserves_uncacheable_fallbacks
      • test_cross_iter_prefetch_does_not_synchronize_main_stream
      • test_cross_iter_prefetch_does_not_rewrite_request_local_embedding
      • test_prefetched_embedding_records_main_consumer_stream
    • Added/updated CUDA-only dispatch materialization coverage via @requires_cuda for test_cross_iter_prefetch_materializes_on_side_stream.
  • tests/unittest/_torch/executor/test_pytorch_model_engine.py
    • Added tests covering _prepare_multimodal_indices behavior for both:
      • models exposing multimodal_token_ids
      • legacy models exposing mm_token_ids
  • tests/unittest/_torch/modeling/test_gemma4_multimodal.py
    • Updated multimodal API usage to call encode_multimodal_inputs (instead of _forward_multimodal_encoder).
    • Added _Gemma4EncoderCacheHarness and test_encoder_cache_reuses_image_embedding_across_requests.
    • Renamed/changed expectation for single-request multiple modalities:
      • test_single_request_with_multiple_modalities_raises (behavior update from prior “allowed” test).
    • Updated existing cache/order tests to use the new mixin methods/helpers.
  • tests/unittest/_torch/modeling/test_modeling_gemma4_unified.py
    • Added test_wrapper_rejects_missing_image_token_id.

Coverage / registration

  • Whether these tests are present in tests/integration/test_lists/ (test-db/qa entries) could not be confirmed from the provided change summary.
  • Verdict: needs follow-up.

@2ez4bz
2ez4bz requested review from a team as code owners July 21, 2026 06:13
@2ez4bz
2ez4bz force-pushed the dev-encoder-cache-more-models branch from 7da572a to f6fabcc Compare July 21, 2026 06:19
@2ez4bz
2ez4bz marked this pull request as draft July 21, 2026 06:23
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The PR centralizes multimodal forwarding hooks, migrates Gemma 4 and Qwen3-VL models to shared contracts, enables encoder caching for additional models, updates token-ID compatibility, and adds CUDA coverage for cross-iteration prefetch behavior.

Changes

Multimodal model integration

Layer / File(s) Summary
Shared multimodal forwarding contracts
tensorrt_llm/_torch/models/modeling_multimodal_mixin.py, tensorrt_llm/_torch/pyexecutor/model_engine.py, tensorrt_llm/_torch/models/modeling_mistral.py, tensorrt_llm/_torch/models/modeling_gemma4mm.py
Shared multimodal hooks, token-ID lookup, parameter selection, prefetch metadata, and language-model forwarding are updated with legacy fallback support.
Gemma multimodal base and unified model migration
tensorrt_llm/_torch/models/modeling_gemma4mm.py, tensorrt_llm/_torch/models/modeling_gemma4_unified.py
Gemma 4 multimodal encoding and language-model integration move into Gemma4MultimodalModelBase; the unified model uses encoder-free vision and audio embedders.
Qwen multimodal forwarding refactor
tensorrt_llm/_torch/models/modeling_qwen3vl.py, tensorrt_llm/_torch/models/modeling_qwen3_5.py, tensorrt_llm/_torch/models/modeling_qwen3vl_moe.py
Qwen3-VL separates multimodal selection, deepstack fusion, encoder invocation, and language-model extras; Qwen variants declare encoder-cache support.
Encoder-cache prefetch validation and configuration
tests/unittest/_torch/multimodal/test_mm_encoder_cross_iter_prefetch.py, tests/unittest/_torch/executor/test_pytorch_model_engine.py, tests/unittest/_torch/modeling/*, tensorrt_llm/_torch/models/modeling_qwen_image_bench.py, docs/source/models/supported-models.md
Tests cover cache reuse, misses, stream handling, token-ID compatibility, and model validation; Qwen Image Bench disables caching and documentation lists supported architectures.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • NVIDIA/TensorRT-LLM#16554: Contains closely related multimodal token-ID, encoder-cache, prefetch, and Gemma 4 integration changes.

Suggested reviewers: qijune, schetlur-nv

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required [None][feat] format and accurately summarizes the main change.
Description check ✅ Passed The description covers why, what, and checklist items, but the Test Coverage section is left blank.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/unittest/_torch/modeling/test_gemma4_multimodal.py (1)

765-776: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Add production-path cache coverage for Qwen and Gemma.

Coverage is insufficient: this harness calls _get_or_encode_multimodal_embeddings() directly, so it does not exercise Gemma4 forward() or Qwen’s new _get_qwen_multimodal_embeddings() routing. Add cache-hit/miss tests to tests/unittest/_torch/modeling/test_gemma4_multimodal.py and the Qwen3-VL model test module, asserting two identical raw requests invoke the encoder once; parameterize the Qwen test across dense, MoE, and Qwen3.5 wrappers. Run the targeted tests under pytest tests/unittest/.

As per path instructions, “Keep feedback actionable: suggest concrete list file names and whether coverage is sufficient, insufficient, or needs follow-up outside the PR.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unittest/_torch/modeling/test_gemma4_multimodal.py` around lines 765 -
776, The cache test only exercises the helper directly and does not cover
production routing. Add cache miss/hit tests through
Gemma4ForConditionalGeneration.forward and Qwen’s
_get_qwen_multimodal_embeddings, asserting identical raw requests invoke the
encoder once; parameterize Qwen coverage across dense, MoE, and Qwen3.5
wrappers, and run the targeted tests under pytest tests/unittest/.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/source/models/supported-models.md`:
- Around line 129-138: Add Gemma4ForConditionalGeneration to the
MultimodalModelMixin optimization matrix, mark Multimodal Embeddings Cache as
Yes, and set Multimodal Encoder Side Stream according to its verified support
status.

---

Nitpick comments:
In `@tests/unittest/_torch/modeling/test_gemma4_multimodal.py`:
- Around line 765-776: The cache test only exercises the helper directly and
does not cover production routing. Add cache miss/hit tests through
Gemma4ForConditionalGeneration.forward and Qwen’s
_get_qwen_multimodal_embeddings, asserting identical raw requests invoke the
encoder once; parameterize Qwen coverage across dense, MoE, and Qwen3.5
wrappers, and run the targeted tests under pytest tests/unittest/.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 2af008bf-08c0-455b-8e97-c6273f5a8e3d

📥 Commits

Reviewing files that changed from the base of the PR and between 4fb31cb and 7da572a.

📒 Files selected for processing (6)
  • docs/source/models/supported-models.md
  • tensorrt_llm/_torch/models/modeling_gemma4mm.py
  • tensorrt_llm/_torch/models/modeling_qwen3_5.py
  • tensorrt_llm/_torch/models/modeling_qwen3vl.py
  • tensorrt_llm/_torch/models/modeling_qwen3vl_moe.py
  • tests/unittest/_torch/modeling/test_gemma4_multimodal.py

Comment thread docs/source/models/supported-models.md
@2ez4bz
2ez4bz force-pushed the dev-encoder-cache-more-models branch 4 times, most recently from 389bb36 to a426936 Compare July 27, 2026 17:24
@2ez4bz
2ez4bz marked this pull request as ready for review July 27, 2026 17:26
@2ez4bz
2ez4bz requested review from a team as code owners July 27, 2026 17:26

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Caution

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

⚠️ Outside diff range comments (2)
tensorrt_llm/_torch/models/modeling_mistral.py (2)

619-634: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

load_tokenizer hardcodes trust_remote_code=True, overriding the caller's setting.

MistralCommonInputProcessor.__init__ accepts trust_remote_code and forwards it to super().__init__, but this fallback ignores it and always enables remote code execution (also hardcodes use_fast=True). Thread the flag through instead.

Separately, MistralTokenizer.from_pretrained can fail with OSError/FileNotFoundError for a checkpoint that simply has no mistral-common artifacts; catching only ValueError means those cases abort instead of falling back.

🔒️ Proposed fix
     `@staticmethod`
     def load_tokenizer(model_path: str,
                        config: PretrainedConfig,
-                       tokenizer: AutoTokenizer | None = None):
+                       tokenizer: AutoTokenizer | None = None,
+                       trust_remote_code: bool = False,
+                       use_fast: bool = True):
         if getattr(config, "input_processor_type", None) == "mistral_large_3":
             try:
                 return MistralTokenizer.from_pretrained(model_path)
 
-            except ValueError:
+            except (ValueError, OSError):
                 logger.info(
                     f"Could not load mistral-common tokenizer from {model_path}, falling back to HuggingFace"
                 )
 
         tokenizer = tokenizer if tokenizer is not None else AutoTokenizer.from_pretrained(
-            model_path, config=config, use_fast=True, trust_remote_code=True)
+            model_path,
+            config=config,
+            use_fast=use_fast,
+            trust_remote_code=trust_remote_code)
         return tokenizer

And at the call site:

-        tokenizer = self.load_tokenizer(model_path,
-                                        config=config,
-                                        tokenizer=tokenizer)
+        tokenizer = self.load_tokenizer(model_path,
+                                        config=config,
+                                        tokenizer=tokenizer,
+                                        trust_remote_code=trust_remote_code)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tensorrt_llm/_torch/models/modeling_mistral.py` around lines 619 - 634,
Update load_tokenizer to accept the caller’s trust_remote_code and use_fast
settings instead of hardcoding them when calling AutoTokenizer.from_pretrained;
update MistralCommonInputProcessor.__init__ to pass those flags into
load_tokenizer. Expand the MistralTokenizer.from_pretrained exception handling
to fall back for missing tokenizer artifacts by catching OSError, including
FileNotFoundError, alongside ValueError.

Source: Linters/SAST tools


64-67: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use a mapping-aware RoPE lookup here config.rope_scaling / config.rope_parameters can be dicts, so getattr(..., "rope_type") returns None and "yarn" falls through to rope_gpt_neox. Use a dict-aware lookup like get("rope_type", get("type")) before the fallback.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tensorrt_llm/_torch/models/modeling_mistral.py` around lines 64 - 67, Update
the RoPE type lookup near rope_params_section so it supports mapping-based
rope_scaling or rope_parameters values, retrieving rope_type and falling back to
type before using attribute access for object configurations. Ensure dictionary
configurations with a "yarn" type enter the existing yarn branch instead of
falling through to rope_gpt_neox.
🧹 Nitpick comments (2)
tensorrt_llm/_torch/models/modeling_mistral.py (1)

428-438: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Drop the image-only do_rescale kwarg on the text-only branch.

do_rescale is an image-processor argument; forwarding it to text_processor for a prompt with no images is meaningless and can raise for processors that validate kwargs.

♻️ Proposed change
         else:
-            processed = self.text_processor(
-                text=inputs["prompt"],
-                do_rescale=do_rescale,
-            )
+            processed = self.text_processor(text=inputs["prompt"])
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tensorrt_llm/_torch/models/modeling_mistral.py` around lines 428 - 438,
Update the text-only branch in the processing flow to remove the do_rescale
keyword argument from the self.text_processor call. Keep do_rescale passed to
self.processor in the images branch, and preserve the existing prompt handling.
tensorrt_llm/_torch/pyexecutor/model_engine.py (1)

2998-3002: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

getattr(..., None) won't catch the mixin's NotImplementedError.

MultimodalModelMixin.multimodal_token_ids is a property whose default body raises NotImplementedError, and getattr with a default only suppresses AttributeError. Every mixin subclass overrides it today, so this is latent rather than broken — but the first model that inherits without overriding will crash here instead of falling back to mm_token_ids. Consider returning None from the mixin's default property (it already documents None as the out-of-vocabulary sentinel behavior) rather than raising.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tensorrt_llm/_torch/pyexecutor/model_engine.py` around lines 2998 - 3002,
Update the default multimodal_token_ids property in MultimodalModelMixin to
return None instead of raising NotImplementedError, preserving the documented
out-of-vocabulary sentinel behavior so model_engine.py can fall back to
mm_token_ids.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tensorrt_llm/_torch/models/modeling_gemma4mm.py`:
- Around line 745-752: Guard the image token assignment in the mm_token_type_ids
initialization block so self.image_token_ids is checked for None before
accessing [0]. Preserve the existing image classification when image_token_ids
is present and the current independent video and audio guards.
- Around line 595-699: The multimodal embedding assembly in the mixed-modality
path currently concatenates modality buckets and loses prompt order. Update the
logic around multimodal_params and multimodal_embeddings to preserve each
parameter’s original content order when combining image, audio, and video
embeddings; alternatively reject mixed-modality parameters explicitly until
ordering metadata is available.

In `@tensorrt_llm/_torch/models/modeling_mistral.py`:
- Around line 817-831: The model-specific
get_language_model_extra_forward_kwargs overrides must preserve all engine
kwargs required by their inner language models. In
tensorrt_llm/_torch/models/modeling_mistral.py lines 817-831, update
get_language_model_extra_forward_kwargs to include lora_params in the returned
kwargs, or verify and document that MistralForCausalLM.forward ignores it. In
tensorrt_llm/_torch/models/modeling_gemma4mm.py lines 734-744, accept and return
spec_metadata and resource_manager alongside lora_params, matching the Mistral
and Qwen3-VL overrides.

In `@tensorrt_llm/_torch/models/modeling_qwen_image_bench.py`:
- Around line 100-109: Update the model_config cloning logic around replace() to
preserve the existing extra_attrs metadata when constructing the new config.
Carry model_config.extra_attrs into the replacement so runtime entries such as
nvfp4_gemm_allowed_backends and allreduce_* remain available, while keeping the
multimodal_config encoder_cache_max_bytes override unchanged.

In `@tensorrt_llm/_torch/models/modeling_qwen3vl.py`:
- Around line 1478-1493: Update the validation in the Qwen multimodal request
flow around `_get_requests_with_mm_data` so batches carrying only attached
`multimodal_embedding` handles are accepted without requiring
`support_mm_disagg`; retain the `NotImplementedError` for genuinely
disaggregated inputs without embeddings. Replace the hardcoded
environment-variable name in the error message with the imported
`_MULTIMODAL_ENV_NAME`.

---

Outside diff comments:
In `@tensorrt_llm/_torch/models/modeling_mistral.py`:
- Around line 619-634: Update load_tokenizer to accept the caller’s
trust_remote_code and use_fast settings instead of hardcoding them when calling
AutoTokenizer.from_pretrained; update MistralCommonInputProcessor.__init__ to
pass those flags into load_tokenizer. Expand the
MistralTokenizer.from_pretrained exception handling to fall back for missing
tokenizer artifacts by catching OSError, including FileNotFoundError, alongside
ValueError.
- Around line 64-67: Update the RoPE type lookup near rope_params_section so it
supports mapping-based rope_scaling or rope_parameters values, retrieving
rope_type and falling back to type before using attribute access for object
configurations. Ensure dictionary configurations with a "yarn" type enter the
existing yarn branch instead of falling through to rope_gpt_neox.

---

Nitpick comments:
In `@tensorrt_llm/_torch/models/modeling_mistral.py`:
- Around line 428-438: Update the text-only branch in the processing flow to
remove the do_rescale keyword argument from the self.text_processor call. Keep
do_rescale passed to self.processor in the images branch, and preserve the
existing prompt handling.

In `@tensorrt_llm/_torch/pyexecutor/model_engine.py`:
- Around line 2998-3002: Update the default multimodal_token_ids property in
MultimodalModelMixin to return None instead of raising NotImplementedError,
preserving the documented out-of-vocabulary sentinel behavior so model_engine.py
can fall back to mm_token_ids.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 56028f2a-821b-433d-ada8-05c37c9e8b56

📥 Commits

Reviewing files that changed from the base of the PR and between 7da572a and a426936.

📒 Files selected for processing (10)
  • docs/source/models/supported-models.md
  • tensorrt_llm/_torch/models/modeling_gemma4_unified.py
  • tensorrt_llm/_torch/models/modeling_gemma4mm.py
  • tensorrt_llm/_torch/models/modeling_mistral.py
  • tensorrt_llm/_torch/models/modeling_multimodal_mixin.py
  • tensorrt_llm/_torch/models/modeling_qwen3_5.py
  • tensorrt_llm/_torch/models/modeling_qwen3vl.py
  • tensorrt_llm/_torch/models/modeling_qwen3vl_moe.py
  • tensorrt_llm/_torch/models/modeling_qwen_image_bench.py
  • tensorrt_llm/_torch/pyexecutor/model_engine.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • tensorrt_llm/_torch/models/modeling_qwen3vl_moe.py
  • tensorrt_llm/_torch/models/modeling_qwen3_5.py
  • docs/source/models/supported-models.md

Comment thread tensorrt_llm/_torch/models/modeling_gemma4mm.py
Comment thread tensorrt_llm/_torch/models/modeling_gemma4mm.py
Comment thread tensorrt_llm/_torch/models/modeling_mistral.py
Comment thread tensorrt_llm/_torch/models/modeling_qwen_image_bench.py
Comment thread tensorrt_llm/_torch/models/modeling_qwen3vl.py
@2ez4bz
2ez4bz force-pushed the dev-encoder-cache-more-models branch from a426936 to 6efe549 Compare July 27, 2026 18:05
@2ez4bz
2ez4bz requested review from a team as code owners July 27, 2026 18:05
@2ez4bz
2ez4bz requested a review from QiJune July 27, 2026 18:05
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62408 [ run ] triggered by Bot. Commit: 8050707 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62408 [ run ] completed with state FAILURE. Commit: 8050707
/LLM/main/L0_MergeRequest_PR pipeline #50567 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

CI Agent Failure Analysis

Link to invocation

@2ez4bz

2ez4bz commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62438 [ run ] triggered by Bot. Commit: 8050707 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62438 [ run ] completed with state SUCCESS. Commit: 8050707
/LLM/main/L0_MergeRequest_PR pipeline #50593 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

CI Agent Failure Analysis

Link to invocation

2ez4bz added 2 commits July 29, 2026 10:32
* Why?

Repeated or chunked multimodal requests re-ran encoder work on supported
Qwen3.x and Gemma4 models, increasing latency and GPU utilization.
Duplicated model-specific multimodal plumbing also made this behavior
harder to maintain consistently.

* What?

Refactor Gemma4 and Qwen3.x VLMs to reuse the multimodal base mixin and
shared encoder flow, removing duplicated multimodal boilerplate.

Enable cached encoder embeddings for supported models, preserve
model-specific behavior, exclude Qwen Image Bench from caching, and
document support.

Signed-off-by: William Zhang <133824995+2ez4bz@users.noreply.github.com>
Signed-off-by: William Zhang <133824995+2ez4bz@users.noreply.github.com>
@2ez4bz
2ez4bz force-pushed the dev-encoder-cache-more-models branch from 8050707 to c104620 Compare July 29, 2026 17:34
@2ez4bz

2ez4bz commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62568 [ run ] triggered by Bot. Commit: c104620 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62568 [ run ] completed with state FAILURE. Commit: c104620
/LLM/main/L0_MergeRequest_PR pipeline #50712 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

CI Agent Failure Analysis

Link to invocation

@2ez4bz

2ez4bz commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62626 [ run ] triggered by Bot. Commit: c104620 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62626 [ run ] completed with state SUCCESS. Commit: c104620
/LLM/main/L0_MergeRequest_PR pipeline #50766 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

CI Agent Failure Analysis

Link to invocation

@2ez4bz

2ez4bz commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62685 [ run ] triggered by Bot. Commit: c104620 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62685 [ run ] completed with state SUCCESS. Commit: c104620
/LLM/main/L0_MergeRequest_PR pipeline #50824 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

CI Agent Failure Analysis

Link to invocation

@2ez4bz

2ez4bz commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62723 [ run ] triggered by Bot. Commit: c104620 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62723 [ run ] completed with state SUCCESS. Commit: c104620
/LLM/main/L0_MergeRequest_PR pipeline #50858 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

CI Agent Failure Analysis

Link to invocation

@2ez4bz

2ez4bz commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62798 [ run ] triggered by Bot. Commit: c104620 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62798 [ run ] completed with state FAILURE. Commit: c104620
/LLM/main/L0_MergeRequest_PR pipeline #50924 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

CI Agent Failure Analysis

Link to invocation

@2ez4bz

2ez4bz commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62872 [ run ] triggered by Bot. Commit: c104620 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62872 [ run ] completed with state FAILURE. Commit: c104620
/LLM/main/L0_MergeRequest_PR pipeline #50994 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

CI Agent Failure Analysis

Link to invocation

@2ez4bz

2ez4bz commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62945 [ run ] triggered by Bot. Commit: c104620 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62945 [ run ] completed with state SUCCESS. Commit: c104620
/LLM/main/L0_MergeRequest_PR pipeline #51061 completed with status: 'SUCCESS'

CI Report

Link to invocation

@2ez4bz
2ez4bz merged commit a2df74e into NVIDIA:main Jul 31, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-compatible Accepted LLM API contract change that is backwards-compatible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants