4949from axlearn .common .config import REQUIRED , Required , config_class , maybe_set_config
5050from axlearn .common .input_dispatch import BaseInputDispatcher , _validate_logical_feed_shapes
5151from axlearn .common .module import Module
52- from axlearn .common .utils import Nested , Tensor , live_devices
52+ from axlearn .common .utils import Nested , Tensor , live_devices , live_slice_indices
53+
5354
5455
5556class ElasticSpmdInputDispatcher (BaseInputDispatcher ):
@@ -79,6 +80,10 @@ def is_in_elastic_mode(self) -> bool:
7980 if cfg .num_max_slices is None :
8081 return False
8182 else :
83+ print (
84+ f"Live_slice_count by lkolluru: { live_slice_indices ()} , slices_cnt: { len (live_slice_indices ())} " ,
85+ live_slice_indices (),len (live_slice_indices ())
86+ )
8287 if slice_count () < cfg .num_max_slices :
8388 return True
8489 elif slice_count () >= cfg .num_max_slices :
@@ -95,6 +100,7 @@ def __init__(self, cfg: Config, *, parent: Optional[Module]):
95100 cfg : ElasticSpmdInputDispatcher .Config = self .config
96101
97102 mesh = thread_resources .env .physical_mesh
103+ print ("physical mesh by lkolluru: " , mesh )
98104 if mesh .empty :
99105 raise ValueError ("Expected to be initialized within the context of a mesh." )
100106
@@ -120,6 +126,7 @@ def __init__(self, cfg: Config, *, parent: Optional[Module]):
120126 )
121127 if self .is_in_elastic_mode :
122128 num_partitions = num_partitions // slice_count () * cfg .num_max_slices
129+ print (f"num_partitions by lkolluru: { num_partitions } and live_devices: { slice_count ()} " )
123130
124131 if cfg .global_logical_batch_size % num_partitions != 0 :
125132 raise ValueError (
@@ -128,6 +135,7 @@ def __init__(self, cfg: Config, *, parent: Optional[Module]):
128135 )
129136
130137 self ._device_physical_batch_size = cfg .global_logical_batch_size // num_partitions
138+ print ("device_physical_batch_size on init by lkolluru: " , self ._device_physical_batch_size )
131139
132140 # Infer the physical feeds and feed index along dim=0.
133141 _ , _ , pid2fid = get_process_index_and_count_and_mapping (
@@ -178,6 +186,7 @@ def fid2pids(feed_id):
178186
179187 if self .is_in_elastic_mode :
180188 print (" In elastic mode lkolluru" )
189+ # I think this should be len(live_slice_indices())....
181190 adjusted_device_physical_batch_size = math .ceil (
182191 self ._device_physical_batch_size * (cfg .num_max_slices / slice_count ())
183192 )
0 commit comments