Skip to content

Conversation

@benzh-2025
Copy link
Collaborator

@benzh-2025 benzh-2025 commented Jan 14, 2026

@coderabbitai summary

Description

Test Coverage

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.

Examples:

@benzh-2025 benzh-2025 requested review from a team as code owners January 14, 2026 05:29
@benzh-2025 benzh-2025 requested review from 2ez4bz and byshiue January 14, 2026 05:29
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 14, 2026

📝 Walkthrough

Walkthrough

The pull request changes the default state of GEMM all-reduce fusion from enabled to disabled by modifying the environment variable TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED default behavior in the Llama model, and adds test coverage to validate both enabled and disabled configurations.

Changes

Cohort / File(s) Summary
Llama Model Configuration
tensorrt_llm/_torch/models/modeling_llama.py
Changed default value of enable_gemm_allreduce_fusion from True to False, altering the default state of the TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED environment variable
Integration Tests
tests/integration/defs/accuracy/test_llm_api_pytorch.py
Added enable_gemm_allreduce_fusion parameter to test cases with environment variable setup; applies to both test_fp4_tp2pp2 and corresponding Llama 3.3 70B Instruct test variants

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description is incomplete and does not follow the repository template. The title section is missing, and critical sections like proper Description and Test Coverage details are largely incomplete. Add a proper PR title following [type] format (e.g., [None][fix]), expand the Description section to explain what changed and why, and complete the Test Coverage section listing specific tests that validate the changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: disabling GEMM+allreduce fusion by default, which matches the primary objective of the pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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: 1

Caution

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

⚠️ Outside diff range comments (1)
tensorrt_llm/_torch/models/modeling_llama.py (1)

1-3: Add SPDX/copyright header to this production .py file (required by repo guidelines).
As per coding guidelines, source files under tensorrt_llm/ should carry the NVIDIA copyright/SPDX header.

Proposed fix
+#
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
 import copy
 import os
 from typing import Any, Dict, List, Optional, Tuple, Union
🤖 Fix all issues with AI agents
In `@tests/integration/defs/accuracy/test_llm_api_pytorch.py`:
- Around line 696-705: The test function test_fp4_tp2pp2 is missing the param
enable_gemm_allreduce_fusion in its signature and mutates os.environ directly;
update the test_fp4_tp2pp2 signature to accept enable_gemm_allreduce_fusion (in
addition to torch_compile) and replace direct os.environ assignments with
monkeypatch.setenv calls to set "TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED" to "1" or
"0" so the environment is isolated and auto-restored after the test.
📜 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 92ae490 and df0e61d.

