@@ -227,3 +227,52 @@ def test_migrate_loop_structure_after_optimizer_loop_removal():
227
227
"epoch_loop.manual_optimization.optim_step_progress" : optim_progress_manual ,
228
228
}
229
229
}
230
+
231
+
232
+ def test_migrate_loop_structure_after_dataloader_loop_removal ():
233
+ """Test the loop state migration after the dataloader loops were removed in 2.0.0."""
234
+ old_dataloader_loop_state_dict = {
235
+ "state_dict" : {},
236
+ "dataloader_progress" : {"total" : {"ready" : 0 , "completed" : 0 }, "current" : {"ready" : 0 , "completed" : 0 }},
237
+ "epoch_loop.state_dict" : {},
238
+ "epoch_loop.batch_progress" : {
239
+ "total" : {"ready" : 123 , "started" : 0 , "processed" : 0 , "completed" : 0 },
240
+ "current" : {"ready" : 0 , "started" : 0 , "processed" : 0 , "completed" : 0 },
241
+ "is_last_batch" : False ,
242
+ },
243
+ }
244
+ old_checkpoint = {
245
+ "loops" : {
246
+ "predict_loop" : old_dataloader_loop_state_dict ,
247
+ "validate_loop" : dict (old_dataloader_loop_state_dict ), # copy
248
+ "test_loop" : dict (old_dataloader_loop_state_dict ), # copy
249
+ }
250
+ }
251
+ _set_version (old_checkpoint , "1.9.0" ) # pretend a checkpoint prior to 2.0.0
252
+ updated_checkpoint , _ = migrate_checkpoint (old_checkpoint .copy (), target_version = "2.0.0" )
253
+ assert updated_checkpoint ["loops" ] == {
254
+ "predict_loop" : {
255
+ "batch_progress" : {
256
+ "current" : {"completed" : 0 , "processed" : 0 , "ready" : 0 , "started" : 0 },
257
+ "is_last_batch" : False ,
258
+ "total" : {"completed" : 0 , "processed" : 0 , "ready" : 123 , "started" : 0 },
259
+ },
260
+ "state_dict" : {},
261
+ },
262
+ "test_loop" : {
263
+ "batch_progress" : {
264
+ "current" : {"completed" : 0 , "processed" : 0 , "ready" : 0 , "started" : 0 },
265
+ "is_last_batch" : False ,
266
+ "total" : {"completed" : 0 , "processed" : 0 , "ready" : 123 , "started" : 0 },
267
+ },
268
+ "state_dict" : {},
269
+ },
270
+ "validate_loop" : {
271
+ "batch_progress" : {
272
+ "current" : {"completed" : 0 , "processed" : 0 , "ready" : 0 , "started" : 0 },
273
+ "is_last_batch" : False ,
274
+ "total" : {"completed" : 0 , "processed" : 0 , "ready" : 123 , "started" : 0 },
275
+ },
276
+ "state_dict" : {},
277
+ },
278
+ }
0 commit comments