megatron.model.gpt_model.GPTModel#
- class megatron.model.gpt_model.GPTModel(num_tokentypes=0, parallel_output=True, pre_process=True, post_process=True, model_type=None)#
Bases:
MegatronModule
GPT-2 Language model.
- forward(input_ids, position_ids, attention_mask, labels=None, tokentype_ids=None, inference_params=None)#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- load_state_dict(state_dict, strict=True)#
Customized load.
- set_input_tensor(input_tensor)#
See megatron.model.transformer.set_input_tensor()
- state_dict_for_save_checkpoint(prefix='', keep_vars=False)#
Use this function to override the state dict for saving checkpoints.