📒 Files selected for processing (2)
  • tensorrt_llm/_torch/models/modeling_llama.py
  • tests/integration/defs/accuracy/test_llm_api_pytorch.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/models/modeling_llama.py
  • tests/integration/defs/accuracy/test_llm_api_pytorch.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/models/modeling_llama.py
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
🧠 Learnings (16)
📓 Common learnings
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/thop/allreduceOp.cpp:352-446
Timestamp: 2025-09-23T15:12:38.312Z
Learning: In TensorRT-LLM NCCL device allreduce implementation (cpp/tensorrt_llm/thop/allreduceOp.cpp), the goto pattern in runNCCLAllReduceDeviceFusion is intentionally used for future extensibility, allowing multiple switch cases to fallback to the default handler. While not aesthetically ideal, this pattern supports adding more fusion cases later that can reuse the same fallback logic.
Learnt from: fredricz-20070104
Repo: NVIDIA/TensorRT-LLM PR: 7645
File: tests/integration/test_lists/qa/llm_function_core.txt:648-648
Timestamp: 2025-09-09T09:40:45.658Z
Learning: In TensorRT-LLM test lists, it's common and intentional for the same test to appear in multiple test list files when they serve different purposes (e.g., llm_function_core.txt for comprehensive core functionality testing and llm_function_core_sanity.txt for quick sanity checks). This duplication allows tests to be run in different testing contexts.
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.
Learnt from: moraxu
Repo: NVIDIA/TensorRT-LLM PR: 6303
File: tests/integration/test_lists/qa/examples_test_list.txt:494-494
Timestamp: 2025-07-28T17:06:08.621Z
Learning: In TensorRT-LLM testing, it's common to have both CLI flow tests (test_cli_flow.py) and PyTorch API tests (test_llm_api_pytorch.py) for the same model. These serve different purposes: CLI flow tests validate the traditional command-line workflow, while PyTorch API tests validate the newer LLM API backend. Both are legitimate and should coexist.
Learnt from: timlee0212
Repo: NVIDIA/TensorRT-LLM PR: 6886
File: tensorrt_llm/_torch/models/modeling_deepseekv3.py:0-0
Timestamp: 2025-08-14T06:36:40.701Z
Learning: In DeepSeek V3 model (tensorrt_llm/_torch/models/modeling_deepseekv3.py), the disagreement between AllReduce.__init__ guard and _compute_mlp_tp_size logic for MNNVL usage is expected by design. The AllReduce component and MLP TP-size computation intentionally use different criteria for MNNVL availability decisions.
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/thop/allreduceOp.cpp:352-446
Timestamp: 2025-09-23T15:12:38.312Z
Learning: In TensorRT-LLM NCCL device implementation, NCCL version 2.28+ requirements are handled at runtime in the nccl_device/config layer rather than with compile-time guards. This allows the allreduceOp to remain version-agnostic and delegates version compatibility validation to the appropriate lower-level components that can gracefully handle unsupported configurations.
📚 Learning: 2025-09-23T15:12:38.312Z
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/thop/allreduceOp.cpp:352-446
Timestamp: 2025-09-23T15:12:38.312Z
Learning: In TensorRT-LLM NCCL device allreduce implementation (cpp/tensorrt_llm/thop/allreduceOp.cpp), the goto pattern in runNCCLAllReduceDeviceFusion is intentionally used for future extensibility, allowing multiple switch cases to fallback to the default handler. While not aesthetically ideal, this pattern supports adding more fusion cases later that can reuse the same fallback logic.

Applied to files:

  • tensorrt_llm/_torch/models/modeling_llama.py
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-08-14T06:36:40.701Z
Learnt from: timlee0212
Repo: NVIDIA/TensorRT-LLM PR: 6886
File: tensorrt_llm/_torch/models/modeling_deepseekv3.py:0-0
Timestamp: 2025-08-14T06:36:40.701Z
Learning: In DeepSeek V3 model (tensorrt_llm/_torch/models/modeling_deepseekv3.py), the disagreement between AllReduce.__init__ guard and _compute_mlp_tp_size logic for MNNVL usage is expected by design. The AllReduce component and MLP TP-size computation intentionally use different criteria for MNNVL availability decisions.

Applied to files:

  • tensorrt_llm/_torch/models/modeling_llama.py
📚 Learning: 2025-08-19T12:45:11.997Z
Learnt from: amitz-nv
Repo: NVIDIA/TensorRT-LLM PR: 7033
File: tensorrt_llm/_torch/pyexecutor/model_engine.py:0-0
Timestamp: 2025-08-19T12:45:11.997Z
Learning: In tensorrt_llm/_torch/pyexecutor/model_engine.py, DoRA (Delta Orthogonal Rank Adaptation) functionality was removed from the PyTorch flow to eliminate issues with inverted DoRA detection logic. The original is_dora condition was checking if scaling_vec_pointer == 0, which was potentially incorrect.

Applied to files:

  • tensorrt_llm/_torch/models/modeling_llama.py
📚 Learning: 2025-08-14T15:38:01.771Z
Learnt from: MatthiasKohl
Repo: NVIDIA/TensorRT-LLM PR: 6904
File: cpp/tensorrt_llm/pybind/thop/bindings.cpp:55-57
Timestamp: 2025-08-14T15:38:01.771Z
Learning: In TensorRT-LLM Python bindings, tensor parameter collections like mla_tensor_params and spec_decoding_tensor_params are kept as required parameters without defaults to maintain API consistency, even when it might affect backward compatibility.

Applied to files:

  • tensorrt_llm/_torch/models/modeling_llama.py
📚 Learning: 2025-09-23T15:12:38.312Z
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/thop/allreduceOp.cpp:352-446
Timestamp: 2025-09-23T15:12:38.312Z
Learning: In TensorRT-LLM NCCL device implementation, NCCL version 2.28+ requirements are handled at runtime in the nccl_device/config layer rather than with compile-time guards. This allows the allreduceOp to remain version-agnostic and delegates version compatibility validation to the appropriate lower-level components that can gracefully handle unsupported configurations.

