Skip to content
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

[Gemma2] Support FA2 softcapping #31887

Merged
merged 3 commits into from
Jul 11, 2024
Merged

[Gemma2] Support FA2 softcapping #31887

merged 3 commits into from
Jul 11, 2024

Conversation

ArthurZucker
Copy link
Collaborator

What does this PR do?

Adds support for the new FA2 softcapping following Dao-AILab/flash-attention#1025

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

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

OK, looks good to me! 2.6.0 was released 3 hours ago, let's go

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for adding!

@ArthurZucker ArthurZucker merged commit f4ec7a2 into main Jul 11, 2024
24 checks passed
@ArthurZucker ArthurZucker deleted the gemma-fa2 branch July 11, 2024 09:57
ArthurZucker added a commit that referenced this pull request Jul 11, 2024
* Support softcapping

* strictly greater than

* update
ArthurZucker added a commit that referenced this pull request Jul 11, 2024
* Support softcapping

* strictly greater than

* update
@ShadowTeamCN
Copy link

Good to see this. Can we use it for model fine-tuning, or is it just for inference? Google recommends fine-tuning in 'eager' mode.

@ArthurZucker
Copy link
Collaborator Author

Now you can use it for finetuning as well if you have the correct version of FA2. Not sure if finetuning "requires" it

@heartkilla
Copy link

Great! Any plans for sdpa support as well?

@ArthurZucker
Copy link
Collaborator Author

Sdpa is a bit more complicated, we need to use flex attention, did not have time to implement. Do you want to open a PR?

@hiyouga
Copy link
Contributor

hiyouga commented Jul 13, 2024

Hi @ArthurZucker, should we also add the sliding window and soft-capping to flash_attn_func

else:
attn_output = flash_attn_func(
query_states, key_states, value_states, dropout, softmax_scale=softmax_scale, causal=causal
)

just like
else:
attn_output = flash_attn_func(
query_states,
key_states,
value_states,
dropout,
softmax_scale=softmax_scale,
causal=causal,
window_size=(self.config.sliding_window, self.config.sliding_window),
)

@ArthurZucker
Copy link
Collaborator Author

ArthurZucker commented Jul 15, 2024

It should be here on main: https://github.com/huggingface/transformers/blob/main/src/transformers/models/gemma2/modeling_gemma2.py#L361 we updated the whole FA2 integration .

On the release branch it was there AFAIK

@hiyouga
Copy link
Contributor

hiyouga commented Jul 15, 2024

Get it, thanks for replying!

amyeroberts pushed a commit to amyeroberts/transformers that referenced this pull request Jul 19, 2024
* Support softcapping

* strictly greater than

* update
MHRDYN7 pushed a commit to MHRDYN7/transformers that referenced this pull request Jul 23, 2024
* Support softcapping

* strictly greater than

* update
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request Jul 24, 2024
* Support softcapping

* strictly greater than

* update
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.

None yet

7 participants