RuVI-AI
/

ArushCodes commited on
Commit
e98c009
·
verified ·
1 Parent(s): f5bec04

Update modeling_pragya.py

Browse files
Files changed (1) hide show
  1. modeling_pragya.py +6 -2
modeling_pragya.py CHANGED
@@ -68,8 +68,12 @@ class PragyaForCausalLM(PreTrainedModel, GenerationMixin):
68
  for name, buf in _non_persistent_buffers(fresh).items():
69
  own[name].copy_(buf)
70
  del fresh
71
- # wte and lm_head are one tensor (checkpoint stores only lm_head). Re-tie after load.
72
- self.model.transformer.wte.weight = self.model.lm_head.weight
 
 
 
 
73
 
74
  def _init_weights(self, module):
75
  # Weights come from GPT.__init__ (Engram tables, zero-init attention gate, tied
 
68
  for name, buf in _non_persistent_buffers(fresh).items():
69
  own[name].copy_(buf)
70
  del fresh
71
+ # wte and lm_head are one tensor. Checkpoints store one of the two, so tie from the
72
+ # one that was actually loaded, not from whichever happens to be first.
73
+ if "model.lm_head.weight" in missing_keys:
74
+ self.model.lm_head.weight = self.model.transformer.wte.weight
75
+ else:
76
+ self.model.transformer.wte.weight = self.model.lm_head.weight
77
 
78
  def _init_weights(self, module):
79
  # Weights come from GPT.__init__ (Engram tables, zero-init attention gate, tied