Applied to files:

  • tensorrt_llm/_torch/models/modeling_llama.py
📚 Learning: 2025-09-09T09:40:45.658Z
Learnt from: fredricz-20070104
Repo: NVIDIA/TensorRT-LLM PR: 7645
File: tests/integration/test_lists/qa/llm_function_core.txt:648-648
Timestamp: 2025-09-09T09:40:45.658Z
Learning: In TensorRT-LLM test lists, it's common and intentional for the same test to appear in multiple test list files when they serve different purposes (e.g., llm_function_core.txt for comprehensive core functionality testing and llm_function_core_sanity.txt for quick sanity checks). This duplication allows tests to be run in different testing contexts.

Applied to files:

  • tensorrt_llm/_torch/models/modeling_llama.py
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-08-06T13:58:07.506Z
Learnt from: galagam
Repo: NVIDIA/TensorRT-LLM PR: 6487
File: tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py:1-12
Timestamp: 2025-08-06T13:58:07.506Z
Learning: In TensorRT-LLM, test files (files under tests/ directories) do not require NVIDIA copyright headers, unlike production source code files. Test files typically start directly with imports, docstrings, or code.

Applied to files:

  • tensorrt_llm/_torch/models/modeling_llama.py
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-11-14T11:22:03.729Z
Learnt from: nzmora-nvidia
Repo: NVIDIA/TensorRT-LLM PR: 9163
File: tensorrt_llm/_torch/auto_deploy/custom_ops/quant.py:107-113
Timestamp: 2025-11-14T11:22:03.729Z
Learning: In TensorRT-LLM AutoDeploy custom ops, when adding hardware capability checks to select between kernel implementations (e.g., cuBLAS vs. CUDA kernel), use descriptive variable names that identify the specific GPU architectures or families being targeted (e.g., `is_blackwell_geforce_or_ada`) rather than generic names like `enable_cuda_core`. This makes it clear that the code is selecting an implementation path based on hardware capabilities, not enabling/disabling hardware features.

Applied to files:

  • tensorrt_llm/_torch/models/modeling_llama.py
📚 Learning: 2025-08-26T09:37:10.463Z
Learnt from: jiaganc
Repo: NVIDIA/TensorRT-LLM PR: 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/_torch/models/modeling_llama.py
📚 Learning: 2025-08-26T09:37:10.463Z
Learnt from: jiaganc
Repo: NVIDIA/TensorRT-LLM PR: 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_llama.py
📚 Learning: 2025-07-28T17:06:08.621Z
Learnt from: moraxu
Repo: NVIDIA/TensorRT-LLM PR: 6303
File: tests/integration/test_lists/qa/examples_test_list.txt:494-494
Timestamp: 2025-07-28T17:06:08.621Z
Learning: In TensorRT-LLM testing, it's common to have both CLI flow tests (test_cli_flow.py) and PyTorch API tests (test_llm_api_pytorch.py) for the same model. These serve different purposes: CLI flow tests validate the traditional command-line workflow, while PyTorch API tests validate the newer LLM API backend. Both are legitimate and should coexist.

Applied to files:

  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-08-26T09:49:04.956Z
Learnt from: pengbowang-nv
Repo: NVIDIA/TensorRT-LLM PR: 7192
File: tests/integration/test_lists/test-db/l0_dgx_b200.yml:56-72
Timestamp: 2025-08-26T09:49:04.956Z
Learning: In TensorRT-LLM test configuration files, the test scheduling system handles wildcard matching with special rules that prevent duplicate test execution even when the same tests appear in multiple yaml files with overlapping GPU wildcards (e.g., "*b200*" and "*gb200*").

Applied to files:

  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-11-27T09:23:18.742Z
Learnt from: fredricz-20070104
Repo: NVIDIA/TensorRT-LLM PR: 9511
File: tests/integration/defs/examples/serve/test_serve.py:136-186
Timestamp: 2025-11-27T09:23:18.742Z
Learning: In TensorRT-LLM testing, when adding test cases based on RCCA commands, the command format should be copied exactly as it appears in the RCCA case, even if it differs from existing tests. For example, some RCCA commands for trtllm-serve may omit the "serve" subcommand while others include it.

