MCPcopy Create free account
hub / github.com/THUDM/GLM / get_checkpoint_iteration

Function get_checkpoint_iteration

utils.py:295–324  ·  view source on GitHub ↗
(load_path)

Source from the content-addressed store, hash-verified

293
294
295def get_checkpoint_iteration(load_path):
296 # Read the tracker file and set the iteration.
297 tracker_filename = get_checkpoint_tracker_filename(load_path)
298 if not os.path.isfile(tracker_filename):
299 print_rank_0('WARNING: could not find the metadata file {} '.format(
300 tracker_filename))
301 if os.path.isdir(load_path):
302 path = os.path.normpath(load_path)
303 load_dir, tag = os.path.split(path)
304 print_rank_0('Try to directly load the checkpoint from the directory')
305 return load_dir, tag, False, True
306 print_rank_0(' will not load any checkpoints and will start from '
307 'random')
308 return load_path, 0, False, False
309 with open(tracker_filename, 'r') as f:
310 metastring = f.read().strip()
311 release = metastring == 'release'
312 # try:
313 # iteration = int(metastring)
314 # except ValueError:
315 # release = metastring == 'release'
316 # if not release:
317 # print_rank_0('ERROR: Invalid metadata file {}. Exiting'.format(
318 # tracker_filename))
319 # exit()
320
321 # assert iteration > 0 or release, 'error parsing metadata file {}'.format(
322 # tracker_filename)
323
324 return load_path, metastring, release, True
325
326
327def load_checkpoint(model, optimizer, lr_scheduler, args, no_deepspeed=False, no_load_optim=False, no_load_rng=False):

Callers 2

load_pretrainedFunction · 0.90
load_checkpointFunction · 0.85

Calls 2

print_rank_0Function · 0.85

Tested by

no test coverage detected