Skip to content

Conversation

ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Oct 16, 2025

What does this PR do?

Some Bark model classes are not GenerationMixin and have their own generation method.

#41445 makes change to GenerationMixin and those changes are not applied to those Bark model classes, then causes the bark tests to fail. One example is

tests/models/bark/test_modeling_bark.py::BarkModelIntegrationTests::test_generate_batching

This PR adds GenerationMixin to those models and the tests pass now.

@HuggingFaceDocBuilderDev

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.

"""
)
class BarkModel(BarkPreTrainedModel):
class BarkModel(BarkPreTrainedModel, GenerationMixin):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't change class BarkFineModel(BarkPreTrainedModel): however. Too many tests fail when I enable it.

@ydshieh ydshieh requested review from ArthurZucker and gante October 16, 2025 08:18
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

its good that it fixes is, tho a bit weird as the bark model is not semantically a gernerate model. IDT that's the best solution 👀

@ydshieh
Copy link
Collaborator Author

ydshieh commented Oct 16, 2025

bark model is not semantically a gernerate model

I agree, but it has a generate method which makes it even confused ...

(and it definitely try to use generation config )

@ydshieh
Copy link
Collaborator Author

ydshieh commented Oct 16, 2025

As @gante wrote in the codebase,

    def can_generate(cls) -> bool:
        # Bark has a unique model structure, where the external class (`BarkModel`) doesn't need to inherit from
        # `GenerationMixin` (it has a non-standard generation method), but one of the internal models do
        # (`BarkSemanticModel`). This means that the base `can_generate()` will return `False`, but we need to
        # override it so as to do `GenerationConfig` handling in multiple parts of the codebase.
        return True

we see BarkModel is:

  • has generate method (although previously not inherits from GenerationMixin)
  • set can_generate = True in order to handle GenerationConfig

So after the change #41445, the fix of the failing tests in this PR seems to be natural IMO.

@github-actions
Copy link
Contributor

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

run-slow: bark

@ydshieh ydshieh merged commit a8cece1 into main Oct 22, 2025
18 checks passed
@ydshieh ydshieh deleted the fix_bark branch October 22, 2025 07:21
@ydshieh
Copy link
Collaborator Author

ydshieh commented Oct 22, 2025

Merged as approved offline on slack

ngazagna-qc pushed a commit to ngazagna-qc/transformers that referenced this pull request Oct 23, 2025
* fix

* fix

* fix

---------

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
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