From cc19726f3d9fd6d02bf3d2c2475df2a5f9f14a42 Mon Sep 17 00:00:00 2001 From: Sayak Paul Date: Sat, 15 Mar 2025 12:56:41 +0530 Subject: [PATCH] [Tests] add requires peft decorator. (#11037) * add requires peft decorator. * install peft conditionally. * conditional deps. Co-authored-by: DN6 --------- Co-authored-by: DN6 --- .github/workflows/nightly_tests.yml | 7 +++++++ tests/quantization/bnb/test_4bit.py | 2 ++ 2 files changed, 9 insertions(+) diff --git a/.github/workflows/nightly_tests.yml b/.github/workflows/nightly_tests.yml index 70dcf0a5f9..2b39eea2fe 100644 --- a/.github/workflows/nightly_tests.yml +++ b/.github/workflows/nightly_tests.yml @@ -414,12 +414,16 @@ jobs: config: - backend: "bitsandbytes" test_location: "bnb" + additional_deps: ["peft"] - backend: "gguf" test_location: "gguf" + additional_deps: [] - backend: "torchao" test_location: "torchao" + additional_deps: [] - backend: "optimum_quanto" test_location: "quanto" + additional_deps: [] runs-on: group: aws-g6e-xlarge-plus container: @@ -437,6 +441,9 @@ jobs: python -m venv /opt/venv && export PATH="/opt/venv/bin:$PATH" python -m uv pip install -e [quality,test] python -m uv pip install -U ${{ matrix.config.backend }} + if [ "${{ join(matrix.config.additional_deps, ' ') }}" != "" ]; then + python -m uv pip install ${{ join(matrix.config.additional_deps, ' ') }} + fi python -m uv pip install pytest-reportlog - name: Environment run: | diff --git a/tests/quantization/bnb/test_4bit.py b/tests/quantization/bnb/test_4bit.py index 97047717cd..a80286fbb8 100644 --- a/tests/quantization/bnb/test_4bit.py +++ b/tests/quantization/bnb/test_4bit.py @@ -33,6 +33,7 @@ from diffusers.utils.testing_utils import ( numpy_cosine_similarity_distance, require_accelerate, require_bitsandbytes_version_greater, + require_peft_backend, require_torch, require_torch_gpu, require_transformers_version_greater, @@ -668,6 +669,7 @@ class SlowBnb4BitFluxTests(Base4bitTests): max_diff = numpy_cosine_similarity_distance(expected_slice, out_slice) self.assertTrue(max_diff < 1e-3) + @require_peft_backend def test_lora_loading(self): self.pipeline_4bit.load_lora_weights( hf_hub_download("ByteDance/Hyper-SD", "Hyper-FLUX.1-dev-8steps-lora.safetensors"), adapter_name="hyper-sd"