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

Fix attn_implementation documentation #29295

Merged
merged 1 commit into from
Feb 27, 2024
Merged

Conversation

fxmarty
Copy link
Contributor

@fxmarty fxmarty commented Feb 26, 2024

As reported in #26572 (comment), attn_implementation is wrongfully documented under PretrainedConfig, and is not under AutoModel.from_config & PreTrainedModel.from_pretrained as it should be.

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

@amyeroberts
Copy link
Collaborator

amyeroberts commented Feb 26, 2024

@fxmarty I don't think this is quite right - if someone can pass in

model = AutoModel.from_config(config, attn_implementation="foo")

they should also be able to pass it in for the config constructor and then pass that to the model

config = ModelConfig(attn_implementation="foo")
model = AutoModel.from_config(config)

@fxmarty
Copy link
Contributor Author

fxmarty commented Feb 26, 2024

@amyeroberts This is not what was suggested in #26572 (comment) by @patrickvonplaten.

Happy to change that, but I think it should be in an other PR. This PR simply reflects in the documentation the current expected usage by users:

model = AutoModel.from_config(cfg, attn_implementation="eager")
model = LlamaModel.from_pretrained("xxx", attn_implementation="eager")

while the following is illegal/not supported:

from transformers import AutoModelForCausalLM, AutoConfig, LlamaForCausalLM

cfg = AutoConfig.from_pretrained("fxmarty/tiny-llama-fast-tokenizer")
cfg.attn_implementation = "eager"

model = LlamaForCausalLM(cfg)

they should also be able to pass it in for the config constructor

Ultimately I agree with you, PreTrainedModel.__init__ should in the future have a way to obey to a specified attn_implementation (currently not exposed to users, only config._attn_implementation = "eager" works).

@amyeroberts
Copy link
Collaborator

@fxmarty OK, thanks for explaining and linking to the relevant comment! If it's something that causes a lot of confusion we can circle back on enabling it through the config creation

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.

Thanks for following up on this and making the docstrings consistent!

@fxmarty fxmarty merged commit 6d3b643 into huggingface:main Feb 27, 2024
8 checks passed
itazap pushed a commit that referenced this pull request May 14, 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