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 on a class in a modeling_*.py or modular_*.py file names a class that is defined in that file, imported into it, or defined by a sibling module of the same model directory. Complements TRF005, which only validates the shape of the value.

Why is this bad?

device_map resolves _no_split_modules by comparing the strings to module.__class__.__name__ at runtime. A stale or misspelled name matches nothing and is silently ignored, so the module it was meant to keep together can still be split across devices. Entries naming another model’s classes are also redundant and must be dropped rather than corrected: post_init already collects _no_split_modules from child submodels, so a submodel’s layers are registered automatically.

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.