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

Allow boolean FSDP options in fsdp_config #30439

Merged

Conversation

helloworld1
Copy link
Contributor

What does this PR do?

When using the fsdp_config option, it must be passed in as string for some configuration.
The following config will result in crash

{
  "limit_all_gathers": true,
  "backward_prefetch": "backward_pre",
  "use_orig_params": true,
  "cpu_ram_efficient_loading": true
}

Error:

Traceback (most recent call last):
  File "/home/jobuser/training.py", line 107, in <module>
    main()
  File "/home/jobuser/training.py", line 40, in main
    training_args, custom_args = parser.parse_args_into_dataclasses()
  File "/home/jobuser/.local/lib/python3.10/site-packages/transformers/hf_argparser.py", line 338, in parse_args_into_dataclasses
    obj = dtype(**inputs)
  File "<string>", line 121, in __init__
  File "/home/jobuser/.local/lib/python3.10/site-packages/transformers/training_args.py", line 1691, in __post_init__
    os.environ[f"{prefix}USE_ORIG_PARAMS"] = self.fsdp_config.get("use_orig_params", "true")
  File "/export/apps/python/3.10/lib/python3.10/os.py", line 684, in __setitem__
    value = self.encodevalue(value)
  File "/export/apps/python/3.10/lib/python3.10/os.py", line 756, in encode
    raise TypeError("str expected, not %s" % type(value).__name__)
TypeError: str expected, not bool

This PR fixed the issue by casting the config value to str.

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?

@pacman100 @muellerzr @amyeroberts

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.

Sorry, something went wrong.

Copy link
Contributor

@muellerzr muellerzr left a comment

Choose a reason for hiding this comment

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

This looks like an okay change to me, however just to be extra careful, let's do a .lower() as well please :)

@muellerzr muellerzr requested a review from pacman100 April 24, 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.

@helloworld1 helloworld1 force-pushed the helloworld1/fsdp_option_boolean branch 3 times, most recently from d3e499b to 7a474c6 Compare April 24, 2024 17:04
@helloworld1 helloworld1 force-pushed the helloworld1/fsdp_option_boolean branch from 7a474c6 to 27e63d9 Compare April 25, 2024 03:45
Copy link
Contributor

@pacman100 pacman100 left a comment

Choose a reason for hiding this comment

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

Thank you @helloworld1 for fixing this!

@pacman100 pacman100 requested a review from amyeroberts April 29, 2024 08:54
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 fixing!

@amyeroberts amyeroberts merged commit 80126f9 into huggingface:main Apr 29, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants