TRF043
Attention classes must not declare position_ids in their forward signature; it flows via **kwargs.
| Default | Enabled |
| Scope | All models |
| Source | mlinter/trf043.py |
| Show in terminal | mlinter --rule TRF043 |
What it does
Checks forward signatures of classes whose name ends in Attention for a declared position_ids parameter.
Why is this bad?
position_ids is consumed downstream by flash-attention padding-free training and must flow through **kwargs. An attention class that names it in the signature swallows it before the attention interface can read it; the llama standard passes position_embeddings plus **kwargs.
Example
class AcmeAttention(nn.Module):
def forward(
self,
hidden_states,
position_embeddings,
attention_mask=None,
- position_ids=None,
**kwargs: Unpack[TransformersKwargs],
):
Suppressing this rule
Add a # trf-ignore: TRF043 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.
Allowlisted models
21 models are exempt from TRF043 in mlinter/rules.toml, because they predate the convention and cannot be changed without breaking backward compatibility.
Show the 21 allowlisted models
axk2chameleonclvpcodegendeepseek_v32deepseek_v4falcongemma4glm_moe_dsagpt_neox_japanesegptjideficsidefics2ministral3mistral4moshipersimmonprophetnetqwen2_vlrecurrent_gemmastablelm
