TRF022

_no_split_modules entries must name module classes that exist in the model.

   
Default Enabled
Scope All models
Source mlinter/trf022.py
Show in terminal mlinter --rule TRF022

What it does

Checks that every string in a _no_split_modules list in modeling_*.py or modular_*.py names a class defined in that file, imported into it, or defined by a sibling module of the same model directory. Complements TRF005, which only checks the value’s shape.

Why is this bad?

device_map matches these strings against module.__class__.__name__ at runtime, so a stale or misspelled name matches nothing and is silently ignored – the module it should keep together can still be split across devices. Delete entries naming another model’s classes rather than correcting them: post_init already collects _no_split_modules from child submodels.

Example

 class VideoLlavaPreTrainedModel(PreTrainedModel):
-    _no_split_modules = ["VideoLlavaVisionAttention"]

Suppressing this rule

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