summerMC commited on
Commit
24b383e
·
verified ·
1 Parent(s): 1e48517

v19: Fix tied weights and lm_head loading

Browse files
Files changed (2) hide show
  1. model.safetensors +2 -2
  2. modeling_trm_text_ism.py +3 -3
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b73a2f8817a80324e50dcbdb5de0efd76813577c1d48700f60c6b6f3f1f2a3bc
3
- size 182717432
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5235b319424854b28c715719aad9870d4ffc4e97e986f7fe4803e1023a7e71d8
3
+ size 182717408
modeling_trm_text_ism.py CHANGED
@@ -39,7 +39,7 @@ class TRMBlock(nn.Module):
39
  self.res, self.n1, self.n2 = config.residual_scale, nn.RMSNorm(config.dim), nn.RMSNorm(config.dim)
40
  self.attn, self.mlp = TRMAttention(config), SwiGLUMLP(config)
41
  self.ag, self.mg = nn.Parameter(torch.ones(config.dim)), nn.Parameter(torch.ones(config.dim))
42
- def forward(self, x, mask, c, s):
43
  x = x + self.res * torch.sigmoid(self.ag) * self.attn(self.n1(x), mask, c, s)
44
  return x + self.res * torch.sigmoid(self.mg) * self.mlp(self.n2(x))
45
 
@@ -57,8 +57,8 @@ class TRMTextISMForCausalLM(PreTrainedModel):
57
  self.post_init()
58
  def get_input_embeddings(self): return self.token_emb
59
  def get_output_embeddings(self): return self.lm_head
60
- def tie_weights(self): self.lm_head.weight = self.token_emb.weight
61
- def forward(self, input_ids, attention_mask=None, **kwargs):
62
  B, S = input_ids.shape
63
  x, m = self.token_emb(input_ids), torch.tril(torch.ones(S, S, device=input_ids.device)).bool().unsqueeze(0).expand(B, -1, -1)
64
  for _ in range(self.config.recurrence_steps): x = self.block(x, m, self.rope_cos, self.rope_sin)
 
39
  self.res, self.n1, self.n2 = config.residual_scale, nn.RMSNorm(config.dim), nn.RMSNorm(config.dim)
40
  self.attn, self.mlp = TRMAttention(config), SwiGLUMLP(config)
41
  self.ag, self.mg = nn.Parameter(torch.ones(config.dim)), nn.Parameter(torch.ones(config.dim))
42
+ def forward(self, x, mask, c, s):
43
  x = x + self.res * torch.sigmoid(self.ag) * self.attn(self.n1(x), mask, c, s)
44
  return x + self.res * torch.sigmoid(self.mg) * self.mlp(self.n2(x))
45
 
 
57
  self.post_init()
58
  def get_input_embeddings(self): return self.token_emb
59
  def get_output_embeddings(self): return self.lm_head
60
+ def tie_weights(self, *args, **kwargs): self.lm_head.weight = self.token_emb.weight
61
+ def forward(self, input_ids, **kwargs):
62
  B, S = input_ids.shape
63
  x, m = self.token_emb(input_ids), torch.tril(torch.ones(S, S, device=input_ids.device)).bool().unsqueeze(0).expand(B, -1, -1)
64
  for _ in range(self.config.recurrence_steps): x = self.block(x, m, self.rope_cos, self.rope_sin)