common.pytorch.model_utils.checkpoint_converters package#
Submodules#
common.pytorch.model_utils.checkpoint_converters.base_converter module#
- class common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.base_converter.BaseDictionaryConverter
,abc.ABC
Converts between checkpoint state_dict formats.
- convert_helper(checkpoint, configs: Tuple[dict, dict], from_index: int, drop_unmatched_keys: bool = False, no_progress_bar: bool = True, debug: bool = False)[source]#
Converts all keys in a checkpoint from from_index 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.
- abstract static get_config_converter_class() common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter [source]#
- post_checkpoint_convert(checkpoint, from_index: int)[source]#
Hook executes after checkpoint conversion.
- post_model_convert(old_state_dict: collections.OrderedDict, new_state_dict: collections.OrderedDict, configs: Tuple[dict, dict], from_index: int, drop_unmatched_keys: bool)[source]#
Hook executes right after model conversion.
- pre_checkpoint_convert(checkpoint, configs: Tuple[dict, dict], from_index: int)[source]#
Hook executes before checkpoint conversion.
- class common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_PT_PT
HF checkpoints contain model only while CS checkpoints package model, optimizer, and lr_scheduler into a single checkpoint. This class overrides the post_checkpoint_convert to automatically extract/package the state_dict correctly.
- class common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_PT_PT[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter
- class common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.base_converter.BaseDictionaryConverter
,abc.ABC
- classmethod convert(config, from_index: int, drop_unmatched_keys: bool = False, no_progress_bar: bool = True, debug: bool = False)[source]#
- convert_helper(config, from_index: int, drop_unmatched_keys: bool = False, no_progress_bar: bool = True, debug: bool = False)[source]#
Converts all keys in a config from from_index 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 config.
- class common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter_CS_CS[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter
CS packages model, optimizer, and lr_scheduler into a single config. This class overrides the [pre|post]_config_convert fn to automatically extract/package the model configuration correctly.
- class common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter_HF_CS[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter
CS packages model, optimizer, and lr_scheduler into a single config. This class overrides the [pre|post]_config_convert fn to automatically extract/package the model configuration correctly.
- class common.pytorch.model_utils.checkpoint_converters.base_converter.BaseDictionaryConverter[source]#
Bases:
abc.ABC
A dictionary converter represents a pair of two dictionary formats that can be converted between each other. The converter object defines a list of conversion rules which should be applied when converting one dict format to the other (and vice-versa).
In order to make your own dictionary converter, simply: 1. Create a new converter class which inherits from BaseDictionaryConverter 2. Supply a list of conversion rules (self.rules) 3. Override the pre_model_convert or post_model_convert hooks if you
need to execute arbitrary behavior before/after the conversion.
- convert_all_keys(old_state_dict: collections.OrderedDict, new_state_dict: collections.OrderedDict, from_index: int, action_fn_args: Optional[dict] = None, no_progress_bar: bool = True, debug: bool = False, suppress_unmatched_key_warning: bool = False)[source]#
- 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 [source]#
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 occured.
- abstract static formats() Tuple[common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- exception common.pytorch.model_utils.checkpoint_converters.base_converter.ConfigConversionError[source]#
Bases:
Exception
Raised when a config cannot be converted
- class common.pytorch.model_utils.checkpoint_converters.base_converter.ConversionRule[source]#
Bases:
object
- ConversionRule defines a “rule” which:
a key can be matched against
procedure for converting this old key to a new one upon a sucessful match
and an action to be taken once the new key is created (ex: updating the state dictionary)
A rule consists of a sequence of regex pattern (supplied as a string), EquivalentSubkey object, and (possibly) a BaseDictionaryConverter as long as this object is last in the sequence. It also contains an “exists” argument which can be set to “left”, “both”, or “right”. The “left” and “right” arguments are used to describe if a key exists in one checkpoint format but not the other and should be ignored. Without this behavior, keys that exist in one but not the other wouldn’t be matched by any conversion rules, causing a failure as drop_unmatched_keys is disabled by default.
Example: The following describes the conversion rule for mapping HF’s layer normalization key to CS layer normalization in the GPT2 model.
>>> ConversionRule( >>> [ >>> EquivalentSubkey("h", "transformer_decoder.layers"), >>> "\.\d+\.", >>> EquivalentSubkey("ln_1", "norm1"), >>> "\.(weight|bias)", >>> ], >>> action=BaseCheckpointConverter.replaceKey, >>> )
- This should be interpreted as:
HF uses ‘h’ to represent the decoder name while CS uses ‘transformer_decoder.layers’
Both will have keys that follow with a dot, the decoder number, and then another dot
HF uses ‘ln_1’ for the first layer norm while CS names it ‘norm1’
Both will have keys that follow with a dot and then either weight or bias
This representation should make it easy to see how we can 1) build a regex which matches against old keys, and 2) use the matched result & EquivalentSubkey information to create a new key. Finally, once thhe new key is constructed the conversion rule will apply the ‘action’ described by the user in order to complete the conversion (in this case simply copying the value at old_state’s old key into the new_state at the new key).
As previously mentioned, a conversion rule object can also contain a checkpoint converter at the end of the sequence. This is used to create a new checkpoint converter which uses another converter to handle a portion of the conversion. Doing so reduces the amount of copy & pasted conversion rules. For example, many models have base model classes which are extended with additional layers for finetuning. For example, HF’s GP2Model doesn’t contain a language model head while GP2LMHeadModel does. Rather than copying the conversion rules, we could instead define a new checkpoint converter as follows:
>>> class Converter_GPT2LMHeadModel_HF_CS17(BaseDictionaryConverter): >>> def __init__(self): >>> super().__init__() >>> self.rules = [ >>> ConversionRule( >>> ["lm_head\.(weight|bias)"], >>> action=BaseCheckpointConverter.replaceKey, >>> ), >>> ConversionRule( >>> [ >>> EquivalentSubkey("transformer.", ""), >>> Converter_GPT2Model_HF_CS17(), >>> ], >>> action=None, >>> ), >>> ]
The first rule simply notates that the lm_head key now exists (and is named the same in both models). The second rule notates that if the “transformer.” prefix is encountered, we should try all of the GPT2Model HF -> CS 1.7 conversion rules.
- __init__(segments: List[Union[str, common.pytorch.model_utils.checkpoint_converters.base_converter.EquivalentSubkey, common.pytorch.model_utils.checkpoint_converters.base_converter.BaseDictionaryConverter]], exists: str = 'both', action: Optional[Callable[[str, collections.OrderedDict, str, collections.OrderedDict, int], None]] = None) None [source]#
- 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) bool [source]#
- static segment_is_converter(elm: Union[str, common.pytorch.model_utils.checkpoint_converters.base_converter.EquivalentSubkey, common.pytorch.model_utils.checkpoint_converters.base_converter.BaseDictionaryConverter]) bool [source]#
- class common.pytorch.model_utils.checkpoint_converters.base_converter.EquivalentSubkey[source]#
Bases:
object
EquivalentSubkey defines the bidirectional relationship between subkeys of a model’s checkpoint. This class is simply a 2-tuple with index bounds checking.
For example if the normalization layer in one model is named “norm” and “ln” in the other, the relationship can be represented as EquivalentSubkey(“norm”, “ln”).
common.pytorch.model_utils.checkpoint_converters.bert module#
- class common.pytorch.model_utils.checkpoint_converters.bert.ConfigConverter_Bert_CS16_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter_CS_CS
- class common.pytorch.model_utils.checkpoint_converters.bert.ConfigConverter_Bert_CS16_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.bert.ConfigConverter_Bert_CS16_CS17
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bert.ConfigConverter_Bert_CS17_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.bert.ConfigConverter_Bert_CS16_CS18
- class common.pytorch.model_utils.checkpoint_converters.bert.ConfigConverter_Bert_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter_HF_CS
- assert_mlm_nonlinearity(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- convert_position_embedding_type(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bert.ConfigConverter_Bert_HF_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.bert.ConfigConverter_Bert_HF_CS17
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bert.Converter_BertLayerNorm_HF_CS[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- class common.pytorch.model_utils.checkpoint_converters.bert.Converter_BertModel_CS16_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_PT_PT
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bert.Converter_BertModel_CS16_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_PT_PT
- class common.pytorch.model_utils.checkpoint_converters.bert.Converter_BertModel_HF_CS17[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.bert.Converter_BertModel_CS16_CS17
,modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bert.Converter_BertModel_HF_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- class common.pytorch.model_utils.checkpoint_converters.bert.Converter_BertPretrainModel_CS16_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_PT_PT
- convert_cls_predictions_bias(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bert.Converter_BertPretrainModel_CS16_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_PT_PT
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bert.Converter_BertPretrainModel_HF_CS17[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.bert.Converter_BertPretrainModel_CS16_CS17
,modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bert.Converter_BertPretrainModel_HF_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.bert.Converter_BertPretrainModel_HF_CS17
- class common.pytorch.model_utils.checkpoint_converters.bert.Converter_Bert_CS17_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_PT_PT
common.pytorch.model_utils.checkpoint_converters.bert_finetune module#
- class common.pytorch.model_utils.checkpoint_converters.bert_finetune.ConfigConverter_BertForQuestionAnswering_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.bert.ConfigConverter_Bert_HF_CS17
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bert_finetune.ConfigConverter_BertForQuestionAnswering_HF_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.bert_finetune.ConfigConverter_BertForQuestionAnswering_HF_CS17
,modelzoo.common.pytorch.model_utils.checkpoint_converters.bert.ConfigConverter_Bert_HF_CS18
- class common.pytorch.model_utils.checkpoint_converters.bert_finetune.ConfigConverter_BertForSequenceClassification_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.bert.ConfigConverter_Bert_HF_CS17
- class common.pytorch.model_utils.checkpoint_converters.bert_finetune.ConfigConverter_BertForSequenceClassification_HF_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.bert_finetune.ConfigConverter_BertForSequenceClassification_HF_CS17
,modelzoo.common.pytorch.model_utils.checkpoint_converters.bert.ConfigConverter_Bert_HF_CS18
- class common.pytorch.model_utils.checkpoint_converters.bert_finetune.ConfigConverter_BertForTokenClassification_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.bert.ConfigConverter_Bert_HF_CS17
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bert_finetune.ConfigConverter_BertForTokenClassification_HF_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.bert_finetune.ConfigConverter_BertForTokenClassification_HF_CS17
,modelzoo.common.pytorch.model_utils.checkpoint_converters.bert.ConfigConverter_Bert_HF_CS18
- class common.pytorch.model_utils.checkpoint_converters.bert_finetune.Converter_BertFinetuneModel_CS16_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_PT_PT
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bert_finetune.Converter_BertFinetuneModel_CS16_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_PT_PT
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bert_finetune.Converter_BertForQuestionAnswering_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- class common.pytorch.model_utils.checkpoint_converters.bert_finetune.Converter_BertForQuestionAnswering_HF_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- class common.pytorch.model_utils.checkpoint_converters.bert_finetune.Converter_BertForSequenceClassification_HF_CS17[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.bert_finetune.Converter_BertFinetuneModel_CS16_CS17
,modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bert_finetune.Converter_BertForSequenceClassification_HF_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- class common.pytorch.model_utils.checkpoint_converters.bert_finetune.Converter_BertForTokenClassification_HF_CS17[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.bert_finetune.Converter_BertFinetuneModel_CS16_CS17
,modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bert_finetune.Converter_BertForTokenClassification_HF_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
common.pytorch.model_utils.checkpoint_converters.bloom_hf_cs module#
- class common.pytorch.model_utils.checkpoint_converters.bloom_hf_cs.ConfigConverter_BloomModel_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter_HF_CS
- assert_attention_inner_dim(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- assert_filter_size(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bloom_hf_cs.ConfigConverter_BloomModel_HF_CS19[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.bloom_hf_cs.ConfigConverter_BloomModel_HF_CS17
- class common.pytorch.model_utils.checkpoint_converters.bloom_hf_cs.Converter_BloomLMHeadModel_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- static get_config_converter_class() modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter [source]#
- class common.pytorch.model_utils.checkpoint_converters.bloom_hf_cs.Converter_BloomLMHeadModel_HF_CS19[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.bloom_hf_cs.Converter_BloomModel_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- static get_config_converter_class() modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter [source]#
- post_model_convert(old_state_dict, new_state_dict, configs, from_index, drop_unmatched_keys)[source]#
- class common.pytorch.model_utils.checkpoint_converters.bloom_hf_cs.Converter_BloomModel_HF_CS19[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.bloom_hf_cs.Converter_BloomModel_HF_CS17
- class common.pytorch.model_utils.checkpoint_converters.bloom_hf_cs.Converter_Bloom_Attention_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- assert_already_converted(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- static get_config_converter_class() modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter [source]#
common.pytorch.model_utils.checkpoint_converters.gpt2_hf_cs module#
- class common.pytorch.model_utils.checkpoint_converters.gpt2_hf_cs.ConfigConverter_GPT2Model_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter_HF_CS
- convert_attention_type(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- class common.pytorch.model_utils.checkpoint_converters.gpt2_hf_cs.ConfigConverter_GPT2Model_HF_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.gpt2_hf_cs.ConfigConverter_GPT2Model_HF_CS17
- class common.pytorch.model_utils.checkpoint_converters.gpt2_hf_cs.Converter_GPT2LMHeadModel_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.gpt2_hf_cs.Converter_GPT2LMHeadModel_HF_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- class common.pytorch.model_utils.checkpoint_converters.gpt2_hf_cs.Converter_GPT2Model_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- static get_config_converter_class() modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter [source]#
- post_model_convert(old_state_dict, new_state_dict, configs, from_index, drop_unmatched_keys)[source]#
- class common.pytorch.model_utils.checkpoint_converters.gpt2_hf_cs.Converter_GPT2Model_HF_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.gpt2_hf_cs.Converter_GPT2Model_HF_CS17
- class common.pytorch.model_utils.checkpoint_converters.gpt2_hf_cs.Converter_GPT2_Attention_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- assert_already_converted(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- c_attn_converter(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- c_attn_converter_cs17_to_hf(old_key, new_key, old_state_dict, new_state_dict, action_fn_args)[source]#
- c_attn_converter_hf_to_cs17(old_key, new_key, old_state_dict, new_state_dict, action_fn_args)[source]#
common.pytorch.model_utils.checkpoint_converters.gpt_neox_hf_cs module#
- class common.pytorch.model_utils.checkpoint_converters.gpt_neox_hf_cs.ConfigConverter_GPT_Neox_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.gpt_neox_hf_cs.ConfigConverter_GPT_Neox_HF_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.gpt_neox_hf_cs.ConfigConverter_GPT_Neox_HF_CS17
- class common.pytorch.model_utils.checkpoint_converters.gpt_neox_hf_cs.Converter_GPT_Neox_Attention_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- assert_already_converted(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- static get_config_converter_class() modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter [source]#
- class common.pytorch.model_utils.checkpoint_converters.gpt_neox_hf_cs.Converter_GPT_Neox_Headless_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- static get_config_converter_class() modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter [source]#
- post_model_convert(old_state_dict, new_state_dict, configs, from_index, drop_unmatched_keys)[source]#
- class common.pytorch.model_utils.checkpoint_converters.gpt_neox_hf_cs.Converter_GPT_Neox_Headless_HF_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.gpt_neox_hf_cs.Converter_GPT_Neox_Headless_HF_CS17
- class common.pytorch.model_utils.checkpoint_converters.gpt_neox_hf_cs.Converter_GPT_Neox_LMHeadModel_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.gpt_neox_hf_cs.Converter_GPT_Neox_LMHeadModel_HF_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
common.pytorch.model_utils.checkpoint_converters.gptj_hf_cs module#
- class common.pytorch.model_utils.checkpoint_converters.gptj_hf_cs.ConfigConverter_GPTJModel_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter_HF_CS
- convert_attention_type(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- convert_position_embedding_type(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.gptj_hf_cs.ConfigConverter_GPTJModel_HF_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.gptj_hf_cs.ConfigConverter_GPTJModel_HF_CS17
- class common.pytorch.model_utils.checkpoint_converters.gptj_hf_cs.Converter_GPTJ_Attention_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.gptj_hf_cs.Converter_GPTJ_Headless_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- static get_config_converter_class() modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter [source]#
- post_model_convert(old_state_dict, new_state_dict, configs, from_index, drop_unmatched_keys)[source]#
- class common.pytorch.model_utils.checkpoint_converters.gptj_hf_cs.Converter_GPTJ_Headless_HF_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.gptj_hf_cs.Converter_GPTJ_Headless_HF_CS17
- class common.pytorch.model_utils.checkpoint_converters.gptj_hf_cs.Converter_GPTJ_LMHeadModel_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.gptj_hf_cs.Converter_GPTJ_LMHeadModel_HF_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
common.pytorch.model_utils.checkpoint_converters.llama module#
- class common.pytorch.model_utils.checkpoint_converters.llama.ConfigConverter_LLaMa_HF_CS19[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter_HF_CS
- assert_rotary_dim(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- convert_nonlinearity(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.llama.Converter_LlamaAttention_HF_CS[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- convert_output_and_inv_freq(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- convert_with_interleaving(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.llama.Converter_LlamaForCausalLM_HF_CS[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- class common.pytorch.model_utils.checkpoint_converters.llama.Converter_LlamaForCausalLM_HF_CS19[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- class common.pytorch.model_utils.checkpoint_converters.llama.Converter_LlamaModel_HF_CS[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- static get_config_converter_class() modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter [source]#
- class common.pytorch.model_utils.checkpoint_converters.llama.Converter_LlamaModel_HF_CS19[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.llama.Converter_LlamaModel_HF_CS
common.pytorch.model_utils.checkpoint_converters.opt_hf_cs module#
- class common.pytorch.model_utils.checkpoint_converters.opt_hf_cs.ConfigConverter_OPTModel_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter_HF_CS
- assert_word_embed_proj_dim(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- convert_attention_type(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.opt_hf_cs.ConfigConverter_OPTModel_HF_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.opt_hf_cs.ConfigConverter_OPTModel_HF_CS17
- class common.pytorch.model_utils.checkpoint_converters.opt_hf_cs.Converter_OPT_Attention_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- class common.pytorch.model_utils.checkpoint_converters.opt_hf_cs.Converter_OPT_Headless_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- static get_config_converter_class() modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter [source]#
- post_model_convert(old_state_dict, new_state_dict, configs, from_index, drop_unmatched_keys)[source]#
- class common.pytorch.model_utils.checkpoint_converters.opt_hf_cs.Converter_OPT_Headless_HF_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.opt_hf_cs.Converter_OPT_Headless_HF_CS17
- class common.pytorch.model_utils.checkpoint_converters.opt_hf_cs.Converter_OPT_LMHeadModel_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.opt_hf_cs.Converter_OPT_LMHeadModel_HF_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
common.pytorch.model_utils.checkpoint_converters.salesforce_codegen_hf_cs module#
- class common.pytorch.model_utils.checkpoint_converters.salesforce_codegen_hf_cs.ConfigConverter_Codegen_Model_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.salesforce_codegen_hf_cs.ConfigConverter_Codegen_Model_HF_CS18[source]#
- class common.pytorch.model_utils.checkpoint_converters.salesforce_codegen_hf_cs.Converter_Codegen_Attention_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- assert_already_converted(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- static get_config_converter_class() modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter [source]#
- class common.pytorch.model_utils.checkpoint_converters.salesforce_codegen_hf_cs.Converter_Codegen_Headless_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- static get_config_converter_class() modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter [source]#
- post_model_convert(old_state_dict, new_state_dict, configs, from_index, drop_unmatched_keys)[source]#
- class common.pytorch.model_utils.checkpoint_converters.salesforce_codegen_hf_cs.Converter_Codegen_Headless_HF_CS18[source]#
- class common.pytorch.model_utils.checkpoint_converters.salesforce_codegen_hf_cs.Converter_Codegen_LMHeadModel_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.salesforce_codegen_hf_cs.Converter_Codegen_LMHeadModel_HF_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
common.pytorch.model_utils.checkpoint_converters.t5 module#
- class common.pytorch.model_utils.checkpoint_converters.t5.ConfigConverter_T5_CS16_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter_CS_CS
- class common.pytorch.model_utils.checkpoint_converters.t5.ConfigConverter_T5_CS16_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.t5.ConfigConverter_T5_CS16_CS17
- class common.pytorch.model_utils.checkpoint_converters.t5.ConfigConverter_T5_CS17_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter_CS_CS
- class common.pytorch.model_utils.checkpoint_converters.t5.ConfigConverter_T5_HF_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseConfigConverter_HF_CS
- assert_decoder_nonlinearity(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- convert_nonlinearity(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.t5.ConfigConverter_T5_HF_CS18[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.t5.ConfigConverter_T5_HF_CS17
- class common.pytorch.model_utils.checkpoint_converters.t5.Converter_T5_CS16_CS17[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_PT_PT
- convert_dense_layer(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- convert_relative_attention_bias_cs16_to_cs17(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- convert_relative_attention_bias_cs17_to_cs16(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.t5.Converter_T5_CS16_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_PT_PT
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.t5.Converter_T5_CS17_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_PT_PT
- class common.pytorch.model_utils.checkpoint_converters.t5.Converter_T5_HF_CS17[source]#
Bases:
common.pytorch.model_utils.checkpoint_converters.t5.Converter_T5_CS16_CS17
,modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS
- convert_embeddings(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- convert_relative_attention_bias_cs17_to_hf(old_key, new_key, old_state_dict, new_state_dict, from_index, action_fn_args)[source]#
- static formats() Tuple[modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions, modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.FormatVersions] [source]#
- class common.pytorch.model_utils.checkpoint_converters.t5.Converter_T5_HF_CS18[source]#
Bases:
modelzoo.common.pytorch.model_utils.checkpoint_converters.base_converter.BaseCheckpointConverter_HF_CS