Applied to files:

  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-08-11T20:09:24.389Z
Learnt from: achartier
Repo: NVIDIA/TensorRT-LLM PR: 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:

  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-08-29T14:07:45.863Z
Learnt from: EmmaQiaoCh
Repo: NVIDIA/TensorRT-LLM PR: 7370
File: tests/unittest/trt/model_api/test_model_quantization.py:24-27
Timestamp: 2025-08-29T14:07:45.863Z
Learning: In TensorRT-LLM's CI infrastructure, pytest skip markers (pytest.mark.skip) are properly honored even when test files have __main__ blocks that call test functions directly. The testing system correctly skips tests without requiring modifications to the __main__ block execution pattern.

Applied to files:

  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
🧬 Code graph analysis (1)
tests/integration/defs/accuracy/test_llm_api_pytorch.py (1)
tests/integration/defs/conftest.py (1)
  • parametrize_with_ids (1836-1862)
🪛 Ruff (0.14.11)
tests/integration/defs/accuracy/test_llm_api_pytorch.py

701-701: Undefined name enable_gemm_allreduce_fusion

(F821)

⏰ 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)
tensorrt_llm/_torch/models/modeling_llama.py (1)

677-690: Default-disable GEMM+allreduce fusion looks consistent with the stated rollout.
This flips the default to disabled while still allowing explicit opt-in via TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED=1.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines 696 to 705
@parametrize_with_ids("enable_gemm_allreduce_fusion", [True, False])
def test_fp4_tp2pp2(self, torch_compile):
model_path = f"{llm_models_root()}/llama-3.3-models/Llama-3.3-70B-Instruct-FP4"
kv_cache_config = KvCacheConfig(free_gpu_memory_fraction=0.5)
torch_compile_config = _get_default_torch_compile_config(torch_compile)
if enable_gemm_allreduce_fusion:
os.environ["TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED"] = "1"
else:
os.environ["TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED"] = "0"

Copy link
Contributor

@coderabbitai coderabbitai bot Jan 14, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Find and read the test file around lines 696-705
find . -path "*/tests/integration/defs/accuracy/test_llm_api_pytorch.py" -type f

Repository: NVIDIA/TensorRT-LLM

Length of output: 120


🏁 Script executed:

# Once found, check file size and read the relevant section
wc -l tests/integration/defs/accuracy/test_llm_api_pytorch.py

Repository: NVIDIA/TensorRT-LLM

Length of output: 123


🏁 Script executed:

# Read the specific section with context
sed -n '690,720p' tests/integration/defs/accuracy/test_llm_api_pytorch.py

Repository: NVIDIA/TensorRT-LLM

Length of output: 1497


🏁 Script executed:

# Check the full method and surrounding decorators
sed -n '680,730p' tests/integration/defs/accuracy/test_llm_api_pytorch.py

Repository: NVIDIA/TensorRT-LLM

Length of output: 2392


🏁 Script executed:

# Look for import statements to understand available fixtures
head -50 tests/integration/defs/accuracy/test_llm_api_pytorch.py | grep -E "(import|from|pytest)"

Repository: NVIDIA/TensorRT-LLM

Length of output: 408


🏁 Script executed:

# Check if monkeypatch is used elsewhere in the file
rg "monkeypatch" tests/integration/defs/accuracy/test_llm_api_pytorch.py

Repository: NVIDIA/TensorRT-LLM

Length of output: 204


Add missing enable_gemm_allreduce_fusion parameter to method signature and use monkeypatch to isolate environment variable changes.

The parametrize decorator references enable_gemm_allreduce_fusion, but the method signature only accepts torch_compile. This will cause a NameError when the method tries to reference the undefined variable on line 702. Additionally, directly modifying os.environ without cleanup can leak state to other tests. Use monkeypatch.setenv() instead, which auto-restores the environment after the test completes.

Proposed fix
 `@pytest.mark.skip_less_device`(4)
 `@skip_pre_blackwell`
 `@parametrize_with_ids`("torch_compile", [False, True])
 `@parametrize_with_ids`("enable_gemm_allreduce_fusion", [True, False])
