From f5aa9aee17e0fc9f9db71a6eab12d5aef8bc498f Mon Sep 17 00:00:00 2001 From: Elad Cohen <78862769+elad-c@users.noreply.github.com> Date: Wed, 8 Nov 2023 14:39:12 +0200 Subject: [PATCH] Support PyTorch 2.1 and add PyTorch tests for python 3.11 (#854) * Support PyTorch 2.1 and add PyTorch tests for python 3.11 * Remove python 3.8 tests * Remove python 3.11 torch 1.13 test (doesn't support 3.11) --------- Co-authored-by: elad cohen --- ...112.yml => run_tests_python310_pytorch21.yml} | 6 +++--- ...h20.yml => run_tests_python311_pytorch20.yml} | 4 ++-- ...113.yml => run_tests_python311_pytorch21.yml} | 6 +++--- .../workflows/run_tests_python38_keras212.yml | 16 ---------------- ...s213.yml => run_tests_python39_pytorch21.yml} | 8 ++++---- README.md | 10 +++++----- .../test_fully_quantized_exporter.py | 2 +- 7 files changed, 18 insertions(+), 34 deletions(-) rename .github/workflows/{run_tests_python38_pytorch112.yml => run_tests_python310_pytorch21.yml} (70%) rename .github/workflows/{run_tests_python38_pytorch20.yml => run_tests_python311_pytorch20.yml} (79%) rename .github/workflows/{run_tests_python38_pytorch113.yml => run_tests_python311_pytorch21.yml} (70%) delete mode 100644 .github/workflows/run_tests_python38_keras212.yml rename .github/workflows/{run_tests_python38_keras213.yml => run_tests_python39_pytorch21.yml} (53%) diff --git a/.github/workflows/run_tests_python38_pytorch112.yml b/.github/workflows/run_tests_python310_pytorch21.yml similarity index 70% rename from .github/workflows/run_tests_python38_pytorch112.yml rename to .github/workflows/run_tests_python310_pytorch21.yml index 51cb8c27b..1a965caf1 100644 --- a/.github/workflows/run_tests_python38_pytorch112.yml +++ b/.github/workflows/run_tests_python310_pytorch21.yml @@ -1,4 +1,4 @@ -name: Python 3.8, Pytorch 1.12 +name: Python 3.10, Pytorch 2.1 on: workflow_dispatch: # Allow manual triggers schedule: @@ -12,5 +12,5 @@ jobs: run-tests: uses: ./.github/workflows/run_pytorch_tests.yml with: - python-version: "3.8" - torch-version: "1.12.*" \ No newline at end of file + python-version: "3.10" + torch-version: "2.1.*" \ No newline at end of file diff --git a/.github/workflows/run_tests_python38_pytorch20.yml b/.github/workflows/run_tests_python311_pytorch20.yml similarity index 79% rename from .github/workflows/run_tests_python38_pytorch20.yml rename to .github/workflows/run_tests_python311_pytorch20.yml index 874dd8e01..d2a81e6f2 100644 --- a/.github/workflows/run_tests_python38_pytorch20.yml +++ b/.github/workflows/run_tests_python311_pytorch20.yml @@ -1,4 +1,4 @@ -name: Python 3.8, Pytorch 2.0 +name: Python 3.11, Pytorch 2.0 on: workflow_dispatch: # Allow manual triggers schedule: @@ -12,5 +12,5 @@ jobs: run-tests: uses: ./.github/workflows/run_pytorch_tests.yml with: - python-version: "3.8" + python-version: "3.11" torch-version: "2.0.*" \ No newline at end of file diff --git a/.github/workflows/run_tests_python38_pytorch113.yml b/.github/workflows/run_tests_python311_pytorch21.yml similarity index 70% rename from .github/workflows/run_tests_python38_pytorch113.yml rename to .github/workflows/run_tests_python311_pytorch21.yml index 733993f53..7f0738c7b 100644 --- a/.github/workflows/run_tests_python38_pytorch113.yml +++ b/.github/workflows/run_tests_python311_pytorch21.yml @@ -1,4 +1,4 @@ -name: Python 3.8, Pytorch 1.13 +name: Python 3.11, Pytorch 2.1 on: workflow_dispatch: # Allow manual triggers schedule: @@ -12,5 +12,5 @@ jobs: run-tests: uses: ./.github/workflows/run_pytorch_tests.yml with: - python-version: "3.8" - torch-version: "1.13.*" \ No newline at end of file + python-version: "3.11" + torch-version: "2.1.*" \ No newline at end of file diff --git a/.github/workflows/run_tests_python38_keras212.yml b/.github/workflows/run_tests_python38_keras212.yml deleted file mode 100644 index 11b4b90de..000000000 --- a/.github/workflows/run_tests_python38_keras212.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Python 3.8, Keras 2.12 -on: - workflow_dispatch: # Allow manual triggers - schedule: - - cron: 0 0 * * * - pull_request: - branches: - - main - - -jobs: - run-tests: - uses: ./.github/workflows/run_keras_tests.yml - with: - python-version: "3.8" - tf-version: "2.12.*" \ No newline at end of file diff --git a/.github/workflows/run_tests_python38_keras213.yml b/.github/workflows/run_tests_python39_pytorch21.yml similarity index 53% rename from .github/workflows/run_tests_python38_keras213.yml rename to .github/workflows/run_tests_python39_pytorch21.yml index 406ccf18f..d0ad42da8 100644 --- a/.github/workflows/run_tests_python38_keras213.yml +++ b/.github/workflows/run_tests_python39_pytorch21.yml @@ -1,4 +1,4 @@ -name: Python 3.8, Keras 2.13 +name: Python 3.9, Pytorch 2.1 on: workflow_dispatch: # Allow manual triggers schedule: @@ -10,7 +10,7 @@ on: jobs: run-tests: - uses: ./.github/workflows/run_keras_tests.yml + uses: ./.github/workflows/run_pytorch_tests.yml with: - python-version: "3.8" - tf-version: "2.13.*" \ No newline at end of file + python-version: "3.9" + torch-version: "2.1.*" \ No newline at end of file diff --git a/README.md b/README.md index f9df23bc6..b14410f2a 100644 --- a/README.md +++ b/README.md @@ -51,11 +51,11 @@ In addition, a set of [notebooks](tutorials/notebooks) are provided for an easy Currently, MCT is being tested on various Python, Pytorch and TensorFlow versions: -| | PyTorch 1.12 | PyTorch 1.13 | PyTorch 2.0 | -|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Python 3.8 | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python38_pytorch112.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python38_pytorch112.yml) | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python38_pytorch113.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python38_pytorch113.yml) | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python38_pytorch20.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python38_pytorch20.yml) | -| Python 3.9 | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python39_pytorch112.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python39_pytorch112.yml) | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python39_pytorch113.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python39_pytorch113.yml) | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python39_pytorch20.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python39_pytorch20.yml) | -| Python 3.10 | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python310_pytorch112.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python310_pytorch112.yml) | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python310_pytorch113.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python310_pytorch113.yml) | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python310_pytorch20.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python310_pytorch20.yml) | +| | PyTorch 1.13 | PyTorch 2.0 | PyTorch 2.1 | +|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Python 3.9 | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python39_pytorch113.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python39_pytorch113.yml) | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python39_pytorch20.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python39_pytorch20.yml) | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python39_pytorch21.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python39_pytorch21.yml) | +| Python 3.10 | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python310_pytorch112.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python310_pytorch112.yml) | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python310_pytorch113.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python310_pytorch113.yml) | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python310_pytorch20.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python310_pytorch20.yml) | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python310_pytorch21.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python310_pytorch21.yml) | +| Python 3.11 | | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python311_pytorch20.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python311_pytorch20.yml) | [![Run Tests](https://github.com/sony/model_optimization/actions/workflows/run_tests_python311_pytorch21.yml/badge.svg)](https://github.com/sony/model_optimization/actions/workflows/run_tests_python311_pytorch21.yml) | | | TensorFlow 2.12 | TensorFlow 2.13 | TensorFlow 2.14 | diff --git a/tests/pytorch_tests/function_tests/test_fully_quantized_exporter.py b/tests/pytorch_tests/function_tests/test_fully_quantized_exporter.py index 77af3a820..b3b383321 100644 --- a/tests/pytorch_tests/function_tests/test_fully_quantized_exporter.py +++ b/tests/pytorch_tests/function_tests/test_fully_quantized_exporter.py @@ -53,7 +53,7 @@ def run_mct(self, model): def set_seed(self, seed): torch.manual_seed(seed) np.random.seed(seed) - random.seed(seed) + random.seed(float(seed)) def test_sanity(self): """