Skip to content

Commit 705a9fd

Browse files
committed
unbloat more.
1 parent 66f922c commit 705a9fd

File tree

7 files changed

+172
-219
lines changed

7 files changed

+172
-219
lines changed

tests/lora/test_lora_layers_cogvideox.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,21 @@ def get_dummy_inputs(self, with_generator=True):
123123
def test_simple_inference_with_text_lora_denoiser_fused_multi(self):
124124
super().test_simple_inference_with_text_lora_denoiser_fused_multi(expected_atol=9e-3)
125125

126-
def test_simple_inference_with_text_denoiser_lora_unfused(self):
127-
super().test_simple_inference_with_text_denoiser_lora_unfused(expected_atol=9e-3)
126+
@parameterized.expand(
127+
[
128+
# Test actions on text_encoder LoRA only
129+
("fused", "text_encoder_only"),
130+
("unloaded", "text_encoder_only"),
131+
("save_load", "text_encoder_only"),
132+
# Test actions on both text_encoder and denoiser LoRA
133+
("fused", "text_and_denoiser"),
134+
("unloaded", "text_and_denoiser"),
135+
("unfused", "text_and_denoiser"),
136+
("save_load", "text_and_denoiser"),
137+
]
138+
)
139+
def test_lora_actions(self, action, components_to_add):
140+
super().test_lora_actions(action, components_to_add, expected_atol=9e-3)
128141

129142
def test_lora_scale_kwargs_match_fusion(self):
130143
super().test_lora_scale_kwargs_match_fusion(expected_atol=9e-3, expected_rtol=9e-3)

tests/lora/test_lora_layers_cogview4.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,21 @@ def get_dummy_inputs(self, with_generator=True):
113113
def test_simple_inference_with_text_lora_denoiser_fused_multi(self):
114114
super().test_simple_inference_with_text_lora_denoiser_fused_multi(expected_atol=9e-3)
115115

116-
def test_simple_inference_with_text_denoiser_lora_unfused(self):
117-
super().test_simple_inference_with_text_denoiser_lora_unfused(expected_atol=9e-3)
116+
@parameterized.expand(
117+
[
118+
# Test actions on text_encoder LoRA only
119+
("fused", "text_encoder_only"),
120+
("unloaded", "text_encoder_only"),
121+
("save_load", "text_encoder_only"),
122+
# Test actions on both text_encoder and denoiser LoRA
123+
("fused", "text_and_denoiser"),
124+
("unloaded", "text_and_denoiser"),
125+
("unfused", "text_and_denoiser"),
126+
("save_load", "text_and_denoiser"),
127+
]
128+
)
129+
def test_lora_actions(self, action, components_to_add):
130+
super().test_lora_actions(action, components_to_add, expected_atol=9e-3)
118131

119132
@parameterized.expand([("block_level", True), ("leaf_level", False)])
120133
@require_torch_accelerator

tests/lora/test_lora_layers_hunyuanvideo.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import numpy as np
2020
import pytest
2121
import torch
22+
from parameterized import parameterized
2223
from transformers import CLIPTextModel, CLIPTokenizer, LlamaModel, LlamaTokenizerFast
2324

