@@ -380,7 +380,7 @@ def test_set_devices_if_none_cpu():
380
380
@RunIf (mps = False )
381
381
def test_unsupported_strategy_types_on_cpu_and_fallback ():
382
382
with pytest .warns (UserWarning , match = "is not supported on CPUs, hence setting `strategy='ddp" ):
383
- connector = _Connector (strategy = "dp" , devices = 2 )
383
+ connector = _Connector (accelerator = "cpu" , strategy = "dp" , devices = 2 )
384
384
assert isinstance (connector .strategy , DDPStrategy )
385
385
386
386
@@ -462,9 +462,9 @@ def test_strategy_choice_ddp_spawn_cpu():
462
462
@RunIf (skip_windows = True )
463
463
@mock .patch ("lightning_fabric.connector._IS_INTERACTIVE" , True )
464
464
def test_strategy_choice_ddp_fork_in_interactive ():
465
- """Test that when accelerator and strategy are unspecified, the connector chooses DDP Fork in interactive
466
- environments by default."""
467
- connector = _Connector (devices = 2 )
465
+ """Test that when strategy is unspecified, the connector chooses DDP Fork in interactive environments by
466
+ default."""
467
+ connector = _Connector (accelerator = "cpu" , devices = 2 )
468
468
assert isinstance (connector .accelerator , CPUAccelerator )
469
469
assert isinstance (connector .strategy , DDPStrategy )
470
470
assert isinstance (connector .strategy .cluster_environment , LightningEnvironment )
@@ -766,7 +766,7 @@ def test_precision_selection_16_on_cpu_warns():
766
766
with pytest .warns (
767
767
UserWarning , match = r"precision=16\)` but native AMP is not supported on CPU. Using `precision='bf16"
768
768
):
769
- _Connector (precision = 16 )
769
+ _Connector (accelerator = "cpu" , precision = 16 )
770
770
771
771
772
772
class MyNativeAMP (MixedPrecision ):
@@ -784,6 +784,7 @@ def test_precision_selection_amp_ddp(strategy, devices, is_custom_plugin, plugin
784
784
if is_custom_plugin :
785
785
plugin = plugin_cls (16 , "cpu" )
786
786
connector = _Connector (
787
+ accelerator = "cpu" ,
787
788
precision = 16 ,
788
789
devices = devices ,
789
790
strategy = strategy ,
@@ -833,7 +834,7 @@ def test_accelerator_strategy_from_environment(accelerator, strategy, expected_a
833
834
env_vars ["LT_STRATEGY" ] = strategy
834
835
835
836
with mock .patch .dict (os .environ , env_vars ):
836
- connector = _Connector ()
837
+ connector = _Connector (accelerator = "cpu" if accelerator is None else "auto" )
837
838
assert isinstance (connector .accelerator , expected_accelerator )
838
839
assert isinstance (connector .strategy , expected_strategy )
839
840
@@ -877,7 +878,7 @@ def test_arguments_from_environment_collision():
877
878
def test_fsdp_unsupported_on_cpu (_ ):
878
879
"""Test that we raise an error if attempting to run FSDP without GPU."""
879
880
with pytest .raises (ValueError , match = "You selected the FSDP strategy but FSDP is only available on GPU" ):
880
- _Connector (strategy = "fsdp" )
881
+ _Connector (accelerator = "cpu" , strategy = "fsdp" )
881
882
882
883
883
884
def test_connector_defaults_match_fabric_defaults ():
0 commit comments