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
0 commit comments