Skip to content

Conversation

@lucaslie
Copy link
Member

@lucaslie lucaslie commented Jan 6, 2026

Summary by CodeRabbit

  • New Features

    • Added support for meta tensor operations, enabling non-zero value checking during model tracing.
  • Improvements

    • Implemented compatibility validation for expert-based models to ensure supported activation configurations.
    • Updated Llama4 vision feature extraction to align with latest library API versions.
    • Expanded automated test coverage by enabling previously conditional tests.

✏️ Tip: You can customize this high-level summary in your review settings.

Description

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

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

@lucaslie lucaslie requested a review from a team as a code owner January 6, 2026 21:15
@lucaslie lucaslie requested a review from nzmora-nvidia January 6, 2026 21:15
@lucaslie lucaslie self-assigned this Jan 6, 2026
@lucaslie lucaslie moved this from Backlog to In review in AutoDeploy Board Jan 6, 2026
@lucaslie
Copy link
Member Author

lucaslie commented Jan 6, 2026

/bot run

@lucaslie lucaslie enabled auto-merge (squash) January 6, 2026 21:16
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2026

📝 Walkthrough

Walkthrough

This PR introduces a meta tensor patch for torch.fx support, updates model patches to align with transformers 4.57.1+ API, adds SiLU activation validation for expert-based models (mixtral, qwen3), and enables previously-skipped test cases for llama4 and auto-deploy builds.

Changes

Cohort / File(s) Summary
Meta Tensor Support
tensorrt_llm/_torch/auto_deploy/export/library/meta_nonzero.py
New patch module registering MetaNonzeroPatch to enable torch.nonzero() on meta tensors during torch.fx tracing by managing fx_config.meta_nonzero_assume_all_nonzero state.
Transformers API Compatibility
tensorrt_llm/_torch/auto_deploy/models/patches/llama4.py
Updated get_image_features call signature to align with transformers 4.57.1+ by removing vision_feature_layer and image_sizes=None parameters.
Expert Model Validation
tensorrt_llm/_torch/auto_deploy/models/patches/mixtral.py, tensorrt_llm/_torch/auto_deploy/models/patches/qwen3.py
Added SiLU activation compatibility checks with helper _is_silu_activation and _SILU_TYPES tuple. Raises NotImplementedError with descriptive messages when experts use non-SiLU activations or have bias, replacing previous fallback behavior.
Test Enablement
tests/unittest/_torch/auto_deploy/unit/singlegpu/models/test_llama4_vlm_patch.py, tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_build_small_single.py
Removed conditional pytest.skip blocks and imports, enabling tests to execute full code paths instead of early termination.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete. It contains only the template structure with placeholders (@coderabbitai summary) but lacks concrete details about the issue, solution, test coverage, and rationale for the changes. Replace the @coderabbitai summary placeholder with a detailed description explaining the transformers 4.57.1 upgrade issues being fixed, the specific changes made to each file, relevant test cases, and the rationale for design decisions.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the PR's main objective of handling transformers 4.57.1 compatibility issues in AutoDeploy, matching the changeset which includes fixes for llama4 vision features, mixtral/qwen3 SiLU validation, and meta tensor support.
✨ Finishing touches
  • 📝 Generate docstrings

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: 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/auto_deploy/models/patches/llama4.py (1)

1-6: Add NVIDIA copyright header.

Per coding guidelines, all TensorRT-LLM source files should contain an NVIDIA copyright header with the year of latest meaningful modification.

