MCPcopy
hub / github.com/zai-org/CogView / get_checkpoint_iteration

Function get_checkpoint_iteration

utils.py:255–280  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

253
254
255def get_checkpoint_iteration(args):
256 # Read the tracker file and set the iteration.
257 tracker_filename = get_checkpoint_tracker_filename(args.load)
258 if not os.path.isfile(tracker_filename):
259 print_rank_0('WARNING: could not find the metadata file {} '.format(
260 tracker_filename))
261 print_rank_0(' will not load any checkpoints and will start from '
262 'random')
263 return 0, False, False
264 iteration = 0
265 release = False
266 with open(tracker_filename, 'r') as f:
267 metastring = f.read().strip()
268 try:
269 iteration = int(metastring)
270 except ValueError:
271 release = metastring == 'release'
272 if not release:
273 print_rank_0('ERROR: Invalid metadata file {}. Exiting'.format(
274 tracker_filename))
275 exit()
276
277 assert iteration > 0 or release, 'error parsing metadata file {}'.format(
278 tracker_filename)
279
280 return iteration, release, True
281
282
283def extend_position_embedding(weight, length):

Callers 2

setup_modelFunction · 0.90
load_checkpointFunction · 0.85

Calls 2

print_rank_0Function · 0.85

Tested by

no test coverage detected