Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 159 additions & 0 deletions .github/workflows/mlir-tensorrt-build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: MLIR-TensorRT Build and Test

on:
workflow_call:
inputs:
channel:
description: 'Channel, valid values are "nightly", "test", or "release"'
default: "test"
type: string
build-matrix:
description: 'Build matrix to utilize'
default: ""
type: string

defaults:
run:
shell: bash

jobs:
mlir-tensorrt-build-test:
name: build-test-${{ matrix.arch }}-cu${{ matrix.cuda }}-trt${{ matrix.trt }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(inputs.build-matrix) }}
env:
# eg. CUDA_VERSION: 12.9.1 or 13.0.0
CUDA_VERSION: ${{ matrix.cuda }}
# eg. TENSORRT_VERSION: 10.12 or 10.13
TENSORRT_VERSION: ${{ matrix.trt }}
# eg. CHANNEL: nightly, test or release
CHANNEL: ${{ inputs.channel }}
runs-on: ${{ matrix.runner }}
container:
image: ${{ matrix.docker_image }}
options: '--gpus all'
steps:
# Checkout the repository
- name: Checkout TensorRT-Incubator
uses: actions/checkout@v4

# Create cache folders
- name: Create Cache Folders
run: |
set -euo pipefail
set -x
mkdir -p mlir-tensorrt/ccache
mkdir -p mlir-tensorrt/.cache.cpm

