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

Introduce AcceleratorConfig dataclass #28664

Merged
merged 18 commits into from
Feb 14, 2024
Merged

Conversation

muellerzr
Copy link
Contributor

What does this PR do?

This PR centralizes all arguments for the Accelerator not covered by fsdp_config and deepspeed_config into a singular dataclass that users can pass in as a json file or through raw CLI param args.

I think I have the CLI args configured right? But I'm not 100% sure. Advice on how to check that would be appreciated!

Fixes # (issue)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@amyeroberts @LysandreJik

@muellerzr
Copy link
Contributor Author

@amyeroberts tests finally pass after losing my mind on imports 🙌

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 adding this! I can see that it's really going to help understand the arguments and handle them in the code.

src/transformers/training_args.py Outdated Show resolved Hide resolved
src/transformers/trainer.py Outdated Show resolved Hide resolved
src/transformers/training_args.py Outdated Show resolved Hide resolved
src/transformers/training_args.py Outdated Show resolved Hide resolved
src/transformers/trainer_pt_utils.py Outdated Show resolved Hide resolved
src/transformers/trainer_pt_utils.py Outdated Show resolved Hide resolved
src/transformers/trainer_pt_utils.py Show resolved Hide resolved
tests/trainer/test_trainer.py Show resolved Hide resolved
tests/trainer/test_trainer.py Show resolved Hide resolved
tests/trainer/test_trainer.py Show resolved Hide resolved
@muellerzr muellerzr requested a review from amyeroberts January 25, 2024 08:44
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 iterating - looking good!

Just a few final comments

src/transformers/trainer_pt_utils.py Outdated Show resolved Hide resolved
src/transformers/trainer.py Outdated Show resolved Hide resolved
tests/trainer/test_trainer.py Show resolved Hide resolved
src/transformers/training_args.py Outdated Show resolved Hide resolved
tests/trainer/test_trainer.py Show resolved Hide resolved
@vanbasten23
Copy link

Hi @muellerzr , could you please get this PR merged? We need the PR to get the accelerate test on TPU v3 to succeed again. Thanks.

@muellerzr muellerzr force-pushed the muellerzr-accelerator-dataclass branch from 2c60474 to c99d51c Compare February 13, 2024 19:32
@muellerzr
Copy link
Contributor Author

muellerzr commented Feb 13, 2024

As a general note, immediately after the next accelerate release I'll make a follow-up PR utilizing the config class seen here so users won't have annoying FutureWarning's huggingface/accelerate#2441 (No big logic difference, just shove it all into the config rather than the Accelerator based on the accelerate version)

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 iterating!

@amyeroberts
Copy link
Collaborator

For the doc tests, there was a recent commit merged to main, which should hopefully resolve this.

@muellerzr muellerzr force-pushed the muellerzr-accelerator-dataclass branch from 8c9535a to 1de6ff5 Compare February 14, 2024 14:06
@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.

@muellerzr muellerzr merged commit 0507e69 into main Feb 14, 2024
21 checks passed
@muellerzr muellerzr deleted the muellerzr-accelerator-dataclass branch February 14, 2024 15:18
sbucaille pushed a commit to sbucaille/transformers that referenced this pull request Feb 14, 2024
* Introduce acceleratorconfig dataclass

* Extra second warn

* Move import

* Try moving import under is_accelerate_available

* Quality

* Apply suggestions from code review

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>

* Clean

* Remove to_kwargs

* Change version

* Improve tests by including dispatch and split batches

* Improve reliability

* Update tests/trainer/test_trainer.py

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>

* Fixup tests and review nits

* Make tests pass

* protect import

* Protect import

* Empty-Commit

* Make training_args.to_dict handle the AcceleratorConfig

---------

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
Copy link

@devCaiquedePaula devCaiquedePaula left a comment

Choose a reason for hiding this comment

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

The docstring for the AcceleratorConfig class is clear and provides a brief description of its purpose. Consider adding information about each attribute's meaning and potential values to make it more informative.

itazap pushed a commit that referenced this pull request May 14, 2024
* Introduce acceleratorconfig dataclass

* Extra second warn

* Move import

* Try moving import under is_accelerate_available

* Quality

* Apply suggestions from code review

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>

* Clean

* Remove to_kwargs

* Change version

* Improve tests by including dispatch and split batches

* Improve reliability

* Update tests/trainer/test_trainer.py

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>

* Fixup tests and review nits

* Make tests pass

* protect import

* Protect import

* Empty-Commit

* Make training_args.to_dict handle the AcceleratorConfig

---------

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants