diff --git a/.github/workflows/build_pr_documentation.yml b/.github/workflows/build_pr_documentation.yml index 6eb09aff30..16117995b9 100644 --- a/.github/workflows/build_pr_documentation.yml +++ b/.github/workflows/build_pr_documentation.yml @@ -131,7 +131,7 @@ jobs: echo ${{ env.COMMIT_SHA }} > ./commit_sha echo ${{ env.PR_NUMBER }} > ./pr_number - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: doc-build-artifact path: optimum-doc-build/ diff --git a/.github/workflows/test_export_onnx.yml b/.github/workflows/test_export_onnx.yml index d1fd4a9723..187aa6a65c 100644 --- a/.github/workflows/test_export_onnx.yml +++ b/.github/workflows/test_export_onnx.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.9'] + python-version: ["3.9"] os: [ubuntu-20.04] runs-on: ${{ matrix.os }} @@ -27,13 +27,14 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies for pytorch export run: | - pip install .[tests,exporters] + pip install .[tests,exporters,diffusers] - 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 uninstall diffusers -y pip install .[tests,exporters-tf] - name: Test with unittest working-directory: tests diff --git a/.github/workflows/test_export_onnx_cli.yml b/.github/workflows/test_export_onnx_cli.yml index 618a140c14..41394fef92 100644 --- a/.github/workflows/test_export_onnx_cli.yml +++ b/.github/workflows/test_export_onnx_cli.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.9] + python-version: ["3.9"] os: [ubuntu-20.04] runs-on: ${{ matrix.os }} @@ -27,7 +27,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies for pytorch export run: | - pip install .[tests,exporters] + pip install .[tests,exporters,diffusers] - name: Test with unittest working-directory: tests run: | diff --git a/.github/workflows/test_exporters_slow.yml b/.github/workflows/test_exporters_slow.yml index b5f142fc7d..51424a18f3 100644 --- a/.github/workflows/test_exporters_slow.yml +++ b/.github/workflows/test_exporters_slow.yml @@ -14,26 +14,27 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.9'] + python-version: ["3.9"] runs-on: ubuntu-20.04 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 -s -m "not tensorflow_test and run_slow" --durations=0 - - name: Install dependencies for tensorflow export - run: | - pip install .[tests,exporters-tf] - - name: Test with unittest - working-directory: tests - run: | - RUN_SLOW=1 pytest exporters -s -m "tensorflow_test and run_slow" --durations=0 + - 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,diffusers] + - name: Test with unittest + working-directory: tests + run: | + RUN_SLOW=1 pytest exporters -s -m "not tensorflow_test and run_slow" --durations=0 + - name: Install dependencies for tensorflow export + run: | + pip uninstall diffusers -y + pip install .[tests,exporters-tf] + - name: Test with unittest + working-directory: tests + run: | + RUN_SLOW=1 pytest exporters -s -m "tensorflow_test and run_slow" --durations=0 diff --git a/.github/workflows/test_onnx.yml b/.github/workflows/test_onnx.yml index 418a9e42c1..79a55a6c4a 100644 --- a/.github/workflows/test_onnx.yml +++ b/.github/workflows/test_onnx.yml @@ -27,7 +27,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - pip install .[tests,exporters] + pip install .[tests,exporters,diffusers] - name: Test with unittest working-directory: tests run: | diff --git a/.github/workflows/test_onnxruntime.yml b/.github/workflows/test_onnxruntime.yml index a0c5893d62..55abfd5683 100644 --- a/.github/workflows/test_onnxruntime.yml +++ b/.github/workflows/test_onnxruntime.yml @@ -38,17 +38,23 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: "3.9" - 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] + pip install .[tests,onnxruntime,diffusers] - name: Install transformers ${{ matrix.transformers-version }} if: ${{ matrix.transformers-version != 'latest' }} - run: pip install transformers==${{ matrix.transformers-version }} + run: | + pip install "transformers==${{ matrix.transformers-version }}" + + - name: Downgrade diffusers + if: matrix.transformers-version == '4.36.*' + run: | + pip install "diffusers<0.32.0" - name: Test with pytest (in series) run: | diff --git a/.github/workflows/test_onnxruntime_slow.yml b/.github/workflows/test_onnxruntime_slow.yml index 89d44e57ad..031aeceea2 100644 --- a/.github/workflows/test_onnxruntime_slow.yml +++ b/.github/workflows/test_onnxruntime_slow.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.9'] + python-version: ["3.9"] os: [ubuntu-20.04] runs-on: ${{ matrix.os }} @@ -26,7 +26,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies for export run: | - pip install .[tests,onnxruntime] + pip install .[tests,onnxruntime,diffusers] - name: Test with unittest working-directory: tests run: | diff --git a/optimum/exporters/onnx/model_configs.py b/optimum/exporters/onnx/model_configs.py index b587f16316..503f28d057 100644 --- a/optimum/exporters/onnx/model_configs.py +++ b/optimum/exporters/onnx/model_configs.py @@ -184,7 +184,7 @@ def inputs(self) -> Dict[str, Dict[int, str]]: class ModernBertOnnxConfig(DistilBertOnnxConfig): - pass + MIN_TRANSFORMERS_VERSION = version.parse("4.48.0") class MPNetOnnxConfig(DistilBertOnnxConfig): diff --git a/optimum/subpackages.py b/optimum/subpackages.py index 8729581521..24eca2a139 100644 --- a/optimum/subpackages.py +++ b/optimum/subpackages.py @@ -48,6 +48,8 @@ def load_namespace_modules(namespace: str, module: str): dist_name = dist.metadata["Name"] if not dist_name.startswith(f"{namespace}-"): continue + if dist_name == f"{namespace}-benchmark": + continue package_import_name = dist_name.replace("-", ".") module_import_name = f"{package_import_name}.{module}" if module_import_name in sys.modules: diff --git a/setup.py b/setup.py index 197d632b43..ec15277f18 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,6 @@ "Pillow", "sacremoses", "torchvision", - "diffusers>=0.17.0,<0.32.0", "torchaudio", "einops", "timm", @@ -89,7 +88,7 @@ "executorch>=0.4.0", "transformers>=4.46", ], - "diffusers": ["diffusers<0.32.0"], + "diffusers": ["diffusers"], "intel": "optimum-intel>=1.18.0", "openvino": "optimum-intel[openvino]>=1.18.0", "nncf": "optimum-intel[nncf]>=1.18.0", diff --git a/tests/onnxruntime/test_diffusion.py b/tests/onnxruntime/test_diffusion.py index a2df69077e..5ff2509264 100644 --- a/tests/onnxruntime/test_diffusion.py +++ b/tests/onnxruntime/test_diffusion.py @@ -54,6 +54,7 @@ def _generate_prompts(batch_size=1): "guidance_scale": 7.5, "output_type": "np", } + return inputs @@ -105,8 +106,7 @@ class ORTPipelineForText2ImageTest(ORTModelTestMixin): def generate_inputs(self, height=128, width=128, batch_size=1): inputs = _generate_prompts(batch_size=batch_size) - inputs["height"] = height - inputs["width"] = width + inputs["height"], inputs["width"] = height, width return inputs @@ -224,17 +224,19 @@ def test_shape(self, model_arch: str): elif output_type == "pt": self.assertEqual(outputs.shape, (batch_size, 3, height, width)) else: - expected_height = height // pipeline.vae_scale_factor - expected_width = width // pipeline.vae_scale_factor - if model_arch == "flux": + expected_height = height // (pipeline.vae_scale_factor * 2) + expected_width = width // (pipeline.vae_scale_factor * 2) channels = pipeline.transformer.config.in_channels expected_shape = (batch_size, expected_height * expected_width, channels) - elif model_arch == "stable-diffusion-3": - out_channels = pipeline.transformer.config.out_channels - expected_shape = (batch_size, out_channels, expected_height, expected_width) else: - out_channels = pipeline.unet.config.out_channels + expected_height = height // pipeline.vae_scale_factor + expected_width = width // pipeline.vae_scale_factor + out_channels = ( + pipeline.unet.config.out_channels + if getattr(pipeline, "unet", None) is not None + else pipeline.transformer.config.out_channels + ) expected_shape = (batch_size, out_channels, expected_height, expected_width) self.assertEqual(outputs.shape, expected_shape) @@ -363,6 +365,7 @@ def generate_inputs(self, height=128, width=128, batch_size=1, channel=3, input_ height=height, width=width, batch_size=batch_size, channel=channel, input_type=input_type ) + inputs["height"], inputs["width"] = height, width inputs["strength"] = 0.75 return inputs @@ -602,9 +605,8 @@ def generate_inputs(self, height=128, width=128, batch_size=1, channel=3, input_ height=height, width=width, batch_size=batch_size, channel=1, input_type=input_type ) + inputs["height"], inputs["width"] = height, width inputs["strength"] = 0.75 - inputs["height"] = height - inputs["width"] = width return inputs