🔎 Suggested copyright header format
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
 """A patch to handle vision branch in Llama4ForConditionalGeneration.

As per coding guidelines, all source files must include an NVIDIA copyright header.

tensorrt_llm/_torch/auto_deploy/models/patches/mixtral.py (1)

1-1: Add NVIDIA copyright header.

Per coding guidelines, all TensorRT-LLM source files should contain an NVIDIA copyright header with the year of latest meaningful modification.

🔎 Suggested copyright header format
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
 """A patch for Mixtral MoE to make it compatible with torch.export."""

As per coding guidelines, all source files must include an NVIDIA copyright header.

tensorrt_llm/_torch/auto_deploy/models/patches/qwen3.py (1)

1-1: Add NVIDIA copyright header.

Per coding guidelines, all TensorRT-LLM source files should contain an NVIDIA copyright header with the year of latest meaningful modification.

🔎 Suggested copyright header format
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
 """A patch for Qwen3 MoE to make it compatible with torch.export and reduce export time."""

As per coding guidelines, all source files must include an NVIDIA copyright header.

🤖 Fix all issues with AI Agents
In @tensorrt_llm/_torch/auto_deploy/export/library/meta_nonzero.py:
- Around line 1-6: Add the required NVIDIA copyright header at the top of
tensorrt_llm/_torch/auto_deploy/export/library/meta_nonzero.py above the module
docstring: insert the standard NVIDIA copyright block including the latest
modification year, "NVIDIA CORPORATION & AFFILIATES" ownership text and the SPDX
license identifier (e.g., SPDX-License-Identifier: Apache-2.0) so the file
header precedes the existing docstring that describes the torch.nonzero()
meta-tensor patch.

In @tensorrt_llm/_torch/auto_deploy/models/patches/llama4.py:
- Around line 75-80: The call to get_image_features is missing the mandatory
vision_feature_layer parameter and will fail at runtime; update the invocation
in llama4.py to pass vision_feature_layer (already extracted earlier) along with
pixel_values and vision_feature_select_strategy to get_image_features, and
update the adjacent comment to reflect the correct signature:
get_image_features(self, pixel_values, vision_feature_layer,
vision_feature_select_strategy, **kwargs).
🧹 Nitpick comments (2)
tensorrt_llm/_torch/auto_deploy/models/patches/mixtral.py (1)

10-21: Consider extracting duplicated SiLU detection logic to a shared utility.

This exact code pattern (lines 10-21) is duplicated in tensorrt_llm/_torch/auto_deploy/models/patches/qwen3.py (lines 10-21). Consider extracting _SILU_TYPES and _is_silu_activation to a shared utility module to follow the DRY principle.

🔎 Suggested refactor approach

Create a new file tensorrt_llm/_torch/auto_deploy/models/patches/utils.py:

# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""Shared utilities for model patches."""

import torch.nn as nn

# Import SiLUActivation for compatibility check
try:
    from transformers.activations import SiLUActivation
    _SILU_TYPES = (nn.SiLU, SiLUActivation)
except ImportError:
    _SILU_TYPES = (nn.SiLU,)


def is_silu_activation(act_fn) -> bool:
    """Check if activation function is SiLU or equivalent."""
    return isinstance(act_fn, _SILU_TYPES)

Then import in both files:

from .utils import is_silu_activation
tensorrt_llm/_torch/auto_deploy/models/patches/qwen3.py (1)

10-21: Duplicated code: extract to shared utility.

This code is identical to tensorrt_llm/_torch/auto_deploy/models/patches/mixtral.py (lines 10-21). See the review comment on mixtral.py for the suggested refactor to eliminate this duplication.

📜 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 00355b2 and ebd3782.

📒 Files selected for processing (6)
  • tensorrt_llm/_torch/auto_deploy/export/library/meta_nonzero.py
  • tensorrt_llm/_torch/auto_deploy/models/patches/llama4.py
  • tensorrt_llm/_torch/auto_deploy/models/patches/mixtral.py
  • tensorrt_llm/_torch/auto_deploy/models/patches/qwen3.py
  • tests/unittest/_torch/auto_deploy/unit/singlegpu/models/test_llama4_vlm_patch.py
  • tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_build_small_single.py
💤 Files with no reviewable changes (2)
  • tests/unittest/_torch/auto_deploy/unit/singlegpu/models/test_llama4_vlm_patch.py
  • tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_build_small_single.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: The code developed for TensorRT-LLM should conform to Python 3.8+
Indent Python code with 4 spaces. Do not use tabs
Always maintain the namespace when importing Python modules, even if only one class or function from a module is used
Python filenames should use snake_case (e.g., some_file.py)
Python classes should use PascalCase (e.g., class SomeClass)
Python functions and methods should use snake_case (e.g., def my_awesome_function():)
Python local variables should use snake_case, with prefix k for variable names that start with a number (e.g., k_99th_percentile)
Python global variables should use upper snake_case with prefix G (e.g., G_MY_GLOBAL)
Python constants should use upper snake_case (e.g., MY_CONSTANT)
Avoid shadowing variables declared in an outer scope in Python
Initialize all externally visible members of a Python class in the constructor
For Python interfaces that may be used outside a file, prefer docstrings over comments
Use comments in Python for code within a function, or interfaces that are local to a file
Use Google-style docstrings for Python classes and functions, which can be parsed by Sphinx
Python attributes and variables can be documented inline with the format """<type>: Description"""
Avoid using reflection in Python when functionality can be easily achieved without reflection
When using try-except blocks in Python, limit the except clause to the smallest set of errors possible
When using try-except blocks in Python to handle multiple possible variable types (duck-typing), keep the body of the try as small as possible and use the else block for the main logic

