cerebras.modelzoo.tools.checkpoint_converters.llama.Converter_LlamaForCausalLM_HF_CS#

class cerebras.modelzoo.tools.checkpoint_converters.llama.Converter_LlamaForCausalLM_HF_CS[source]#

Bases: cerebras.modelzoo.tools.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS

Methods

attempt_mup_to_sp

convert

convert_all_keys

convert_helper

Converts all keys in a checkpoint from converter_indices.direction format to the other format.

convert_key

Attempts to convert the old key by matching against the list of conversion rules.

extract_model_dict

Hook to extract model state dicts out of the input/output checkpoint

file_formats

formats

get_config_converter_class

get_converter_indices

init_output_checkpoint

(Pre)Initializes the output checkpoint at a supplied path.

load

post_checkpoint_convert

Hook executes after checkpoint conversion.

post_model_convert

Hook executes right after model conversion.

pre_checkpoint_convert

Hook executes before checkpoint conversion.

pre_model_convert

Hook executes right before model conversion.

replaceKey

Copies value that exists at old_state_dict's old_key to new_state_dict's new_key.

save

supports_conversion

supports_mup_conversion

__init__()[source]#
convert_helper(input_checkpoint, configs: Tuple[dict, dict], converter_indices: cerebras.modelzoo.tools.checkpoint_converters.base_converter.FormatIndices, output_checkpoint={}, drop_unmatched_keys: bool = False, no_progress_bar: bool = True, debug: bool = False)#

Converts all keys in a checkpoint from converter_indices.direction format to the other format. Conversion will fail if at least one of the keys did not match on any conversion rules and drop_unmatched_keys is not enabled. Returns the newly converted checkpoint.

convert_key(old_key: str, old_state_dict: collections.OrderedDict, new_state_dict: collections.OrderedDict, from_index: int, match_start: int = 0, prefix: str = '', action_fn_args: Optional[dict] = None, debug: bool = False) None#

Attempts to convert the old key by matching against the list of conversion rules. The first rule to match is used for conversion (i.e. even if multiple rules would match, the latter ones are never used). Returns True if a conversion occurred.

extract_model_dict(input_checkpoint, output_checkpoint, configs: Tuple[dict, dict], converter_indices: cerebras.modelzoo.tools.checkpoint_converters.base_converter.FormatIndices)#

Hook to extract model state dicts out of the input/output checkpoint

classmethod init_output_checkpoint(file_without_ext: str, converter_indices: cerebras.modelzoo.tools.checkpoint_converters.base_converter.FormatIndices, hf_shard_size: Union[str, int] = '10GB', export_safetensors: bool = False, **kwargs) str#

(Pre)Initializes the output checkpoint at a supplied path. This is used in streaming conversion when the checkpoint is written to file as conversion is performed rather than accumulating the full checkpoint in memory and saving to file at the very end.

post_checkpoint_convert(input_checkpoint, output_checkpoint, configs: Tuple[dict, dict], converter_indices: cerebras.modelzoo.tools.checkpoint_converters.base_converter.FormatIndices)#

Hook executes after checkpoint conversion.

post_model_convert(old_state_dict: collections.OrderedDict, new_state_dict: collections.OrderedDict, configs: Tuple[dict, dict], converter_indices: cerebras.modelzoo.tools.checkpoint_converters.base_converter.FormatIndices, drop_unmatched_keys: bool, key_prefix: str = '')#

Hook executes right after model conversion.

pre_checkpoint_convert(input_checkpoint, output_checkpoint, configs: Tuple[dict, dict], converter_indices: cerebras.modelzoo.tools.checkpoint_converters.base_converter.FormatIndices)#

Hook executes before checkpoint conversion.

pre_model_convert(old_state_dict: collections.OrderedDict, new_state_dict: collections.OrderedDict, configs: Tuple[dict, dict], converter_indices: cerebras.modelzoo.tools.checkpoint_converters.base_converter.FormatIndices, drop_unmatched_keys: bool)#

Hook executes right before model conversion.

static replaceKey(old_key: str, new_key: str, old_state_dict: collections.OrderedDict, new_state_dict: collections.OrderedDict, from_index: int, action_fn_args: Optional[dict] = None) None#

Copies value that exists at old_state_dict’s old_key to new_state_dict’s new_key.