Skip to content

[https://nvbugs/6445494][infra] Upgrade Triton to 3.7.1 for Torch 2.12.1 compatibility - #16303

Open
HandongLi-01 wants to merge 4 commits into
NVIDIA:mainfrom
HandongLi-01:dev/handongl/upgrade-triton-3.7.0
Open

[https://nvbugs/6445494][infra] Upgrade Triton to 3.7.1 for Torch 2.12.1 compatibility#16303
HandongLi-01 wants to merge 4 commits into
NVIDIA:mainfrom
HandongLi-01:dev/handongl/upgrade-triton-3.7.0

Conversation

@HandongLi-01

@HandongLi-01 HandongLi-01 commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Description

Upgrade the public PyTorch stack to Torch 2.12.1 and Triton 3.7.1. Torch 2.12.1 requires triton==3.7.1 on Linux, replacing the previous Torch 2.11.0/Triton 3.6.0 combination. Triton 3.7.1 also includes the missing async-read proxy fence fix for Blackwell.

This PR migrates TensorRT-LLM to the Triton 3.7 APIs and re-vendors triton_kernels from v3.7.1.

Triton API migration

  • Replace triton_kernels.matmul_ogs with triton_kernels.matmul.
  • Update matmul_ogs() calls to matmul() and migrate the renamed a, b, c, and c_acc_in arguments.
  • Replace the removed RoutingData, GatherIndx, and ScatterIndx wrappers with TritonRoutingData, RaggedTensorMetadata, and plain gather/scatter tensors.
  • Explicitly combine the scattered GEMM2 expert outputs with triton_kernels.reduce, including masking invalid expert-parallel routing slots.
  • Migrate PrecisionConfig fields to a_mx_scale, b_mx_scale, and c_mx_scale.
  • Update MXFP4 layout handling for the new layout objects and trailing-dimension axis convention.
  • Keep MXFP4 value and scale layouts paired on Hopper while preserving the natural strided path for Blackwell and StridedLayout fallbacks.
  • Pad and slice unaligned MXFP4 quantization axes required by the new fast conversion kernels.

Dependency and CI updates

  • Pin Torch to >=2.12.1,<=2.13.0a0.
  • Pin Triton to 3.7.1.
  • Re-vendor triton_kernels from the Triton v3.7.1 tag.
  • Update the public installation script, installation documentation, Jenkins bare-metal installation, and README Torch badge.
  • Refresh security_scanning/pyproject.toml and poetry.lock with Poetry 2.4.1.
  • Preserve the new NCCL-EP nccl4py>=0.3.1,<0.4 dependency introduced on main.
  • Remove the obsolete Jenkins Torch pin workaround, since the public Torch wheel now supplies the matching Triton dependency.

Test Coverage

Relevant coverage includes:

  • tests/unittest/others/test_triton_kernels_vendoring.py
  • tests/unittest/_torch/modules/test_fused_moe.py
  • tests/unittest/_torch/modules/test_triton_linear.py
  • tests/unittest/_torch/modules/fused_moe/test_triton_mxfp4_swizzle.py
  • tests/unittest/auto_deploy/singlegpu/custom_ops/moe/test_mxfp4_moe_layout.py
  • tests/unittest/auto_deploy/singlegpu/custom_ops/moe/test_triton_moe.py

Local validation completed:

  • Pre-commit checks
  • Poetry lock validation
  • Vendored Triton version verification
  • Python syntax checks
  • DCO sign-off verification

PR Checklist

  • PR title follows the required format
  • PR description explains the change
  • CI results pending

Dev Engineer Review

  • Upgraded vendored Triton/triton-kernels for PyTorch 2.12.x compatibility:
    • Bumped triton / triton-kernels to 3.7.1 and updated vendored provenance metadata across triton_kernels/* (including triton_kernels/VERSION, triton_kernels/README.md, and numerous header “Source” comments).
  • Migrated Triton MoE GEMM implementation from the removed matmul_ogs/routing-precision API to the new triton_kernels.matmul flex-precision API:
    • Deleted triton_kernels/matmul_ogs.py.
    • Updated tensorrt_llm/_torch/modules/fused_moe/fused_moe_triton.py to use matmul and the new routing contract:
      • Introduced TritonRoutingData.
      • Replaced matmul_ogs final/top-k behavior with explicit masked reduction via combine_expert_outputs() after GEMM2 output reshaping.
    • Updated tensorrt_llm/_torch/modules/triton_linear.py and MXFP4 MoE fused op (tensorrt_llm/_torch/auto_deploy/custom_ops/fused_moe/mxfp4_moe.py) to use matmul and updated precision/routing fields (notably b_mx_scale, FlexCtx, and MXFP4 routing-data wiring).
    • Updated MXFP4 swizzle/layout handling to match the updated layout/TMA model, including conversion skipping behavior on Blackwell and refactors to swizzle/layout caching and layout-conversion gating.
  • Updated supporting vendored infrastructure enabled by Triton 3.7.x changes:
    • Added symmetric distributed memory support (triton_kernels/distributed_details/mesh.py) and extended Triton topk/reduce paths to use it.
    • Extended tensorrt_llm/tools/profiler/nsys_profile_tools/trtllm_engine_model.json MoE GEMM kernel matching regexes for additional fused/MoE variants.
    • Updated triton_kernels/reduce.py API to accept unpadded_batch_size.
  • Updated PyTorch install/test configuration and removed Jenkins workaround:
    • Set Torch to 2.12.1 (and updated torchvision pins as applicable) in docker/common/install_pytorch.sh, docs/source/installation/installation-guide.md, requirements.txt, security_scanning/pyproject.toml.
    • Removed Jenkins pin_torch parameter logic in jenkins/L0_Test.groovy and adjusted “Extra PyTorch CUDA 13.2 install” pins accordingly.
  • CI health/correctness risk:
    • Multiple helper and MR pipelines reported failures/aborts for the listed commits; given this is a stacked migration test, follow-up reruns and failure-analysis/rectification are required before declaring correctness.

QA Engineer Review

Test changes

Touched unit/auto-deploy test code under tests/:

  • tests/unittest/_torch/modules/fused_moe/test_triton_mxfp4_swizzle.py
    • Modified the value/scale swizzle conversion tests to pass explicit HopperMX*Layout instances into convert_layout and convert_layout_expert_chunked.
  • tests/unittest/_torch/modules/test_fused_moe.py
    • Modified test_fused_moe_triton_mxfp4 MXFP4 FP32 conversion helpers to satisfy Triton 3.7.x 32-alignment requirements (pad/slice logic added for quant axis handling).
  • tests/unittest/auto_deploy/singlegpu/custom_ops/moe/test_mxfp4_moe_layout.py
    • Removed: test_mxfp4_value_layout_uses_strided_layout_on_blackwell
    • Added/updated:
      • test_mxfp4_value_layout_skips_conversion_on_blackwell
      • test_mxfp4_value_layout_skips_conversion_for_strided_fallback
      • test_mxfp4_scale_layout_skips_conversion_on_blackwell
      • test_mxfp4_scale_layout_skips_conversion_for_strided_fallback
      • test_mxfp4_scale_layout_keeps_hopper_layout

Test list / CI entry coverage

  • No changes were found in tests/integration/test_lists/, test-db/, qa/, or waives.txt for this PR’s diff.
  • Coverage against test-db/CI/manual-qa entries for the modified test functions could not be confirmed from the repo’s list/waiver files during review.
  • Verdict: needs follow-up (CI helper/MR pipelines reported failures for multiple commits; updated unit tests may not yet reflect/cover the failing CI paths).

@HandongLi-01

Copy link
Copy Markdown
Collaborator Author

/bot run

@HandongLi-01 HandongLi-01 changed the title [TRTLLM-14254][infra] Upgrade triton to 3.7.0 for torch 2.12.0 compatibility [TRTLLM-14254][infra] DO NOT REVIEW: Upgrade triton to 3.7.0 for torch 2.12.0 compatibility Jul 13, 2026
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58911 [ run ] triggered by Bot. Commit: 1c778bb Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58911 [ run ] completed with state FAILURE. Commit: 1c778bb

Link to invocation

@HandongLi-01

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58918 [ run ] triggered by Bot. Commit: 1c778bb Link to invocation

@HandongLi-01

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58939 [ run ] triggered by Bot. Commit: bb6d6c4 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58918 [ run ] completed with state ABORTED. Commit: 1c778bb

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@HandongLi-01

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #59078 [ run ] triggered by Bot. Commit: bb6d6c4 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@HandongLi-01
HandongLi-01 force-pushed the dev/handongl/upgrade-triton-3.7.0 branch from bb6d6c4 to fe98fc6 Compare July 16, 2026 07:05
@HandongLi-01

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #59653 [ run ] triggered by Bot. Commit: fe98fc6 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@HandongLi-01

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #59675 [ run ] triggered by Bot. Commit: fe98fc6 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@HandongLi-01
HandongLi-01 force-pushed the dev/handongl/upgrade-triton-3.7.0 branch 2 times, most recently from 392e437 to 6d76449 Compare July 20, 2026 04:50
@HandongLi-01

Copy link
Copy Markdown
Collaborator Author

/bot run

@HandongLi-01
HandongLi-01 force-pushed the dev/handongl/upgrade-triton-3.7.0 branch from 6d76449 to 62e992e Compare July 20, 2026 05:52
@HandongLi-01

Copy link
Copy Markdown
Collaborator Author

/bot run

@HandongLi-01 HandongLi-01 changed the title [TRTLLM-14254][infra] DO NOT REVIEW: Upgrade triton to 3.7.0 for torch 2.12.0 compatibility [https://nvbugs/6445494][infra] Upgrade triton to 3.7.0 for torch 2.12.0 compatibility Jul 20, 2026
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #60281 [ run ] triggered by Bot. Commit: 62e992e Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #60281 [ run ] completed with state SUCCESS. Commit: 62e992e
/LLM/main/L0_MergeRequest_PR pipeline #48637 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

@HandongLi-01

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@EmmaQiaoCh

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61199 [ run ] triggered by Bot. Commit: b5f093c Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@HandongLi-01
HandongLi-01 force-pushed the dev/handongl/upgrade-triton-3.7.0 branch from f5d35b2 to 92dc585 Compare July 23, 2026 08:56

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

Caution

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

⚠️ Outside diff range comments (1)
tests/unittest/_torch/modules/test_fused_moe.py (1)

2593-2633: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add a test-list entry for test_fused_moe_triton_mxfp4 The parametrization already covers unaligned sizes (INTERMEDIATE_SIZE=720 and 360), but there’s no matching entry under tests/integration/test_lists/test-db/ or tests/integration/test_lists/qa/.

🤖 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/modules/test_fused_moe.py` around lines 2593 - 2633,
The test-list configuration is missing an entry for test_fused_moe_triton_mxfp4.
Add this test to the appropriate test-db and QA lists under the existing
fused-MoE test-list conventions, preserving its parameterization for
INTERMEDIATE_SIZE values 720 and 360.

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.

Outside diff comments:
In `@tests/unittest/_torch/modules/test_fused_moe.py`:
- Around line 2593-2633: The test-list configuration is missing an entry for
test_fused_moe_triton_mxfp4. Add this test to the appropriate test-db and QA
lists under the existing fused-MoE test-list conventions, preserving its
parameterization for INTERMEDIATE_SIZE values 720 and 360.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e7b5f975-334a-4f4e-bfb3-1821adcf6cda

📥 Commits

Reviewing files that changed from the base of the PR and between 92dc585 and c17dc45.

📒 Files selected for processing (6)
  • requirements.txt
  • tensorrt_llm/_torch/auto_deploy/custom_ops/fused_moe/mxfp4_moe.py
  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_triton.py
  • tensorrt_llm/_torch/modules/triton_linear.py
  • tests/unittest/_torch/modules/test_fused_moe.py
  • tests/unittest/auto_deploy/singlegpu/custom_ops/moe/test_mxfp4_moe_layout.py
🚧 Files skipped from review as they are similar to previous changes (5)
  • requirements.txt
  • tensorrt_llm/_torch/modules/triton_linear.py
  • tests/unittest/auto_deploy/singlegpu/custom_ops/moe/test_mxfp4_moe_layout.py
  • tensorrt_llm/_torch/auto_deploy/custom_ops/fused_moe/mxfp4_moe.py
  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_triton.py

@HandongLi-01
HandongLi-01 force-pushed the dev/handongl/upgrade-triton-3.7.0 branch from c17dc45 to 817d2d6 Compare July 23, 2026 09:24

@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: 2

🤖 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 `@docker/common/install_pytorch.sh`:
- Line 8: Update the PyPI install command in install_pytorch.sh to pin
torchvision to version 0.27.1 instead of leaving it unversioned. Preserve the
existing torch version variable and all other installation arguments.

In `@triton_kernels/matmul_details/opt_flags.py`:
- Around line 241-271: Update the bf16 exclusion in the conditional heuristic
after compute_block_k to compare lhs_dtype against Triton’s BF16 DataType
constant rather than torch.bfloat16, preserving the intended behavior of
skipping the swap for bf16 inputs.
🪄 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: 597c47dd-843e-46b6-8c3b-f6504280aaf9

📥 Commits

Reviewing files that changed from the base of the PR and between c17dc45 and 817d2d6.

⛔ Files ignored due to path filters (1)
  • security_scanning/poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (66)
  • ATTRIBUTIONS-Python.md
  • docker/common/install_pytorch.sh
  • docs/source/installation/installation-guide.md
  • jenkins/L0_Test.groovy
  • requirements.txt
  • scripts/vendor_triton_kernels.py
  • security_scanning/pyproject.toml
  • tensorrt_llm/_torch/auto_deploy/custom_ops/README.md
  • tensorrt_llm/_torch/auto_deploy/custom_ops/fused_moe/mxfp4_moe.py
  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_triton.py
  • tensorrt_llm/_torch/modules/triton_linear.py
  • tensorrt_llm/tools/profiler/nsys_profile_tools/trtllm_engine_model.json
  • tests/unittest/_torch/modules/fused_moe/test_triton_mxfp4_swizzle.py
  • tests/unittest/_torch/modules/test_fused_moe.py
  • tests/unittest/auto_deploy/singlegpu/custom_ops/moe/test_mxfp4_moe_layout.py
  • triton_kernels/README.md
  • triton_kernels/VERSION
  • triton_kernels/__init__.py
  • triton_kernels/compaction.py
  • triton_kernels/compaction_details/_masked_compaction.py
  • triton_kernels/distributed.py
  • triton_kernels/distributed_details/__init__.py
  • triton_kernels/distributed_details/mesh.py
  • triton_kernels/matmul.py
  • triton_kernels/matmul_details/__init__.py
  • triton_kernels/matmul_details/_common.py
  • triton_kernels/matmul_details/_matmul.py
  • triton_kernels/matmul_details/_p_matmul.py
  • triton_kernels/matmul_details/opt_flags.py
  • triton_kernels/matmul_details/opt_flags_details/__init__.py
  • triton_kernels/matmul_details/opt_flags_details/opt_flags_amd.py
  • triton_kernels/matmul_details/opt_flags_details/opt_flags_nvidia.py
  • triton_kernels/matmul_ogs.py
  • triton_kernels/meta.py
  • triton_kernels/numerics.py
  • triton_kernels/numerics_details/__init__.py
  • triton_kernels/numerics_details/flexpoint.py
  • triton_kernels/numerics_details/mxfp.py
  • triton_kernels/numerics_details/mxfp_details/_downcast_to_mxfp.py
  • triton_kernels/numerics_details/mxfp_details/_upcast_from_mxfp.py
  • triton_kernels/proton_opts.py
  • triton_kernels/reduce.py
  • triton_kernels/roofline.py
  • triton_kernels/specialize.py
  • triton_kernels/swiglu.py
  • triton_kernels/swiglu_details/_swiglu.py
  • triton_kernels/target_info.py
  • triton_kernels/tensor.py
  • triton_kernels/tensor_details/bitmatrix.py
  • triton_kernels/tensor_details/bitmatrix_details/sum_bitmatrix_rows.py
  • triton_kernels/tensor_details/dtype.py
  • triton_kernels/tensor_details/layout.py
  • triton_kernels/tensor_details/layout_details/base.py
  • triton_kernels/tensor_details/layout_details/blackwell_scale.py
  • triton_kernels/tensor_details/layout_details/blackwell_value.py
  • triton_kernels/tensor_details/layout_details/cdna4_scale.py
  • triton_kernels/tensor_details/layout_details/hopper_scale.py
  • triton_kernels/tensor_details/layout_details/hopper_value.py
  • triton_kernels/tensor_details/layout_details/strided.py
  • triton_kernels/tensor_details/layout_details/torch_utils.py
  • triton_kernels/tensor_details/ragged_tensor.py
  • triton_kernels/testing.py
  • triton_kernels/topk.py
  • triton_kernels/topk_details/__init__.py
  • triton_kernels/topk_details/_topk_backward.py
  • triton_kernels/topk_details/_topk_forward.py
💤 Files with no reviewable changes (1)
  • triton_kernels/matmul_ogs.py
🚧 Files skipped from review as they are similar to previous changes (43)
  • triton_kernels/VERSION
  • docs/source/installation/installation-guide.md
  • triton_kernels/topk_details/_topk_backward.py
  • triton_kernels/swiglu.py
  • triton_kernels/numerics_details/init.py
  • triton_kernels/tensor_details/bitmatrix_details/sum_bitmatrix_rows.py
  • triton_kernels/distributed_details/init.py
  • triton_kernels/compaction_details/_masked_compaction.py
  • triton_kernels/matmul_details/init.py
  • triton_kernels/README.md
  • triton_kernels/tensor_details/bitmatrix.py
  • ATTRIBUTIONS-Python.md
  • triton_kernels/init.py
  • triton_kernels/matmul_details/opt_flags_details/init.py
  • triton_kernels/meta.py
  • triton_kernels/numerics_details/mxfp_details/_upcast_from_mxfp.py
  • triton_kernels/numerics_details/flexpoint.py
  • tensorrt_llm/_torch/auto_deploy/custom_ops/README.md
  • triton_kernels/tensor_details/dtype.py
  • security_scanning/pyproject.toml
  • triton_kernels/target_info.py
  • triton_kernels/numerics.py
  • triton_kernels/specialize.py
  • tests/unittest/_torch/modules/test_fused_moe.py
  • triton_kernels/tensor_details/layout.py
  • triton_kernels/topk_details/_topk_forward.py
  • triton_kernels/tensor_details/layout_details/base.py
  • triton_kernels/compaction.py
  • tests/unittest/_torch/modules/fused_moe/test_triton_mxfp4_swizzle.py
  • triton_kernels/tensor_details/layout_details/torch_utils.py
  • requirements.txt
  • tensorrt_llm/tools/profiler/nsys_profile_tools/trtllm_engine_model.json
  • triton_kernels/matmul_details/opt_flags_details/opt_flags_amd.py
  • triton_kernels/roofline.py
  • jenkins/L0_Test.groovy
  • triton_kernels/tensor_details/layout_details/strided.py
  • triton_kernels/distributed.py
  • triton_kernels/tensor_details/ragged_tensor.py
  • triton_kernels/tensor_details/layout_details/hopper_scale.py
  • triton_kernels/numerics_details/mxfp.py
  • triton_kernels/matmul_details/opt_flags_details/opt_flags_nvidia.py
  • triton_kernels/tensor_details/layout_details/blackwell_scale.py
  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_triton.py

# and closest to the version specified in
# https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/rel-26-05.html#rel-26-05
TORCH_VERSION="2.11.0"
TORCH_VERSION="2.12.1"

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== file outline ==\n'
ast-grep outline docker/common/install_pytorch.sh --view expanded || true

printf '\n== relevant lines ==\n'
cat -n docker/common/install_pytorch.sh | sed -n '1,180p'

Repository: NVIDIA/TensorRT-LLM

Length of output: 3652


🏁 Script executed:

set -euo pipefail

printf '\n== file outline ==\n'
ast-grep outline docker/common/install_pytorch.sh --view expanded || true

printf '\n== relevant lines ==\n'
cat -n docker/common/install_pytorch.sh | sed -n '1,180p'

Repository: NVIDIA/TensorRT-LLM

Length of output: 3652


🌐 Web query:

PyTorch torchvision compatibility matrix torch 2.12.1 torchvision version 2025

💡 Result:

For PyTorch version 2.12.1, the compatible version of torchvision is 0.27.1 [1][2]. According to the official PyTorch installation documentation, you should use the following command to install these compatible versions [2]: pip install torch==2.12.1 torchvision==0.27.1 The torchvision 0.27.x series is designed to support PyTorch 2.12 [3][4][5]. Torchvision 0.27.1 was released on June 17, 2026, to accompany the PyTorch 2.12.1 release [1][5]. This version supports Python versions 3.10 through 3.14 [3][4][5].

Citations:


Pin torchvision in the PyPI install path. The source-build flow already resolves the matching vision branch, but pip3 install torch==${TORCH_VERSION} torchvision ... can drift as the index changes. Use torchvision==0.27.1 here to keep the image reproducible.

🤖 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 `@docker/common/install_pytorch.sh` at line 8, Update the PyPI install command
in install_pytorch.sh to pin torchvision to version 0.27.1 instead of leaving it
unversioned. Preserve the existing torch version variable and all other
installation arguments.

Source: MCP tools

Comment on lines +241 to +271
a_mx_scale_layout = None if not isinstance(precision_config.a_mx_scale, Tensor) else precision_config.a_mx_scale.storage.layout
b_mx_scale_layout = None if not isinstance(precision_config.b_mx_scale, Tensor) else precision_config.b_mx_scale.storage.layout

def _is_layout_strided(layout: Layout | None) -> bool:
return layout is None or isinstance(layout, StridedLayout)

requires_persistent = (not _is_layout_strided(a_mx_scale_layout) or not _is_layout_strided(b_mx_scale_layout)) and target_info.has_native_mxfp()
if constraints.get("is_persistent", None) is not None:
is_persistent = constraints["is_persistent"]
elif requires_persistent:
assert supports_persistent, "persistent kernel required but not supported"
is_persistent = True
else:
has_simple_epilogue = precision_config.max_num_imprecise_acc is None
is_persistent = supports_persistent and has_simple_epilogue and (tiles_per_sm >= 2.0 or lhs_dtype.itemsize <= 1) and out_dtype.itemsize < 4
is_persistent = supports_persistent and has_simple_epilogue and (tiles_per_sm >= 2.0 or lhs_dtype.bitwidth <= 8) and out_dtype.bitwidth < 32
# TMA is slower for batched matmuls with small m/n/k.
if m * n * k < 131072:
is_persistent = False
if isinstance(b_mx_scale_layout, HopperMXScaleLayout):
# TODO: persistent kernel is currently slower than non-persistent
is_persistent = False

# adjust block_n based on is_persistent signal
block_n = block_n_tma if is_persistent else block_n
# adjust block_m based on is_persistent signal
if is_persistent and opt_flags_nvidia.is_x_scale_swizzled(precision_config):
# a mx scale has been swizzled to BlackwellActMXScaleLayout, enforce block_m=128 to align with swizzling layout
block_m = 128
# block k
block_k = opt_flags_nvidia.compute_block_k(m, k, is_persistent, lhs_dtype, rhs_dtype, precision_config, has_y_acc_in)
if block_n == 256 and block_k == 128 and block_m <= 64 and is_persistent and rhs_dtype == FP4 and k >= 4096 and tokens_per_expt > 1 and lhs_dtype != torch.bfloat16:
if block_n == 256 and block_k == 128 and block_m <= 64 and is_persistent and rhs_dtype == FP4 and k >= 4096 and slice_size > 1 and lhs_dtype != torch.bfloat16:

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Does triton_kernels DType (FloatType/IntegerType) define __eq__ that compares against torch.dtype, in triton-lang/triton triton_kernels v3.7.1?

💡 Result:

In the triton-lang/triton repository, specifically within the triton_kernels package (as observed in the current development codebase), the FloatType and IntegerType classes defined in triton_kernels/tensor_details/dtype.py [1] do not define an eq method that compares against torch.dtype. Instead, the triton_kernels package relies on explicit conversion functions—such as dtype_to_torch_dtype and torch_dtype_to_dtype—to map between Triton's internal tensor data types and PyTorch's torch.dtype [2]. While some test utilities in triton_kernels may implement helper classes that store a torch_dtype attribute for comparison purposes [3], the core FloatType and IntegerType dataclasses do not natively support equality comparison with torch.dtype objects [1]. Comparisons between these types and torch.dtype typically require explicit conversion or mapping [2].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## Files of interest\n'
git ls-files triton_kernels/matmul_details/opt_flags.py triton_kernels/tensor_details/dtype.py triton_kernels/tensor.py 2>/dev/null || true

printf '\n## Outline: opt_flags.py\n'
ast-grep outline triton_kernels/matmul_details/opt_flags.py --view expanded || true

printf '\n## Outline: dtype.py\n'
ast-grep outline triton_kernels/tensor_details/dtype.py --view expanded || true

printf '\n## Relevant snippets\n'
sed -n '200,290p' triton_kernels/matmul_details/opt_flags.py
printf '\n--- dtype.py ---\n'
sed -n '1,260p' triton_kernels/tensor_details/dtype.py
printf '\n--- tensor.py (conversion helpers) ---\n'
sed -n '1,220p' triton_kernels/tensor.py

Repository: NVIDIA/TensorRT-LLM

Length of output: 17501


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
import re

p = Path("triton_kernels/matmul_details/opt_flags.py")
text = p.read_text()
for needle in ["lhs_dtype != torch.bfloat16", "rhs_dtype == FP4", "a.dtype", "b.dtype"]:
    print(f"{needle}: {needle in text}")

print("\nContext around comparison:")
m = re.search(r'.{0,120}lhs_dtype != torch\.bfloat16.{0,120}', text, re.S)
print(m.group(0) if m else "not found")
PY

Repository: NVIDIA/TensorRT-LLM

Length of output: 540


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
import re

for path in ["triton_kernels/tensor_details/dtype.py", "triton_kernels/tensor.py"]:
    p = Path(path)
    if not p.exists():
        print(f"{path}: missing")
        continue
    text = p.read_text()
    for pattern in [
        r'class\s+\w+.*?:',
        r'def __eq__',
        r'dtype_to_torch_dtype',
        r'torch_dtype_to_dtype',
        r'torch\.dtype',
    ]:
        print(f"\n[{path}] pattern={pattern}")
        for m in re.finditer(pattern, text):
            start = max(0, m.start() - 80)
            end = min(len(text), m.end() + 180)
            print(text[start:end].splitlines()[0:8])
            break
PY

Repository: NVIDIA/TensorRT-LLM

Length of output: 1933


Compare against BF16 here. lhs_dtype is a Triton DataType, so lhs_dtype != torch.bfloat16 is always true and the bf16 exclusion never triggers. Use the Triton BF16 constant (or convert to a torch.dtype first) so the swap heuristic actually skips bf16 inputs.

🤖 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 `@triton_kernels/matmul_details/opt_flags.py` around lines 241 - 271, Update
the bf16 exclusion in the conditional heuristic after compute_block_k to compare
lhs_dtype against Triton’s BF16 DataType constant rather than torch.bfloat16,
preserving the intended behavior of skipping the swap for bf16 inputs.

Source: Learnings

@HandongLi-01

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61556 [ run ] triggered by Bot. Commit: 817d2d6 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61556 [ run ] completed with state FAILURE. Commit: 817d2d6
/LLM/main/L0_MergeRequest_PR pipeline #49767 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

Signed-off-by: handongl <15242213+HandongLi-01@users.noreply.github.com>
Signed-off-by: handongl <15242213+HandongLi-01@users.noreply.github.com>
Signed-off-by: handongl <15242213+HandongLi-01@users.noreply.github.com>
@HandongLi-01
HandongLi-01 force-pushed the dev/handongl/upgrade-triton-3.7.0 branch from 817d2d6 to 2f42fa1 Compare July 27, 2026 02:24
@HandongLi-01
HandongLi-01 requested a review from a team as a code owner July 27, 2026 02:24
@HandongLi-01
HandongLi-01 requested review from BowenFu and QiJune July 27, 2026 02:24
@HandongLi-01

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61778 [ run ] triggered by Bot. Commit: 2f42fa1 Link to invocation

@HandongLi-01 HandongLi-01 changed the title [https://nvbugs/6445494][infra] Upgrade triton to 3.7.0 for torch 2.12.0 compatibility [https://nvbugs/6445494][infra] Upgrade Triton to 3.7.1 for Torch 2.12.1 compatibility Jul 27, 2026
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61778 [ run ] completed with state FAILURE. Commit: 2f42fa1
/LLM/main/L0_MergeRequest_PR pipeline #49978 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

Signed-off-by: handongl <15242213+HandongLi-01@users.noreply.github.com>
@HandongLi-01

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "Build-Docker-Images"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61835 [ run ] triggered by Bot. Commit: 9908e1d Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61835 [ run ] completed with state FAILURE. Commit: 9908e1d
/LLM/main/L0_MergeRequest_PR pipeline #50030 (Partly Tested) 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

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