Skip to content

Conversation

@gante
Copy link
Contributor

@gante gante commented Aug 17, 2024

What does this PR do?

See title :)

We know that SDPA yields inferior modeling results, so we should use eager by default. This has been the source of some model quality GH issues, e.g. #32848

Slow tests for gemma 2 ran, no regressions

@gante gante requested a review from ArthurZucker August 17, 2024 16:41
@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.

Comment on lines +105 to +106
config._attn_implementation = "sdpa"
model = Gemma2Model(config)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we should check that you can set the attention in the canonical way - rather than overriding the private attribute

Suggested change
config._attn_implementation = "sdpa"
model = Gemma2Model(config)
model = Gemma2Model(config, attn_implementation="sdpa")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@amyeroberts hehe I had the same idea, but this actually doesn't work :D

The API you're suggesting is for .from_pretrained(), not for __init__()

Copy link
Collaborator

Choose a reason for hiding this comment

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

we can pass _attn_implementation I think no?

Copy link
Contributor

Choose a reason for hiding this comment

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

The API you're suggesting is for .from_pretrained(), not for init()

Oh, true!

we can pass _attn_implementation I think no?

I don't think we can for the model init as it just accepts config as an input arg

Comment on lines +105 to +106
config._attn_implementation = "sdpa"
model = Gemma2Model(config)
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can pass _attn_implementation I think no?

@gante gante merged commit 975b988 into huggingface:main Aug 22, 2024
@gante gante deleted the gemma_2_eager_default branch August 22, 2024 14:59
BernardZach pushed a commit to BernardZach/transformers that referenced this pull request Dec 5, 2024
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