2425
from diffusers import (
@@ -153,8 +154,21 @@ def get_dummy_inputs(self, with_generator=True):
153154
def test_simple_inference_with_text_lora_denoiser_fused_multi(self):
154155
super().test_simple_inference_with_text_lora_denoiser_fused_multi(expected_atol=9e-3)
155156

156-
def test_simple_inference_with_text_denoiser_lora_unfused(self):
157-
super().test_simple_inference_with_text_denoiser_lora_unfused(expected_atol=9e-3)
157+
@parameterized.expand(
158+
[
159+
# Test actions on text_encoder LoRA only
160+
("fused", "text_encoder_only"),
161+
("unloaded", "text_encoder_only"),
162+
("save_load", "text_encoder_only"),
163+
# Test actions on both text_encoder and denoiser LoRA
164+
("fused", "text_and_denoiser"),
165+
("unloaded", "text_and_denoiser"),
166+
("unfused", "text_and_denoiser"),
167+
("save_load", "text_and_denoiser"),
168+
]
169+
)
170+
def test_lora_actions(self, action, components_to_add):
171+
super().test_lora_actions(action, components_to_add, expected_atol=9e-3)
158172

159173
@unittest.skip("Not supported in HunyuanVideo.")
160174
def test_simple_inference_with_text_denoiser_block_scale(self):

tests/lora/test_lora_layers_ltx_video.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import unittest
1717

1818
import torch
19+
from parameterized import parameterized
1920
from transformers import AutoTokenizer, T5EncoderModel
2021

2122
from diffusers import (
@@ -111,8 +112,21 @@ def get_dummy_inputs(self, with_generator=True):
111112
def test_simple_inference_with_text_lora_denoiser_fused_multi(self):
112113
super().test_simple_inference_with_text_lora_denoiser_fused_multi(expected_atol=9e-3)
113114

114-
def test_simple_inference_with_text_denoiser_lora_unfused(self):
115-
super().test_simple_inference_with_text_denoiser_lora_unfused(expected_atol=9e-3)
115+
@parameterized.expand(
116+
[
117+
# Test actions on text_encoder LoRA only
118+
("fused", "text_encoder_only"),
119+
("unloaded", "text_encoder_only"),
120+
("save_load", "text_encoder_only"),
121+
# Test actions on both text_encoder and denoiser LoRA
122+
("fused", "text_and_denoiser"),
123+
("unloaded", "text_and_denoiser"),
124+
("unfused", "text_and_denoiser"),
125+
("save_load", "text_and_denoiser"),
126+
]
127+
)
128+
def test_lora_actions(self, action, components_to_add):
129+
super().test_lora_actions(action, components_to_add, expected_atol=9e-3)
116130

117131
@unittest.skip("Not supported in LTXVideo.")
118132
def test_simple_inference_with_text_denoiser_block_scale(self):

tests/lora/test_lora_layers_mochi.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@
1616
import unittest
1717

1818
import torch
19+
from parameterized import parameterized
1920
from transformers import AutoTokenizer, T5EncoderModel
2021

2122
from diffusers import AutoencoderKLMochi, FlowMatchEulerDiscreteScheduler, MochiPipeline, MochiTransformer3DModel
22-
from diffusers.utils.testing_utils import (
23-
floats_tensor,
24-
require_peft_backend,
25-
skip_mps,
26-
)
23+
from diffusers.utils.testing_utils import floats_tensor, require_peft_backend, skip_mps
2724

2825

2926
sys.path.append(".")
@@ -102,8 +99,21 @@ def get_dummy_inputs(self, with_generator=True):
10299
def test_simple_inference_with_text_lora_denoiser_fused_multi(self):
103100
super().test_simple_inference_with_text_lora_denoiser_fused_multi(expected_atol=9e-3)
104101

105-
def test_simple_inference_with_text_denoiser_lora_unfused(self):
106-
super().test_simple_inference_with_text_denoiser_lora_unfused(expected_atol=9e-3)
102+
@parameterized.expand(
103+
[
104+
# Test actions on text_encoder LoRA only
105+
("fused", "text_encoder_only"),
106+
("unloaded", "text_encoder_only"),
107+
("save_load", "text_encoder_only"),
108+
# Test actions on both text_encoder and denoiser LoRA
109+
("fused", "text_and_denoiser"),
110+
("unloaded", "text_and_denoiser"),
111+
("unfused", "text_and_denoiser"),
112+
("save_load", "text_and_denoiser"),
113+
]
114+
)
115+
def test_lora_actions(self, action, components_to_add):
116+
super().test_lora_actions(action, components_to_add, expected_atol=9e-3)
107117

108118
@unittest.skip("Not supported in Mochi.")
109119
def test_simple_inference_with_text_denoiser_block_scale(self):

tests/lora/test_lora_layers_wan.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import unittest
1717

1818
import torch
19+
from parameterized import parameterized
1920
from transformers import AutoTokenizer, T5EncoderModel
2021

2122
from diffusers import (
@@ -107,8 +108,21 @@ def get_dummy_inputs(self, with_generator=True):
107108
def test_simple_inference_with_text_lora_denoiser_fused_multi(self):
108109
super().test_simple_inference_with_text_lora_denoiser_fused_multi(expected_atol=9e-3)
109110

110-
def test_simple_inference_with_text_denoiser_lora_unfused(self):
111-
super().test_simple_inference_with_text_denoiser_lora_unfused(expected_atol=9e-3)
111+
@parameterized.expand(
112+
[
113+
# Test actions on text_encoder LoRA only
114+
("fused", "text_encoder_only"),
115+
("unloaded", "text_encoder_only"),
116+
("save_load", "text_encoder_only"),
117+
# Test actions on both text_encoder and denoiser LoRA
118+
("fused", "text_and_denoiser"),
119+
("unloaded", "text_and_denoiser"),
120+
("unfused", "text_and_denoiser"),
121+
("save_load", "text_and_denoiser"),
122+
]
123+
)
124+
def test_lora_actions(self, action, components_to_add):
125+
super().test_lora_actions(action, components_to_add, expected_atol=9e-3)
112126

113127
@unittest.skip("Not supported in Wan.")
114128
def test_simple_inference_with_text_denoiser_block_scale(self):

0 commit comments

Comments
 (0)