@@ -1046,7 +1046,7 @@ def test_sdxl_1_0_lora_fusion(self):
10461046 self .assertTrue (np .allclose (images , expected , atol = 1e-4 ))
10471047
10481048 def test_sdxl_1_0_lora_unfusion (self ):
1049- generator = torch .manual_seed (0 )
1049+ generator = torch .Generator (). manual_seed (0 )
10501050
10511051 pipe = DiffusionPipeline .from_pretrained ("stabilityai/stable-diffusion-xl-base-1.0" )
10521052 lora_model_id = "hf-internal-testing/sdxl-1.0-lora"
@@ -1061,19 +1061,19 @@ def test_sdxl_1_0_lora_unfusion(self):
10611061 images_with_fusion = images [0 , - 3 :, - 3 :, - 1 ].flatten ()
10621062
10631063 pipe .unet .unfuse_lora ()
1064- generator = torch .manual_seed (0 )
1064+ generator = torch .Generator (). manual_seed (0 )
10651065 images = pipe (
10661066 "masterpiece, best quality, mountain" , output_type = "np" , generator = generator , num_inference_steps = 2
10671067 ).images
10681068 images_without_fusion = images [0 , - 3 :, - 3 :, - 1 ].flatten ()
10691069
1070- self .assertFalse (np .allclose (images_with_fusion , images_without_fusion ))
1070+ self .assertFalse (np .allclose (images_with_fusion , images_without_fusion , atol = 1e-3 ))
10711071
10721072 def test_sdxl_1_0_lora_unfusion_effectivity (self ):
10731073 pipe = DiffusionPipeline .from_pretrained ("stabilityai/stable-diffusion-xl-base-1.0" )
10741074 pipe .enable_model_cpu_offload ()
10751075
1076- generator = torch .manual_seed (0 )
1076+ generator = torch .Generator (). manual_seed (0 )
10771077 images = pipe (
10781078 "masterpiece, best quality, mountain" , output_type = "np" , generator = generator , num_inference_steps = 2
10791079 ).images
@@ -1084,13 +1084,13 @@ def test_sdxl_1_0_lora_unfusion_effectivity(self):
10841084 pipe .load_lora_weights (lora_model_id , weight_name = lora_filename )
10851085 pipe .unet .fuse_lora ()
10861086
1087- generator = torch .manual_seed (0 )
1087+ generator = torch .Generator (). manual_seed (0 )
10881088 _ = pipe (
10891089 "masterpiece, best quality, mountain" , output_type = "np" , generator = generator , num_inference_steps = 2
10901090 ).images
10911091
10921092 pipe .unet .unfuse_lora ()
1093- generator = torch .manual_seed (0 )
1093+ generator = torch .Generator (). manual_seed (0 )
10941094 images = pipe (
10951095 "masterpiece, best quality, mountain" , output_type = "np" , generator = generator , num_inference_steps = 2
10961096 ).images
@@ -1123,6 +1123,7 @@ def test_sdxl_1_0_lora_fusion_efficiency(self):
11231123 pipe .enable_model_cpu_offload ()
11241124
11251125 start_time = time .time ()
1126+ generator = torch .Generator ().manual_seed (0 )
11261127 for _ in range (3 ):
11271128 pipe (
11281129 "masterpiece, best quality, mountain" , output_type = "np" , generator = generator , num_inference_steps = 2
0 commit comments