Skip to content

chore(linter): add TRF018 modeling rule#46259

Open
tarekziade wants to merge 5 commits into
mainfrom
tarek-rule-18
Open

chore(linter): add TRF018 modeling rule#46259
tarekziade wants to merge 5 commits into
mainfrom
tarek-rule-18

Conversation

@tarekziade
Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds support for mlinter TRF018

@tarekziade tarekziade requested a review from zucchini-nlp May 28, 2026 11:49
@HuggingFaceDocBuilderDev
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.

@tarekziade tarekziade changed the title Add TRF018 modeling rule chore(linter): add TRF018 modeling rule May 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: albert, align, altclip, autoformer, bit, blt, bridgetower, chinese_clip, clap, clip, clipseg, clvp, colmodernvbert, colpali, colqwen2, conditional_detr

@tarekziade
Copy link
Copy Markdown
Collaborator Author

run-slow: albert, align, altclip, autoformer, bit, blt, bridgetower, chinese_clip, clap, clip, clipseg, clvp, colmodernvbert, colpali, colqwen2, conditional_detr

@github-actions
Copy link
Copy Markdown
Contributor

Workflow Run ⚙️

This comment contains run-slow, running the specified jobs:

models: ["models/albert", "models/align", "models/altclip", "models/autoformer", "models/bit", "models/blt", "models/bridgetower", "models/chinese_clip", "models/clap", "models/clip", "models/clipseg", "models/clvp", "models/colmodernvbert", "models/colpali", "models/colqwen2", "models/conditional_detr"]
quantizations: []

@github-actions
Copy link
Copy Markdown
Contributor

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=46259&sha=ddd8a0

@github-actions
Copy link
Copy Markdown
Contributor

CI Results

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN cd245dfb workflow commit (merge commit)
PR ddd8a06a branch commit (from PR)
main bc8f70a9 base commit (on main)

✅ No failing test specific to this PR 🎉 👏 !

Copy link
Copy Markdown
Contributor

@vasqu vasqu left a comment

Choose a reason for hiding this comment

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

Please see my first comment. Imo, we are not actually utilizing what the goal behind this is: removing unnecessary code that does the same as the parent

This cannot really be caught with an ast rule imo but we should use the opportunity to refactor the affected models here

def _init_weights(self, module):
+ super()._init_weights(module)
if isinstance(module, AcmeCustomLayer):
module.gate.data.zero_()
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.

Suggested change
module.gate.data.zero_()
init.zeros(module.gate)

we are using the init module to initialize just as nit

@torch.no_grad()
def _init_weights(self, module):
"""Initialize the weights."""
super()._init_weights(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.

Imo, if we add this, we also should check the code below whether we can remove parts. For example right below, the linear init looks very standard and likely could come from the parent instead

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.

I don't thin this can be done with a static rule so we have to be really picky during review to catch these + here now

Comment thread utils/rules.toml
description = "`trust_remote_code` should never be used in native model integrations."
default_enabled = true
allowlist_models = []
allowlist_models = ["auto"]
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.

same here as in the other PR, why is/was this actually needed 👀

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.

3 participants