@@ -771,8 +771,8 @@ def test_from_pipe_consistent_forward_pass(self, expected_max_diff=1e-3):
771771 ), "`from_pipe` changed the attention processor in original pipeline."
772772
773773 @unittest .skipIf (
774- not is_accelerate_available () or is_accelerate_version ("<" , "0.14.0" ),
775- reason = "CPU offload is only available with `accelerate v0.14.0` or higher" ,
774+ torch_device = "cpu" or not is_accelerate_available () or is_accelerate_version ("<" , "0.14.0" ),
775+ reason = "CPU offload is only available with hardware accelerator and `accelerate v0.14.0` or higher" ,
776776 )
777777 def test_from_pipe_consistent_forward_pass_cpu_offload (self , expected_max_diff = 1e-3 ):
778778 components = self .get_dummy_components ()
@@ -1317,6 +1317,7 @@ def test_save_load_optional_components(self, expected_max_difference=1e-4):
13171317 max_diff = np .abs (to_np (output ) - to_np (output_loaded )).max ()
13181318 self .assertLess (max_diff , expected_max_difference )
13191319
1320+ @unittest .skipIf (torch_device = "cpu" , reason = "Hardware accelerator and CPU are required to switch devices" )
13201321 def test_to_device (self ):
13211322 components = self .get_dummy_components ()
13221323 pipe = self .pipeline_class (** components )
@@ -1391,8 +1392,8 @@ def _test_attention_slicing_forward_pass(
13911392 assert_mean_pixel_difference (to_np (output_with_slicing2 [0 ]), to_np (output_without_slicing [0 ]))
13921393
13931394 @unittest .skipIf (
1394- not is_accelerate_available () or is_accelerate_version ("<" , "0.14.0" ),
1395- reason = "CPU offload is only available with `accelerate v0.14.0` or higher" ,
1395+ torch_device = "cpu" or not is_accelerate_available () or is_accelerate_version ("<" , "0.14.0" ),
1396+ reason = "CPU offload is only available with hardware accelerator and `accelerate v0.14.0` or higher" ,
13961397 )
13971398 def test_sequential_cpu_offload_forward_pass (self , expected_max_diff = 1e-4 ):
13981399 import accelerate
@@ -1454,8 +1455,8 @@ def test_sequential_cpu_offload_forward_pass(self, expected_max_diff=1e-4):
14541455 )
14551456
14561457 @unittest .skipIf (
1457- not is_accelerate_available () or is_accelerate_version ("<" , "0.17.0" ),
1458- reason = "CPU offload is only available with `accelerate v0.17.0` or higher" ,
1458+ torch_device = "cpu" or not is_accelerate_available () or is_accelerate_version ("<" , "0.17.0" ),
1459+ reason = "CPU offload is only available with hardware accelerator and `accelerate v0.17.0` or higher" ,
14591460 )
14601461 def test_model_cpu_offload_forward_pass (self , expected_max_diff = 2e-4 ):
14611462 import accelerate
@@ -1511,8 +1512,8 @@ def test_model_cpu_offload_forward_pass(self, expected_max_diff=2e-4):
15111512 )
15121513
15131514 @unittest .skipIf (
1514- not is_accelerate_available () or is_accelerate_version ("<" , "0.17.0" ),
1515- reason = "CPU offload is only available with `accelerate v0.17.0` or higher" ,
1515+ torch_device = "cpu" or not is_accelerate_available () or is_accelerate_version ("<" , "0.17.0" ),
1516+ reason = "CPU offload is only available with hardware accelerator and `accelerate v0.17.0` or higher" ,
15161517 )
15171518 def test_cpu_offload_forward_pass_twice (self , expected_max_diff = 2e-4 ):
15181519 import accelerate
@@ -1568,8 +1569,8 @@ def test_cpu_offload_forward_pass_twice(self, expected_max_diff=2e-4):
15681569 )
15691570
15701571 @unittest .skipIf (
1571- not is_accelerate_available () or is_accelerate_version ("<" , "0.14.0" ),
1572- reason = "CPU offload is only available with `accelerate v0.14.0` or higher" ,
1572+ torch_device = "cpu" or not is_accelerate_available () or is_accelerate_version ("<" , "0.14.0" ),
1573+ reason = "CPU offload is only available with hardware accelerator and `accelerate v0.14.0` or higher" ,
15731574 )
15741575 def test_sequential_offload_forward_pass_twice (self , expected_max_diff = 2e-4 ):
15751576 import accelerate
0 commit comments