Skip to content

Commit fb31255

Browse files
Fix decoupled rampup and mesh configs for bare-metal tests
1 parent dcb6a90 commit fb31255

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

tests/data_loader_test.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from MaxText.data_loader import DataLoader, RampUpDataLoader
2828
from MaxText.rampup_batch import RampupBatchManager
2929
from MaxText.maxtext_utils import create_device_mesh
30+
from MaxText.gcloud_stub import is_decoupled
3031
from MaxText import exceptions
3132
from MaxText import pyconfig
3233
from MaxText.globals import MAXTEXT_PKG_DIR
@@ -58,6 +59,14 @@ def get_test_config(self, reuse_example_batch, **kwargs):
5859
"reuse_example_batch": reuse_example_batch,
5960
}
6061
args.update(kwargs)
62+
63+
# In decoupled mode, adapt mesh/ICI parallelism so that the
64+
# product of ICI parallelism matches the available devices for
65+
# this test only.
66+
if is_decoupled():
67+
args.setdefault("mesh_axes", ["data"])
68+
args.setdefault("ici_data_parallelism", -1)
69+
6170
return pyconfig.initialize(
6271
[None, get_test_config_path()],
6372
**args,
@@ -170,9 +179,26 @@ def test_rampup_data_loader_from_checkpointing(self):
170179
data_loader = RampUpDataLoader(self.config_rampup, self.mesh, self.mock_data_iterator, None)
171180

172181
# Expected batch sizes based on test config.
173-
# The end global batch size is self.num_devices * per_device_batch_size
174-
# The rampup should be: 3 steps of size 8, 2 steps of size 12, then size 16.
175-
expected_batch_sizes = [8, 8, 8, 12, 12, 16, 16]
182+
# The end global batch size is self.num_devices * per_device_batch_size.
183+
# In decoupled mode, derive the schedule from a fresh RampupBatchManager
184+
# so it matches the actual global batch sizes on the host.
185+
if is_decoupled():
186+
tmp_manager = RampupBatchManager(self.config_rampup, checkpoint_step)
187+
expected_batch_sizes = []
188+
# Collect sizes for the ramp-up phase.
189+
while True:
190+
expected_batch_sizes.append(tmp_manager.global_batch_size_current)
191+
rampup_active = tmp_manager.update()
192+
if not rampup_active:
193+
break
194+
# Add a couple of post-ramp-up steps at the final size, mirroring
195+
# the original test's intent.
196+
for _ in range(2):
197+
expected_batch_sizes.append(tmp_manager.global_batch_size_current)
198+
tmp_manager.update()
199+
else:
200+
# The rampup should be: 3 steps of size 8, 2 steps of size 12, then size 16.
201+
expected_batch_sizes = [8, 8, 8, 12, 12, 16, 16]
176202
for i, expected_size in enumerate(expected_batch_sizes):
177203
batch = data_loader.load_next_batch(rampup_manager=rampup_manager)
178204
expected_shape = (expected_size, self.config_rampup.max_target_length)

0 commit comments

Comments
 (0)