-    def test_fp4_tp2pp2(self, torch_compile):
+    def test_fp4_tp2pp2(self, torch_compile, enable_gemm_allreduce_fusion,
+                        monkeypatch):
         model_path = f"{llm_models_root()}/llama-3.3-models/Llama-3.3-70B-Instruct-FP4"
         kv_cache_config = KvCacheConfig(free_gpu_memory_fraction=0.5)
         torch_compile_config = _get_default_torch_compile_config(torch_compile)
-        if enable_gemm_allreduce_fusion:
-            os.environ["TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED"] = "1"
-        else:
-            os.environ["TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED"] = "0"
+        monkeypatch.setenv(
+            "TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED",
+            "1" if enable_gemm_allreduce_fusion else "0",
+        )
 
         with LLM(model_path,
                  tensor_parallel_size=2,
                  pipeline_parallel_size=2,
                  max_batch_size=32,
                  kv_cache_config=kv_cache_config,
                  torch_compile_config=torch_compile_config) as llm:
🧰 Tools
🪛 Ruff (0.14.11)

701-701: Undefined name enable_gemm_allreduce_fusion

(F821)

🤖 Prompt for AI Agents
In `@tests/integration/defs/accuracy/test_llm_api_pytorch.py` around lines 696 -
705, The test function test_fp4_tp2pp2 is missing the param
enable_gemm_allreduce_fusion in its signature and mutates os.environ directly;
update the test_fp4_tp2pp2 signature to accept enable_gemm_allreduce_fusion (in
addition to torch_compile) and replace direct os.environ assignments with
monkeypatch.setenv calls to set "TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED" to "1" or
"0" so the environment is isolated and auto-restored after the test.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment by CodeRabbit should be followed :) you can use the built-in libraries as well:

with mock.patch.dict(
    os.environ,
    {"TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED": str(int(enable_gemm_allreduce_fusion))},
), LLM(...):
    # etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

@2ez4bz Thank you for the suggestion! Using mock.patch.dict is indeed a cleaner approach. Here's the complete fix including the missing parameter in the function signature:

`@pytest.mark.skip_less_device`(4)
`@skip_pre_blackwell`
`@parametrize_with_ids`("torch_compile", [False, True])
`@parametrize_with_ids`("enable_gemm_allreduce_fusion", [True, False])
def test_fp4_tp2pp2(self, torch_compile, enable_gemm_allreduce_fusion):
    model_path = f"{llm_models_root()}/llama-3.3-models/Llama-3.3-70B-Instruct-FP4"
    kv_cache_config = KvCacheConfig(free_gpu_memory_fraction=0.5)
    torch_compile_config = _get_default_torch_compile_config(torch_compile)
    
    with mock.patch.dict(
        os.environ,
        {"TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED": str(int(enable_gemm_allreduce_fusion))},
    ), LLM(
        model_path,
        tensor_parallel_size=2,
        pipeline_parallel_size=2,
        max_batch_size=32,
        kv_cache_config=kv_cache_config,
        torch_compile_config=torch_compile_config
    ) as llm:
        assert llm.args.quant_config.quant_algo == QuantAlgo.NVFP4
        sampling_params = SamplingParams(
            max_tokens=256,
            temperature=0.0,
            add_special_tokens=False,
        )
        task = MMLU(self.MODEL_NAME)
        task.evaluate(llm, sampling_params=sampling_params)
        task = GSM8K(self.MODEL_NAME)
        task.evaluate(llm, sampling_params=sampling_params)
        task = GPQADiamond(self.MODEL_NAME)
        task.evaluate(llm,
                      extra_evaluator_kwargs=dict(apply_chat_template=True))

Note: Make sure mock is imported at the top of the file:

from unittest import mock

This approach is better because:

  • No need for the monkeypatch fixture parameter
  • The environment variable change is scoped to just this test execution
  • Automatic cleanup via context managers
  • More explicit and readable

