From 965dd132cd8fbee434afc5d28a4e757ae69feb9a Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Fri, 21 Jun 2024 15:45:34 -0700 Subject: [PATCH 01/22] Test only: Only run certain test cases if the folder has changed --- .github/scripts/check_files.py | 7 ++++ .github/workflows/build-test-linux.yml | 46 ++++++++++++++++++++++-- .github/workflows/build-test-windows.yml | 2 +- 3 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 .github/scripts/check_files.py diff --git a/.github/scripts/check_files.py b/.github/scripts/check_files.py new file mode 100644 index 0000000000..bfa646195d --- /dev/null +++ b/.github/scripts/check_files.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 + +""" +Check whether a test suites should be run or not through github actions +""" +dummy_output_folders = ("tests/py/dynamo", "tests/py/core") +print(dummy_output_folders) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index 0bd570155e..d3f4aad64c 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -54,9 +54,47 @@ jobs: smoke-test-script: ${{ matrix.smoke-test-script }} trigger-event: ${{ github.event_name }} + check: + needs: build + name: Check files + outputs: + folder_names: + description: "the list of folder names which has file change" + value: ${{ steps.check_files.outputs.folder_names }} + runs-on: ubuntu-latest + steps: + - name: Checkout torch-tensorrt repository + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository }} + ref: ${{ inputs.ref_ }} + - name: Check modified files + id: check_files + run: | + set -eou pipfail + if [ ${{ github.event.ref }} == refs/tags/v* ]; then + echo "this is the release tag, always run the full tests" + elif [ ${{github.event.ref_type != 'branch' }} ]; then + echo "this is ref_type=${{github.event.ref_type}}, always run the full tests " + else + echo "=============== last modified files ===============" + git diff --name-only HEAD^ HEAD + echo "=============== check paths of modified files ===============" + git diff --name-only github.event.ref main + fi + + echo "github.event.ref_type: ${{ github.event.ref_type }}" + echo "github.event.ref: ${{ github.event.ref }}" + echo "github.event.ref_name: ${{ github.event.ref_name }}" + echo "github.event.master_branch: ${{ github.event.master_branch }}" + echo "github.event.pull_request: ${{ github.event.pull_request }}" + folder_names="$(python3 scripts/check_files.py)" + echo "folder_names=${folder_names}" >> "${GITHUB_OUTPUT}" + tests-py-torchscript-fe: name: Test torchscript frontend [Python] - needs: [generate-matrix, build] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.folder_names, 'tests/modules') }} strategy: fail-fast: false matrix: @@ -91,7 +129,8 @@ jobs: tests-py-dynamo-converters: name: Test dynamo converters [Python] - needs: [generate-matrix, build] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.folder_names, 'tests/py/dynamo') }} strategy: fail-fast: false matrix: @@ -236,7 +275,8 @@ jobs: tests-py-core: name: Test core [Python] - needs: [generate-matrix, build] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.folder_names, 'tests/py/dynamo') }} strategy: fail-fast: false matrix: diff --git a/.github/workflows/build-test-windows.yml b/.github/workflows/build-test-windows.yml index 1bdb52ae8a..d8c84c9afe 100644 --- a/.github/workflows/build-test-windows.yml +++ b/.github/workflows/build-test-windows.yml @@ -1,7 +1,7 @@ name: Build and test Windows wheels on: - pull_request: + # pull_request: push: branches: - main From 4157954abbed976093d154efdd4e4aba81c06e59 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Fri, 21 Jun 2024 15:52:20 -0700 Subject: [PATCH 02/22] test --- .github/workflows/build-test-linux.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index d3f4aad64c..5f5415aad8 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -58,9 +58,7 @@ jobs: needs: build name: Check files outputs: - folder_names: - description: "the list of folder names which has file change" - value: ${{ steps.check_files.outputs.folder_names }} + folder_names: ${{ steps.check_files.outputs.folder_names }} runs-on: ubuntu-latest steps: - name: Checkout torch-tensorrt repository From f62033c9d266b185e7ddaabf9f698aee69fb4d98 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Fri, 21 Jun 2024 16:48:57 -0700 Subject: [PATCH 03/22] test --- .github/workflows/build-test-linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index 5f5415aad8..c2eae05f89 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -65,11 +65,11 @@ jobs: uses: actions/checkout@v3 with: repository: ${{ inputs.repository }} - ref: ${{ inputs.ref_ }} + ref: ${{ inputs.ref }} - name: Check modified files id: check_files run: | - set -eou pipfail + set -euxo pipefail if [ ${{ github.event.ref }} == refs/tags/v* ]; then echo "this is the release tag, always run the full tests" elif [ ${{github.event.ref_type != 'branch' }} ]; then From 17ce09376e363473e85adf97c0beda5fc42b8cdf Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Tue, 25 Jun 2024 11:24:58 -0700 Subject: [PATCH 04/22] test --- .github/scripts/check_files.py | 7 - .github/workflows/build-test-linux.yml | 253 +++++++++++++------------ 2 files changed, 128 insertions(+), 132 deletions(-) delete mode 100644 .github/scripts/check_files.py diff --git a/.github/scripts/check_files.py b/.github/scripts/check_files.py deleted file mode 100644 index bfa646195d..0000000000 --- a/.github/scripts/check_files.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python3 - -""" -Check whether a test suites should be run or not through github actions -""" -dummy_output_folders = ("tests/py/dynamo", "tests/py/core") -print(dummy_output_folders) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index c2eae05f89..894a5253f1 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -69,11 +69,12 @@ jobs: - name: Check modified files id: check_files run: | - set -euxo pipefail - if [ ${{ github.event.ref }} == refs/tags/v* ]; then + # set -euxo pipefail + set -x + if [ ${{ github.ref }} == refs/tags/v* ]; then echo "this is the release tag, always run the full tests" - elif [ ${{github.event.ref_type != 'branch' }} ]; then - echo "this is ref_type=${{github.event.ref_type}}, always run the full tests " + elif [ ${{ github.ref_type }} != 'branch' ]; then + echo "this is ref_type=${{ github.event.ref_type }}, always run the full tests " else echo "=============== last modified files ===============" git diff --name-only HEAD^ HEAD @@ -81,18 +82,18 @@ jobs: git diff --name-only github.event.ref main fi - echo "github.event.ref_type: ${{ github.event.ref_type }}" - echo "github.event.ref: ${{ github.event.ref }}" - echo "github.event.ref_name: ${{ github.event.ref_name }}" + echo "github.event_name: ${{ github.event_name }}" + echo "github.ref: ${{ github.ref }}" + echo "github.ref_name: ${{ github.ref_name }}" echo "github.event.master_branch: ${{ github.event.master_branch }}" - echo "github.event.pull_request: ${{ github.event.pull_request }}" - folder_names="$(python3 scripts/check_files.py)" - echo "folder_names=${folder_names}" >> "${GITHUB_OUTPUT}" + echo "github.event.pull_request.base.sha: ${{ github.event.pull_request.base.sha }}" + echo "github.event.pull_request.head.sha: ${{ github.event.pull_request.head.sha }}" + echo "folder_names=py/dynamo" >> "${GITHUB_OUTPUT}" tests-py-torchscript-fe: name: Test torchscript frontend [Python] needs: [generate-matrix, build, check] - if: ${{ contains(needs.check.folder_names, 'tests/modules') }} + if: ${{ contains(needs.check.folder_names, 'py/ts') }} strategy: fail-fast: false matrix: @@ -128,7 +129,7 @@ jobs: tests-py-dynamo-converters: name: Test dynamo converters [Python] needs: [generate-matrix, build, check] - if: ${{ contains(needs.check.folder_names, 'tests/py/dynamo') }} + if: ${{ contains(needs.check.folder_names, 'py/dynamo') }} strategy: fail-fast: false matrix: @@ -176,6 +177,8 @@ jobs: build-matrix: ${{ needs.generate-matrix.outputs.matrix }} pre-script: ${{ matrix.pre-script }} script: | + set -x + echo ${{ needs.check.folder_names }} export USE_HOST_DEPS=1 pushd . cd tests/py/dynamo @@ -183,122 +186,122 @@ jobs: python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dyn_models_export.xml --ir dynamo models/test_dyn_models.py popd - tests-py-dynamo-serde: - name: Test dynamo export serde [Python] - needs: [generate-matrix, build] - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - pre-script: packaging/pre_build_script.sh - post-script: packaging/post_build_script.sh - smoke-test-script: packaging/smoke_test_script.sh - uses: pytorch/tensorrt/.github/workflows/linux-test.yml@main - with: - job-name: tests-py-dynamo-serde - repository: "pytorch/tensorrt" - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - pre-script: ${{ matrix.pre-script }} - script: | - export USE_HOST_DEPS=1 - pushd . - cd tests/py/dynamo - python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/export_serde_test_results.xml --ir dynamo models/test_export_serde.py - popd + # tests-py-dynamo-serde: + # name: Test dynamo export serde [Python] + # needs: [generate-matrix, build] + # strategy: + # fail-fast: false + # matrix: + # include: + # - repository: pytorch/tensorrt + # package-name: torch_tensorrt + # pre-script: packaging/pre_build_script.sh + # post-script: packaging/post_build_script.sh + # smoke-test-script: packaging/smoke_test_script.sh + # uses: pytorch/tensorrt/.github/workflows/linux-test.yml@main + # with: + # job-name: tests-py-dynamo-serde + # repository: "pytorch/tensorrt" + # ref: "" + # test-infra-repository: pytorch/test-infra + # test-infra-ref: main + # build-matrix: ${{ needs.generate-matrix.outputs.matrix }} + # pre-script: ${{ matrix.pre-script }} + # script: | + # export USE_HOST_DEPS=1 + # pushd . + # cd tests/py/dynamo + # python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/export_serde_test_results.xml --ir dynamo models/test_export_serde.py + # popd - tests-py-torch-compile-be: - name: Test torch compile backend [Python] - needs: [generate-matrix, build] - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - pre-script: packaging/pre_build_script.sh - post-script: packaging/post_build_script.sh - smoke-test-script: packaging/smoke_test_script.sh - uses: pytorch/tensorrt/.github/workflows/linux-test.yml@main - with: - job-name: tests-py-torch-compile-be - repository: "pytorch/tensorrt" - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - pre-script: ${{ matrix.pre-script }} - script: | - export USE_HOST_DEPS=1 - pushd . - cd tests/py/dynamo - python -m pytest -n 10 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_be_test_results.xml backend/ - python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_comple_be_e2e_test_results.xml --ir torch_compile models/test_models.py - python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_dyn_models_export.xml --ir torch_compile models/test_dyn_models.py - popd + # tests-py-torch-compile-be: + # name: Test torch compile backend [Python] + # needs: [generate-matrix, build] + # strategy: + # fail-fast: false + # matrix: + # include: + # - repository: pytorch/tensorrt + # package-name: torch_tensorrt + # pre-script: packaging/pre_build_script.sh + # post-script: packaging/post_build_script.sh + # smoke-test-script: packaging/smoke_test_script.sh + # uses: pytorch/tensorrt/.github/workflows/linux-test.yml@main + # with: + # job-name: tests-py-torch-compile-be + # repository: "pytorch/tensorrt" + # ref: "" + # test-infra-repository: pytorch/test-infra + # test-infra-ref: main + # build-matrix: ${{ needs.generate-matrix.outputs.matrix }} + # pre-script: ${{ matrix.pre-script }} + # script: | + # export USE_HOST_DEPS=1 + # pushd . + # cd tests/py/dynamo + # python -m pytest -n 10 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_be_test_results.xml backend/ + # python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_comple_be_e2e_test_results.xml --ir torch_compile models/test_models.py + # python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_dyn_models_export.xml --ir torch_compile models/test_dyn_models.py + # popd - tests-py-dynamo-core: - name: Test dynamo core [Python] - needs: [generate-matrix, build] - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - pre-script: packaging/pre_build_script.sh - post-script: packaging/post_build_script.sh - smoke-test-script: packaging/smoke_test_script.sh - uses: pytorch/tensorrt/.github/workflows/linux-test.yml@main - with: - job-name: tests-py-dynamo-core - repository: "pytorch/tensorrt" - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - pre-script: ${{ matrix.pre-script }} - script: | - export USE_HOST_DEPS=1 - pushd . - cd tests/py/dynamo - python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_test_results.xml runtime/ - python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_partitioning_test_results.xml partitioning/ - python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_lowering_test_results.xml lowering/ - popd + # tests-py-dynamo-core: + # name: Test dynamo core [Python] + # needs: [generate-matrix, build] + # strategy: + # fail-fast: false + # matrix: + # include: + # - repository: pytorch/tensorrt + # package-name: torch_tensorrt + # pre-script: packaging/pre_build_script.sh + # post-script: packaging/post_build_script.sh + # smoke-test-script: packaging/smoke_test_script.sh + # uses: pytorch/tensorrt/.github/workflows/linux-test.yml@main + # with: + # job-name: tests-py-dynamo-core + # repository: "pytorch/tensorrt" + # ref: "" + # test-infra-repository: pytorch/test-infra + # test-infra-ref: main + # build-matrix: ${{ needs.generate-matrix.outputs.matrix }} + # pre-script: ${{ matrix.pre-script }} + # script: | + # export USE_HOST_DEPS=1 + # pushd . + # cd tests/py/dynamo + # python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_test_results.xml runtime/ + # python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_partitioning_test_results.xml partitioning/ + # python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_lowering_test_results.xml lowering/ + # popd - tests-py-core: - name: Test core [Python] - needs: [generate-matrix, build, check] - if: ${{ contains(needs.check.folder_names, 'tests/py/dynamo') }} - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - pre-script: packaging/pre_build_script.sh - post-script: packaging/post_build_script.sh - smoke-test-script: packaging/smoke_test_script.sh - uses: pytorch/tensorrt/.github/workflows/linux-test.yml@release/2.3 - with: - job-name: tests-py-core - repository: "pytorch/tensorrt" - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - pre-script: ${{ matrix.pre-script }} - script: | - export USE_HOST_DEPS=1 - pushd . - cd tests/py/core - python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml . - popd + # tests-py-core: + # name: Test core [Python] + # needs: [generate-matrix, build, check] + # if: ${{ contains(needs.check.folder_names, 'tests/py/dynamo') }} + # strategy: + # fail-fast: false + # matrix: + # include: + # - repository: pytorch/tensorrt + # package-name: torch_tensorrt + # pre-script: packaging/pre_build_script.sh + # post-script: packaging/post_build_script.sh + # smoke-test-script: packaging/smoke_test_script.sh + # uses: pytorch/tensorrt/.github/workflows/linux-test.yml@release/2.3 + # with: + # job-name: tests-py-core + # repository: "pytorch/tensorrt" + # ref: "" + # test-infra-repository: pytorch/test-infra + # test-infra-ref: main + # build-matrix: ${{ needs.generate-matrix.outputs.matrix }} + # pre-script: ${{ matrix.pre-script }} + # script: | + # export USE_HOST_DEPS=1 + # pushd . + # cd tests/py/core + # python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml . + # popd concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }} From 7040501d6286ed616bfc7e2f798108222d857239 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Tue, 25 Jun 2024 13:15:47 -0700 Subject: [PATCH 05/22] test --- .github/workflows/build-test-linux.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index 894a5253f1..da2b51e0f6 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -71,16 +71,16 @@ jobs: run: | # set -euxo pipefail set -x - if [ ${{ github.ref }} == refs/tags/v* ]; then - echo "this is the release tag, always run the full tests" - elif [ ${{ github.ref_type }} != 'branch' ]; then - echo "this is ref_type=${{ github.event.ref_type }}, always run the full tests " - else - echo "=============== last modified files ===============" - git diff --name-only HEAD^ HEAD - echo "=============== check paths of modified files ===============" - git diff --name-only github.event.ref main - fi + # if [ ${{ github.ref }} == refs/tags/v* ]; then + # echo "this is the release tag, always run the full tests" + # elif [ ${{ github.ref_type }} != 'branch' ]; then + # echo "this is ref_type=${{ github.event.ref_type }}, always run the full tests " + # else + # echo "=============== last modified files ===============" + # git diff --name-only HEAD^ HEAD + # echo "=============== check paths of modified files ===============" + # git diff --name-only github.event.ref main + # fi echo "github.event_name: ${{ github.event_name }}" echo "github.ref: ${{ github.ref }}" From e651dfa2c5e07e01bf97ededea564c41b62e6526 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Wed, 26 Jun 2024 22:03:04 -0700 Subject: [PATCH 06/22] test --- .github/scripts/generate_test_module.py | 110 ++++++++++ .github/workflows/build-test-linux.yml | 260 ++++++++++++------------ 2 files changed, 241 insertions(+), 129 deletions(-) create mode 100644 .github/scripts/generate_test_module.py diff --git a/.github/scripts/generate_test_module.py b/.github/scripts/generate_test_module.py new file mode 100644 index 0000000000..04e7a03d2e --- /dev/null +++ b/.github/scripts/generate_test_module.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 + +"""Generate test modules list to be utilized through gihub actions + +Will output a list of modules needs run test cases: +* +""" + +import argparse +import os +import sys +from typing import List + +MAX_FOLDER_DEPTH = 3 + +# TODO: discuss with Naren for a better mapping +Folder_To_TestModules_Dict = { + "py/torch_tensorrt/dynamo": [ + "dynamo_frontend", + "dynamo_core", + "dynamo_converter", + "dynamo_serde", + "torch_compile_backend", + ], + "py/torch_tensorrt/ts": ["ts_frontend"], + "py/torch_tensorrt": ["py_core"], +} + +Full_Test_Modules = [ + "ts_frontend", + "py_core", + "dynamo_frontend", + "dynamo_core", + "dynamo_converter", + "dynamo_serde", + "torch_compile_backend", +] + + +def filter_files_to_folders( + files: str, +) -> List[str]: + fileList = files.split(" ") + folders = [] + + for file in fileList: + if file == "": + continue + filePath = os.path.dirname(file) + splits = filePath.split("/", MAX_FOLDER_DEPTH) + if len(splits) > MAX_FOLDER_DEPTH: + splits = splits[: len(splits) - 1] + folder = "/".join(splits) + folders.append(folder) + + ret = list(dict.fromkeys(folders)) + return ret + + +def generate_test_modules( + folders: List[str], +) -> List[str]: + testModules = [] + for folder in folders: + if folder in Folder_To_TestModules_Dict.keys(): + modules = Folder_To_TestModules_Dict[folder] + testModules.extend(modules) + return list(dict.fromkeys(testModules)) + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser() + parser.add_argument( + "--event-name", + help="", + type=str, + default="", + ) + parser.add_argument( + "--files", + help="", + type=str, + default="", + ) + return parser.parse_args(sys.argv[1:]) + + +def main() -> None: + options = parse_args() + print(f"got options={options}") + assert options.event_name != "", "Must provide the --event-name str" + + # if it is the Pull Request: + # for the pull request, it will run the full tests of the test module if the related files changed + # else only run the l0 testcases + if options.event_name == "pull_request": + assert ( + options.files != "" + ), "Must provide the --files str, if the --event-name is pull_request" + folders = filter_files_to_folders(options.files) + test_modules = generate_test_modules(folders) + else: + # for the non pull_request, always run the full tests of all the test modules + test_modules = Full_Test_Modules + + print(test_modules) + + +if __name__ == "__main__": + main() diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index da2b51e0f6..e7a606c1f1 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -58,7 +58,7 @@ jobs: needs: build name: Check files outputs: - folder_names: ${{ steps.check_files.outputs.folder_names }} + test_modules: ${{ steps.check_files.outputs.test_modules }} runs-on: ubuntu-latest steps: - name: Checkout torch-tensorrt repository @@ -71,29 +71,27 @@ jobs: run: | # set -euxo pipefail set -x - # if [ ${{ github.ref }} == refs/tags/v* ]; then - # echo "this is the release tag, always run the full tests" - # elif [ ${{ github.ref_type }} != 'branch' ]; then - # echo "this is ref_type=${{ github.event.ref_type }}, always run the full tests " - # else - # echo "=============== last modified files ===============" - # git diff --name-only HEAD^ HEAD - # echo "=============== check paths of modified files ===============" - # git diff --name-only github.event.ref main - # fi + #if [ ${{ github.event_name }} == 'pull_request' ]; then + if [[ ${event_name} == 'pull_request' ]]; then + files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) + test_modules="$(python .github/scripts/generate_test_module.py --event-name 'pull_request' --files '${files}')" + else + test_modules="$(python .github/scripts/generate_test_module.py --event-name ${{ github.event_name }})" + + fi echo "github.event_name: ${{ github.event_name }}" echo "github.ref: ${{ github.ref }}" echo "github.ref_name: ${{ github.ref_name }}" echo "github.event.master_branch: ${{ github.event.master_branch }}" echo "github.event.pull_request.base.sha: ${{ github.event.pull_request.base.sha }}" - echo "github.event.pull_request.head.sha: ${{ github.event.pull_request.head.sha }}" - echo "folder_names=py/dynamo" >> "${GITHUB_OUTPUT}" + echo "github.event.pull_request.head.sha: " + echo "test_modules=${test_modules}" >> "${GITHUB_OUTPUT}" tests-py-torchscript-fe: name: Test torchscript frontend [Python] needs: [generate-matrix, build, check] - if: ${{ contains(needs.check.folder_names, 'py/ts') }} + if: ${{ contains(needs.check.outputs.test_modules, 'ts_frontend') }} strategy: fail-fast: false matrix: @@ -129,7 +127,7 @@ jobs: tests-py-dynamo-converters: name: Test dynamo converters [Python] needs: [generate-matrix, build, check] - if: ${{ contains(needs.check.folder_names, 'py/dynamo') }} + if: ${{ contains(needs.check.outputs.test_modules, 'dynamo_converter') }} strategy: fail-fast: false matrix: @@ -158,6 +156,7 @@ jobs: tests-py-dynamo-fe: name: Test dynamo frontend [Python] needs: [generate-matrix, build] + if: ${{ contains(needs.check.outputs.test_modules, 'dynamo_frontend') }} strategy: fail-fast: false matrix: @@ -178,7 +177,7 @@ jobs: pre-script: ${{ matrix.pre-script }} script: | set -x - echo ${{ needs.check.folder_names }} + echo "needs.check.outputs.test_modules: ${{ needs.check.outputs.test_modules }}" export USE_HOST_DEPS=1 pushd . cd tests/py/dynamo @@ -186,122 +185,125 @@ jobs: python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dyn_models_export.xml --ir dynamo models/test_dyn_models.py popd - # tests-py-dynamo-serde: - # name: Test dynamo export serde [Python] - # needs: [generate-matrix, build] - # strategy: - # fail-fast: false - # matrix: - # include: - # - repository: pytorch/tensorrt - # package-name: torch_tensorrt - # pre-script: packaging/pre_build_script.sh - # post-script: packaging/post_build_script.sh - # smoke-test-script: packaging/smoke_test_script.sh - # uses: pytorch/tensorrt/.github/workflows/linux-test.yml@main - # with: - # job-name: tests-py-dynamo-serde - # repository: "pytorch/tensorrt" - # ref: "" - # test-infra-repository: pytorch/test-infra - # test-infra-ref: main - # build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - # pre-script: ${{ matrix.pre-script }} - # script: | - # export USE_HOST_DEPS=1 - # pushd . - # cd tests/py/dynamo - # python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/export_serde_test_results.xml --ir dynamo models/test_export_serde.py - # popd + tests-py-dynamo-serde: + name: Test dynamo export serde [Python] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.outputs.test_modules, 'dynamo_serde') }} + strategy: + fail-fast: false + matrix: + include: + - repository: pytorch/tensorrt + package-name: torch_tensorrt + pre-script: packaging/pre_build_script.sh + post-script: packaging/post_build_script.sh + smoke-test-script: packaging/smoke_test_script.sh + uses: pytorch/tensorrt/.github/workflows/linux-test.yml@main + with: + job-name: tests-py-dynamo-serde + repository: "pytorch/tensorrt" + ref: "" + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build-matrix: ${{ needs.generate-matrix.outputs.matrix }} + pre-script: ${{ matrix.pre-script }} + script: | + export USE_HOST_DEPS=1 + pushd . + cd tests/py/dynamo + python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/export_serde_test_results.xml --ir dynamo models/test_export_serde.py + popd - # tests-py-torch-compile-be: - # name: Test torch compile backend [Python] - # needs: [generate-matrix, build] - # strategy: - # fail-fast: false - # matrix: - # include: - # - repository: pytorch/tensorrt - # package-name: torch_tensorrt - # pre-script: packaging/pre_build_script.sh - # post-script: packaging/post_build_script.sh - # smoke-test-script: packaging/smoke_test_script.sh - # uses: pytorch/tensorrt/.github/workflows/linux-test.yml@main - # with: - # job-name: tests-py-torch-compile-be - # repository: "pytorch/tensorrt" - # ref: "" - # test-infra-repository: pytorch/test-infra - # test-infra-ref: main - # build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - # pre-script: ${{ matrix.pre-script }} - # script: | - # export USE_HOST_DEPS=1 - # pushd . - # cd tests/py/dynamo - # python -m pytest -n 10 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_be_test_results.xml backend/ - # python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_comple_be_e2e_test_results.xml --ir torch_compile models/test_models.py - # python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_dyn_models_export.xml --ir torch_compile models/test_dyn_models.py - # popd + tests-py-torch-compile-be: + name: Test torch compile backend [Python] + needs: [generate-matrix, build ,check] + if: ${{ contains(needs.check.outputs.test_modules, 'torch_compile_backend') }} + strategy: + fail-fast: false + matrix: + include: + - repository: pytorch/tensorrt + package-name: torch_tensorrt + pre-script: packaging/pre_build_script.sh + post-script: packaging/post_build_script.sh + smoke-test-script: packaging/smoke_test_script.sh + uses: pytorch/tensorrt/.github/workflows/linux-test.yml@main + with: + job-name: tests-py-torch-compile-be + repository: "pytorch/tensorrt" + ref: "" + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build-matrix: ${{ needs.generate-matrix.outputs.matrix }} + pre-script: ${{ matrix.pre-script }} + script: | + export USE_HOST_DEPS=1 + pushd . + cd tests/py/dynamo + python -m pytest -n 10 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_be_test_results.xml backend/ + python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_comple_be_e2e_test_results.xml --ir torch_compile models/test_models.py + python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_dyn_models_export.xml --ir torch_compile models/test_dyn_models.py + popd - # tests-py-dynamo-core: - # name: Test dynamo core [Python] - # needs: [generate-matrix, build] - # strategy: - # fail-fast: false - # matrix: - # include: - # - repository: pytorch/tensorrt - # package-name: torch_tensorrt - # pre-script: packaging/pre_build_script.sh - # post-script: packaging/post_build_script.sh - # smoke-test-script: packaging/smoke_test_script.sh - # uses: pytorch/tensorrt/.github/workflows/linux-test.yml@main - # with: - # job-name: tests-py-dynamo-core - # repository: "pytorch/tensorrt" - # ref: "" - # test-infra-repository: pytorch/test-infra - # test-infra-ref: main - # build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - # pre-script: ${{ matrix.pre-script }} - # script: | - # export USE_HOST_DEPS=1 - # pushd . - # cd tests/py/dynamo - # python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_test_results.xml runtime/ - # python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_partitioning_test_results.xml partitioning/ - # python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_lowering_test_results.xml lowering/ - # popd + tests-py-dynamo-core: + name: Test dynamo core [Python] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.folder_names, 'dynamo_core') }} + strategy: + fail-fast: false + matrix: + include: + - repository: pytorch/tensorrt + package-name: torch_tensorrt + pre-script: packaging/pre_build_script.sh + post-script: packaging/post_build_script.sh + smoke-test-script: packaging/smoke_test_script.sh + uses: pytorch/tensorrt/.github/workflows/linux-test.yml@main + with: + job-name: tests-py-dynamo-core + repository: "pytorch/tensorrt" + ref: "" + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build-matrix: ${{ needs.generate-matrix.outputs.matrix }} + pre-script: ${{ matrix.pre-script }} + script: | + export USE_HOST_DEPS=1 + pushd . + cd tests/py/dynamo + python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_test_results.xml runtime/ + python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_partitioning_test_results.xml partitioning/ + python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_lowering_test_results.xml lowering/ + popd - # tests-py-core: - # name: Test core [Python] - # needs: [generate-matrix, build, check] - # if: ${{ contains(needs.check.folder_names, 'tests/py/dynamo') }} - # strategy: - # fail-fast: false - # matrix: - # include: - # - repository: pytorch/tensorrt - # package-name: torch_tensorrt - # pre-script: packaging/pre_build_script.sh - # post-script: packaging/post_build_script.sh - # smoke-test-script: packaging/smoke_test_script.sh - # uses: pytorch/tensorrt/.github/workflows/linux-test.yml@release/2.3 - # with: - # job-name: tests-py-core - # repository: "pytorch/tensorrt" - # ref: "" - # test-infra-repository: pytorch/test-infra - # test-infra-ref: main - # build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - # pre-script: ${{ matrix.pre-script }} - # script: | - # export USE_HOST_DEPS=1 - # pushd . - # cd tests/py/core - # python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml . - # popd + tests-py-core: + name: Test core [Python] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.folder_names, 'py_core') }} + strategy: + fail-fast: false + matrix: + include: + - repository: pytorch/tensorrt + package-name: torch_tensorrt + pre-script: packaging/pre_build_script.sh + post-script: packaging/post_build_script.sh + smoke-test-script: packaging/smoke_test_script.sh + uses: pytorch/tensorrt/.github/workflows/linux-test.yml@release/2.3 + with: + job-name: tests-py-core + repository: "pytorch/tensorrt" + ref: "" + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build-matrix: ${{ needs.generate-matrix.outputs.matrix }} + pre-script: ${{ matrix.pre-script }} + script: | + export USE_HOST_DEPS=1 + pushd . + cd tests/py/core + python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml . + popd concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }} From f5df0667759af5f7144767a96953a22530afbf82 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Wed, 26 Jun 2024 23:01:28 -0700 Subject: [PATCH 07/22] test --- .github/scripts/generate_test_module.py | 6 ++++++ .github/workflows/build-test-linux.yml | 14 ++------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/scripts/generate_test_module.py b/.github/scripts/generate_test_module.py index 04e7a03d2e..f217fbea38 100644 --- a/.github/scripts/generate_test_module.py +++ b/.github/scripts/generate_test_module.py @@ -26,6 +26,9 @@ "py/torch_tensorrt": ["py_core"], } +# TODO: discuss with Naren for a basic set of tests here +# this is just an example only +Base_Test_Modules = ["torch_compile_back"] Full_Test_Modules = [ "ts_frontend", "py_core", @@ -65,6 +68,9 @@ def generate_test_modules( if folder in Folder_To_TestModules_Dict.keys(): modules = Folder_To_TestModules_Dict[folder] testModules.extend(modules) + else: + # if there is files changed in other folders, always run the base tests + testModules.extend(Base_Test_Modules) return list(dict.fromkeys(testModules)) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index e7a606c1f1..d148519539 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -69,23 +69,13 @@ jobs: - name: Check modified files id: check_files run: | - # set -euxo pipefail - set -x - #if [ ${{ github.event_name }} == 'pull_request' ]; then - if [[ ${event_name} == 'pull_request' ]]; then + set -euxo pipefail + if [ ${{ github.event_name }} == 'pull_request' ]; then files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) test_modules="$(python .github/scripts/generate_test_module.py --event-name 'pull_request' --files '${files}')" else test_modules="$(python .github/scripts/generate_test_module.py --event-name ${{ github.event_name }})" - fi - - echo "github.event_name: ${{ github.event_name }}" - echo "github.ref: ${{ github.ref }}" - echo "github.ref_name: ${{ github.ref_name }}" - echo "github.event.master_branch: ${{ github.event.master_branch }}" - echo "github.event.pull_request.base.sha: ${{ github.event.pull_request.base.sha }}" - echo "github.event.pull_request.head.sha: " echo "test_modules=${test_modules}" >> "${GITHUB_OUTPUT}" tests-py-torchscript-fe: From 373d0d0c35d091b6ac2b2b5c7071b291e30da129 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Thu, 27 Jun 2024 09:32:54 -0700 Subject: [PATCH 08/22] test --- .github/workflows/build-test-linux.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index d148519539..a7ffca47a8 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -69,9 +69,16 @@ jobs: - name: Check modified files id: check_files run: | - set -euxo pipefail + #set -euxo pipefail + set -x + echo "${{ github. }}" if [ ${{ github.event_name }} == 'pull_request' ]; then - files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) + git log -10 + base=${{ github.event.pull_request.base.sha }} + head=${{ github.event.pull_request.head.sha }} + git merge-base "${base}" "${head}" + + files=$(git diff --name-only "${base}" "${head}") test_modules="$(python .github/scripts/generate_test_module.py --event-name 'pull_request' --files '${files}')" else test_modules="$(python .github/scripts/generate_test_module.py --event-name ${{ github.event_name }})" From 70d9b694c893e0035f2d9e1275dd06efa48ea103 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Thu, 27 Jun 2024 09:58:58 -0700 Subject: [PATCH 09/22] test --- .github/workflows/build-test-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index a7ffca47a8..dffabc580d 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -71,7 +71,7 @@ jobs: run: | #set -euxo pipefail set -x - echo "${{ github. }}" + if [ ${{ github.event_name }} == 'pull_request' ]; then git log -10 base=${{ github.event.pull_request.base.sha }} From c4e14237d377b66b4463eca60ad731e45362826f Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Thu, 27 Jun 2024 10:18:07 -0700 Subject: [PATCH 10/22] test --- .github/workflows/build-test-linux.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index dffabc580d..cf397116eb 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -62,10 +62,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout torch-tensorrt repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: ${{ inputs.repository }} ref: ${{ inputs.ref }} + fetch-depth: 0 - name: Check modified files id: check_files run: | From 5a646bd9c1447e5624125cd7f761e02571e03e88 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Thu, 27 Jun 2024 10:43:35 -0700 Subject: [PATCH 11/22] test --- .github/scripts/generate_test_module.py | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/scripts/generate_test_module.py b/.github/scripts/generate_test_module.py index f217fbea38..6dfd9f9dff 100644 --- a/.github/scripts/generate_test_module.py +++ b/.github/scripts/generate_test_module.py @@ -93,7 +93,6 @@ def parse_args() -> argparse.Namespace: def main() -> None: options = parse_args() - print(f"got options={options}") assert options.event_name != "", "Must provide the --event-name str" # if it is the Pull Request: From e605316b794370eda698dafcc57a3b8faffa8050 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Thu, 27 Jun 2024 14:00:43 -0700 Subject: [PATCH 12/22] test --- .github/scripts/generate_test_module.py | 2 +- .github/workflows/build-test-linux.yml | 5 +-- .github/workflows/build-test-windows.yml | 52 ++++++++++++++++++++---- 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/.github/scripts/generate_test_module.py b/.github/scripts/generate_test_module.py index 6dfd9f9dff..fc52cf06eb 100644 --- a/.github/scripts/generate_test_module.py +++ b/.github/scripts/generate_test_module.py @@ -28,7 +28,7 @@ # TODO: discuss with Naren for a basic set of tests here # this is just an example only -Base_Test_Modules = ["torch_compile_back"] +Base_Test_Modules = ["torch_compile_backend"] Full_Test_Modules = [ "ts_frontend", "py_core", diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index cf397116eb..a0ec5c44e6 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -70,11 +70,8 @@ jobs: - name: Check modified files id: check_files run: | - #set -euxo pipefail - set -x - + set -euxo pipefail if [ ${{ github.event_name }} == 'pull_request' ]; then - git log -10 base=${{ github.event.pull_request.base.sha }} head=${{ github.event.pull_request.head.sha }} git merge-base "${base}" "${head}" diff --git a/.github/workflows/build-test-windows.yml b/.github/workflows/build-test-windows.yml index d8c84c9afe..f80b3e7e49 100644 --- a/.github/workflows/build-test-windows.yml +++ b/.github/workflows/build-test-windows.yml @@ -1,7 +1,7 @@ name: Build and test Windows wheels on: - # pull_request: + pull_request: push: branches: - main @@ -63,9 +63,39 @@ jobs: package-name: ${{ matrix.package-name }} trigger-event: ${{ github.event_name }} + check: + needs: build + name: Check files + outputs: + test_modules: ${{ steps.check_files.outputs.test_modules }} + runs-on: ubuntu-latest + steps: + - name: Checkout torch-tensorrt repository + uses: actions/checkout@v4 + with: + repository: ${{ inputs.repository }} + ref: ${{ inputs.ref }} + fetch-depth: 0 + - name: Check modified files + id: check_files + run: | + set -euxo pipefail + if [ ${{ github.event_name }} == 'pull_request' ]; then + base=${{ github.event.pull_request.base.sha }} + head=${{ github.event.pull_request.head.sha }} + git merge-base "${base}" "${head}" + + files=$(git diff --name-only "${base}" "${head}") + test_modules="$(python .github/scripts/generate_test_module.py --event-name 'pull_request' --files '${files}')" + else + test_modules="$(python .github/scripts/generate_test_module.py --event-name ${{ github.event_name }})" + fi + echo "test_modules=${test_modules}" >> "${GITHUB_OUTPUT}" + tests-py-torchscript-fe: name: Test torchscript frontend [Python] - needs: [generate-matrix, build] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.outputs.test_modules, 'ts_frontend') }} strategy: fail-fast: false matrix: @@ -96,7 +126,8 @@ jobs: tests-py-dynamo-converters: name: Test dynamo converters [Python] - needs: [generate-matrix, build] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.outputs.test_modules, 'dynamo_converter') }} strategy: fail-fast: false matrix: @@ -121,7 +152,8 @@ jobs: tests-py-dynamo-fe: name: Test dynamo frontend [Python] - needs: [generate-matrix, build] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.outputs.test_modules, 'dynamo_frontend') }} strategy: fail-fast: false matrix: @@ -147,7 +179,8 @@ jobs: tests-py-dynamo-serde: name: Test dynamo export serde [Python] - needs: [generate-matrix, build] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.outputs.test_modules, 'dynamo_serde') }} strategy: fail-fast: false matrix: @@ -172,7 +205,8 @@ jobs: tests-py-torch-compile-be: name: Test torch compile backend [Python] - needs: [generate-matrix, build] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.outputs.test_modules, 'torch_compile_backend') }} strategy: fail-fast: false matrix: @@ -199,7 +233,8 @@ jobs: tests-py-dynamo-core: name: Test dynamo core [Python] - needs: [generate-matrix, build] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.folder_names, 'dynamo_core') }} strategy: fail-fast: false matrix: @@ -226,7 +261,8 @@ jobs: tests-py-core: name: Test core [Python] - needs: [generate-matrix, build] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.folder_names, 'py_core') }} strategy: fail-fast: false matrix: From 79a13f299c1a663a796bd912fbcfa48321a31c2c Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Thu, 27 Jun 2024 15:52:44 -0700 Subject: [PATCH 13/22] test --- .github/scripts/generate_test_module.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/scripts/generate_test_module.py b/.github/scripts/generate_test_module.py index fc52cf06eb..de6500b147 100644 --- a/.github/scripts/generate_test_module.py +++ b/.github/scripts/generate_test_module.py @@ -11,6 +11,8 @@ import sys from typing import List +import regex + MAX_FOLDER_DEPTH = 3 # TODO: discuss with Naren for a better mapping @@ -26,6 +28,18 @@ "py/torch_tensorrt": ["py_core"], } +Folder_To_Skip_TestModules = { + "docker/*", + "docs/*", + "docsrc/*", + "examples/*", + "notenooks/*", + "packaging/*", + "third_party/*", + "toolchains/*", + "tools/*", +} + # TODO: discuss with Naren for a basic set of tests here # this is just an example only Base_Test_Modules = ["torch_compile_backend"] @@ -65,6 +79,13 @@ def generate_test_modules( ) -> List[str]: testModules = [] for folder in folders: + skip = False + for to_skip in Folder_To_Skip_TestModules: + if regex.match(to_skip, folder): + skip = True + break + if skip == True: + continue if folder in Folder_To_TestModules_Dict.keys(): modules = Folder_To_TestModules_Dict[folder] testModules.extend(modules) From 47f0bc211b9915d3a0ee9a3a189abda59ceefb28 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Thu, 27 Jun 2024 15:53:49 -0700 Subject: [PATCH 14/22] test --- .github/scripts/generate_test_module.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/scripts/generate_test_module.py b/.github/scripts/generate_test_module.py index de6500b147..fb12c7328a 100644 --- a/.github/scripts/generate_test_module.py +++ b/.github/scripts/generate_test_module.py @@ -28,6 +28,7 @@ "py/torch_tensorrt": ["py_core"], } +# The following folder files change will trigger the build but will skip all the test modules Folder_To_Skip_TestModules = { "docker/*", "docs/*", From 06e0c2cbd5148737a17032462b2c0d1ceccb4e25 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Thu, 27 Jun 2024 15:56:44 -0700 Subject: [PATCH 15/22] test --- .github/workflows/build-test-linux.yml | 3 +-- .github/workflows/build-test-windows.yml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index a0ec5c44e6..6aa9dcc1be 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -74,8 +74,7 @@ jobs: if [ ${{ github.event_name }} == 'pull_request' ]; then base=${{ github.event.pull_request.base.sha }} head=${{ github.event.pull_request.head.sha }} - git merge-base "${base}" "${head}" - + python -m pip install regex files=$(git diff --name-only "${base}" "${head}") test_modules="$(python .github/scripts/generate_test_module.py --event-name 'pull_request' --files '${files}')" else diff --git a/.github/workflows/build-test-windows.yml b/.github/workflows/build-test-windows.yml index f80b3e7e49..c1e22af239 100644 --- a/.github/workflows/build-test-windows.yml +++ b/.github/workflows/build-test-windows.yml @@ -83,8 +83,7 @@ jobs: if [ ${{ github.event_name }} == 'pull_request' ]; then base=${{ github.event.pull_request.base.sha }} head=${{ github.event.pull_request.head.sha }} - git merge-base "${base}" "${head}" - + python -m pip install regex files=$(git diff --name-only "${base}" "${head}") test_modules="$(python .github/scripts/generate_test_module.py --event-name 'pull_request' --files '${files}')" else From db78d9358fd7ebdfca61f57b6240625266d51d27 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Mon, 8 Jul 2024 09:28:14 -0700 Subject: [PATCH 16/22] test --- .github/scripts/generate_test_module.py | 2 +- .github/workflows/build-test-linux.yml | 1 + .github/workflows/build-test-windows.yml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/scripts/generate_test_module.py b/.github/scripts/generate_test_module.py index fb12c7328a..50220925a4 100644 --- a/.github/scripts/generate_test_module.py +++ b/.github/scripts/generate_test_module.py @@ -43,7 +43,7 @@ # TODO: discuss with Naren for a basic set of tests here # this is just an example only -Base_Test_Modules = ["torch_compile_backend"] +Base_Test_Modules = ["py_core"] Full_Test_Modules = [ "ts_frontend", "py_core", diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index 5b5466b13e..d1f262672b 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -298,6 +298,7 @@ jobs: cd tests/py/core python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml . popd + bazel test //tests/core/conversion/converters:test_activation --compilation_mode=opt --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }} diff --git a/.github/workflows/build-test-windows.yml b/.github/workflows/build-test-windows.yml index c1e22af239..2697022ffb 100644 --- a/.github/workflows/build-test-windows.yml +++ b/.github/workflows/build-test-windows.yml @@ -1,7 +1,7 @@ name: Build and test Windows wheels on: - pull_request: + # pull_request: push: branches: - main From 92d001a827c804dca5b0908948f1ca7486982bed Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Mon, 8 Jul 2024 14:26:52 -0700 Subject: [PATCH 17/22] test --- .github/workflows/build-test-linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index d1f262672b..419d8cb5f4 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -242,7 +242,7 @@ jobs: tests-py-dynamo-core: name: Test dynamo core [Python] needs: [generate-matrix, build, check] - if: ${{ contains(needs.check.folder_names, 'dynamo_core') }} + if: ${{ contains(needs.check.outputs.test_modules, 'dynamo_core') }} strategy: fail-fast: false matrix: @@ -273,7 +273,7 @@ jobs: tests-py-core: name: Test core [Python] needs: [generate-matrix, build, check] - if: ${{ contains(needs.check.folder_names, 'py_core') }} + if: ${{ contains(needs.check.outputs.test_modules, 'py_core') }} strategy: fail-fast: false matrix: From 0a39ac0fefe32a46841bdc76f5ab1ed45f4195d1 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Mon, 8 Jul 2024 15:03:16 -0700 Subject: [PATCH 18/22] test --- .github/workflows/build-test-linux.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index 419d8cb5f4..9c45aec11c 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -293,12 +293,14 @@ jobs: build-matrix: ${{ needs.generate-matrix.outputs.matrix }} pre-script: ${{ matrix.pre-script }} script: | + set -x export USE_HOST_DEPS=1 pushd . cd tests/py/core python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml . popd - bazel test //tests/core/conversion/converters:test_activation --compilation_mode=opt --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi + bazel test //tests/core/conversion/converters:test_activation --compilation_mode=opt \ + --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }} From a86b23391aae5fec7e86f425032ac176574e5b64 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Mon, 8 Jul 2024 15:57:31 -0700 Subject: [PATCH 19/22] test --- .github/scripts/generate_test_module.py | 7 +- .github/workflows/build-test-linux.yml | 111 +++++++++++++++++++++++- 2 files changed, 116 insertions(+), 2 deletions(-) diff --git a/.github/scripts/generate_test_module.py b/.github/scripts/generate_test_module.py index 50220925a4..a97b22bd01 100644 --- a/.github/scripts/generate_test_module.py +++ b/.github/scripts/generate_test_module.py @@ -43,7 +43,12 @@ # TODO: discuss with Naren for a basic set of tests here # this is just an example only -Base_Test_Modules = ["py_core"] +Base_Test_Modules = [ + "cpp_core_conversion", + "cpp_core_lowering", + "cpp_core_partitioning", + "cpp_core_runtime", +] Full_Test_Modules = [ "ts_frontend", "py_core", diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index 9c45aec11c..d53ef02fc8 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -299,9 +299,118 @@ jobs: cd tests/py/core python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml . popd - bazel test //tests/core/conversion/converters:test_activation --compilation_mode=opt \ + + tests-cpp-core-conversion: + name: Test core conversion[CPP] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.outputs.test_modules, 'cpp_core_conversion') }} + strategy: + fail-fast: false + matrix: + include: + - repository: pytorch/tensorrt + package-name: torch_tensorrt + pre-script: packaging/pre_build_script.sh + post-script: packaging/post_build_script.sh + smoke-test-script: packaging/smoke_test_script.sh + uses: ./.github/workflows/linux-test.yml + with: + job-name: tests-cpp-core-conversion + repository: "pytorch/tensorrt" + ref: "" + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build-matrix: ${{ needs.generate-matrix.outputs.matrix }} + pre-script: ${{ matrix.pre-script }} + script: | + set -x + export USE_HOST_DEPS=1 + bazel test //tests/core/conversion/conversion_tests --compilation_mode=opt \ + --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures + + tests-cpp-core-lowering: + name: Test core lowering[CPP] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.outputs.test_modules, 'cpp_core_lowering') }} + strategy: + fail-fast: false + matrix: + include: + - repository: pytorch/tensorrt + package-name: torch_tensorrt + pre-script: packaging/pre_build_script.sh + post-script: packaging/post_build_script.sh + smoke-test-script: packaging/smoke_test_script.sh + uses: ./.github/workflows/linux-test.yml + with: + job-name: tests-cpp-core-lowering + repository: "pytorch/tensorrt" + ref: "" + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build-matrix: ${{ needs.generate-matrix.outputs.matrix }} + pre-script: ${{ matrix.pre-script }} + script: | + set -x + export USE_HOST_DEPS=1 + bazel test //tests/core/lowering/lowering_tests --compilation_mode=opt \ --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures + tests-cpp-core-partitioning: + name: Test core partitioning[CPP] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.outputs.test_modules, 'cpp_core_partitioning') }} + strategy: + fail-fast: false + matrix: + include: + - repository: pytorch/tensorrt + package-name: torch_tensorrt + pre-script: packaging/pre_build_script.sh + post-script: packaging/post_build_script.sh + smoke-test-script: packaging/smoke_test_script.sh + uses: ./.github/workflows/linux-test.yml + with: + job-name: tests-cpp-core-partitioning + repository: "pytorch/tensorrt" + ref: "" + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build-matrix: ${{ needs.generate-matrix.outputs.matrix }} + pre-script: ${{ matrix.pre-script }} + script: | + set -x + export USE_HOST_DEPS=1 + bazel test //tests/core/partitioning/partitioning_tests --compilation_mode=opt \ + --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures + + tests-cpp-core-runtime: + name: Test core runtime[CPP] + needs: [generate-matrix, build, check] + if: ${{ contains(needs.check.outputs.test_modules, 'cpp_core_runtime') }} + strategy: + fail-fast: false + matrix: + include: + - repository: pytorch/tensorrt + package-name: torch_tensorrt + pre-script: packaging/pre_build_script.sh + post-script: packaging/post_build_script.sh + smoke-test-script: packaging/smoke_test_script.sh + uses: ./.github/workflows/linux-test.yml + with: + job-name: tests-cpp-core-partitioning + repository: "pytorch/tensorrt" + ref: "" + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build-matrix: ${{ needs.generate-matrix.outputs.matrix }} + pre-script: ${{ matrix.pre-script }} + script: | + set -x + export USE_HOST_DEPS=1 + bazel test //tests/core/runtime/runtime_tests --compilation_mode=opt \ + --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }} cancel-in-progress: true From 42fbf174c5624ece83d310a6ecf88890b9930c7a Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Mon, 8 Jul 2024 20:18:39 -0700 Subject: [PATCH 20/22] test --- .github/workflows/build-test-linux.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index d53ef02fc8..57b7e30e44 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -325,7 +325,7 @@ jobs: script: | set -x export USE_HOST_DEPS=1 - bazel test //tests/core/conversion/conversion_tests --compilation_mode=opt \ + bazel test //tests/core/conversion:conversion_tests --compilation_mode=opt \ --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures tests-cpp-core-lowering: @@ -353,7 +353,7 @@ jobs: script: | set -x export USE_HOST_DEPS=1 - bazel test //tests/core/lowering/lowering_tests --compilation_mode=opt \ + bazel test //tests/core/lowering:lowering_tests --compilation_mode=opt \ --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures tests-cpp-core-partitioning: @@ -381,7 +381,7 @@ jobs: script: | set -x export USE_HOST_DEPS=1 - bazel test //tests/core/partitioning/partitioning_tests --compilation_mode=opt \ + bazel test //tests/core/partitioning:partitioning_tests --compilation_mode=opt \ --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures tests-cpp-core-runtime: @@ -409,7 +409,7 @@ jobs: script: | set -x export USE_HOST_DEPS=1 - bazel test //tests/core/runtime/runtime_tests --compilation_mode=opt \ + bazel test //tests/core/runtime:runtime_tests --compilation_mode=opt \ --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }} From f77dc5c046b36c0fe96a062bbeb3882e62273ea7 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Mon, 8 Jul 2024 21:09:28 -0700 Subject: [PATCH 21/22] test --- .github/workflows/build-test-linux.yml | 5 ++++- toolchains/ci_workspaces/WORKSPACE.x86_64.release.rhel.tmpl | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index 57b7e30e44..9116b3a79e 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -325,6 +325,9 @@ jobs: script: | set -x export USE_HOST_DEPS=1 + python -m pip show torch_tensorrt + location=$(python -m pip show torch_tensorrt | grep Location | sed "s/Location: //g") + ls -lart $location | grep torch_tensorrt bazel test //tests/core/conversion:conversion_tests --compilation_mode=opt \ --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures @@ -399,7 +402,7 @@ jobs: smoke-test-script: packaging/smoke_test_script.sh uses: ./.github/workflows/linux-test.yml with: - job-name: tests-cpp-core-partitioning + job-name: tests-cpp-core-runtime repository: "pytorch/tensorrt" ref: "" test-infra-repository: pytorch/test-infra diff --git a/toolchains/ci_workspaces/WORKSPACE.x86_64.release.rhel.tmpl b/toolchains/ci_workspaces/WORKSPACE.x86_64.release.rhel.tmpl index 146ce9e90d..7fb6149c33 100644 --- a/toolchains/ci_workspaces/WORKSPACE.x86_64.release.rhel.tmpl +++ b/toolchains/ci_workspaces/WORKSPACE.x86_64.release.rhel.tmpl @@ -35,7 +35,7 @@ http_archive( # External dependency for torch_tensorrt if you already have precompiled binaries. local_repository( name = "torch_tensorrt", - path = "/opt/circleci/.pyenv/versions/3.10.9/lib/python3.10/site-packages/torch_tensorrt" + path = "${CONDA_ENV}/lib/python${PYTHON_VERSION}/site-packages/torch_tensorrt" ) # CUDA should be installed on the system locally From 4499fd346aeb03ce78dc1c3d0595c8123c4c6ff7 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Tue, 16 Jul 2024 19:59:07 -0700 Subject: [PATCH 22/22] test --- .github/workflows/build-test-linux.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index d4b88e88c2..7fbab9e663 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -329,7 +329,7 @@ jobs: location=$(python -m pip show torch_tensorrt | grep Location | sed "s/Location: //g") ls -lart $location | grep torch_tensorrt bazel test //tests/core/conversion:conversion_tests --compilation_mode=opt \ - --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures + --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures --cxxopt='-std=c++17' tests-cpp-core-lowering: name: Test core lowering[CPP] @@ -357,7 +357,7 @@ jobs: set -x export USE_HOST_DEPS=1 bazel test //tests/core/lowering:lowering_tests --compilation_mode=opt \ - --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures + --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures --cxxopt='-std=c++17' tests-cpp-core-partitioning: name: Test core partitioning[CPP] @@ -385,7 +385,7 @@ jobs: set -x export USE_HOST_DEPS=1 bazel test //tests/core/partitioning:partitioning_tests --compilation_mode=opt \ - --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures + --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures --cxxopt='-std=c++17' tests-cpp-core-runtime: name: Test core runtime[CPP] @@ -413,7 +413,7 @@ jobs: set -x export USE_HOST_DEPS=1 bazel test //tests/core/runtime:runtime_tests --compilation_mode=opt \ - --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures + --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi --sandbox_debug --verbose_failures --cxxopt='-std=c++17' concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }} cancel-in-progress: true