Skip to content

fix(utils): Resolve backbone utils test regressions - #45594

Merged
zucchini-nlp merged 2 commits into
huggingface:mainfrom
harshaljanjani:fix/fix-backbone-test-regressions
May 1, 2026
Merged

zucchini-nlp merged 2 commits into
huggingface:mainfrom
harshaljanjani:fix/fix-backbone-test-regressions

Conversation

@harshaljanjani

@harshaljanjani harshaljanjani commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

The following regressions were identified and fixed in this PR:

→ 0c4fe5c ("Delete duplicate code in backbone utils") removed use_pretrained_backbone from load_backbone; pretrained weights are now loaded via from_pretrained on the parent. The tests in test_backbone_utils.py#L217 weren't updated likely because tests/utils/ wasn't in the run-slow scope of that PR. Updated the test to match the new design (load_backbone always initializes with random weights).
→ dff54ad ("out_indices always a list") made out_indices always return a list via backbone_utils.py#L57. The assertion at test_backbone_utils.py#L165 was written before that change in #28784 and still expected a tuple. Updated the assertion to expect a list.

cc: @zucchini-nlp @Rocketknight1

CI coverage fixed by this PR (checked in the latest CI run):

tests/generation/test_utils.py::GenerationIntegrationTests::test_green_red_watermark_generation, tests/utils/test_backbone_utils.py::BackboneUtilsTester::test_load_backbone_from_config, tests/utils/test_backbone_utils.py::BackboneUtilsTester::test_load_backbone_in_new_model

Current output:

6

Output after fix:

5

Code Agent Policy

  • I confirm that this is not a pure code agent PR.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline, Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you fix any necessary existing tests?

@harshaljanjani
harshaljanjani marked this pull request as ready for review April 23, 2026 06:22
@github-actions
github-actions Bot requested a review from ydshieh April 23, 2026 06:22
@Rocketknight1

Copy link
Copy Markdown
Member

cc @ydshieh @tarekziade maybe? We may want to consider ditching these tests if they're all slow and we don't even notice when they break!

@zucchini-nlp

Copy link
Copy Markdown
Member

Hm, I usually try to check daily CI for things that I might have broken, so prob this one slipped off the CI-bot feedback? Been quite a while since the last time "timm" was updated...

@harshaljanjani

Copy link
Copy Markdown
Contributor Author

Good day; just checking in to see if there are any updates on the direction we should take regarding this :)

@zucchini-nlp zucchini-nlp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sorry for delay, I checked with the prev breaking PRs and existing tests. I think these slow tests are meant to be in timm_backbone tester as IntegrationTests, whenever it makes sense

https://github.com/huggingface/transformers/blob/main/tests/models/timm_backbone/test_modeling_timm_backbone.py

Since we simplified a lot loading backbones, and there's no specific loading anymore, some could be not-useful anymore. For ex test_load_backbone from config/kwargs/ckpt are tested in individual models

@harshaljanjani

Copy link
Copy Markdown
Contributor Author

Will look into the same and revert, thank you :)

@github-actions

Copy link
Copy Markdown
Contributor

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

run-slow: timm_backbone

@harshaljanjani

harshaljanjani commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor Author

@zucchini-nlp Done, sorry for the delay!


@slow
@require_torch
def test_load_backbone_in_new_model(self):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just removed this one test without relocation since use_pretrained_backbone was removed in #43323.

@zucchini-nlp zucchini-nlp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, lgtm, thanks for moving it to where it belongs better

@zucchini-nlp

Copy link
Copy Markdown
Member

run-slow: timm_backbone

@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Workflow Run ⚙️

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

models: ["models/timm_backbone"]
quantizations: []

@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

CI Results

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN d92de1f2 workflow commit (merge commit)
PR 73326e24 branch commit (from PR)
main 756dffe0 base commit (on main)

✅ No failing test specific to this PR 🎉 👏 !

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

@zucchini-nlp
zucchini-nlp added this pull request to the merge queue May 1, 2026
Merged via the queue into huggingface:main with commit ecc3d0d May 1, 2026
23 checks passed
@harshaljanjani
harshaljanjani deleted the fix/fix-backbone-test-regressions branch May 1, 2026 10:05
Exile333 pushed a commit to Exile333/transformers that referenced this pull request May 6, 2026
* fix: Resolve backbone test regressions

* refactor: Relocate 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.

4 participants