Repository navigation
[modular] Inherited code must not silently use classes the modular redefines - #50163
ArthurZucker wants to merge 8 commits into
Conversation
…2 modular files; allowlist 53 to fix
There was a problem hiding this comment.
Model linter — first pass
transformers-mlinter found 2 item(s) in the model files this PR touches. These are structural conventions a maintainer would otherwise flag by hand.
This is automated and advisory — it does not block merging.
| rule | count | what it checks |
|---|---|---|
TRF018 |
1 | _init_weights overrides should call super()._init_weights(module), except modular-file sentinels. |
TRF007 |
1 | self.post_init() should stay last in a PreTrainedModel init. |
1 item(s) outside this diff
src/transformers/models/pp_doclayout_v3/modular_pp_doclayout_v3.py:1324TRF007 — TRF007: PPDocLayoutV3ForObjectDetection assigns self.* after self.post_init() in init.
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. Pages changed in this PR: |
There was a problem hiding this comment.
Model linter — first pass
transformers-mlinter found 1 item(s) in the model files this PR touches. These are structural conventions a maintainer would otherwise flag by hand.
This is automated and advisory — it does not block merging.
| rule | count | what it checks |
|---|---|---|
TRF018 |
1 | _init_weights overrides should call super()._init_weights(module), except modular-file sentinels. |
| _keys_to_ignore_on_load_unexpected = ["semantic_model.masked_spec_embed"] | ||
|
|
||
| @torch.no_grad() | ||
| def _init_weights(self, module): |
There was a problem hiding this comment.
TRF018 — TRF018: _init_weights of HiggsAudioV2TokenizerPreTrainedModel does not call super()._init_weights(...). If this is intentional, suppress with # trf-ignore: TRF018 on the line above the method.
Why this matters
The base _init_weights covers the standard module types (Linear, Embedding, LayerNorm, RotaryEmbedding, ...). Skipping it leaves every submodule the override misses uninitialized -- which passes tests and surfaces much later as a subtle weight-init bug (cf. #45597).
from ... import initialization as init
def _init_weights(self, module):
+ super()._init_weights(module)
if isinstance(module, AcmeCustomLayer):
- module.gate.data.zero_()
+ init.zeros_(module.gate)Suppress with # trf-ignore: TRF018 if intentional.
# Conflicts: # src/transformers/models/deepseek_ocr2/modular_deepseek_ocr2.py
|
[For maintainers] Suggested jobs to run (before merge) run-slow: aimv2, altclip, apertus, aria, audioflamingo3, axk1, axk2, aya_vision, bailing_hybrid, bamba, beam, beit, bitnet, canary, chinese_clip, clipseg |
The converter now errors when an inherited member would use a redefined class (Python inheritance would use the parent's). Modular files are fixed to be explicit; generated files are unchanged, and 53 models are temporarily allowlisted.
🤖 mlinter review state
dc4f76ae07b89b1c