Repository navigation
Conversation
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 |
|---|---|---|
TRF013 |
1 | PreTrainedModel init must call self.post_init(). |
|
@molbap I added some low hanging fruits archs to the branch as well : efficientnet, poolformer, mobilenet v1 and v2, mobilevit v1 and v2 |
e5ab17b to
5b6ee2a
Compare
There was a problem hiding this comment.
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 |
|---|---|---|
TRF040 |
5 | @can_return_tuple must not be combined with @capture_outputs. |
| # Initialize weights and apply final processing | ||
| self.post_init() | ||
|
|
||
| @can_return_tuple |
There was a problem hiding this comment.
TRF040 — TRF040: forward combines @can_return_tuple with @capture_outputs. @capture_outputs already handles returning tuples, drop @can_return_tuple.
Why this matters
Both decorators pop return_dict, so only the outermost one sees the true value. @capture_outputs already handles the to_tuple conversion, making @can_return_tuple redundant.
-@can_return_tuple
@merge_with_config_defaults
@capture_outputs
@auto_docstring
def forward(self, x):
return AcmeModelOutput(last_hidden_state=x)Suppress with # trf-ignore: TRF040 if intentional.
| # Initialize weights and apply final processing | ||
| self.post_init() | ||
|
|
||
| @can_return_tuple |
There was a problem hiding this comment.
TRF040 — TRF040: forward combines @can_return_tuple with @capture_outputs. @capture_outputs already handles returning tuples, drop @can_return_tuple.
Why this matters
Both decorators pop return_dict, so only the outermost one sees the true value. @capture_outputs already handles the to_tuple conversion, making @can_return_tuple redundant.
-@can_return_tuple
@merge_with_config_defaults
@capture_outputs
@auto_docstring
def forward(self, x):
return AcmeModelOutput(last_hidden_state=x)Suppress with # trf-ignore: TRF040 if intentional.
| # Initialize weights and apply final processing | ||
| self.post_init() | ||
|
|
||
| @can_return_tuple |
There was a problem hiding this comment.
TRF040 — TRF040: forward combines @can_return_tuple with @capture_outputs. @capture_outputs already handles returning tuples, drop @can_return_tuple.
Why this matters
Both decorators pop return_dict, so only the outermost one sees the true value. @capture_outputs already handles the to_tuple conversion, making @can_return_tuple redundant.
-@can_return_tuple
@merge_with_config_defaults
@capture_outputs
@auto_docstring
def forward(self, x):
return AcmeModelOutput(last_hidden_state=x)Suppress with # trf-ignore: TRF040 if intentional.
| # Initialize weights and apply final processing | ||
| self.post_init() | ||
|
|
||
| @can_return_tuple |
There was a problem hiding this comment.
TRF040 — TRF040: forward combines @can_return_tuple with @capture_outputs. @capture_outputs already handles returning tuples, drop @can_return_tuple.
Why this matters
Both decorators pop return_dict, so only the outermost one sees the true value. @capture_outputs already handles the to_tuple conversion, making @can_return_tuple redundant.
-@can_return_tuple
@merge_with_config_defaults
@capture_outputs
@auto_docstring
def forward(self, x):
return AcmeModelOutput(last_hidden_state=x)Suppress with # trf-ignore: TRF040 if intentional.
| # Initialize weights and apply final processing | ||
| self.post_init() | ||
|
|
||
| @can_return_tuple |
There was a problem hiding this comment.
TRF040 — TRF040: forward combines @can_return_tuple with @capture_outputs. @capture_outputs already handles returning tuples, drop @can_return_tuple.
Why this matters
Both decorators pop return_dict, so only the outermost one sees the true value. @capture_outputs already handles the to_tuple conversion, making @can_return_tuple redundant.
-@can_return_tuple
@merge_with_config_defaults
@capture_outputs
@auto_docstring
def forward(self, x):
return AcmeModelOutput(last_hidden_state=x)Suppress with # trf-ignore: TRF040 if intentional.
55f3c16 to
db0acbd
Compare
|
Thank you for your contribution 🤗! CI Security Gate — automatic approval blockedThis PR was not automatically approved for CI because the security gate failed. Possible reasons:
See the workflow run for the exact violations. A maintainer can review and manually approve CI if a finding is a false positive. |
db0acbd to
470689f
Compare
|
@molbap bumping the PR with small changes. Tests not passing are not relevant to the PR |
Move ResNetEncoder to PreTrainedModel, record stage hidden states via _can_record_outputs, and drop manual return_dict / hidden-state loops.
Add modular_regnet as source of truth, generate modeling_regnet, and drop Copied-from blocks in favor of modern capture_outputs patterns.
Add modular_rt_detr_resnet, keep base_model_prefix=resnet for checkpoint BC, and modernize backbone forward while preserving RT-DETR stem/shortcut rules.
Add modular_swinv2 with Swin inheritance, cosine attention via attention interface, SDPA support, and regenerate modeling_swinv2.
Emit modern attention/mlp keys from the original conversion script.
Add modular_swin2sr reusing the SwinV2 attention stack, RSTB stages, prefixed upsamplers, and regenerate modeling_swin2sr.
Align the original convert script and add swinv2/swin2sr WeightRenaming entries for Bert-style attention and MLP keys.
Add headdim helper, flash-dispatch skip, greyscale classifier coverage, and loosen fp16 integration tolerance.
Add headdim config helper and skip flash dispatch for dense CRPB masks.
Collapse duplicate SwinBackbone guards in check_hidden_states_output.
- drop unused torch_int import in modular_swinv2 - ruff-format convert_swin2sr qkv split - regenerate regnet/rt_detr encoders with post_init from resnet - restore convnextv2 _init_weights skip comment from modular
align encoder/model/backbone with capture_outputs and can_return_tuple
use can_return_tuple and kwargs while keeping manual encoder hidden states
introduce PoolFormerStage, capture-based encoder hs, and weight key mapping
use can_return_tuple and kwargs while keeping manual hidden states length 26
use can_return_tuple and kwargs while preserving segmentation last-hs path
use can_return_tuple and kwargs while preserving segmentation last-hs path
thin max-inherit modular source and drop copied-from generated modeling
`nn.DataParallel` cannot replicate or gather the forward patterns and output types modern Transformers models use, so this common test measures PyTorch's legacy DP path rather than model correctness. DataParallel is a Trainer feature, not a per-model contract, and it keeps its coverage there (tests/trainer/test_trainer.py). This removes the common test and all 66 overrides; no `src/` behavior changes.
Add headdim helper, flash-dispatch skip, greyscale classifier coverage, and loosen fp16 integration tolerance.
Add headdim config helper and skip flash dispatch for dense CRPB masks.
7f84e1e to
ec60bee
Compare
|
@molbap bumping this here, I merged with main to update the branch, failures seem to come from main |
|
Thanks, will have a look! |
|
[For maintainers] Suggested jobs to run (before merge) run-slow: bit, convnextv2, efficientnet, mobilenet_v1, mobilenet_v2, mobilevit, mobilevitv2, poolformer, regnet, resnet, rt_detr, swin, swin2sr, swinv2 |
What does this PR do?
Modernize several vision arch to last library standards : ConvNextV2, ResNet, RegNet, RTDetrResnet, SwinV2, Swin2SR
Moved to modular and save overall approx. 1600 LoC
I stopped there because it would end up being a big PR but I can continue onto other arch in the same PR if you want (such as DETR archs)
Before submitting
Pull Request checks?
to it if that's the case.
Who can review?
@molbap @guarin
🤖 mlinter review state
f9803bde5b6ee2af