Skip to content

Commit a02c010

Browse files
committed
Revert LSTM HF tied-weights compatibility patch
1 parent e4371b1 commit a02c010

1 file changed

Lines changed: 0 additions & 16 deletions

File tree

mostlyai/engine/_language/lstm.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,6 @@ def __init__(
5151

5252
class LSTMFromScratchLMHeadModel(PreTrainedModel, GenerationMixin):
5353
config_class = LSTMFromScratchConfig
54-
# Opacus DPLSTM exposes duplicate parameter aliases (for example `lstm.l0.ih.weight`
55-
# and `lstm.weight_ih_l0`) that need to be treated as tied when saving.
56-
_tied_weights_keys = [
57-
r"lstm\.l\d+\.(ih|hh)\.(weight|bias)",
58-
r"lstm\.(weight|bias)_(ih|hh)_l\d+",
59-
]
60-
61-
@property
62-
def all_tied_weights_keys(self) -> set[str]:
63-
"""
64-
Compatibility shim for newer Transformers save paths.
65-
"""
66-
tied_keys = set(getattr(self, "_tied_weights_keys", []) or [])
67-
tied_keys.update(getattr(self, "_dynamic_tied_weights_keys", []) or [])
68-
return tied_keys
6954

7055
def __init__(self, config: LSTMFromScratchConfig):
7156
super().__init__(config)
@@ -88,7 +73,6 @@ def __init__(self, config: LSTMFromScratchConfig):
8873
)
8974
self.lm_head = nn.Linear(self.config.hidden_size, self.config.vocab_size)
9075
self.loss_fn = nn.CrossEntropyLoss()
91-
self.post_init()
9276

9377
# this will be filled by left_to_right_padding() during the generation
9478
self.pad_token_id = None

0 commit comments

Comments
 (0)