5252 XLAStrategy ,
5353)
5454from lightning_lite .strategies .ddp_spawn import _DDP_FORK_ALIASES
55- from lightning_lite .utilities import _StrategyType , rank_zero_deprecation , rank_zero_info , rank_zero_warn
55+ from lightning_lite .utilities import _StrategyType , rank_zero_info , rank_zero_warn
5656from lightning_lite .utilities .device_parser import determine_root_gpu_device
5757from lightning_lite .utilities .imports import _HPU_AVAILABLE , _IPU_AVAILABLE , _IS_INTERACTIVE , _TPU_AVAILABLE
5858
59- _PLUGIN = Union [Strategy , Precision , ClusterEnvironment , CheckpointIO ]
59+ _PLUGIN = Union [Precision , ClusterEnvironment , CheckpointIO ]
6060_PLUGIN_INPUT = Union [_PLUGIN , str ]
6161
6262
@@ -99,8 +99,6 @@ def __init__(
9999 num_nodes : int = 1 ,
100100 precision : Union [int , str ] = 32 ,
101101 plugins : Optional [Union [_PLUGIN_INPUT , List [_PLUGIN_INPUT ]]] = None ,
102- tpu_cores : Optional [Union [List [int ], str , int ]] = None , # deprecated
103- gpus : Optional [Union [List [int ], str , int ]] = None , # deprecated
104102 ) -> None :
105103 # 1. Parsing flags
106104 # Get registered strategies, built-in accelerators and precision plugins
@@ -125,9 +123,7 @@ def __init__(
125123 precision = precision ,
126124 plugins = plugins ,
127125 )
128- self ._check_device_config_and_set_final_flags (
129- devices = devices , num_nodes = num_nodes , gpus = gpus , tpu_cores = tpu_cores
130- )
126+ self ._check_device_config_and_set_final_flags (devices = devices , num_nodes = num_nodes )
131127
132128 # 2. Instantiate Accelerator
133129 # handle `auto`, `None` and `gpu`
@@ -278,11 +274,7 @@ def _check_config_and_set_final_flags(
278274 self ._parallel_devices = self ._strategy_flag .parallel_devices
279275
280276 def _check_device_config_and_set_final_flags (
281- self ,
282- devices : Optional [Union [List [int ], str , int ]],
283- num_nodes : int ,
284- gpus : Optional [Union [List [int ], str , int ]],
285- tpu_cores : Optional [Union [List [int ], str , int ]],
277+ self , devices : Optional [Union [List [int ], str , int ]], num_nodes : int
286278 ) -> None :
287279 self ._num_nodes_flag = int (num_nodes ) if num_nodes is not None else 1
288280 self ._devices_flag = devices
@@ -298,56 +290,12 @@ def _check_device_config_and_set_final_flags(
298290 f" using { accelerator_name } accelerator."
299291 )
300292
301- # TODO: Delete this method when num_processes, gpus, ipus and tpu_cores gets removed
302- self ._map_deprecated_devices_specific_info_to_accelerator_and_device_flag (devices , gpus , tpu_cores )
303-
304293 if self ._devices_flag == "auto" and self ._accelerator_flag is None :
305294 raise ValueError (
306295 f"You passed `devices={ devices } ` but haven't specified"
307296 " `accelerator=('auto'|'tpu'|'gpu'|'cpu'|'mps')` for the devices mapping."
308297 )
309298
310- def _map_deprecated_devices_specific_info_to_accelerator_and_device_flag (
311- self ,
312- devices : Optional [Union [List [int ], str , int ]],
313- gpus : Optional [Union [List [int ], str , int ]],
314- tpu_cores : Optional [Union [List [int ], str , int ]],
315- ) -> None :
316- """Emit deprecation warnings for num_processes, gpus, ipus, tpu_cores and set the `devices_flag` and
317- `accelerator_flag`."""
318- if gpus is not None :
319- rank_zero_deprecation (
320- f"Setting `Lite(gpus={ gpus !r} )` is deprecated in v1.7 and will be removed"
321- f" in v2.0. Please use `Lite(accelerator='gpu', devices={ gpus !r} )` instead."
322- )
323- if tpu_cores is not None :
324- rank_zero_deprecation (
325- f"Setting `Lite(tpu_cores={ tpu_cores !r} )` is deprecated in v1.7 and will be removed"
326- f" in v2.0. Please use `Lite(accelerator='tpu', devices={ tpu_cores !r} )` instead."
327- )
328- self ._gpus : Optional [Union [List [int ], str , int ]] = gpus
329- self ._tpu_cores : Optional [Union [List [int ], str , int ]] = tpu_cores
330- deprecated_devices_specific_flag = gpus or tpu_cores
331- if deprecated_devices_specific_flag and deprecated_devices_specific_flag not in ([], 0 , "0" ):
332- if devices :
333- # TODO: improve error message
334- rank_zero_warn (
335- f"The flag `devices={ devices } ` will be ignored, "
336- f"instead the device specific number { deprecated_devices_specific_flag } will be used"
337- )
338-
339- if [(gpus is not None ), (tpu_cores is not None )].count (True ) > 1 :
340- # TODO: improve error message
341- rank_zero_warn ("more than one device specific flag has been set" )
342- self ._devices_flag = deprecated_devices_specific_flag
343-
344- if self ._accelerator_flag is None :
345- # set accelerator type based on num_processes, gpus, ipus, tpu_cores
346- if tpu_cores :
347- self ._accelerator_flag = "tpu"
348- if gpus :
349- self ._accelerator_flag = "cuda"
350-
351299 def _choose_auto_accelerator (self ) -> str :
352300 """Choose the accelerator type (str) based on availability when ``accelerator='auto'``."""
353301 if self ._accelerator_flag == "auto" :
@@ -392,9 +340,6 @@ def _set_parallel_devices_and_init_accelerator(self) -> None:
392340
393341 self ._set_devices_flag_if_auto_passed ()
394342
395- self ._gpus = self ._devices_flag if not self ._gpus else self ._gpus
396- self ._tpu_cores = self ._devices_flag if not self ._tpu_cores else self ._tpu_cores
397-
398343 self ._devices_flag = self .accelerator .parse_devices (self ._devices_flag )
399344 if not self ._parallel_devices :
400345 self ._parallel_devices = self .accelerator .get_parallel_devices (self ._devices_flag )
0 commit comments