diff --git a/.github/workflows/push_tests_fast.yml b/.github/workflows/push_tests_fast.yml index eabbd7a91e49..4c5c566688aa 100644 --- a/.github/workflows/push_tests_fast.yml +++ b/.github/workflows/push_tests_fast.yml @@ -69,7 +69,7 @@ jobs: - name: Install dependencies run: | - uv pip install -e ".[quality]" "pyarrow<26" + uv pip install -e ".[quality]" "pyarrow<26" "numpy>=2" - name: Environment run: | diff --git a/docker/diffusers-doc-builder/Dockerfile b/docker/diffusers-doc-builder/Dockerfile index e927b21c89d4..a173620cea9b 100644 --- a/docker/diffusers-doc-builder/Dockerfile +++ b/docker/diffusers-doc-builder/Dockerfile @@ -32,7 +32,7 @@ RUN uv pip install --no-cache-dir "git+https://github.com/huggingface/diffusers. # Extra dependencies RUN uv pip install --no-cache-dir \ accelerate \ - numpy==1.26.4 \ + "numpy>=2" \ hf_xet \ setuptools==69.5.1 \ bitsandbytes \ diff --git a/docker/diffusers-onnxruntime-cpu/Dockerfile b/docker/diffusers-onnxruntime-cpu/Dockerfile index 25bbb347cf0b..85e4d0602084 100644 --- a/docker/diffusers-onnxruntime-cpu/Dockerfile +++ b/docker/diffusers-onnxruntime-cpu/Dockerfile @@ -40,7 +40,7 @@ RUN python3 -m pip install --no-cache-dir --upgrade pip uv==0.1.11 && \ huggingface-hub \ Jinja2 \ librosa \ - numpy==1.26.4 \ + "numpy>=2" \ scipy \ tensorboard \ transformers \ diff --git a/docker/diffusers-onnxruntime-cuda/Dockerfile b/docker/diffusers-onnxruntime-cuda/Dockerfile index fd425d82c371..8b134c4d9264 100644 --- a/docker/diffusers-onnxruntime-cuda/Dockerfile +++ b/docker/diffusers-onnxruntime-cuda/Dockerfile @@ -41,7 +41,7 @@ RUN python3.10 -m pip install --no-cache-dir --upgrade pip uv==0.1.11 && \ hf_xet \ Jinja2 \ librosa \ - numpy==1.26.4 \ + "numpy>=2" \ scipy \ tensorboard \ transformers diff --git a/docker/diffusers-pytorch-cpu/Dockerfile b/docker/diffusers-pytorch-cpu/Dockerfile index 7703883a567e..b82979436b9a 100644 --- a/docker/diffusers-pytorch-cpu/Dockerfile +++ b/docker/diffusers-pytorch-cpu/Dockerfile @@ -30,7 +30,7 @@ RUN uv pip install --no-cache-dir "git+https://github.com/huggingface/diffusers. # Extra dependencies RUN uv pip install --no-cache-dir \ accelerate \ - numpy==1.26.4 \ + "numpy>=2" \ "pyarrow<26" \ hf_xet diff --git a/docker/diffusers-pytorch-cuda/Dockerfile b/docker/diffusers-pytorch-cuda/Dockerfile index adbbb473fd49..08ecfb70a233 100644 --- a/docker/diffusers-pytorch-cuda/Dockerfile +++ b/docker/diffusers-pytorch-cuda/Dockerfile @@ -51,7 +51,7 @@ RUN uv pip install --no-cache-dir "git+https://github.com/huggingface/diffusers. # Extra dependencies RUN uv pip install --no-cache-dir \ accelerate \ - numpy==1.26.4 \ + "numpy>=2" \ pytorch-lightning \ hf_xet diff --git a/docker/diffusers-pytorch-minimum-cuda/Dockerfile b/docker/diffusers-pytorch-minimum-cuda/Dockerfile index 0cfaae5837da..fbd380332475 100644 --- a/docker/diffusers-pytorch-minimum-cuda/Dockerfile +++ b/docker/diffusers-pytorch-minimum-cuda/Dockerfile @@ -45,7 +45,7 @@ RUN uv pip install --no-cache-dir "git+https://github.com/huggingface/diffusers. # Extra dependencies RUN uv pip install --no-cache-dir \ accelerate \ - numpy==1.26.4 \ + "numpy>=2" \ pytorch-lightning \ hf_xet diff --git a/tests/models/autoencoders/test_models_autoencoder_oobleck.py b/tests/models/autoencoders/test_models_autoencoder_oobleck.py index 3371ecfb0d99..e1e384bc5587 100644 --- a/tests/models/autoencoders/test_models_autoencoder_oobleck.py +++ b/tests/models/autoencoders/test_models_autoencoder_oobleck.py @@ -14,12 +14,10 @@ # limitations under the License. import gc -import unittest import pytest import torch from datasets import load_dataset -from parameterized import parameterized from diffusers import AutoencoderOobleck from diffusers.utils.torch_utils import randn_tensor @@ -27,6 +25,7 @@ from ...testing_utils import ( backend_empty_cache, enable_full_determinism, + require_torchcodec, slow, torch_all_close, torch_device, @@ -132,9 +131,9 @@ def test_enable_disable_slicing(self): @slow -class AutoencoderOobleckIntegrationTests(unittest.TestCase): - def tearDown(self): - super().tearDown() +@require_torchcodec +class TestAutoencoderOobleckIntegration: + def teardown_method(self): gc.collect() backend_empty_cache(torch_device) @@ -166,13 +165,14 @@ def get_generator(self, seed=0): return torch.Generator(device=generator_device).manual_seed(seed) return torch.manual_seed(seed) - @parameterized.expand( + @pytest.mark.parametrize( + "seed, expected_slice, expected_mean_absolute_diff", [ # fmt: off - [33, [1.193e-4, 6.56e-05, 1.314e-4, 3.80e-05, -4.01e-06], 0.001192], - [44, [2.77e-05, -2.65e-05, 1.18e-05, -6.94e-05, -9.57e-05], 0.001196], + (33, [1.193e-4, 6.56e-05, 1.314e-4, 3.80e-05, -4.01e-06], 0.001192), + (44, [2.77e-05, -2.65e-05, 1.18e-05, -6.94e-05, -9.57e-05], 0.001196), # fmt: on - ] + ], ) def test_stable_diffusion(self, seed, expected_slice, expected_mean_absolute_diff): model = self.get_oobleck_vae_model() @@ -198,13 +198,14 @@ def test_stable_diffusion_mode(self): assert sample.shape == audio.shape - @parameterized.expand( + @pytest.mark.parametrize( + "seed, expected_slice, expected_mean_absolute_diff", [ # fmt: off - [33, [1.193e-4, 6.56e-05, 1.314e-4, 3.80e-05, -4.01e-06], 0.001192], - [44, [2.77e-05, -2.65e-05, 1.18e-05, -6.94e-05, -9.57e-05], 0.001196], + (33, [1.193e-4, 6.56e-05, 1.314e-4, 3.80e-05, -4.01e-06], 0.001192), + (44, [2.77e-05, -2.65e-05, 1.18e-05, -6.94e-05, -9.57e-05], 0.001196), # fmt: on - ] + ], ) def test_stable_diffusion_encode_decode(self, seed, expected_slice, expected_mean_absolute_diff): model = self.get_oobleck_vae_model() diff --git a/tests/testing_utils.py b/tests/testing_utils.py index cda114cbde6d..e5448a054d16 100644 --- a/tests/testing_utils.py +++ b/tests/testing_utils.py @@ -2,6 +2,7 @@ import glob import importlib import importlib.metadata +import importlib.util import inspect import io import logging @@ -784,6 +785,15 @@ def require_flashpack(test_case): return pytest.mark.skipif(not is_flashpack_available(), reason="test requires flashpack")(test_case) +def require_torchcodec(test_case): + """ + Decorator marking a test that requires torchcodec. These tests are skipped when torchcodec isn't installed. + """ + return pytest.mark.skipif(importlib.util.find_spec("torchcodec") is None, reason="test requires torchcodec")( + test_case + ) + + def require_peft_version_greater(peft_version): """ Decorator marking a test that requires PEFT backend with a specific version, this would require some specific