🧠 Learnings used
Learnt from: moraxu
Repo: NVIDIA/TensorRT-LLM PR: 6303
File: tests/integration/test_lists/qa/examples_test_list.txt:494-494
Timestamp: 2025-07-28T17:06:08.621Z
Learning: In TensorRT-LLM testing, it's common to have both CLI flow tests (test_cli_flow.py) and PyTorch API tests (test_llm_api_pytorch.py) for the same model. These serve different purposes: CLI flow tests validate the traditional command-line workflow, while PyTorch API tests validate the newer LLM API backend. Both are legitimate and should coexist.

Learnt from: fredricz-20070104
Repo: NVIDIA/TensorRT-LLM PR: 7645
File: tests/integration/test_lists/qa/llm_function_core.txt:648-648
Timestamp: 2025-09-09T09:40:45.658Z
Learning: In TensorRT-LLM test lists, it's common and intentional for the same test to appear in multiple test list files when they serve different purposes (e.g., llm_function_core.txt for comprehensive core functionality testing and llm_function_core_sanity.txt for quick sanity checks). This duplication allows tests to be run in different testing contexts.

Learnt from: nvpohanh
Repo: NVIDIA/TensorRT-LLM PR: 7478
File: tests/unittest/_torch/modeling/test_modeling_llama_min_latency.py:286-308
Timestamp: 2025-09-03T13:16:38.028Z
Learning: In test files, temporary monkey-patches for upstream bugs can be kept simple when they are explicitly intended to be removed soon, rather than investing effort in making them more robust.

Learnt from: EmmaQiaoCh
Repo: NVIDIA/TensorRT-LLM PR: 7370
File: tests/unittest/trt/model_api/test_model_quantization.py:24-27
Timestamp: 2025-08-29T14:07:45.863Z
Learning: In TensorRT-LLM's CI infrastructure, pytest skip markers (pytest.mark.skip) are properly honored even when test files have __main__ blocks that call test functions directly. The testing system correctly skips tests without requiring modifications to the __main__ block execution pattern.

Learnt from: pengbowang-nv
Repo: NVIDIA/TensorRT-LLM PR: 7192
File: tests/integration/test_lists/test-db/l0_dgx_b200.yml:56-72
Timestamp: 2025-08-26T09:49:04.956Z
Learning: In TensorRT-LLM test configuration files, the test scheduling system handles wildcard matching with special rules that prevent duplicate test execution even when the same tests appear in multiple yaml files with overlapping GPU wildcards (e.g., "*b200*" and "*gb200*").

Learnt from: fredricz-20070104
Repo: NVIDIA/TensorRT-LLM PR: 9511
File: tests/integration/defs/examples/serve/test_serve.py:136-186
Timestamp: 2025-11-27T09:23:18.742Z
Learning: In TensorRT-LLM testing, when adding test cases based on RCCA commands, the command format should be copied exactly as it appears in the RCCA case, even if it differs from existing tests. For example, some RCCA commands for trtllm-serve may omit the "serve" subcommand while others include it.

Learnt from: galagam
Repo: NVIDIA/TensorRT-LLM PR: 6487
File: tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py:1-12
Timestamp: 2025-08-06T13:58:07.506Z
Learning: In TensorRT-LLM, test files (files under tests/ directories) do not require NVIDIA copyright headers, unlike production source code files. Test files typically start directly with imports, docstrings, or code.

Learnt from: achartier
Repo: NVIDIA/TensorRT-LLM PR: 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.

Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/thop/allreduceOp.cpp:352-446
Timestamp: 2025-09-23T15:12:38.312Z
Learning: In TensorRT-LLM NCCL device allreduce implementation (cpp/tensorrt_llm/thop/allreduceOp.cpp), the goto pattern in runNCCLAllReduceDeviceFusion is intentionally used for future extensibility, allowing multiple switch cases to fallback to the default handler. While not aesthetically ideal, this pattern supports adding more fusion cases later that can reuse the same fallback logic.

Learnt from: nzmora-nvidia
Repo: NVIDIA/TensorRT-LLM PR: 9163
File: tensorrt_llm/_torch/auto_deploy/custom_ops/quant.py:107-113
Timestamp: 2025-11-14T11:22:03.729Z
Learning: In TensorRT-LLM AutoDeploy custom ops, when adding hardware capability checks to select between kernel implementations (e.g., cuBLAS vs. CUDA kernel), use descriptive variable names that identify the specific GPU architectures or families being targeted (e.g., `is_blackwell_geforce_or_ada`) rather than generic names like `enable_cuda_core`. This makes it clear that the code is selecting an implementation path based on hardware capabilities, not enabling/disabling hardware features.

