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, flags *Config fields named after an upstream paper’s abbreviation instead of the 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 read from the class body and from __init__/__post_init__ assignments and defaults. Ambiguous but idiomatic names (num_heads, num_layers, embed_dim, mlp_ratio) are not flagged, and models added before cutoff_date keep theirs.

Why is this bad?

Everything 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, so a config spelling the same quantity d_model silently opts out of all of them. Map the checkpoint’s own spelling in the conversion script.

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