-
Notifications
You must be signed in to change notification settings - Fork 27.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Flash Attention 2 support to Musicgen and Musicgen Melody #29939
Merged
Merged
Changes from 7 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a7207c9
add FA2 to o.g Musicgen
ylacombe cb3fd9f
make style
ylacombe 716c18a
add FA2 support to Musicgen Melody
ylacombe a165c30
add generation FA2 tests to o.g Musicgen
ylacombe b0f4258
make style and fix copies
ylacombe 3d7e1a5
add Musicgen to FA2 docs + deprecate list
ylacombe 6ca29ce
Merge branch 'huggingface:main' into add-FA2-musicgen
ylacombe 0a3ce47
add sdpa supports to Musicgen's
ylacombe 4d5f009
make style and fix copies
ylacombe 1231285
refactor attention implementation arguments
ylacombe 2ed6e9e
add Copied from to sdpa tests
ylacombe 1479ef2
Merge branch 'huggingface:main' into add-FA2-musicgen
ylacombe 1146c92
add copied form in sdpa tests melody
ylacombe 16657c6
add copied for FA2 generation tests
ylacombe c36bf26
add FA2 inference copied from
ylacombe 9fbd9ec
make style
ylacombe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,7 @@ | |
|
||
logger = logging.get_logger(__name__) | ||
|
||
MUSICGEN_MELODY_PRETRAINED_CONFIG_ARCHIVE_MAP = { | ||
"facebook/musicgen-melody": "https://huggingface.co/facebook/musicgen-melody/resolve/main/config.json", | ||
} | ||
from ..deprecated._archive_maps import MUSICGEN_MELODY_PRETRAINED_CONFIG_ARCHIVE_MAP # noqa: F401, E402 | ||
|
||
|
||
class MusicgenMelodyDecoderConfig(PretrainedConfig): | ||
|
@@ -254,3 +252,20 @@ def from_sub_models_config( | |
# This is a property because you might want to change the codec model on the fly | ||
def sampling_rate(self): | ||
return self.audio_encoder.sampling_rate | ||
|
||
@property | ||
def _attn_implementation(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
# This property is made private for now (as it cannot be changed and a PreTrainedModel.use_attn_implementation method needs to be implemented.) | ||
if hasattr(self, "_attn_implementation_internal"): | ||
if self._attn_implementation_internal is None: | ||
# `config.attn_implementation` should never be None, for backward compatibility. | ||
return "eager" | ||
else: | ||
return self._attn_implementation_internal | ||
else: | ||
return "eager" | ||
|
||
@_attn_implementation.setter | ||
def _attn_implementation(self, value): | ||
self._attn_implementation_internal = value | ||
self.decoder._attn_implementation = value |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is one-to-one the same as in the
PreTrainedConfig
class:transformers/src/transformers/configuration_utils.py
Line 407 in 536ea2a
Can we remove it from here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not if we want to keep the
setter
part!