Skip to content

Commit

Permalink
[LoRA test suite] refactor the test suite and cleanse it (huggingface…
Browse files Browse the repository at this point in the history
…#7316)

* cleanse and refactor lora testing suite.

* more cleanup.

* make check_if_lora_correctly_set a utility function

* fix: typo

* retrigger ci

* style
  • Loading branch information
sayakpaul authored Mar 20, 2024
1 parent de9adb9 commit e25e525
Show file tree
Hide file tree
Showing 35 changed files with 2,399 additions and 2,353 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr_test_peft_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ jobs:
python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile \
-s -v \
--make-reports=tests_${{ matrix.config.report }} \
tests/lora/test_lora_layers_peft.py
tests/lora/
5 changes: 3 additions & 2 deletions examples/community/imagic_stable_diffusion.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""
modeled after the textual_inversion.py / train_dreambooth.py and the work
of justinpinkney here: https://github.com/justinpinkney/stable-diffusion/blob/main/notebooks/imagic.ipynb
modeled after the textual_inversion.py / train_dreambooth.py and the work
of justinpinkney here: https://github.com/justinpinkney/stable-diffusion/blob/main/notebooks/imagic.ipynb
"""

import inspect
import warnings
from typing import List, Optional, Union
Expand Down
3 changes: 2 additions & 1 deletion examples/community/seed_resize_stable_diffusion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
modified based on diffusion library from Huggingface: https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py
modified based on diffusion library from Huggingface: https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py
"""

import inspect
from typing import Callable, List, Optional, Union

Expand Down
1 change: 0 additions & 1 deletion examples/community/unclip_text_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def slerp(val, low, high):


class UnCLIPTextInterpolationPipeline(DiffusionPipeline):

"""
Pipeline for prompt-to-prompt interpolation on CLIP text embeddings and using the UnCLIP / Dall-E to decode them to images.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
6. Integrate to training x
7. Test
"""

import copy
import random

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Conversion script for stable diffusion checkpoints which _only_ contain a controlnet. """
"""Conversion script for stable diffusion checkpoints which _only_ contain a controlnet."""

import argparse
import re
Expand Down
2 changes: 1 addition & 1 deletion scripts/change_naming_configs_and_checkpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Conversion script for the LDM checkpoints. """
"""Conversion script for the LDM checkpoints."""

import argparse
import json
Expand Down
2 changes: 1 addition & 1 deletion scripts/convert_i2vgen_to_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Conversion script for the LDM checkpoints. """
"""Conversion script for the LDM checkpoints."""

import argparse

Expand Down
2 changes: 1 addition & 1 deletion scripts/convert_ldm_original_checkpoint_to_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Conversion script for the LDM checkpoints. """
"""Conversion script for the LDM checkpoints."""

import argparse
import json
Expand Down
2 changes: 1 addition & 1 deletion scripts/convert_lora_safetensor_to_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

""" Conversion script for the LoRA's safetensors checkpoints. """
"""Conversion script for the LoRA's safetensors checkpoints."""

import argparse

Expand Down
2 changes: 1 addition & 1 deletion scripts/convert_ms_text_to_video_to_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Conversion script for the LDM checkpoints. """
"""Conversion script for the LDM checkpoints."""

import argparse

Expand Down
2 changes: 1 addition & 1 deletion scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Conversion script for the NCSNPP checkpoints. """
"""Conversion script for the NCSNPP checkpoints."""

import argparse
import json
Expand Down
2 changes: 1 addition & 1 deletion scripts/convert_original_audioldm2_to_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Conversion script for the AudioLDM2 checkpoints."""
"""Conversion script for the AudioLDM2 checkpoints."""

import argparse
import re
Expand Down
2 changes: 1 addition & 1 deletion scripts/convert_original_audioldm_to_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Conversion script for the AudioLDM checkpoints."""
"""Conversion script for the AudioLDM checkpoints."""

import argparse
import re
Expand Down
2 changes: 1 addition & 1 deletion scripts/convert_original_controlnet_to_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Conversion script for stable diffusion checkpoints which _only_ contain a controlnet. """
"""Conversion script for stable diffusion checkpoints which _only_ contain a controlnet."""

import argparse

Expand Down
2 changes: 1 addition & 1 deletion scripts/convert_original_musicldm_to_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Conversion script for the MusicLDM checkpoints."""
"""Conversion script for the MusicLDM checkpoints."""

import argparse
import re
Expand Down
2 changes: 1 addition & 1 deletion scripts/convert_original_stable_diffusion_to_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Conversion script for the LDM checkpoints. """
"""Conversion script for the LDM checkpoints."""

import argparse
import importlib
Expand Down
2 changes: 1 addition & 1 deletion scripts/convert_versatile_diffusion_to_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Conversion script for the Versatile Stable Diffusion checkpoints. """
"""Conversion script for the Versatile Stable Diffusion checkpoints."""

import argparse
from argparse import Namespace
Expand Down
1 change: 1 addition & 0 deletions scripts/convert_zero123_to_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
--original_config_file /path/zero123/configs/sd-objaverse-finetune-c_concat-256.yaml
```
"""

import argparse

import torch
Expand Down
3 changes: 2 additions & 1 deletion src/diffusers/configuration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" ConfigMixin base class and utilities."""
"""ConfigMixin base class and utilities."""

import dataclasses
import functools
import importlib
Expand Down
2 changes: 1 addition & 1 deletion src/diffusers/loaders/single_file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Conversion script for the Stable Diffusion checkpoints."""
"""Conversion script for the Stable Diffusion checkpoints."""

import os
import re
Expand Down
3 changes: 2 additions & 1 deletion src/diffusers/models/modeling_flax_pytorch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" PyTorch - Flax general utilities."""
"""PyTorch - Flax general utilities."""

import re

import jax.numpy as jnp
Expand Down
2 changes: 1 addition & 1 deletion src/diffusers/models/modeling_pytorch_flax_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" PyTorch - Flax general utilities."""
"""PyTorch - Flax general utilities."""

from pickle import UnpicklingError

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Conversion script for the Stable Diffusion checkpoints."""
"""Conversion script for the Stable Diffusion checkpoints."""

import re
from contextlib import nullcontext
Expand Down
1 change: 1 addition & 0 deletions src/diffusers/utils/doc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""
Doc utilities: Utilities related to documentation
"""

import re


Expand Down
2 changes: 1 addition & 1 deletion src/diffusers/utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""" Logging utilities."""
"""Logging utilities."""

import logging
import os
Expand Down
1 change: 1 addition & 0 deletions src/diffusers/utils/peft_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""
PEFT utilities: Utilities related to peft library
"""

import collections
import importlib
from typing import Optional
Expand Down
1 change: 1 addition & 0 deletions src/diffusers/utils/state_dict_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""
State dict utilities: utility methods for converting state dicts easily
"""

import enum

from .logging import get_logger
Expand Down
1 change: 1 addition & 0 deletions src/diffusers/utils/torch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""
PyTorch utilities: Utilities related to PyTorch
"""

from typing import List, Optional, Tuple, Union

from . import logging
Expand Down
Loading

0 comments on commit e25e525

Please sign in to comment.