|
27 | 27 | from MaxText.data_loader import DataLoader, RampUpDataLoader |
28 | 28 | from MaxText.rampup_batch import RampupBatchManager |
29 | 29 | from MaxText.maxtext_utils import create_device_mesh |
| 30 | +from MaxText.gcloud_stub import is_decoupled |
30 | 31 | from MaxText import exceptions |
31 | 32 | from MaxText import pyconfig |
32 | 33 | from MaxText.globals import MAXTEXT_PKG_DIR |
@@ -58,6 +59,14 @@ def get_test_config(self, reuse_example_batch, **kwargs): |
58 | 59 | "reuse_example_batch": reuse_example_batch, |
59 | 60 | } |
60 | 61 | 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 | + |
61 | 70 | return pyconfig.initialize( |
62 | 71 | [None, get_test_config_path()], |
63 | 72 | **args, |
@@ -170,9 +179,26 @@ def test_rampup_data_loader_from_checkpointing(self): |
170 | 179 | data_loader = RampUpDataLoader(self.config_rampup, self.mesh, self.mock_data_iterator, None) |
171 | 180 |
|
172 | 181 | # 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] |
176 | 202 | for i, expected_size in enumerate(expected_batch_sizes): |
177 | 203 | batch = data_loader.load_next_batch(rampup_manager=rampup_manager) |
178 | 204 | expected_shape = (expected_size, self.config_rampup.max_target_length) |
|
0 commit comments