diff --git a/.github/workflows/build-test-linux-aarch64-jetpack.yml b/.github/workflows/build-test-linux-aarch64-jetpack.yml index 744a802bfa..ad35bd6da5 100644 --- a/.github/workflows/build-test-linux-aarch64-jetpack.yml +++ b/.github/workflows/build-test-linux-aarch64-jetpack.yml @@ -1,7 +1,7 @@ name: Build and test Linux aarch64 wheels for Jetpack on: - pull_request: + #pull_request: push: branches: - main diff --git a/.github/workflows/build-test-linux-aarch64.yml b/.github/workflows/build-test-linux-aarch64.yml index 1f2c98da56..fb1ed0af0a 100644 --- a/.github/workflows/build-test-linux-aarch64.yml +++ b/.github/workflows/build-test-linux-aarch64.yml @@ -1,7 +1,7 @@ name: Build and test Linux aarch64 wheels on: - pull_request: + #pull_request: push: branches: - main diff --git a/.github/workflows/build-test-linux-x86_64.yml b/.github/workflows/build-test-linux-x86_64.yml index f788f88dc9..52eae3c40e 100644 --- a/.github/workflows/build-test-linux-x86_64.yml +++ b/.github/workflows/build-test-linux-x86_64.yml @@ -1,7 +1,7 @@ name: Build and test Linux x86_64 wheels on: - pull_request: + #pull_request: push: branches: - main diff --git a/.github/workflows/build-test-windows.yml b/.github/workflows/build-test-windows.yml index 40171540fc..85b025231b 100644 --- a/.github/workflows/build-test-windows.yml +++ b/.github/workflows/build-test-windows.yml @@ -118,61 +118,61 @@ jobs: python -m pytest -ra --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_integrations_test_results.xml integrations/ popd - tests-py-dynamo-converters: - name: Test dynamo converters [Python] - needs: [substitute-runner, build] - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - uses: ./.github/workflows/windows-test.yml - with: - job-name: tests-py-dynamo-converters - repository: ${{ matrix.repository }} - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.substitute-runner.outputs.matrix }} - pre-script: packaging/driver_upgrade.bat - script: | - set -euo pipefail - export USE_HOST_DEPS=1 - export CI_BUILD=1 - pushd . - cd tests/py - cd dynamo - python -m pytest -ra --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_converters_test_results.xml -n 4 conversion/ - popd + # tests-py-dynamo-converters: + # name: Test dynamo converters [Python] + # needs: [substitute-runner, build] + # strategy: + # fail-fast: false + # matrix: + # include: + # - repository: pytorch/tensorrt + # package-name: torch_tensorrt + # uses: ./.github/workflows/windows-test.yml + # with: + # job-name: tests-py-dynamo-converters + # repository: ${{ matrix.repository }} + # ref: "" + # test-infra-repository: pytorch/test-infra + # test-infra-ref: main + # build-matrix: ${{ needs.substitute-runner.outputs.matrix }} + # pre-script: packaging/driver_upgrade.bat + # script: | + # set -euo pipefail + # export USE_HOST_DEPS=1 + # export CI_BUILD=1 + # pushd . + # cd tests/py + # cd dynamo + # python -m pytest -ra --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_converters_test_results.xml -n 4 conversion/ + # popd - tests-py-dynamo-fe: - name: Test dynamo frontend [Python] - needs: [substitute-runner, build] - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - uses: ./.github/workflows/windows-test.yml - with: - job-name: tests-py-dynamo-fe - repository: ${{ matrix.repository }} - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.substitute-runner.outputs.matrix }} - pre-script: packaging/driver_upgrade.bat - script: | - set -euo pipefail - export USE_HOST_DEPS=1 - export CI_BUILD=1 - pushd . - cd tests/py - cd dynamo - python -m pytest -ra --junitxml=${RUNNER_TEST_RESULTS_DIR}/dyn_models_export.xml --ir dynamo models/ - popd + # tests-py-dynamo-fe: + # name: Test dynamo frontend [Python] + # needs: [substitute-runner, build] + # strategy: + # fail-fast: false + # matrix: + # include: + # - repository: pytorch/tensorrt + # package-name: torch_tensorrt + # uses: ./.github/workflows/windows-test.yml + # with: + # job-name: tests-py-dynamo-fe + # repository: ${{ matrix.repository }} + # ref: "" + # test-infra-repository: pytorch/test-infra + # test-infra-ref: main + # build-matrix: ${{ needs.substitute-runner.outputs.matrix }} + # pre-script: packaging/driver_upgrade.bat + # script: | + # set -euo pipefail + # export USE_HOST_DEPS=1 + # export CI_BUILD=1 + # pushd . + # cd tests/py + # cd dynamo + # python -m pytest -ra --junitxml=${RUNNER_TEST_RESULTS_DIR}/dyn_models_export.xml --ir dynamo models/ + # popd tests-py-dynamo-serde: name: Test dynamo export serde [Python] @@ -203,121 +203,121 @@ jobs: python -m pytest -ra --junitxml=${RUNNER_TEST_RESULTS_DIR}/reexport_test_results.xml --ir dynamo models/test_reexport.py popd - tests-py-torch-compile-be: - name: Test torch compile backend [Python] - needs: [substitute-runner, build] - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - uses: ./.github/workflows/windows-test.yml - with: - job-name: tests-py-torch-compile-be - repository: ${{ matrix.repository }} - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.substitute-runner.outputs.matrix }} - pre-script: packaging/driver_upgrade.bat - script: | - set -euo pipefail - export USE_HOST_DEPS=1 - export CI_BUILD=1 - pushd . - cd tests/py - cd dynamo - python -m pytest -ra -n 10 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_be_test_results.xml backend/ - python -m pytest -ra -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_complete_be_e2e_test_results.xml --ir torch_compile models/test_models.py - python -m pytest -ra --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: [substitute-runner, build] + # strategy: + # fail-fast: false + # matrix: + # include: + # - repository: pytorch/tensorrt + # package-name: torch_tensorrt + # uses: ./.github/workflows/windows-test.yml + # with: + # job-name: tests-py-torch-compile-be + # repository: ${{ matrix.repository }} + # ref: "" + # test-infra-repository: pytorch/test-infra + # test-infra-ref: main + # build-matrix: ${{ needs.substitute-runner.outputs.matrix }} + # pre-script: packaging/driver_upgrade.bat + # script: | + # set -euo pipefail + # export USE_HOST_DEPS=1 + # export CI_BUILD=1 + # pushd . + # cd tests/py + # cd dynamo + # python -m pytest -ra -n 10 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_be_test_results.xml backend/ + # python -m pytest -ra -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_complete_be_e2e_test_results.xml --ir torch_compile models/test_models.py + # python -m pytest -ra --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: [substitute-runner, build] - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - uses: ./.github/workflows/windows-test.yml - with: - job-name: tests-py-dynamo-core - repository: ${{ matrix.repository }} - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.substitute-runner.outputs.matrix }} - pre-script: packaging/driver_upgrade.bat - script: | - set -euo pipefail - export USE_HOST_DEPS=1 - export CI_BUILD=1 - pushd . - cd tests/py - cd dynamo - python -m pytest -ra -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_test_results.xml --ignore runtime/test_002_cudagraphs_py.py --ignore runtime/test_002_cudagraphs_cpp.py runtime/ - python -m pytest -ra -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_partitioning_test_results.xml partitioning/ - python -m pytest -ra -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: [substitute-runner, build] + # strategy: + # fail-fast: false + # matrix: + # include: + # - repository: pytorch/tensorrt + # package-name: torch_tensorrt + # uses: ./.github/workflows/windows-test.yml + # with: + # job-name: tests-py-dynamo-core + # repository: ${{ matrix.repository }} + # ref: "" + # test-infra-repository: pytorch/test-infra + # test-infra-ref: main + # build-matrix: ${{ needs.substitute-runner.outputs.matrix }} + # pre-script: packaging/driver_upgrade.bat + # script: | + # set -euo pipefail + # export USE_HOST_DEPS=1 + # export CI_BUILD=1 + # pushd . + # cd tests/py + # cd dynamo + # python -m pytest -ra -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_test_results.xml --ignore runtime/test_002_cudagraphs_py.py --ignore runtime/test_002_cudagraphs_cpp.py runtime/ + # python -m pytest -ra -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_partitioning_test_results.xml partitioning/ + # python -m pytest -ra -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_lowering_test_results.xml lowering/ + # popd - tests-py-dynamo-cudagraphs: - name: Test dynamo cudagraphs [Python] - needs: [substitute-runner, build] - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - uses: ./.github/workflows/windows-test.yml - with: - job-name: tests-py-dynamo-cudagraphs - repository: ${{ matrix.repository }} - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.substitute-runner.outputs.matrix }} - pre-script: packaging/driver_upgrade.bat - script: | - set -euo pipefail - export USE_HOST_DEPS=1 - export CI_BUILD=1 - pushd . - cd tests/py - cd dynamo - python -m pytest -ra --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_cudagraphs_cpp_test_results.xml runtime/test_002_cudagraphs_cpp.py - python -m pytest -ra --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_cudagraphs_py_test_results.xml runtime/test_002_cudagraphs_py.py - popd + # tests-py-dynamo-cudagraphs: + # name: Test dynamo cudagraphs [Python] + # needs: [substitute-runner, build] + # strategy: + # fail-fast: false + # matrix: + # include: + # - repository: pytorch/tensorrt + # package-name: torch_tensorrt + # uses: ./.github/workflows/windows-test.yml + # with: + # job-name: tests-py-dynamo-cudagraphs + # repository: ${{ matrix.repository }} + # ref: "" + # test-infra-repository: pytorch/test-infra + # test-infra-ref: main + # build-matrix: ${{ needs.substitute-runner.outputs.matrix }} + # pre-script: packaging/driver_upgrade.bat + # script: | + # set -euo pipefail + # export USE_HOST_DEPS=1 + # export CI_BUILD=1 + # pushd . + # cd tests/py + # cd dynamo + # python -m pytest -ra --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_cudagraphs_cpp_test_results.xml runtime/test_002_cudagraphs_cpp.py + # python -m pytest -ra --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_cudagraphs_py_test_results.xml runtime/test_002_cudagraphs_py.py + # popd - tests-py-core: - name: Test core [Python] - needs: [substitute-runner, build] - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - uses: ./.github/workflows/windows-test.yml - with: - job-name: tests-py-core - repository: ${{ matrix.repository }} - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.substitute-runner.outputs.matrix }} - pre-script: packaging/driver_upgrade.bat - script: | - set -euo pipefail - export USE_HOST_DEPS=1 - export CI_BUILD=1 - pushd . - cd tests/py/core - python -m pytest -ra -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml . - popd + # tests-py-core: + # name: Test core [Python] + # needs: [substitute-runner, build] + # strategy: + # fail-fast: false + # matrix: + # include: + # - repository: pytorch/tensorrt + # package-name: torch_tensorrt + # uses: ./.github/workflows/windows-test.yml + # with: + # job-name: tests-py-core + # repository: ${{ matrix.repository }} + # ref: "" + # test-infra-repository: pytorch/test-infra + # test-infra-ref: main + # build-matrix: ${{ needs.substitute-runner.outputs.matrix }} + # pre-script: packaging/driver_upgrade.bat + # script: | + # set -euo pipefail + # export USE_HOST_DEPS=1 + # export CI_BUILD=1 + # pushd . + # cd tests/py/core + # python -m pytest -ra -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 }} diff --git a/py/torch_tensorrt/__init__.py b/py/torch_tensorrt/__init__.py index 6d79f9b4f3..c0f43ae2af 100644 --- a/py/torch_tensorrt/__init__.py +++ b/py/torch_tensorrt/__init__.py @@ -100,15 +100,23 @@ def _register_with_torch() -> None: ) linked_file_full_path = os.path.join(trtorch_dir, linked_file) linked_file_runtime_full_path = os.path.join(trtorch_dir, linked_file_runtime) - - if os.path.isfile(linked_file_full_path): - assert ENABLED_FEATURES.torchscript_frontend - assert ENABLED_FEATURES.torch_tensorrt_runtime - torch.ops.load_library(linked_file_full_path) - - elif os.path.isfile(linked_file_runtime_full_path): - assert ENABLED_FEATURES.torch_tensorrt_runtime - torch.ops.load_library(linked_file_runtime_full_path) + import traceback + + try: + if os.path.isfile(linked_file_full_path): + assert ENABLED_FEATURES.torchscript_frontend + assert ENABLED_FEATURES.torch_tensorrt_runtime + print(f"Loading library: {linked_file_full_path=} {torch.__version__=} {torch.cuda.is_available()=}") + torch.ops.load_library(linked_file_full_path) + + elif os.path.isfile(linked_file_runtime_full_path): + assert ENABLED_FEATURES.torch_tensorrt_runtime + print(f"Loading library: {linked_file_runtime_full_path=} {torch.__version__=} {torch.cuda.is_available()=}") + torch.ops.load_library(linked_file_runtime_full_path) + except Exception as e: + print(f"Error loading library: {e}") + print(traceback.format_exc()) + raise e from e _register_with_torch()