MCPcopy Create free account
hub / github.com/AI-Hypercomputer/maxtext / test_rampup_data_loader

Method test_rampup_data_loader

tests/data_loader_test.py:129–153  ·  view source on GitHub ↗

Tests that RampUpLoader correctly slices and increment.

(self)

Source from the content-addressed store, hash-verified

127 self.assertTrue(str(e.exception).startswith("You may have run out of training data."))
128
129 def test_rampup_data_loader(self):
130 """Tests that RampUpLoader correctly slices and increment."""
131 # Mock iterator returns a FULL batch (size 4)
132 full_batch_size = int(self.config_rampup.per_device_batch_size * self.config_rampup.num_target_devices)
133 full_shape = [full_batch_size, self.config_rampup.max_target_length]
134 full_batch = {"inputs": np.ones(full_shape, dtype=int)}
135 self.mock_data_iterator.__next__.return_value = full_batch
136
137 # Create the RampUpDataLoader
138 rampup_manager = RampupBatchManager(self.config_rampup, -1)
139 data_loader = RampUpDataLoader(self.config_rampup, self.mesh, self.mock_data_iterator, None)
140
141 # Expected batch sizes based on test config.
142 # The end global batch size is self.num_devices * per_device_batch_size
143 # The rampup should be: 5 steps of size 4, 3 steps of size 8, 2 steps of size 12, then size 16.
144 expected_batch_sizes = [4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16]
145 for i, expected_size in enumerate(expected_batch_sizes):
146 batch = data_loader.load_next_batch(rampup_manager=rampup_manager)
147 expected_shape = (expected_size, self.config_rampup.max_target_length)
148 self.assertEqual(
149 batch["inputs"].shape,
150 expected_shape,
151 f"Mismatch at step {i+1}: expected {expected_shape}, got {batch['inputs'].shape}",
152 )
153 self.assertTrue((batch["inputs"] == 1).all())
154
155 def test_rampup_data_loader_from_checkpointing(self):
156 """Tests that RampUpLoader correctly slices and increment resumed from checkpointing."""

Callers

nothing calls this directly

Calls 3

load_next_batchMethod · 0.95
RampupBatchManagerClass · 0.90
RampUpDataLoaderClass · 0.90

Tested by

no test coverage detected