TRF023

Config fields must use canonical dimension names (hidden_size, intermediate_size, num_attention_heads, …).

   
Default Enabled
Scope Models added on or after 2026-06-20
Source mlinter/trf023.py
Show in terminal mlinter --rule TRF023

What it does

In configuration_*.py and modular_*.py, checks classes whose name ends in Config for fields declared under an upstream paper’s abbreviation instead of the library’s canonical name: d_model/n_embd (hidden_size), d_ff/d_inner/ffn_dim/ffn_hidden_size/expansion_ratio (intermediate_size), d_head (head_dim), n_head/n_heads (num_attention_heads), n_layer/n_layers/num_blocks (num_hidden_layers). Fields are collected from the class body and from __init__/__post_init__ assignments and signature defaults. Ambiguous names that are still idiomatic in parts of the library (num_heads, num_layers, embed_dim, mlp_ratio) are deliberately not flagged. Models contributed before cutoff_date keep their existing names.

Why is this bad?

Every generic that reads a model’s shape — device_map planning, tensor/pipeline parallel plans, quantization, PEFT, attention-backend selection, attribute_map consumers — looks up the canonical names. A config that spells the same quantity d_model silently opts out of all of it, and the mismatch has to be rediscovered by a reviewer on every single new model. Derive the checkpoint’s own spelling in the conversion script instead.

Example

 @strict(accept_kwargs=True)
 class AcmeConfig(PreTrainedConfig):
-    d_model: int = 1024
-    d_ff: int = 4096
-    n_heads: int = 16
-    n_layers: int = 24
+    hidden_size: int = 1024
+    intermediate_size: int = 4096
+    num_attention_heads: int = 16
+    num_hidden_layers: int = 24

Suppressing this rule

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

3 models are exempt from TRF023 in mlinter/rules.toml, because they predate the convention and cannot be changed without breaking backward compatibility.

Show the 3 allowlisted models
  • kosmos2
  • openai
  • qwen3_asr