WIP: Adding TRT options/task #502
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/**"] | |
env: | |
DEFAULT_IMAGE: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.5-ubuntu-llvm17 | |
REGISTRY: ghcr.io | |
jobs: | |
mlir-tensorrt-test-pr: | |
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false | |
# `ubuntu-latest` is a CPU runner. | |
# If selected, tests requiring GPU are not run. | |
runs-on: ubuntu-latest | |
steps: | |
# Free some disk space, otherwise we get OOM error. | |
- name: Free disk space | |
run: | | |
sudo rm -rf \ | |
/usr/share/dotnet "$AGENT_TOOLSDIRECTORY" /usr/local/lib/android /opt/ghc \ | |
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \ | |
/usr/lib/jvm | |
sudo apt-get purge microsoft-edge-stable || true | |
sudo apt-get purge google-cloud-cli || true | |
sudo apt-get purge dotnet-sdk-* || true | |
sudo apt-get purge google-chrome-stable || true | |
sudo apt-get autoremove -y | |
sudo apt-get autoclean -y | |
# 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 | |
with: | |
fetch-depth: 5 | |
- name: Validate commit message | |
if: ${{ github.event_name == 'pull_request' }} | |
env: | |
PR_HEAD_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} | |
run: | | |
cat > commit_message_checker.py <<EOF | |
#!/usr/bin/python3 | |
import re | |
import sys | |
import subprocess | |
git_cmd = f"git show -s --format=%B {sys.argv[1]}" | |
try: | |
commit_message_cmd = subprocess.run(git_cmd.split(' '), capture_output=True, text=True, check=True) | |
commit_message = commit_message_cmd.stdout.strip() | |
except subprocess.CalledProcessError as e: | |
print(f"Failed to get PR HEAD commit message with error: {e.stderr.strip()}") | |
match = re.search(r"^(\[bot\].+|NFC: .+|(.+\n\n+.+\n+.+))$", commit_message, re.DOTALL) | |
if match: | |
print("Commit message is in canonical form :)") | |
sys.exit(0) | |
print("Commit message is not in the canonical form!") | |
print(commit_message) | |
print("") | |
print("Expected format is, ") | |
print("<title>") | |
print("<body>") | |
print("NOTE: Body should start on new line. '2 spaces + enter' for new line!") | |
print("NOTE: Body should be at least two lines.") | |
sys.exit(1) | |
EOF | |
python3 commit_message_checker.py ${PR_HEAD_COMMIT_SHA} | |
# 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/python/ | |
git clang-format HEAD~1 --diff | |
EOF | |
bash run_format_check.sh | |
# Create cache folders | |
- name: Create cache folder | |
run: | | |
mkdir -p ${{ github.workspace }}/ccache | |
mkdir -p ${{ github.workspace }}/.cache.cpm | |
# Create cache action | |
- name: Create cache action | |
id: core-build-cache | |
uses: actions/cache@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 | |
# Run LIT tests with TensorRT 10 | |
- name: Run MLIR-TensorRT lit tests with TensorRT 10 | |
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 | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
cd mlir-tensorrt | |
./build_tools/scripts/cicd_build.sh | |
# Run LIT tests with TensorRT 10 & ASAN | |
- name: Run MLIR-TensorRT lit tests with TensorRT 10, ASAN enabled | |
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 | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
cd mlir-tensorrt | |
ENABLE_ASAN=ON ./build_tools/scripts/cicd_build.sh | |
# Run LIT tests with TensorRT 8 | |
- name: Run MLIR-TensorRT lit tests with TensorRT 8 | |
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 | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
cd mlir-tensorrt | |
DOWNLOAD_TENSORRT_VERSION="8.6.1.6" ./build_tools/scripts/cicd_build.sh |