Skip to content

Commit 489e48b

Browse files
committed
[CI] Add release wheel pipeline
[mlir-tensorrt] Migrate internal change - Remove global suppression of C++20 extension warnings and fix some minor warnings that appear after this. - Consolidate 'MTRTRelativeDebugPaths.cmake' into 'MTRTCompilationOptions.cmake' and don't populate prefix paths for the build directory if it is a sub directory of the source directory. - Suppress a warning in third-party code. GitOrigin-RevId: c6ba3bbbb3e464061a854b35ecadda1e9ed72936 Add conversion of JAX shape_assertion custom calls to cf.assert (#728) - Lower stablehlo.custom_call @shape_assertion to cf.assert operations - Extract scalar condition from tensor<i1> before assertion - Preserve error message from custom call attributes - Add ControlFlowDialect dependency to StablehloToPlan conversion - Include test case demonstrating the conversion GitOrigin-RevId: 9b8d8e61a6e139ad6700b1c31e1038b15b20a7af
1 parent cc1fc23 commit 489e48b

File tree

26 files changed

+537
-110
lines changed

26 files changed

+537
-110
lines changed

.github/workflows/mlir-tensorrt-build-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
options: >-
5252
--gpus all
5353
--shm-size=1g
54+
timeout-minutes: 120
5455
steps:
5556
# Checkout the repository
5657
- name: Checkout TensorRT-Incubator

.github/workflows/mlir-tensorrt-ci.yml

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ on:
77
branches:
88
- "pull-request/[0-9]+"
99
- "main"
10-
# Disable the release and nightly CI for now, we will enable them later
11-
# # this is for release CI
12-
# tags:
13-
# # release tag example: v0.4.2
14-
# # release candidate tag example: v0.4.2-rc1
15-
# - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
16-
# workflow_dispatch:
17-
# # this is for nightly CI, it will be automatically triggered by the schedule on main branch only
18-
# schedule:
19-
# - cron: '0 0 * * *' # Runs at 00:00 UTC every day (minute hour day-of-month month-of-year day-of-week)
10+
# this is for release CI
11+
tags:
12+
# release tag example: v0.4.2
13+
# release candidate tag example: v0.4.2-rc1
14+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
15+
workflow_dispatch:
16+
# this is for nightly CI, it will be automatically triggered by the schedule on main branch only
17+
schedule:
18+
- cron: '0 0 * * *' # Runs at 00:00 UTC every day (minute hour day-of-month month-of-year day-of-week)
2019

2120
env:
2221
DEFAULT_IMAGE: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.9-ubuntu24.04-0.1
@@ -45,6 +44,12 @@ jobs:
4544
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
4645
4746
EVENT_NAME="${{ github.event_name }}"
47+
REF_TYPE="${{ github.ref_type }}"
48+
if [ "${EVENT_NAME}" = "schedule" || "${EVENT_NAME}" = "workflow_dispatch" || ${REF_TYPE} == 'tag' ]; then
49+
echo "github.event_name: ${EVENT_NAME} or github.ref_type: ${REF_TYPE}"
50+
echo "has_changes=true" >> "${GITHUB_OUTPUT}"
51+
exit 0
52+
fi
4853
DEFAULT_BASE="${{ github.event.repository.default_branch || 'main' }}"
4954
RANGE=""
5055
if [ "${EVENT_NAME}" = "push" ]; then
@@ -85,7 +90,7 @@ jobs:
8590
format-check:
8691
name: Lint Check
8792
needs: changes
88-
if: ${{ needs.changes.outputs.has_changes == 'true' }}
93+
if: ${{ needs.changes.outputs.has_changes == 'true' || github.event_name == 'schedule' || github.ref_type == 'tag' }}
8994
runs-on: ubuntu-latest
9095
container:
9196
image: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.9-ubuntu24.04-0.1
@@ -170,7 +175,6 @@ jobs:
170175
needs:
171176
- changes
172177
- format-check
173-
- mlir-tensorrt-build-test-x86_64
174178
if: ${{ needs.changes.outputs.has_changes == 'true' && needs.format-check.outputs.channel != 'release' }}
175179
uses: ./.github/workflows/mlir-tensorrt-build-test.yml
176180
with:
@@ -179,6 +183,28 @@ jobs:
179183
arch: aarch64
180184
github_runner: linux-arm64-gpu-l4-latest-1
181185