Files:

  • tensorrt_llm/_torch/auto_deploy/models/patches/llama4.py
  • tensorrt_llm/_torch/auto_deploy/models/patches/mixtral.py
  • tensorrt_llm/_torch/auto_deploy/export/library/meta_nonzero.py
  • tensorrt_llm/_torch/auto_deploy/models/patches/qwen3.py
**/*.{cpp,cc,cxx,h,hpp,hxx,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

All TensorRT-LLM source files (.cpp, .h, .cu, .py, and other source files) should contain an NVIDIA copyright header with the year of latest meaningful modification

Files:

  • tensorrt_llm/_torch/auto_deploy/models/patches/llama4.py
  • tensorrt_llm/_torch/auto_deploy/models/patches/mixtral.py
  • tensorrt_llm/_torch/auto_deploy/export/library/meta_nonzero.py
  • tensorrt_llm/_torch/auto_deploy/models/patches/qwen3.py
🧠 Learnings (2)
📚 Learning: 2025-08-08T04:10:19.038Z
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 6728
File: cpp/tensorrt_llm/plugins/mixtureOfExperts/mixtureOfExpertsPlugin.cpp:966-966
Timestamp: 2025-08-08T04:10:19.038Z
Learning: TensorRT plugins currently don't support padding functionality, and TensorRT is not getting new features (in maintenance mode). This means that duplicating parameters like mExpertHiddenSize in function calls, even with TODO comments, can be acceptable as pragmatic solutions within these constraints.

Applied to files:

  • tensorrt_llm/_torch/auto_deploy/models/patches/mixtral.py
📚 Learning: 2025-08-14T23:23:27.449Z
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 6915
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:4010-4012
Timestamp: 2025-08-14T23:23:27.449Z
Learning: For MOE (Mixture of Experts) code reviews in TensorRT-LLM, avoid repeatedly suggesting finalize fusion validation checks and safety assertions. The user djns99 has indicated these suggestions are repetitive and unwanted across multiple MOE-related changes.

Applied to files:

  • tensorrt_llm/_torch/auto_deploy/models/patches/qwen3.py
🧬 Code graph analysis (3)
tensorrt_llm/_torch/auto_deploy/models/patches/mixtral.py (1)
tensorrt_llm/_torch/auto_deploy/models/patches/qwen3.py (2)
  • _is_silu_activation (19-21)
  • _forward_moe (24-64)
tensorrt_llm/_torch/auto_deploy/export/library/meta_nonzero.py (1)
tensorrt_llm/_torch/auto_deploy/export/interface.py (2)
  • BaseExportPatch (47-139)
  • ExportPatchRegistry (186-233)
tensorrt_llm/_torch/auto_deploy/models/patches/qwen3.py (1)
tensorrt_llm/_torch/auto_deploy/models/patches/mixtral.py (2)
  • _is_silu_activation (19-21)
  • _forward_moe (24-67)
⏰ 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 (4)
tensorrt_llm/_torch/auto_deploy/models/patches/mixtral.py (1)

26-41: LGTM: Explicit error handling improves export-time diagnostics.

The change from a conditional fallback to raising NotImplementedError with a detailed message is a good improvement. This fail-fast approach makes incompatibilities explicit during export rather than silently failing later.

tensorrt_llm/_torch/auto_deploy/models/patches/qwen3.py (1)

26-41: LGTM: Consistent error handling improves export-time diagnostics.

The explicit error handling with NotImplementedError is consistent with the approach in mixtral.py and provides clear diagnostics for unsupported configurations.

tensorrt_llm/_torch/auto_deploy/export/library/meta_nonzero.py (2)

33-37: LGTM: Clean revert implementation.

The revert logic properly restores the original config value, ensuring the patch is fully reversible.


23-31: No changes required—the implementation is correct.

The meta_nonzero_assume_all_nonzero flag exists in torch.fx.experimental._config and behaves as expected. The patch correctly stores and restores the original config value, safely enabling torch.nonzero() on meta tensors during export.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30784 [ run ] triggered by Bot. Commit: ebd3782

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30784 [ run ] completed with state SUCCESS. Commit: ebd3782
/LLM/main/L0_MergeRequest_PR pipeline #23766 completed with status: 'SUCCESS'

@lucaslie lucaslie merged commit bb6a397 into NVIDIA:main Jan 7, 2026
8 of 9 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in AutoDeploy Board Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants