-
Notifications
You must be signed in to change notification settings - Fork 2k
[https://nvbugs/5732942][fix] AutoDeploy: handle transformers 4.57.1 upgrade fixes #10466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Lucas Liebenwein <[email protected]>
|
/bot run |
📝 WalkthroughWalkthroughThis 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
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.
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_TYPESand_is_silu_activationto 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_activationtensorrt_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
📒 Files selected for processing (6)
tensorrt_llm/_torch/auto_deploy/export/library/meta_nonzero.pytensorrt_llm/_torch/auto_deploy/models/patches/llama4.pytensorrt_llm/_torch/auto_deploy/models/patches/mixtral.pytensorrt_llm/_torch/auto_deploy/models/patches/qwen3.pytests/unittest/_torch/auto_deploy/unit/singlegpu/models/test_llama4_vlm_patch.pytests/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 prefixkfor variable names that start with a number (e.g.,k_99th_percentile)
Python global variables should use upper snake_case with prefixG(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.pytensorrt_llm/_torch/auto_deploy/models/patches/mixtral.pytensorrt_llm/_torch/auto_deploy/export/library/meta_nonzero.pytensorrt_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.pytensorrt_llm/_torch/auto_deploy/models/patches/mixtral.pytensorrt_llm/_torch/auto_deploy/export/library/meta_nonzero.pytensorrt_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
NotImplementedErrorwith 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
NotImplementedErroris 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_nonzeroflag exists intorch.fx.experimental._configand behaves as expected. The patch correctly stores and restores the original config value, safely enablingtorch.nonzero()on meta tensors during export.
|
PR_Github #30784 [ run ] triggered by Bot. Commit: |
|
PR_Github #30784 [ run ] completed with state |
Summary by CodeRabbit
New Features
Improvements
✏️ 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 thestage-listparameter 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.mdand the
scripts/test_to_stage_mapping.pyhelper.kill
killKill all running builds associated with pull request.
skip
skip --comment COMMENTSkip 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-pipelineReuse 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.