# Restore cache, if exists.
- name: Restore Cache
uses: actions/cache/restore@v4
with:
key: ${{ runner.os }}-mlir-tensorrt-cache-${{ hashFiles('mlir-tensorrt/**/*.cpp', 'mlir-tensorrt/**/*.h', 'mlir-tensorrt/build_tools/**/*') }}
restore-keys: |
${{ runner.os }}-mlir-tensorrt-cache-
path: |
mlir-tensorrt/ccache
mlir-tensorrt/.cache.cpm/*
!mlir-tensorrt/.cache.cpm/tensorrt

# Build the project
- name: Build With CUDA:${{ matrix.cuda }} + TensorRT:${{ matrix.trt }}
run: |
set -euo pipefail
set -x
cd mlir-tensorrt
# Build only, skip tests
SKIP_TESTS=1 \
./build_tools/scripts/cicd_build_test.sh

# Save cache
- name: Save cache
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-mlir-tensorrt-cache-${{ hashFiles('mlir-tensorrt/**/*.cpp', 'mlir-tensorrt/**/*.h', 'mlir-tensorrt/build_tools/**/*') }}
path: |
mlir-tensorrt/ccache
mlir-tensorrt/.cache.cpm/*
!mlir-tensorrt/.cache.cpm/tensorrt

# Run tests
- name: Run Basic Tests With CUDA:${{ matrix.cuda }} + TensorRT:${{ matrix.trt }}
id: basic-tests
run: |
set -euo pipefail
set -x
cd mlir-tensorrt
# run tests
./build_tools/scripts/cicd_build_test.sh

# Run ASAN tests
- name: Run ASAN Tests With CUDA:${{ matrix.cuda }} + TensorRT:${{ matrix.trt }}
id: asan-tests
if: ${{ always() && inputs.channel == 'nightly' }}
run: |
set -euo pipefail
set -x
cd mlir-tensorrt
CMAKE_PRESET=github-cicd-with-asan \
./build_tools/scripts/cicd_build_test.sh

# Run Long tests
- name: Run Long Tests With CUDA:${{ matrix.cuda }} + TensorRT:${{ matrix.trt }}
id: long-tests
if: ${{ always() && inputs.channel == 'nightly' }}
run: |
set -euo pipefail
set -x
cd mlir-tensorrt
CMAKE_PRESET=github-cicd-with-long-tests \
./build_tools/scripts/cicd_build_test.sh

# Run NCCL Long tests
- name: Run NCCL Long Tests With CUDA:${{ matrix.cuda }} + TensorRT:${{ matrix.trt }}
id: nccl-long-tests
if: ${{ always() && inputs.channel == 'nightly' }}
run: |
set -euo pipefail
set -x
cd mlir-tensorrt
CMAKE_PRESET=github-cicd-with-nccl-long-tests \
./build_tools/scripts/cicd_build_test.sh

# Build wheels
- name: Build Wheels With CUDA:${{ matrix.cuda }} + TensorRT:${{ matrix.trt }}
id: build-wheels
if: ${{ always() && inputs.channel == 'nightly' }}
run: |
set -euo pipefail
set -x
cd mlir-tensorrt
./build_tools/scripts/cicd_build_wheels.sh

# Smoke test the wheels built
- name: Smoke Test Wheels
id: smoke-test-wheels
if: ${{ inputs.channel == 'nightly' }}
run: |
set -euo pipefail
set -x
cd mlir-tensorrt
for whl in .wheels/*.whl; do
uv pip install "$whl"
done
# TODO: add smoke test for the wheel

# Build distribution tar.gz with CUDA:${{ matrix.cuda }} + TensorRT:${{ matrix.trt }}
- name: Build Distribution Tar.gz With CUDA:${{ matrix.cuda }} + TensorRT:${{ matrix.trt }}
id: build-distribution
if: ${{ always() && inputs.channel == 'nightly' }}
run: |
set -euo pipefail
set -x
cd mlir-tensorrt
./build_tools/scripts/cicd_build_distribution.sh

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-mlir-tensorrt-${{ inputs.channel }}
cancel-in-progress: true
178 changes: 76 additions & 102 deletions .github/workflows/mlir-tensorrt-ci.yml
Original file line number Diff line number Diff line change
@@ -1,123 +1,97 @@
name: MLIR-TensorRT CI

on:
pull_request:
branches:
- main
types: [synchronize, opened, reopened, ready_for_review]
paths: ["mlir-tensorrt/**"]
push:
branches:
- main
paths: ["mlir-tensorrt/**"]
- "pull-request/[0-9]+"
tags:
# release tag example: v0.4.2
# release candidate tag example: v0.4.2-rc1
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Runs at 00:00 UTC every day (minute hour day-of-month month-of-year day-of-week)

env:
DEFAULT_IMAGE: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.5-ubuntu-llvm17
DEFAULT_IMAGE: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.9-ubuntu-llvm17
REGISTRY: ghcr.io

jobs:
mlir-tensorrt-test-pr:
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
runs-on: tripy-self-hosted
defaults:
run:
shell: bash

jobs:
format-check:
name: Lint Check
runs-on: ubuntu-latest
container:
image: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.9-ubuntu-llvm17
steps:
# Value of `github.workspace` is /home/runner/work/{repo_name}/{repo-name}
# i.e. /home/runner/work/TensorRT-Incubator/TensorRT-Incubator in our case.
# After this action, repo is cloned inside above path.
- uses: actions/checkout@v4
- name: checkout TensorRT-Incubator
uses: actions/checkout@v4
with:
fetch-depth: 5

# Run initial format check
- name: Run python format and clang check
uses: addnab/docker-run-action@v3
if: ${{ github.event_name == 'pull_request' }}
with:
image: ${{ env.DEFAULT_IMAGE }}
options: -v ${{ github.workspace }}:/tensorrt-incubator
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step does two things
# 1. Check if Python files follow black format
# 2. Check if C++ files follow clang format
# NOTE: We are placed at the root directory ('/') inside the container.
run: |
cd tensorrt-incubator
git config --global --add safe.directory /tensorrt-incubator
cat > run_format_check.sh <<EOF
#!/bin/bash
set -e
python3 -m black --check --extend-exclude='.*\.pyi' mlir-tensorrt/compiler/
python3 -m black --check --extend-exclude='.*\.pyi' mlir-tensorrt/integrations/python/
git clang-format HEAD~1 --diff
EOF
shell: bash
run: |
set -euo pipefail
set -x

bash run_format_check.sh
uv venv .venv || { echo "Failed to create virtual environment"; exit 1; }
source .venv/bin/activate || { echo "Failed to activate virtual environment"; exit 1; }
uv pip install black
uv run black --check --extend-exclude='.*\.pyi' \
mlir-tensorrt/compiler/ mlir-tensorrt/integrations/python/

# Create cache folders
- name: Create cache folder
run: |
mkdir -p ${{ github.workspace }}/ccache
mkdir -p ${{ github.workspace }}/.cache.cpm
git config --global --add safe.directory $(pwd)
uv run git clang-format HEAD~1 --diff

# Restore cache, if exists.
- name: Restore cache
id: restore-cache
uses: actions/cache/restore@v4
with:
key: ${{ runner.os }}-mlir-tensorrt-cache-${{ hashFiles('mlir-tensorrt/**/*.cpp', 'mlir-tensorrt/**/*.h', 'mlir-tensorrt/build_tools/**/*') }}
restore-keys: |
${{ runner.os }}-mlir-tensorrt-cache-
path: |
${{ github.workspace }}/ccache
${{ github.workspace }}/.cache.cpm/*
!${{ github.workspace }}/.cache.cpm/tensorrt
generate-matrix:
name: Generate Build Matrix
runs-on: ubuntu-latest
needs: format-check
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
channel: ${{ steps.generate.outputs.channel }}
steps:
- name: Checkout TensorRT-Incubator
uses: actions/checkout@v4

# TensorRT 10 tests
- name: TensorRT 10 build
uses: addnab/docker-run-action@v3
with:
image: ${{ env.DEFAULT_IMAGE }}
options: -v ${{ github.workspace }}/mlir-tensorrt:/mlir-tensorrt -v ${{ github.workspace }}/ccache:/ccache -v ${{ github.workspace }}/.cache.cpm:/.cache.cpm --gpus all
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
run: |
cd mlir-tensorrt
./build_tools/scripts/cicd_build.sh --build_only
- name: Generate Build Matrix
id: generate
run: |
set -euo pipefail
set -x
CHANNEL="test"
if [ "${GITHUB_EVENT_NAME:-}" = "schedule" ]; then
CHANNEL="nightly"
elif [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then
CHANNEL="release"
fi
MATRIX_BLOB="$(python3 ./.github/workflows/mlir-tensorrt/generate-matrix.py --channel "${CHANNEL}")"
echo "${MATRIX_BLOB}"
echo "${CHANNEL}"
echo "matrix=${MATRIX_BLOB}" >> "${GITHUB_OUTPUT}"
echo "channel=${CHANNEL}" >> "${GITHUB_OUTPUT}"

- name: Save cache
id: save-cache
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-mlir-tensorrt-cache-${{ hashFiles('mlir-tensorrt/**/*.cpp', 'mlir-tensorrt/**/*.h', 'mlir-tensorrt/build_tools/**/*') }}
path: |
${{ github.workspace }}/ccache
${{ github.workspace }}/.cache.cpm/*
!${{ github.workspace }}/.cache.cpm/tensorrt
mlir-tensorrt-build-test:
name: Build and Test
needs: generate-matrix
if: ${{ needs.generate-matrix.outputs.channel != 'release' }}
uses: ./.github/workflows/mlir-tensorrt-build-test.yml
with:
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
channel: ${{ needs.generate-matrix.outputs.channel }}

- name: TensorRT 10 test
uses: addnab/docker-run-action@v3
with:
image: ${{ env.DEFAULT_IMAGE }}
options: -v ${{ github.workspace }}/mlir-tensorrt:/mlir-tensorrt -v ${{ github.workspace }}/ccache:/ccache -v ${{ github.workspace }}/.cache.cpm:/.cache.cpm --gpus all
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
run: |
cd mlir-tensorrt
./build_tools/scripts/cicd_build.sh
mlir-tensorrt-release:
name: Release
needs: generate-matrix
if: ${{ needs.generate-matrix.outputs.channel == 'release' }}
uses: ./.github/workflows/mlir-tensorrt-release.yml
with:
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
channel: release

# TensorRT 10 & ASAN
- name: TensorRT 10 ASAN test
uses: addnab/docker-run-action@v3
with:
image: ${{ env.DEFAULT_IMAGE }}
options: -v ${{ github.workspace }}/mlir-tensorrt:/mlir-tensorrt -v ${{ github.workspace }}/ccache:/ccache -v ${{ github.workspace }}/.cache.cpm:/.cache.cpm --gpus all
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
run: |
cd mlir-tensorrt
ENABLE_ASAN=ON ./build_tools/scripts/cicd_build.sh
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-mlir-tensorrt
cancel-in-progress: true
Loading
Loading