TRF048

_tied_weights_keys must be a dict mapping target to source, not the pre-v5 list form.

   
Default Enabled
Scope All models
Source mlinter/trf048.py
Show in terminal mlinter --rule TRF048

What it does

Checks class-level _tied_weights_keys declarations for list/tuple/set literals.

Why is this bad?

v5 changed _tied_weights_keys to a dict mapping the tied target parameter to its source. The list form no longer tells the loading code which parameter is the source, so tying, device_map computation, and saving misbehave silently.

Example

 class AcmeForCausalLM(AcmePreTrainedModel):
-    _tied_weights_keys = ["lm_head.weight"]
+    _tied_weights_keys = {"lm_head.weight": "model.embed_tokens.weight"}

Suppressing this rule

Add a # trf-ignore: TRF048 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.