Skip to content

Commit

Permalink
raise error when incompatible diffusers andtransformers and don't tes…
Browse files Browse the repository at this point in the history
…t difusers with transformers 4.36
  • Loading branch information
IlyasMoutawwakil committed Jan 9, 2025
1 parent 15ee274 commit 2e0cd2e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test_onnxruntime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@ 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,diffusers]
- name: Remove Diffusers if transformers 4.36
if: matrix.transformers-version == '4.36.*'
run: pip uninstall -y diffusers

- name: Install transformers ${{ matrix.transformers-version }}
if: ${{ matrix.transformers-version != 'latest' }}
run: pip install transformers==${{ matrix.transformers-version }}
Expand Down
13 changes: 12 additions & 1 deletion optimum/exporters/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
from transformers import AutoConfig, PretrainedConfig, is_tf_available, is_torch_available
from transformers.utils import SAFE_WEIGHTS_NAME, TF2_WEIGHTS_NAME, WEIGHTS_NAME, logging

from ..utils.import_utils import is_diffusers_available, is_onnx_available
from ..utils.import_utils import (
is_diffusers_available,
is_diffusers_version,
is_onnx_available,
is_transformers_version,
)


if TYPE_CHECKING:
Expand All @@ -51,6 +56,12 @@
from transformers import TFPreTrainedModel

if is_diffusers_available():
if is_diffusers_version(">=", "0.32.0") and is_transformers_version("<", "4.41.2"):
raise ImportError(
"The current version of `diffusers` requires `transformers>=4.41.2`."
" Please upgrade to the latest version of Transformers."
)

from diffusers import DiffusionPipeline
from diffusers.pipelines.auto_pipeline import (
AUTO_IMAGE2IMAGE_PIPELINES_MAPPING,
Expand Down

0 comments on commit 2e0cd2e

Please sign in to comment.