Skip to content

[modular] Inherited code must not silently use classes the modular redefines - #50163

Draft
ArthurZucker wants to merge 8 commits into
mainfrom
modular-check-inherited-deps
Draft

ArthurZucker wants to merge 8 commits into
mainfrom
modular-check-inherited-deps

Conversation

@ArthurZucker

@ArthurZucker ArthurZucker commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

🤗 Transformers CI

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

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:1324 TRF007 — TRF007: PPDocLayoutV3ForObjectDetection assigns self.* after self.post_init() in init.

@HuggingFaceDocBuilderDev

HuggingFaceDocBuilderDev commented Oct 30, 2026 •

Copy link
Copy Markdown

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:

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

Copy link
Copy Markdown
Contributor

[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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants