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

Bye bye env vars, keep everything as configs #34886

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

muellerzr
Copy link
Contributor

What does this PR do?

As @BenjaminBossan found, (huggingface/accelerate#3252), the TrainingArguments will set environmental variables automatically when using Accelerate because before it wouldn't work otherwise. Nowadays the only env variable required for things to run smoothly is the ones for model init (fsdp cpu eff ram).

This PR does a few things:

  1. We completely remove the need for environmental variables, creating the proper configs (dynamo relies on Allow for full dynamo config passed to Accelerator accelerate#3251)
  2. I've refactored how mixed_precision gets set, to simplify the training arguments and combine 7 args into 2.

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.

@SunMarc @Rocketknight1

Comment on lines 73 to 85
"accelerate",
"launch",
"--use_fsdp",
"--main_process_port",
f"{get_torch_dist_unique_port()}",
"--num_processes",
f"{torch.cuda.device_count()}",
f"{self.test_file_dir}/test_trainer_fsdp.py",
"--fsdp",
"full_shard",
"--fsdp_transformer_layer_cls_to_wrap",
"GPT2Block",
f"{self.test_file_dir}/test_trainer_fsdp.py",
"--output_dir",
f"{output_dir}",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactoring the test this way forces us to use the transformers parser rather than accelerate's CLI env var setting

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

@BenjaminBossan
Copy link
Member

Thanks for cleaning up the use of env vars. I only did a quick check, are there deprecation warnings added for fp16, bf16, etc.? It should be clearly communicated when these arguments will be removed, as a lot of code would be affected.

@muellerzr muellerzr marked this pull request as draft November 22, 2024 17:47
@muellerzr
Copy link
Contributor Author

Not yet but it will be, meant to open this as a draft just to make sure we're all okay w/ the core parts

Copy link
Member

@SunMarc SunMarc 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 cleaning this up ! Left a few comments as reminder since this is still a draft

Comment on lines +1764 to +1765
self.fp16 = mixed_precision_dtype == "fp16"
self.bf16 = mixed_precision_dtype == "bf16"
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice that we don't have to define them as I think the goal is to deprecate them ? Are we using them somewhere else ?

Comment on lines +1576 to +1577
if self.mixed_precision_config is None:
self.mixed_precision_config = {}
Copy link
Member

Choose a reason for hiding this comment

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

Make sure to replace the existing logic (e.g bf16_full_eval) with mixed_precision_config

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