2929from ...testing_utils import assert_tensors_close , torch_device
3030from ..testing_utils import (
3131 BasePipelineTesterConfig ,
32- PipelineOffloadTesterMixin ,
32+ LoraMemoryTesterMixin ,
33+ LoraTesterMixin ,
34+ MemoryTesterMixin ,
3335 PipelineTesterMixin ,
3436)
3537
@@ -73,7 +75,17 @@ def get_dummy_components(self):
7375 z_dim = 16 ,
7476 )
7577 scheduler = FlowMatchEulerDiscreteScheduler ()
76- text_encoder = SmolLM3ForCausalLM (SmolLM3Config (hidden_size = 32 ))
78+ text_encoder = SmolLM3ForCausalLM (
79+ SmolLM3Config (
80+ hidden_size = 32 ,
81+ intermediate_size = 64 ,
82+ num_hidden_layers = 2 ,
83+ num_attention_heads = 2 ,
84+ num_key_value_heads = 1 ,
85+ # `vocab_size` stays at the SmolLM3 default: the pipeline hardcodes the beginning-of-text id
86+ # (128000) for empty prompts, so a smaller vocabulary would not be a valid text encoder here.
87+ )
88+ )
7789 tokenizer = AutoTokenizer .from_pretrained ("hf-internal-testing/tiny-random-t5" )
7890
7991 return {
@@ -111,7 +123,7 @@ def test_inference(self):
111123 assert generated_image .shape == self .output_shape
112124
113125 # fmt: off
114- expected_slice = torch .tensor ([0.5615 , 0.4469 , 0.4043 , 0.4312 , 0.3783 , 0.4426 , 0.4081 , 0.4446 , 0.6549 , 0.6302 , 0.6324 , 0.5871 , 0.6117 , 0.6647 , 0.5871 , 0.6246 ])
126+ expected_slice = torch .tensor ([0.5594 , 0.4469 , 0.4011 , 0.4329 , 0.3747 , 0.4408 , 0.4074 , 0.4452 , 0.6472 , 0.6353 , 0.6258 , 0.5867 , 0.6104 , 0.6624 , 0.5824 , 0.6277 ])
115127 # fmt: on
116128
117129 generated_slice = generated_image .flatten ()
@@ -131,7 +143,7 @@ def test_inference_batch_single_identical(self):
131143 pass
132144
133145 def test_bria_fibo_different_prompts (self ):
134- pipe = self .pipeline_class ( ** self . get_dummy_components () ).to (torch_device )
146+ pipe = self .get_pipeline ( ).to (torch_device )
135147
136148 inputs = self .get_dummy_inputs ()
137149 output_same_prompt = pipe (** inputs ).images [0 ]
@@ -144,7 +156,7 @@ def test_bria_fibo_different_prompts(self):
144156 assert max_diff > 1e-6
145157
146158 def test_image_output_shape (self ):
147- pipe = self .pipeline_class ( ** self . get_dummy_components () ).to (torch_device )
159+ pipe = self .get_pipeline ( ).to (torch_device )
148160 inputs = self .get_dummy_inputs ()
149161
150162 height_width_pairs = [(32 , 32 ), (64 , 64 ), (32 , 64 )]
@@ -155,7 +167,7 @@ def test_image_output_shape(self):
155167 assert (output_height , output_width ) == (height , width )
156168
157169 def test_bria_fibo_multi_reference_uses_distinct_rope_time_planes (self ):
158- pipe = self .pipeline_class ( ** self . get_dummy_components () ).to (torch_device )
170+ pipe = self .get_pipeline ( ).to (torch_device )
159171
160172 references = [
161173 Image .new ("RGB" , (336 , 192 ), (255 , 255 , 255 )),
@@ -180,7 +192,7 @@ def test_bria_fibo_multi_reference_uses_distinct_rope_time_planes(self):
180192 assert image .shape == self .output_shape
181193
182194 def test_batched_prompts_with_multiple_references (self ):
183- pipe = self .pipeline_class ( ** self . get_dummy_components () ).to (torch_device )
195+ pipe = self .get_pipeline ( ).to (torch_device )
184196 inputs = self .get_dummy_inputs ()
185197 inputs .update (
186198 prompt = [inputs ["prompt" ], inputs ["prompt" ].replace ("squirrel" , "robot" )],
@@ -192,15 +204,15 @@ def test_batched_prompts_with_multiple_references(self):
192204 assert (images [0 ] - images [1 ]).abs ().max () > 1e-4
193205
194206 def test_multi_reference_mask_requires_single_reference (self ):
195- pipe = self .pipeline_class ( ** self . get_dummy_components () ).to (torch_device )
207+ pipe = self .get_pipeline ( ).to (torch_device )
196208 inputs = self .get_dummy_inputs ()
197209 inputs ["image" ] = [inputs ["image" ], Image .new ("RGB" , (160 , 96 ), (0 , 0 , 0 ))]
198210 inputs ["mask" ] = Image .new ("L" , (336 , 192 ), 255 )
199211 with pytest .raises (ValueError , match = "exactly one reference" ):
200212 pipe (** inputs )
201213
202214 def test_bria_fibo_edit_mask (self ):
203- pipe = self .pipeline_class ( ** self . get_dummy_components () ).to (torch_device )
215+ pipe = self .get_pipeline ( ).to (torch_device )
204216 inputs = self .get_dummy_inputs ()
205217
206218 mask = Image .fromarray ((np .ones ((192 , 336 )) * 255 ).astype (np .uint8 ), mode = "L" )
@@ -211,7 +223,7 @@ def test_bria_fibo_edit_mask(self):
211223 assert output .shape == (3 , 192 , 336 )
212224
213225 def test_bria_fibo_edit_mask_image_size_mismatch (self ):
214- pipe = self .pipeline_class ( ** self . get_dummy_components () ).to (torch_device )
226+ pipe = self .get_pipeline ( ).to (torch_device )
215227 inputs = self .get_dummy_inputs ()
216228
217229 mask = Image .fromarray ((np .ones ((64 , 64 )) * 255 ).astype (np .uint8 ), mode = "L" )
@@ -221,7 +233,7 @@ def test_bria_fibo_edit_mask_image_size_mismatch(self):
221233 pipe (** inputs )
222234
223235 def test_bria_fibo_edit_mask_no_image (self ):
224- pipe = self .pipeline_class ( ** self . get_dummy_components () ).to (torch_device )
236+ pipe = self .get_pipeline ( ).to (torch_device )
225237 inputs = self .get_dummy_inputs ()
226238
227239 mask = Image .fromarray ((np .ones ((32 , 32 )) * 255 ).astype (np .uint8 ), mode = "L" )
@@ -233,5 +245,22 @@ def test_bria_fibo_edit_mask_no_image(self):
233245 pipe (** inputs )
234246
235247
236- class TestBriaFiboEditPipelineMemory (BriaFiboEditPipelineTesterConfig , PipelineOffloadTesterMixin ):
237- pass
248+ class TestBriaFiboEditPipelineMemory (BriaFiboEditPipelineTesterConfig , MemoryTesterMixin ):
249+ """Memory optimization tests (CPU offload, group offload, layerwise casting) for the Bria FIBO Edit pipeline."""
250+
251+
252+ class TestBriaFiboEditPipelineLoRA (BriaFiboEditPipelineTesterConfig , LoraTesterMixin ):
253+ """LoRA tests for the Bria FIBO Edit pipeline."""
254+
255+ @pytest .mark .skip (
256+ "`_load_lora_into_text_encoder` only infers per-module ranks for CLIP-style names "
257+ "(`.q_proj`/`.k_proj`/`.v_proj`/`.out_proj`/`.fc1`/`.fc2`, see `src/diffusers/loaders/lora_base.py`), so the "
258+ "LLaMA-style `.o_proj` on the SmolLM3 text encoder falls back to the default rank and the non-uniform "
259+ "`rank_pattern` this test builds cannot round-trip."
260+ )
261+ def test_simple_inference_with_partial_text_lora (self ):
262+ pass
263+
264+
265+ class TestBriaFiboEditPipelineLoRAMemory (BriaFiboEditPipelineTesterConfig , LoraMemoryTesterMixin ):
266+ """LoRA x memory-optimization tests (group offload, CPU offload) for the Bria FIBO Edit pipeline."""
0 commit comments