Skip to content

[don't merge] check mlinter - #47774

Open
ydshieh wants to merge 25 commits into
mainfrom
check_mlinter
Open

[don't merge] check mlinter#47774
ydshieh wants to merge 25 commits into
mainfrom
check_mlinter

Conversation

@ydshieh

@ydshieh ydshieh commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

CI

Summary

  • Intentionally introduces a TRF008 violation in modeling_kosmos2_5.py (empty @add_start_docstrings("")) to verify that transformers-mlinter runs correctly via make check-code-quality in CI.

Test plan

  • CI check_code_quality job should fail on the Modeling file structure step with a TRF008 error
🤖 mlinter review state

Empty @add_start_docstrings("") on Kosmos2_5Model to verify mlinter runs in CI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@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.

@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.

aaa

…er is merged

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@huggingface huggingface deleted a comment from github-actions Bot Aug 6, 2026
ydshieh and others added 3 commits August 7, 2026 10:26
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@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 5 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
TRF034 2 Layer classes held in an nn.ModuleList must subclass GradientCheckpointingLayer.
TRF029 1 A module taking config must not also take arguments that live on the config.
TRF020 1 MLA models must isolate the KV LoRA expansion (kv_b_proj) in a dedicated method that forward() calls.
TRF008 1 Doc decorators on PreTrainedModel classes should avoid empty add_start_docstrings usage.
4 item(s) outside this diff
  • src/transformers/models/axk2/modular_axk2.py:202 TRF029 — TRF029: AXK2GatedRMSNorm.__init__ takes config and also eps. Read those off the config inside the module so there is one source of truth.
  • src/transformers/models/axk2/modular_axk2.py:314 TRF020 — TRF020: AXK2Attention declares the KV LoRA expansion self.kv_b_proj but forward does not call a dedicated expansion method. Move the expansion into a method (e.g. expand_kv(k_nope, k_pe) -> key_states, value_states) and call it from forward, so external backends (vLLM/SGLang) can override it and consume the compressed KV cache directly.
  • src/transformers/models/granite_swa/modular_granite_swa.py:246 TRF034 — TRF034: GraniteSWADecoderLayer is stacked in an nn.ModuleList but does not subclass GradientCheckpointingLayer, so gradient checkpointing silently skips it.
  • src/transformers/models/granitemoe_swa/modular_granitemoe_swa.py:180 TRF034 — TRF034: GraniteMoeSWADecoderLayer is stacked in an nn.ModuleList but does not subclass GradientCheckpointingLayer, so gradient checkpointing silently skips it.

@@ -1136,9 +1136,7 @@ def forward(


@add_start_docstrings(

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.

TRF008 — TRF008: Kosmos2_5Model uses add_start_docstrings without non-empty docstring arguments.

Why this matters

Empty decorator usage produces unclear docs and weakens generated API documentation quality.

-@add_start_docstrings("")
+@add_start_docstrings("The Acme model.")
 class AcmeModel(AcmePreTrainedModel):
     ...

Suppress with # trf-ignore: TRF008 if intentional.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@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 5 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
TRF034 2 Layer classes held in an nn.ModuleList must subclass GradientCheckpointingLayer.
TRF029 1 A module taking config must not also take arguments that live on the config.
TRF020 1 MLA models must isolate the KV LoRA expansion (kv_b_proj) in a dedicated method that forward() calls.
TRF008 1 Doc decorators on PreTrainedModel classes should avoid empty add_start_docstrings usage.
4 item(s) outside this diff
  • src/transformers/models/axk2/modular_axk2.py:202 TRF029 — TRF029: AXK2GatedRMSNorm.__init__ takes config and also eps. Read those off the config inside the module so there is one source of truth.
  • src/transformers/models/axk2/modular_axk2.py:314 TRF020 — TRF020: AXK2Attention declares the KV LoRA expansion self.kv_b_proj but forward does not call a dedicated expansion method. Move the expansion into a method (e.g. expand_kv(k_nope, k_pe) -> key_states, value_states) and call it from forward, so external backends (vLLM/SGLang) can override it and consume the compressed KV cache directly.
  • src/transformers/models/granite_swa/modular_granite_swa.py:246 TRF034 — TRF034: GraniteSWADecoderLayer is stacked in an nn.ModuleList but does not subclass GradientCheckpointingLayer, so gradient checkpointing silently skips it.
  • src/transformers/models/granitemoe_swa/modular_granitemoe_swa.py:180 TRF034 — TRF034: GraniteMoeSWADecoderLayer is stacked in an nn.ModuleList but does not subclass GradientCheckpointingLayer, so gradient checkpointing silently skips it.

@@ -1136,9 +1136,7 @@ def forward(


@add_start_docstrings(

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.

TRF008 — TRF008: Kosmos2_5Model uses add_start_docstrings without non-empty docstring arguments.

Why this matters

Empty decorator usage produces unclear docs and weakens generated API documentation quality.

-@add_start_docstrings("")
+@add_start_docstrings("The Acme model.")
 class AcmeModel(AcmePreTrainedModel):
     ...

Suppress with # trf-ignore: TRF008 if intentional.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@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 5 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
TRF034 2 Layer classes held in an nn.ModuleList must subclass GradientCheckpointingLayer.
TRF029 1 A module taking config must not also take arguments that live on the config.
TRF020 1 MLA models must isolate the KV LoRA expansion (kv_b_proj) in a dedicated method that forward() calls.
TRF008 1 Doc decorators on PreTrainedModel classes should avoid empty add_start_docstrings usage.
4 item(s) outside this diff
  • src/transformers/models/axk2/modular_axk2.py:202 TRF029 — TRF029: AXK2GatedRMSNorm.__init__ takes config and also eps. Read those off the config inside the module so there is one source of truth.
  • src/transformers/models/axk2/modular_axk2.py:314 TRF020 — TRF020: AXK2Attention declares the KV LoRA expansion self.kv_b_proj but forward does not call a dedicated expansion method. Move the expansion into a method (e.g. expand_kv(k_nope, k_pe) -> key_states, value_states) and call it from forward, so external backends (vLLM/SGLang) can override it and consume the compressed KV cache directly.
  • src/transformers/models/granite_swa/modular_granite_swa.py:246 TRF034 — TRF034: GraniteSWADecoderLayer is stacked in an nn.ModuleList but does not subclass GradientCheckpointingLayer, so gradient checkpointing silently skips it.
  • src/transformers/models/granitemoe_swa/modular_granitemoe_swa.py:180 TRF034 — TRF034: GraniteMoeSWADecoderLayer is stacked in an nn.ModuleList but does not subclass GradientCheckpointingLayer, so gradient checkpointing silently skips it.

@@ -1136,9 +1136,7 @@ def forward(


@add_start_docstrings(

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.

TRF008 — TRF008: Kosmos2_5Model uses add_start_docstrings without non-empty docstring arguments.

Why this matters

Empty decorator usage produces unclear docs and weakens generated API documentation quality.

-@add_start_docstrings("")
+@add_start_docstrings("The Acme model.")
 class AcmeModel(AcmePreTrainedModel):
     ...

Suppress with # trf-ignore: TRF008 if intentional.

ydshieh and others added 2 commits August 7, 2026 14:28
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@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 5 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
TRF034 2 Layer classes held in an nn.ModuleList must subclass GradientCheckpointingLayer.
TRF029 1 A module taking config must not also take arguments that live on the config.
TRF020 1 MLA models must isolate the KV LoRA expansion (kv_b_proj) in a dedicated method that forward() calls.
TRF008 1 Doc decorators on PreTrainedModel classes should avoid empty add_start_docstrings usage.
4 item(s) outside this diff
  • src/transformers/models/axk2/modular_axk2.py:202 TRF029 — TRF029: AXK2GatedRMSNorm.__init__ takes config and also eps. Read those off the config inside the module so there is one source of truth.
  • src/transformers/models/axk2/modular_axk2.py:314 TRF020 — TRF020: AXK2Attention declares the KV LoRA expansion self.kv_b_proj but forward does not call a dedicated expansion method. Move the expansion into a method (e.g. expand_kv(k_nope, k_pe) -> key_states, value_states) and call it from forward, so external backends (vLLM/SGLang) can override it and consume the compressed KV cache directly.
  • src/transformers/models/granite_swa/modular_granite_swa.py:246 TRF034 — TRF034: GraniteSWADecoderLayer is stacked in an nn.ModuleList but does not subclass GradientCheckpointingLayer, so gradient checkpointing silently skips it.
  • src/transformers/models/granitemoe_swa/modular_granitemoe_swa.py:180 TRF034 — TRF034: GraniteMoeSWADecoderLayer is stacked in an nn.ModuleList but does not subclass GradientCheckpointingLayer, so gradient checkpointing silently skips it.

@@ -1136,9 +1137,7 @@ def forward(


@add_start_docstrings(

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.

TRF008 — TRF008: Kosmos2_5Model uses add_start_docstrings without non-empty docstring arguments.

Why this matters

Empty decorator usage produces unclear docs and weakens generated API documentation quality.

-@add_start_docstrings("")
+@add_start_docstrings("The Acme model.")
 class AcmeModel(AcmePreTrainedModel):
     ...

Suppress with # trf-ignore: TRF008 if intentional.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ydshieh and others added 2 commits August 7, 2026 14:58

@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 6 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
TRF034 2 Layer classes held in an nn.ModuleList must subclass GradientCheckpointingLayer.
TRF004 1 Models must never override tie_weights. Use _tied_weights_keys instead.
TRF029 1 A module taking config must not also take arguments that live on the config.
TRF020 1 MLA models must isolate the KV LoRA expansion (kv_b_proj) in a dedicated method that forward() calls.
TRF008 1 Doc decorators on PreTrainedModel classes should avoid empty add_start_docstrings usage.
4 item(s) outside this diff
  • src/transformers/models/axk2/modular_axk2.py:202 TRF029 — TRF029: AXK2GatedRMSNorm.__init__ takes config and also eps. Read those off the config inside the module so there is one source of truth.
  • src/transformers/models/axk2/modular_axk2.py:314 TRF020 — TRF020: AXK2Attention declares the KV LoRA expansion self.kv_b_proj but forward does not call a dedicated expansion method. Move the expansion into a method (e.g. expand_kv(k_nope, k_pe) -> key_states, value_states) and call it from forward, so external backends (vLLM/SGLang) can override it and consume the compressed KV cache directly.
  • src/transformers/models/granite_swa/modular_granite_swa.py:246 TRF034 — TRF034: GraniteSWADecoderLayer is stacked in an nn.ModuleList but does not subclass GradientCheckpointingLayer, so gradient checkpointing silently skips it.
  • src/transformers/models/granitemoe_swa/modular_granitemoe_swa.py:180 TRF034 — TRF034: GraniteMoeSWADecoderLayer is stacked in an nn.ModuleList but does not subclass GradientCheckpointingLayer, so gradient checkpointing silently skips it.

"attentions": AlbertAttention,
}

def tie_weights(self): # intentional TRF004 violation for testing

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.

TRF004 — TRF004: AlbertPreTrainedModel overrides tie_weights. Use _tied_weights_keys class attribute to declare tied weights instead.

Why this matters

Overriding tie_weights leads to bad consequences for loading, device_map computation, and saving. Use _tied_weights_keys class attribute to declare tied weights instead.

-def tie_weights(self):
-    self.lm_head.weight = self.emb.weight
+class AcmeForCausalLM(AcmePreTrainedModel):
+    _tied_weights_keys = ["lm_head.weight"]

Suppress with # trf-ignore: TRF004 if intentional.

@@ -1136,9 +1137,7 @@ def forward(


@add_start_docstrings(

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.

TRF008 — TRF008: Kosmos2_5Model uses add_start_docstrings without non-empty docstring arguments.

Why this matters

Empty decorator usage produces unclear docs and weakens generated API documentation quality.

-@add_start_docstrings("")
+@add_start_docstrings("The Acme model.")
 class AcmeModel(AcmePreTrainedModel):
     ...

Suppress with # trf-ignore: TRF008 if intentional.

…r now

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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

run-slow: albert, kosmos2_5

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 31180676409:1
Result: failure | Jobs: 2 | Tests: 10 | Failures: 2 | Duration: 49s

Code quality check failed: test jobs were skipped. Fix the code quality issues and push again to run tests.

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