From a131a9708dcd15fb5b6f4a67a15950926358b1bb Mon Sep 17 00:00:00 2001 From: IlyasMoutawwakil Date: Thu, 6 Jun 2024 17:10:57 +0200 Subject: [PATCH] update actions and upgrade pip and speed up installations --- .../workflows/build_main_documentation.yml | 79 ++++++------------- .github/workflows/build_pr_documentation.yml | 33 ++++---- .github/workflows/check_code_quality.yml | 53 +++++-------- .github/workflows/test_benckmark.yml | 36 +++++---- .github/workflows/test_bettertransformer.yml | 16 ++-- .github/workflows/test_cli.yml | 3 +- .github/workflows/test_export_onnx.yml | 50 +++++++----- .github/workflows/test_export_onnx_cli.yml | 34 ++++---- .../workflows/test_export_onnx_cli_timm.yml | 32 +++++--- .github/workflows/test_export_onnx_timm.yml | 29 ++++--- .github/workflows/test_export_tflite.yml | 33 ++++---- .github/workflows/test_export_tflite_cli.yml | 38 +++++---- ...t_tflite_cli_dynamic_quantization_int8.yml | 38 +++++---- ...st_export_tflite_cli_quantization_fp16.yml | 34 ++++---- ...port_tflite_cli_quantization_full_int8.yml | 34 ++++---- ...e_cli_quantization_int8_custom_dataset.yml | 34 ++++---- ..._cli_quantization_int8_default_dataset.yml | 34 ++++---- ...export_tflite_cli_quantization_int8x16.yml | 34 ++++---- .github/workflows/test_exporters_common.yml | 33 ++++---- .github/workflows/test_fx.yml | 6 +- .github/workflows/test_offline.yml | 42 +++++----- .github/workflows/test_onnx.yml | 34 ++++---- .github/workflows/test_onnxruntime.yml | 2 - .github/workflows/test_optimum_common.yml | 43 +++++----- .github/workflows/test_utils.yml | 4 +- 25 files changed, 429 insertions(+), 379 deletions(-) diff --git a/.github/workflows/build_main_documentation.yml b/.github/workflows/build_main_documentation.yml index 20face917a..3b834c8f41 100644 --- a/.github/workflows/build_main_documentation.yml +++ b/.github/workflows/build_main_documentation.yml @@ -13,87 +13,54 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main with: - repository: 'huggingface/doc-builder' + tool-cache: false + swap-storage: false + large-packages: false + + - uses: actions/checkout@v4 + with: + repository: "huggingface/doc-builder" path: doc-builder - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - repository: 'huggingface/doc-build' + repository: "huggingface/doc-build" path: doc-build token: ${{ secrets.HUGGINGFACE_PUSH }} - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - repository: 'huggingface/optimum' + repository: "huggingface/optimum" path: optimum - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - repository: 'huggingface/optimum-habana' + repository: "huggingface/optimum-habana" path: optimum-habana - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - repository: 'huggingface/optimum-intel' + repository: "huggingface/optimum-intel" path: optimum-intel - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - repository: 'huggingface/optimum-furiosa' + repository: "huggingface/optimum-furiosa" path: optimum-furiosa - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - repository: 'huggingface/optimum-amd' + repository: "huggingface/optimum-amd" path: optimum-amd - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - repository: 'huggingface/optimum-tpu' + repository: "huggingface/optimum-tpu" path: optimum-tpu - - name: Free disk space - run: | - df -h - sudo apt-get purge -y '^apache.*' - sudo apt-get purge -y '^imagemagick.*' - sudo apt-get purge -y '^dotnet.*' - sudo apt-get purge -y '^aspnetcore.*' - sudo apt-get purge -y 'php.*' - sudo apt-get purge -y '^temurin.*' - sudo apt-get purge -y '^mysql.*' - sudo apt-get purge -y '^java.*' - sudo apt-get purge -y '^openjdk.*' - sudo apt-get purge -y microsoft-edge-stable google-cloud-cli azure-cli google-chrome-stable firefox powershell mono-devel - df -h - sudo apt-get autoremove -y >/dev/null 2>&1 - sudo apt-get clean - df -h - echo "https://github.com/actions/virtual-environments/issues/709" - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - df -h - echo "remove big /usr/local" - sudo rm -rf "/usr/local/share/boost" - sudo rm -rf /usr/local/lib/android >/dev/null 2>&1 - df -h - echo "remove /usr/share leftovers" - sudo rm -rf /usr/share/dotnet/sdk > /dev/null 2>&1 - sudo rm -rf /usr/share/dotnet/shared > /dev/null 2>&1 - sudo rm -rf /usr/share/swift > /dev/null 2>&1 - df -h - echo "remove other leftovers" - sudo rm -rf /var/lib/mysql > /dev/null 2>&1 - sudo rm -rf /home/runner/.dotnet > /dev/null 2>&1 - sudo rm -rf /home/runneradmin/.dotnet > /dev/null 2>&1 - sudo rm -rf /etc/skel/.dotnet > /dev/null 2>&1 - sudo rm -rf /usr/local/.ghcup > /dev/null 2>&1 - sudo rm -rf /usr/local/aws-cli > /dev/null 2>&1 - sudo rm -rf /usr/lib/heroku > /dev/null 2>&1 - sudo rm -rf /usr/local/share/chromium > /dev/null 2>&1 - df -h - - name: Set environment variables run: | cd optimum diff --git a/.github/workflows/build_pr_documentation.yml b/.github/workflows/build_pr_documentation.yml index e5f2dcb0d1..0ef17da968 100644 --- a/.github/workflows/build_pr_documentation.yml +++ b/.github/workflows/build_pr_documentation.yml @@ -3,7 +3,7 @@ name: Build PR documentation on: workflow_dispatch: pull_request: - branches: [ main ] + branches: [main] paths: - "optimum/**.py" - "docs/**.mdx" @@ -23,46 +23,47 @@ jobs: PR_CLONE_URL: ${{ github.event.pull_request.head.repo.clone_url }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - repository: 'huggingface/doc-builder' + repository: "huggingface/doc-builder" path: doc-builder - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - repository: 'huggingface/optimum' + repository: "huggingface/optimum" path: optimum - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - repository: 'huggingface/optimum-habana' + repository: "huggingface/optimum-habana" path: optimum-habana - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - repository: 'huggingface/optimum-intel' + repository: "huggingface/optimum-intel" path: optimum-intel - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - repository: 'huggingface/optimum-furiosa' + repository: "huggingface/optimum-furiosa" path: optimum-furiosa - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - repository: 'huggingface/optimum-amd' + repository: "huggingface/optimum-amd" path: optimum-amd - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - repository: 'huggingface/optimum-tpu' + repository: "huggingface/optimum-tpu" path: optimum-tpu - name: Setup environment run: | + pip install --upgrade pip pip uninstall -y doc-builder cd doc-builder - git pull origin main + git pull origin main pip install . pip install black cd .. diff --git a/.github/workflows/check_code_quality.yml b/.github/workflows/check_code_quality.yml index 660f417019..ed8870470b 100644 --- a/.github/workflows/check_code_quality.yml +++ b/.github/workflows/check_code_quality.yml @@ -1,19 +1,11 @@ -name: check_code_quality +name: Code quality on: push: - branches: [ main ] - paths: - - "optimum/**.py" - - "tests/**.py" - - "examples/**.py" + branches: [main] pull_request: - branches: [ main ] - paths: - - "optimum/**.py" - - "tests/**.py" - - "examples/**.py" + branches: [main] concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -29,25 +21,20 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Create and start a virtual environment - run: | - python -m venv venv - source venv/bin/activate - - name: Install dependencies - run: | - source venv/bin/activate - pip install --upgrade pip - pip install .[quality] - - name: Check style with black - run: | - source venv/bin/activate - black --check . - - name: Check style with ruff - run: | - source venv/bin/activate - ruff . + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + pip install .[quality] + + - name: Check style + run: | + make style_check diff --git a/.github/workflows/test_benckmark.yml b/.github/workflows/test_benckmark.yml index 7f7f2ace32..08f24511ed 100644 --- a/.github/workflows/test_benckmark.yml +++ b/.github/workflows/test_benckmark.yml @@ -1,12 +1,10 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions name: Benchmark suite / Python - Test on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -22,15 +20,21 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install wheel - pip install .[tests,onnxruntime,benchmark] - - name: Test with unittest - run: | - python -m unittest discover --start-directory tests/benchmark --pattern 'test_*.py' + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + pip install .[tests,onnxruntime,benchmark] + + - name: Test with pytest + working-directory: tests + run: | + pytest benchmark -s -vvvv --durations=0 diff --git a/.github/workflows/test_bettertransformer.yml b/.github/workflows/test_bettertransformer.yml index 080d8272df..358b812a10 100644 --- a/.github/workflows/test_bettertransformer.yml +++ b/.github/workflows/test_bettertransformer.yml @@ -17,7 +17,6 @@ jobs: matrix: python-version: [3.8, 3.9] os: [ubuntu-20.04, macos-13] - exclude: [{ python-version: 3.8, os: macos-13 }] runs-on: ${{ matrix.os }} steps: @@ -25,27 +24,26 @@ jobs: uses: actions/checkout@v4 - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies + - name: Install dependencies 1 run: | + pip install --upgrade pip + pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu pip install .[tests] - pip install --no-cache-dir --upgrade torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu - pip install accelerate - - name: Test with stable pytorch + - name: Test with pytest (stable pytorch) working-directory: tests run: | pytest bettertransformer -s -vvvvv - name: Install dependencies 2 run: | - pip uninstall -y torch torchvision torchaudio - pip install --no-cache-dir --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu + pip install --no-cache-dir --upgrade --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu - - name: Test with nightly pytorch + - name: Test with pytest (nightly pytorch) working-directory: tests run: | pytest bettertransformer -s -vvvvv diff --git a/.github/workflows/test_cli.yml b/.github/workflows/test_cli.yml index ecb19d23aa..9d8c731a29 100644 --- a/.github/workflows/test_cli.yml +++ b/.github/workflows/test_cli.yml @@ -37,5 +37,6 @@ jobs: pip install .[tests,exporters,exporters-tf] - name: Test with pytest + working-directory: tests run: | - pytest tests/cli -s -vvvv --durations=0 + pytest cli -s -vvvv --durations=0 diff --git a/.github/workflows/test_export_onnx.yml b/.github/workflows/test_export_onnx.yml index 56ef674cb4..1ed8275f9c 100644 --- a/.github/workflows/test_export_onnx.yml +++ b/.github/workflows/test_export_onnx.yml @@ -2,9 +2,9 @@ name: Exporters ONNX / Python - Test on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -20,22 +20,30 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies for pytorch export - run: | - pip install .[tests,exporters] - - name: Test with unittest - working-directory: tests - run: | - pytest exporters/onnx/test_onnx_*.py -s -n auto -m "not tensorflow_test and not timm_test" --durations=0 - - name: Install dependencies for tensorflow export - run: | - pip install .[tests,exporters-tf] - - name: Test with unittest - working-directory: tests - run: | - pytest exporters/onnx/test_onnx_*.py -n auto -m "tensorflow_test" -s --durations=0 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies for pytorch export + run: | + pip install --upgrade pip + pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + pip install .[tests,exporters] + + - name: Test with pytest + working-directory: tests + run: | + pytest exporters/onnx -n auto -m "not tensorflow_test and not timm_test" -s --durations=0 + + - name: Install dependencies for tensorflow export + run: | + pip install .[tests,exporters-tf] + + - name: Test with pytest + working-directory: tests + run: | + pytest exporters/onnx -n auto -m "tensorflow_test" -s --durations=0 diff --git a/.github/workflows/test_export_onnx_cli.yml b/.github/workflows/test_export_onnx_cli.yml index 8fa4ebb045..397c05b9ca 100644 --- a/.github/workflows/test_export_onnx_cli.yml +++ b/.github/workflows/test_export_onnx_cli.yml @@ -2,9 +2,9 @@ name: Exporters ONNX CLI / Python - Test on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -20,15 +20,21 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies for pytorch export - run: | - pip install .[tests,exporters] - - name: Test with unittest - working-directory: tests - run: | - pytest exporters/onnx/test_exporters_onnx_cli.py -n auto -m "not tensorflow_test and not timm_test" -s --durations=0 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies for pytorch export + run: | + pip install --upgrade pip + pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + pip install .[tests,exporters] + + - name: Test with unittest + working-directory: tests + run: | + pytest exporters/onnx -n auto -m "not tensorflow_test and not timm_test" -s --durations=0 diff --git a/.github/workflows/test_export_onnx_cli_timm.yml b/.github/workflows/test_export_onnx_cli_timm.yml index 76a535fceb..e59be00ac1 100644 --- a/.github/workflows/test_export_onnx_cli_timm.yml +++ b/.github/workflows/test_export_onnx_cli_timm.yml @@ -19,15 +19,23 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies for pytorch export - run: | - pip install .[tests,exporters] - - name: Test with unittest - working-directory: tests - run: | - RUN_SLOW=1 pytest exporters/onnx/test_exporters_onnx_cli.py -n auto -k "timm" -s --durations=0 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies for pytorch export + run: | + pip install --upgrade pip + pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + pip install .[tests,exporters] + + - name: Test with pytest + working-directory: tests + env: + RUN_SLOW: "1" + run: | + pytest exporters/onnx -k "timm" -n auto -s -vvvv --durations=0 diff --git a/.github/workflows/test_export_onnx_timm.yml b/.github/workflows/test_export_onnx_timm.yml index 339e3e93de..bcc99d2b37 100644 --- a/.github/workflows/test_export_onnx_timm.yml +++ b/.github/workflows/test_export_onnx_timm.yml @@ -19,16 +19,21 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies for pytorch export - run: | - pip install .[tests,exporters] - - name: Test with unittest - working-directory: tests - run: | - RUN_SLOW=1 pytest exporters/onnx/ -s -n auto -k "timm" --durations=0 + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies for pytorch export + run: | + pip install .[tests,exporters] + + - name: Test with pytest + working-directory: tests + env: + RUN_SLOW: "1" + run: | + pytest exporters/onnx/ -s -n auto -k "timm" --durations=0 diff --git a/.github/workflows/test_export_tflite.yml b/.github/workflows/test_export_tflite.yml index 362390b166..539f77331b 100644 --- a/.github/workflows/test_export_tflite.yml +++ b/.github/workflows/test_export_tflite.yml @@ -2,9 +2,9 @@ name: Exporters TFLite / Python - Test on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] paths: - "optimum/exporters/tasks.py" - "optimum/exporters/tflite/**.py" @@ -25,15 +25,20 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install .[tests,exporters-tf] - - name: Test with unittest - working-directory: tests - run: | - pytest exporters/tflite/test_tflite_*.py -s --durations=0 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install .[tests,exporters-tf] + + - name: Test with pytest + working-directory: tests + run: | + pytest exporters/tflite -s -vvvv --durations=0 diff --git a/.github/workflows/test_export_tflite_cli.yml b/.github/workflows/test_export_tflite_cli.yml index e14e4cde32..8310c22666 100644 --- a/.github/workflows/test_export_tflite_cli.yml +++ b/.github/workflows/test_export_tflite_cli.yml @@ -2,9 +2,9 @@ name: Exporters TFLite CLI / Python - Test on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] paths: - "optimum/exporters/tasks.py" - "optimum/exporters/tflite/**.py" @@ -21,19 +21,25 @@ jobs: fail-fast: false matrix: python-version: [3.8, 3.9] - os: [ubuntu-20.04] - runs-on: ${{ matrix.os }} + runs-on: [] + steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install .[tests,exporters-tf] - - name: Test with unittest - working-directory: tests - run: | - pytest exporters/tflite/test_exporters_tflite_cli.py -m "not quantization" -s --durations=0 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install --no-cache-dir torch==2.1.2 torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + pip install .[tests,exporters-tf] + + - name: Test with pytest + working-directory: tests + run: | + pytest exporters/tflite -n auto -s -vvvv --durations=0 diff --git a/.github/workflows/test_export_tflite_cli_dynamic_quantization_int8.yml b/.github/workflows/test_export_tflite_cli_dynamic_quantization_int8.yml index 7e4a83b3b7..9940805c79 100644 --- a/.github/workflows/test_export_tflite_cli_dynamic_quantization_int8.yml +++ b/.github/workflows/test_export_tflite_cli_dynamic_quantization_int8.yml @@ -2,9 +2,9 @@ name: Exporters TFLite CLI Dynamic Quantization INT8 / Python - Test on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] paths: - "optimum/exporters/tasks.py" - "optimum/exporters/tflite/**.py" @@ -21,19 +21,25 @@ jobs: fail-fast: false matrix: python-version: [3.8, 3.9] - os: [ubuntu-20.04] - runs-on: ${{ matrix.os }} + runs-on: [intel-cpu, 8-cpu, ci] + steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install .[tests,exporters-tf] - - name: Test with unittest - working-directory: tests - run: | - pytest exporters/tflite/test_exporters_tflite_cli.py -k "int8_dynamic_quantization" -s --durations=0 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install --no-cache-dir torch==2.1.2 torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + pip install .[tests,exporters-tf] + + - name: Test with pytest + working-directory: tests + run: | + pytest exporters/tflite/test_exporters_tflite_cli.py -n auto -k "int8_dynamic_quantization" -s -vvvv --durations=0 diff --git a/.github/workflows/test_export_tflite_cli_quantization_fp16.yml b/.github/workflows/test_export_tflite_cli_quantization_fp16.yml index 981dd005e5..edb466451e 100644 --- a/.github/workflows/test_export_tflite_cli_quantization_fp16.yml +++ b/.github/workflows/test_export_tflite_cli_quantization_fp16.yml @@ -2,9 +2,9 @@ name: Exporters TFLite CLI Quantization FP16 / Python - Test on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] paths: - "optimum/exporters/tasks.py" - "optimum/exporters/tflite/**.py" @@ -25,15 +25,21 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install .[tests,exporters-tf] - - name: Test with unittest - working-directory: tests - run: | - pytest exporters/tflite/test_exporters_tflite_cli.py -k "float16_quantization" -s --durations=0 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install --no-cache-dir torch==2.1.2 torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + pip install .[tests,exporters-tf] + + - name: Test with pytest + working-directory: tests + run: | + pytest exporters/tflite/test_exporters_tflite_cli.py -n auto -k "float16_quantization" -s -vvvv --durations=0 diff --git a/.github/workflows/test_export_tflite_cli_quantization_full_int8.yml b/.github/workflows/test_export_tflite_cli_quantization_full_int8.yml index 9064bfaf31..14403dfff4 100644 --- a/.github/workflows/test_export_tflite_cli_quantization_full_int8.yml +++ b/.github/workflows/test_export_tflite_cli_quantization_full_int8.yml @@ -2,9 +2,9 @@ name: Exporters TFLite CLI Quantization Full INT8 Default Dataset / Python - Tes on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] paths: - "optimum/exporters/tasks.py" - "optimum/exporters/tflite/**.py" @@ -25,15 +25,21 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install .[tests,exporters-tf] - - name: Test with unittest - working-directory: tests - run: | - pytest exporters/tflite/test_exporters_tflite_cli.py -k "full_int8_quantization_with_default_dataset" -s --durations=0 + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install --no-cache-dir torch==2.1.2 torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + pip install .[tests,exporters-tf] + + - name: Test with unittest + working-directory: tests + run: | + pytest exporters/tflite/test_exporters_tflite_cli.py -n auto -k "full_int8_quantization_with_default_dataset" -s -vvvv --durations=0 diff --git a/.github/workflows/test_export_tflite_cli_quantization_int8_custom_dataset.yml b/.github/workflows/test_export_tflite_cli_quantization_int8_custom_dataset.yml index 824e8933a0..68b4287d8f 100644 --- a/.github/workflows/test_export_tflite_cli_quantization_int8_custom_dataset.yml +++ b/.github/workflows/test_export_tflite_cli_quantization_int8_custom_dataset.yml @@ -2,9 +2,9 @@ name: Exporters TFLite CLI Quantization INT8 Custom Dataset / Python - Test on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] paths: - "optimum/exporters/tasks.py" - "optimum/exporters/tflite/**.py" @@ -25,15 +25,21 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install .[tests,exporters-tf] - - name: Test with unittest - working-directory: tests - run: | - pytest exporters/tflite/test_exporters_tflite_cli.py -k "tflite_int8_quantization_with_custom_dataset" -s --durations=0 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install --no-cache-dir torch==2.1.2 torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + pip install .[tests,exporters-tf] + + - name: Test with pytest + working-directory: tests + run: | + pytest exporters/tflite/test_exporters_tflite_cli.py -n auto -k "tflite_int8_quantization_with_custom_dataset" -s -vvvv --durations=0 diff --git a/.github/workflows/test_export_tflite_cli_quantization_int8_default_dataset.yml b/.github/workflows/test_export_tflite_cli_quantization_int8_default_dataset.yml index e975997e37..f2afa7541a 100644 --- a/.github/workflows/test_export_tflite_cli_quantization_int8_default_dataset.yml +++ b/.github/workflows/test_export_tflite_cli_quantization_int8_default_dataset.yml @@ -2,9 +2,9 @@ name: Exporters TFLite CLI Quantization INT8 Default Dataset / Python - Test on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] paths: - "optimum/exporters/tasks.py" - "optimum/exporters/tflite/**.py" @@ -25,15 +25,21 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install .[tests,exporters-tf] - - name: Test with unittest - working-directory: tests - run: | - pytest exporters/tflite/test_exporters_tflite_cli.py -k "tflite_int8_quantization_with_default_dataset" -s --durations=0 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install --no-cache-dir torch==2.1.2 torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + pip install .[tests,exporters-tf] + + - name: Test with pytest + working-directory: tests + run: | + pytest exporters/tflite/test_exporters_tflite_cli.py -n auto -k "tflite_int8_quantization_with_default_dataset" -s -vvvv --durations=0 diff --git a/.github/workflows/test_export_tflite_cli_quantization_int8x16.yml b/.github/workflows/test_export_tflite_cli_quantization_int8x16.yml index ef59cff0b9..e418c2c2f8 100644 --- a/.github/workflows/test_export_tflite_cli_quantization_int8x16.yml +++ b/.github/workflows/test_export_tflite_cli_quantization_int8x16.yml @@ -2,9 +2,9 @@ name: Exporters TFLite CLI Quantization INT8x16 / Python - Test on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] paths: - "optimum/exporters/tasks.py" - "optimum/exporters/tflite/**.py" @@ -25,15 +25,21 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install .[tests,exporters-tf] - - name: Test with unittest - working-directory: tests - run: | - pytest exporters/tflite/test_exporters_tflite_cli.py -k "tflite_int8x16_quantization_with_default_dataset" -s --durations=0 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install --no-cache-dir torch==2.1.2 torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + pip install .[tests,exporters-tf] + + - name: Test with pytest + working-directory: tests + run: | + pytest exporters/tflite/test_exporters_tflite_cli.py -n auto -k "tflite_int8x16_quantization_with_default_dataset" -s -vvvv --durations=0 diff --git a/.github/workflows/test_exporters_common.yml b/.github/workflows/test_exporters_common.yml index 8e8c3360c1..f643e640b9 100644 --- a/.github/workflows/test_exporters_common.yml +++ b/.github/workflows/test_exporters_common.yml @@ -2,9 +2,9 @@ name: Exporters Common / Python - Test on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -20,15 +20,20 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install .[tests,exporters-tf] - - name: Test with unittest - working-directory: tests - run: | - pytest exporters/common/ -s --durations=0 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install .[tests,exporters-tf] + + - name: Test with unittest + working-directory: tests + run: | + pytest exporters/common -s -vvvv --durations=0 diff --git a/.github/workflows/test_fx.yml b/.github/workflows/test_fx.yml index f0366cf0d1..6ddebd1a05 100644 --- a/.github/workflows/test_fx.yml +++ b/.github/workflows/test_fx.yml @@ -24,15 +24,17 @@ jobs: uses: actions/checkout@v4 - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | + pip install --upgrade pip + pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu pip install .[tests] - name: Test with pytest working-directory: tests run: | - python -m pytest -s -v -x fx/optimization + pytest fx -s -vvvv --durations=0 diff --git a/.github/workflows/test_offline.yml b/.github/workflows/test_offline.yml index ca90730b6b..2bcb05476a 100644 --- a/.github/workflows/test_offline.yml +++ b/.github/workflows/test_offline.yml @@ -2,9 +2,9 @@ name: Offline usage / Python - Test on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -20,24 +20,30 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies for pytorch export - run: | - pip install .[tests,exporters,onnxruntime] - - name: Test with unittest - run: | - HF_HOME=/tmp/ huggingface-cli download hf-internal-testing/tiny-random-gpt2 + - name: Checkout code + uses: actions/checkout@v4 - HF_HOME=/tmp/ HF_HUB_OFFLINE=1 optimum-cli export onnx --model hf-internal-testing/tiny-random-gpt2 gpt2_onnx --task text-generation + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} - huggingface-cli download hf-internal-testing/tiny-random-gpt2 + - name: Install dependencies for pytorch export + run: | + pip install --upgrade pip + pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + pip install .[tests,exporters,onnxruntime] - HF_HUB_OFFLINE=1 optimum-cli export onnx --model hf-internal-testing/tiny-random-gpt2 gpt2_onnx --task text-generation + - name: Test with unittest + run: | + HF_HOME=/tmp/ huggingface-cli download hf-internal-testing/tiny-random-gpt2 - pytest tests/onnxruntime/test_modeling.py -k "test_load_model_from_hub and not from_hub_onnx" -s -vvvvv + HF_HOME=/tmp/ HF_HUB_OFFLINE=1 optimum-cli export onnx --model hf-internal-testing/tiny-random-gpt2 gpt2_onnx --task text-generation - HF_HUB_OFFLINE=1 pytest tests/onnxruntime/test_modeling.py -k "test_load_model_from_hub and not from_hub_onnx" -s -vvvvv \ No newline at end of file + huggingface-cli download hf-internal-testing/tiny-random-gpt2 + + HF_HUB_OFFLINE=1 optimum-cli export onnx --model hf-internal-testing/tiny-random-gpt2 gpt2_onnx --task text-generation + + pytest tests/onnxruntime/test_modeling.py -k "test_load_model_from_hub and not from_hub_onnx" -s -vvvvv + + HF_HUB_OFFLINE=1 pytest tests/onnxruntime/test_modeling.py -k "test_load_model_from_hub and not from_hub_onnx" -s -vvvvv diff --git a/.github/workflows/test_onnx.yml b/.github/workflows/test_onnx.yml index 5a21f12d01..efcd417fd3 100644 --- a/.github/workflows/test_onnx.yml +++ b/.github/workflows/test_onnx.yml @@ -2,9 +2,9 @@ name: ONNX / Python - Test on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -20,15 +20,21 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install .[tests,onnxruntime,exporters-tf] - - name: Test with unittest - working-directory: tests - run: | - python -m unittest discover -s onnx -p 'test_*.py' + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + pip install .[tests,onnxruntime,exporters-tf] + + - name: Test with unittest + working-directory: tests + run: | + pytest onnx -s -vvvv --durations=0 diff --git a/.github/workflows/test_onnxruntime.yml b/.github/workflows/test_onnxruntime.yml index 4893b681a6..236bb36a80 100644 --- a/.github/workflows/test_onnxruntime.yml +++ b/.github/workflows/test_onnxruntime.yml @@ -1,5 +1,3 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions name: ONNX Runtime / Python - Test on: diff --git a/.github/workflows/test_optimum_common.yml b/.github/workflows/test_optimum_common.yml index ded149c9b6..518efde330 100644 --- a/.github/workflows/test_optimum_common.yml +++ b/.github/workflows/test_optimum_common.yml @@ -1,12 +1,10 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions name: Optimum common / Python - Test on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -22,20 +20,23 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install .[tests] - ls -l optimum/ - - name: Test with unittest - shell: bash - run: | - # Setting HUGGINGFACE_CO_STAGING to true for only one job of the matrix as the staging tests cannot run in parallel. - export HUGGINGFACE_CO_STAGING=${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-20.04' }} - pytest tests/test_*.py - + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu + pip install .[tests] + + - name: Test with unittest + shell: bash + run: | + # Setting HUGGINGFACE_CO_STAGING to true for only one job of the matrix as the staging tests cannot run in parallel. + export HUGGINGFACE_CO_STAGING=${{ matrix.python-version == '3.8' && matrix.os == 'ubuntu-20.04' }} + pytest tests/test_*.py diff --git a/.github/workflows/test_utils.yml b/.github/workflows/test_utils.yml index 1ef33ced08..aa3b776e2f 100644 --- a/.github/workflows/test_utils.yml +++ b/.github/workflows/test_utils.yml @@ -24,13 +24,13 @@ jobs: uses: actions/checkout@v4 - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip + pip install --upgrade pip pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu pip install .[tests]