@benzh-2025 benzh-2025 changed the title [None][fix]: default disable gemm+allreduce fusion [None][fix] default disable gemm+allreduce fusion Jan 14, 2026
@benzh-2025
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31898 [ run ] triggered by Bot. Commit: df0e61d

kv_cache_config = KvCacheConfig(free_gpu_memory_fraction=0.5)
torch_compile_config = _get_default_torch_compile_config(torch_compile)
if enable_gemm_allreduce_fusion:
os.environ["TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED"] = "1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Multiple tests can run in same process, so you'll need to clean up the env after the test run.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point, let me change, thanks a lot.

Comment on lines 696 to 705
@parametrize_with_ids("enable_gemm_allreduce_fusion", [True, False])
def test_fp4_tp2pp2(self, torch_compile):
model_path = f"{llm_models_root()}/llama-3.3-models/Llama-3.3-70B-Instruct-FP4"
kv_cache_config = KvCacheConfig(free_gpu_memory_fraction=0.5)
torch_compile_config = _get_default_torch_compile_config(torch_compile)
if enable_gemm_allreduce_fusion:
os.environ["TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED"] = "1"
else:
os.environ["TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED"] = "0"

Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment by CodeRabbit should be followed :) you can use the built-in libraries as well:

with mock.patch.dict(
    os.environ,
    {"TRTLLM_GEMM_ALLREDUCE_FUSION_ENABLED": str(int(enable_gemm_allreduce_fusion))},
), LLM(...):
    # etc.

@benzh-2025
Copy link
Collaborator Author

/bot run --disable-fail-fast

@benzh-2025 benzh-2025 requested a review from 2ez4bz January 14, 2026 06:21
@tensorrt-cicd
Copy link
Collaborator

PR_Github #31905 [ run ] triggered by Bot. Commit: 48d067b

@benzh-2025
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31932 [ run ] triggered by Bot. Commit: 48d067b

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31932 [ run ] completed with state SUCCESS. Commit: 48d067b
/LLM/main/L0_MergeRequest_PR pipeline #24731 completed with status: 'FAILURE'

⚠️ 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

@benzh-2025
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31971 [ run ] triggered by Bot. Commit: 48d067b

@tensorrt-cicd
Copy link
Collaborator

PR_Github #31971 [ run ] completed with state SUCCESS. Commit: 48d067b
/LLM/main/L0_MergeRequest_PR pipeline #24768 completed with status: 'FAILURE'

⚠️ 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

@benzh-2025
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32036 [ run ] triggered by Bot. Commit: 48d067b

@benzh-2025 benzh-2025 force-pushed the fix/benzh/default_disabble_gemm_allreduce branch from 48d067b to 3746393 Compare January 15, 2026 03:31
@benzh-2025 benzh-2025 requested a review from a team as a code owner January 15, 2026 03:31
@benzh-2025 benzh-2025 requested a review from yuxianq January 15, 2026 03:31
@benzh-2025 benzh-2025 force-pushed the fix/benzh/default_disabble_gemm_allreduce branch from 3746393 to ef7e9ba Compare January 15, 2026 03:34
@benzh-2025
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32062 [ run ] triggered by Bot. Commit: ef7e9ba

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32036 [ run ] completed with state ABORTED. Commit: 48d067b
LLM/main/L0_MergeRequest_PR #24828 (Blue Ocean) completed with status: ABORTED

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32062 [ run ] completed with state SUCCESS. Commit: ef7e9ba
/LLM/main/L0_MergeRequest_PR pipeline #24849 completed with status: 'FAILURE'

⚠️ 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

Signed-off-by: benzh-2025 <[email protected]>
Signed-off-by: benzh-2025 <[email protected]>
Signed-off-by: benzh-2025 <[email protected]>
@benzh-2025 benzh-2025 force-pushed the fix/benzh/default_disabble_gemm_allreduce branch from ef7e9ba to aa363ed Compare January 15, 2026 08:05
@benzh-2025
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #32099 [ run ] triggered by Bot. Commit: aa363ed

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