MCPcopy Create free account
hub / github.com/AIS-SNU/Smart-Infinity / check_checkpoint_args

Function check_checkpoint_args

DeepSpeedExample/megatron/checkpointing.py:42–62  ·  view source on GitHub ↗

Ensure fixed arguments for a model are the same for the input arguments and the one retreived frm checkpoint.

(checkpoint_args)

Source from the content-addressed store, hash-verified

40 return _CHECKPOINT_VERSION
41
42def check_checkpoint_args(checkpoint_args):
43 """Ensure fixed arguments for a model are the same for the input
44 arguments and the one retreived frm checkpoint."""
45 args = get_args()
46
47 def _compare(arg_name):
48 checkpoint_value = getattr(checkpoint_args, arg_name)
49 args_value = getattr(args, arg_name)
50 error_message = '{} value from checkpoint ({}) is not equal to the ' \
51 'input argument value ({}).'.format(
52 arg_name, checkpoint_value, args_value)
53 assert checkpoint_value == args_value, error_message
54
55 _compare('num_layers')
56 _compare('hidden_size')
57 _compare('num_attention_heads')
58 _compare('max_position_embeddings')
59 _compare('make_vocab_size_divisible_by')
60 _compare('padded_vocab_size')
61 _compare('tokenizer_type')
62 _compare('model_parallel_size')
63
64
65def ensure_directory_exists(filename):

Callers 1

load_checkpointFunction · 0.85

Calls 2

get_argsFunction · 0.90
_compareFunction · 0.85

Tested by

no test coverage detected