186+
mlir-tensorrt-wheel-tarball-release-x86_64:
187+
name: Release on x86_64
188+
needs:
189+
- format-check
190+
if: ${{ needs.format-check.outputs.channel == 'release' }}
191+
uses: ./.github/workflows/mlir-tensorrt-release.yml
192+
with:
193+
build-matrix: ${{ needs.format-check.outputs.matrix }}
194+
arch: x86_64
195+
github_runner: linux-amd64-gpu-h100-latest-1
196+
197+
mlir-tensorrt-wheel-tarball-release-aarch64:
198+
name: Release on aarch64
199+
needs:
200+
- format-check
201+
if: ${{ needs.format-check.outputs.channel == 'release' }}
202+
uses: ./.github/workflows/mlir-tensorrt-release.yml
203+
with:
204+
build-matrix: ${{ needs.format-check.outputs.matrix }}
205+
arch: aarch64
206+
github_runner: linux-arm64-gpu-l4-latest-1
207+
182208
concurrency:
183209
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-mlir-tensorrt
184210
cancel-in-progress: true
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: MLIR-TensorRT Release Wheel and Tarball
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
build-matrix:
7+
description: 'Build matrix to utilize'
8+
default: ""
9+
type: string
10+
arch:
11+
description: 'Architecture, valid values are "x86_64" or "aarch64"'
12+
default: "x86_64"
13+
type: string
14+
github_runner:
15+
description: 'Runner, valid values are "linux-amd64-gpu-h100-latest-1" or "linux-arm64-gpu-l4-latest-1"'
16+
default: "linux-amd64-gpu-h100-latest-1"
17+
type: string
18+
19+
defaults:
20+
run:
21+
shell: bash
22+
23+
jobs:
24+
mlir-tensorrt-wheel-build:
25+
name: ${{ inputs.arch }}-cu${{ matrix.cuda }}-trt${{ matrix.trt }}-wheel-build
26+
strategy:
27+
fail-fast: false
28+
max-parallel: 1
29+
matrix: ${{ fromJSON(inputs.build-matrix) }}
30+
env:
31+
# eg. 10.12 or 10.13
32+
DOWNLOAD_TENSORRT_VERSION: ${{ matrix.trt }}
33+
LATEST_CUDA_VERSION: ${{ matrix.latest_cuda }}
34+
LATEST_TENSORRT_VERSION: ${{ matrix.latest_trt }}
35+
ARCH: ${{ inputs.arch }}
36+
CCACHE_DIR: ${{ github.workspace }}/mlir-tensorrt/ccache
37+
CPM_SOURCE_CACHE: ${{ github.workspace }}/mlir-tensorrt/.cache.cpm
38+
CMAKE_PRESET: distribution-wheels
39+
CCACHE_KEY: mlir-tensorrt-ccache-v1-${{ inputs.arch }}-distribution-wheels
40+
# if exact cache key is not matched, fallback to the restore key to restore the cache
41+
CCACHE_RESTORE_KEY: mlir-tensorrt-ccache-v1-${{ inputs.arch }}-
42+
CPM_KEY: mlir-tensorrt-cpm-v1
43+
CPM_RESTORE_KEY: mlir-tensorrt-cpm-v1
44+
WHEELS_DIR: ${{ github.workspace }}/mlir-tensorrt/.wheels/
45+
runs-on: ${{ inputs.github_runner }}
46+
timeout-minutes: 120
47+
container:
48+
image: ${{ matrix.docker_image }}
49+
options: >-
50+
--gpus all
51+
--shm-size=1g
52+
steps:
53+
# Checkout the repository
54+
- name: Checkout TensorRT-Incubator
55+
uses: actions/checkout@v5
56+
with:
57+
fetch-depth: 5
58+
59+
# Create cache folders
60+
- name: Create Cache Folders
61+
run: |
62+
set -euo pipefail
63+
set -x
64+
mkdir -p ${{ env.CCACHE_DIR }}
65+
mkdir -p ${{ env.CPM_SOURCE_CACHE }}
66+
67+
# Restore cache, if exists.
68+
- name: Restore CCache
69+
id: restore-ccache
70+
uses: actions/cache/restore@v4
71+
with:
72+
key: ${{ env.CCACHE_KEY }}
73+
restore-keys: |
74+
${{ env.CCACHE_RESTORE_KEY }}
75+
path: |
76+
${{ env.CCACHE_DIR }}
77+
78+
- name: Restore CPM cache
79+
id: restore-cpm
80+
uses: actions/cache/restore@v4
81+
with:
82+
key: ${{ env.CPM_KEY }}
83+
enableCrossOsArchive: true
84+
restore-keys: |
85+
${{ env.CPM_RESTORE_KEY }}
86+
# exclude only works for the relative path pattern
87+
# restore must use the exactly same path defined in the save step, cannot ignore the exclude path
88+
path: |
89+
mlir-tensorrt/.cache.cpm/*
90+
!mlir-tensorrt/.cache.cpm/tensorrt
91+
!mlir-tensorrt/.cache.cpm/tensorrt/**
92+
93+
# Build wheels
94+
- name: Build Wheels With CUDA:${{ matrix.cuda }} + TensorRT:${{ matrix.trt }}
95+
env:
96+
ENABLE_ASAN: "OFF"
97+
run: |
98+
set -euo pipefail
99+
set -x
100+
cd mlir-tensorrt
101+
export MTRT_TENSORRT_VERSION=${{ matrix.trt }}
102+
# TODO: remove this, once patch is in our rockylinux prebuilt image
103+
dnf install -yq patch
104+
# mlir-tensorrt-tools is not cuda, trt dependent, so we only build it once
105+
# mlir-tensorrt-compiler, mlir-tensorrt-runtime is built per cuda, trt version
106+
if [[ "${{ matrix.cuda }}" == "${{ env.LATEST_CUDA_VERSION }}" && "${{ matrix.trt }}" == "${{env.LATEST_TENSORRT_VERSION }}" ]]; then
107+
./build_tools/scripts/cicd-build-wheels.sh
108+
else
109+
PACKAGES="mlir_tensorrt_compiler mlir_tensorrt_runtime" \
110+
./build_tools/scripts/cicd-build-wheels.sh
111+
fi
112+
113+
# Save ccache when cache is not hit or cache was a fallback(cache-matched is not the same as the cache key)
114+
- name: Save CCache
115+
uses: actions/cache/save@v4
116+
if: ${{ steps.restore-ccache.outputs.cache-hit != 'true' || steps.restore-ccache.outputs['cache-matched-key'] != env.CCACHE_KEY }}
117+
with:
118+
key: ${{ env.CCACHE_KEY }}
119+
path: |
120+
${{ env.CCACHE_DIR }}
121+
122+
# Save cpm cache
123+
- name: Save CPM Cache
124+
# cpm cache is shared across x86_64 and aarch64, we let only x86_64 to save cpm cache when in cache miss case
125+
# this is to avoid both x86_64 and aarch64 to save cpm cache when in cache miss case
126+
if: ${{ inputs.arch == 'x86_64' &&
127+
(
128+
steps.restore-cpm.outputs.cache-hit != 'true' ||
129+
steps.restore-cpm.outputs['cache-matched-key'] != env.CPM_KEY
130+
)
131+
}}
132+
uses: actions/cache/save@v4
133+
with:
134+
key: ${{ env.CPM_KEY }}
135+
enableCrossOsArchive: true
136+
# exclude only works for the relative path pattern
137+
path: |
138+
mlir-tensorrt/.cache.cpm/*
139+
!mlir-tensorrt/.cache.cpm/tensorrt
140+
!mlir-tensorrt/.cache.cpm/tensorrt/**
141+
142+
# Upload wheels to GitHub Actions artifact
143+
- name: Upload Wheels
144+
uses: actions/upload-artifact@v4
145+
with:
146+
name: release-wheels-${{ inputs.arch }}-cu${{ matrix.cuda }}-trt${{ matrix.trt }}
147+
path: ${{ env.WHEELS_DIR }}
148+
if-no-files-found: error
149+
150+
concurrency:
151+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-mlir-tensorrt-release-${{ inputs.arch }}
152+
cancel-in-progress: true

.github/workflows/mlir-tensorrt/generate-matrix.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@
1010
"release": ["12.9", "13.0"],
1111
}
1212

13+
LATEST_CUDA_VERSION = "13.0"
14+
LATEST_TRT_VERSION = "10.13"
15+
1316
TRT_VERSIONS_DICT = {
1417
"nightly": ["10.12", "10.13"],
1518
"test": ["10.13"],
1619
"release": ["10.12", "10.13"],
1720
}
1821

22+
TRT_VERSIONS_CUDA_MIN_MAX_DICT = {
23+
"10.12": {"min_cuda_version": "12.9", "max_cuda_version": "12.9"},
24+
"10.13": {"min_cuda_version": "12.9", "max_cuda_version": "13.0"},
25+
}
26+
1927
CMAKE_PRESET_DICT = {
2028
"nightly": "github-cicd",
2129
"test": "github-cicd",
@@ -40,6 +48,10 @@
4048
}
4149

4250

51+
def _version_tuple(version: str) -> tuple[int, ...]:
52+
return tuple(int(part) for part in version.split("."))
53+
54+
4355
def main(args: list[str]) -> None:
4456
parser = argparse.ArgumentParser()
4557
parser.add_argument(
@@ -64,12 +76,30 @@ def main(args: list[str]) -> None:
6476
matrix_dict = {"include": []}
6577
for cuda_version in cuda_versions:
6678
for trt_version in trt_versions:
79+
if trt_version not in TRT_VERSIONS_CUDA_MIN_MAX_DICT:
80+
raise Exception(
81+
f"TRT version {trt_version} is not in TRT_VERSIONS_CUDA_MIN_MAX_DICT"
82+
)
83+
min_cuda_version = TRT_VERSIONS_CUDA_MIN_MAX_DICT[trt_version][
84+
"min_cuda_version"
85+
]
86+
max_cuda_version = TRT_VERSIONS_CUDA_MIN_MAX_DICT[trt_version][
87+
"max_cuda_version"
88+
]
89+
if not (
90+
_version_tuple(min_cuda_version)
91+
<= _version_tuple(cuda_version)
92+
<= _version_tuple(max_cuda_version)
93+
):
94+
continue
6795
matrix_dict["include"].append(
6896
{
6997
"cuda": cuda_version,
7098
"trt": trt_version,
7199
"docker_image": docker_images[cuda_version],
72100
"cmake_preset": cmake_preset,
101+
"latest_cuda": LATEST_CUDA_VERSION,
102+
"latest_trt": LATEST_TRT_VERSION,
73103
}
74104
)
75105
print(json.dumps(matrix_dict))

mlir-tensorrt/.clang-format-ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/*.td

mlir-tensorrt/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ include(MTRTCMakePolicy NO_POLICY_SCOPE)
77
include(CMakeDependentOption)
88
include(CMakePrintHelpers)
99
include(MTRTCPM)
10+
include(MTRTCMakeExtras)
1011
include(MTRTDependencies)
1112
include(MTRTFeatures)
1213
include(AddMLIRTensorRT)

mlir-tensorrt/CMakeOptions.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ mtrt_option(MLIR_TRT_RELATIVE_DEBUG_PATHS
3939
# whereas the definition of the source groups belonging to those packages
4040
# are distributed across multiple sub-directories.
4141
set(MLIR_TRT_ENABLE_PROJECTS_DEFAULT
42-
executor tensorrt compiler
42+
executor tensorrt
4343
)
4444

45+
list(APPEND MLIR_TRT_ENABLE_PROJECTS_DEFAULT "compiler")
46+
4547
if(MLIR_TRT_ENABLE_PYTHON)
4648
list(APPEND MLIR_TRT_ENABLE_PROJECTS_DEFAULT "integrations/python")
4749
endif()
@@ -74,3 +76,4 @@ if(MLIR_TRT_ENABLE_NCCL)
7476
else()
7577
set(MLIR_TRT_NCCL_TARGET "" CACHE INTERNAL "")
7678
endif()
79+

mlir-tensorrt/Version.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@ set(MLIR_TENSORRT_VERSION_MINOR "4")
33
set(MLIR_TENSORRT_VERSION_PATCH "3")
44
set(MLIR_TENSORRT_VERSION
55
"${MLIR_TENSORRT_VERSION_MAJOR}.${MLIR_TENSORRT_VERSION_MINOR}.${MLIR_TENSORRT_VERSION_PATCH}")
6+
7+
# The source release script replaces the empty string with a actual
8+
# hash, so don't change the default here.
9+
set(MLIR_TENSORRT_GIT_HASH "")
10+
11+
set(CPACK_PACKAGE_VERSION_MAJOR ${MLIR_TENSORRT_VERSION_MAJOR})
12+
set(CPACK_PACKAGE_VERSION_MINOR ${MLIR_TENSORRT_VERSION_MINOR})
13+
set(CPACK_PACKAGE_VERSION_PATCH ${MLIR_TENSORRT_VERSION_PATCH})

mlir-tensorrt/build_tools/cmake/MTRTCommonFunctions.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ function(mtrt_add_project_library name)
332332
add_mlir_library(${name} ${lib_type_args} DISABLE_INSTALL EXCLUDE_FROM_LIBMLIR ${ARG_UNPARSED_ARGUMENTS})
333333
endif()
334334

335+
mtrt_apply_extra_check_options("${name}")
336+
335337
if(ARG_MLIR_LIBS)
336338
list(POP_FRONT ARG_MLIR_LIBS VISIBILITY)
337339
mtrt_target_link_mlir_libraries(${name} ${VISIBILITY} ${ARG_MLIR_LIBS})

0 commit comments

Comments
 (0)