TRF013
PreTrainedModel __init__ must call self.post_init().
| Default | Enabled |
| Scope | All models |
| Source | mlinter/trf013.py |
| Show in terminal | mlinter --rule TRF013 |
What it does
Checks that every PreTrainedModel subclass defining __init__ calls self.post_init(). In modular files super().__init__() counts, since it propagates the parent’s post_init.
Why is this bad?
post_init does essential finalization (weight init, gradient checkpointing setup, …); skipping it causes subtle runtime bugs.
Example
class AcmeModel(AcmePreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.layers = nn.ModuleList(...)
+ self.post_init()
Suppressing this rule
Add a # trf-ignore: TRF013 comment on the flagged line or the line directly above it. See Suppressing rules for whole-file directives and when a suppression is the wrong answer.
