Call self.post_init() in __init__
Browse filestransformers 5.x sets all_tied_weights_keys inside PreTrainedModel.post_init(), and its loading path then reads that attribute directly, so a model whose __init__ skips post_init() fails with AttributeError on load.
Under 4.x the call is a no-op here: the module tree is empty at __init__ time and the real weights are loaded later by load_variant, so nothing is re-initialised.
Verified: outputs are bit-identical with and without the call under transformers 4.57.6 (max|diff| = 0.0), and the model loads under 5.3.0 only with it.
modeling_vjepa2_fmri_encoder.py
CHANGED
|
@@ -163,6 +163,7 @@ class VJEPA2FMRIEncoderModel(PreTrainedModel):
|
|
| 163 |
self.register_buffer("decoding_units", torch.empty(0, dtype=torch.long))
|
| 164 |
self.extractor: HookedFeatureExtractor | None = None
|
| 165 |
self.vjepa: LocalVJEPA2Backbone | None = None
|
|
|
|
| 166 |
|
| 167 |
@classmethod
|
| 168 |
def from_pretrained(
|
|
|
|
| 163 |
self.register_buffer("decoding_units", torch.empty(0, dtype=torch.long))
|
| 164 |
self.extractor: HookedFeatureExtractor | None = None
|
| 165 |
self.vjepa: LocalVJEPA2Backbone | None = None
|
| 166 |
+
self.post_init()
|
| 167 |
|
| 168 |
@classmethod
|
| 169 |
def from_pretrained(
|