Skip to content

Conversation

@yuanwu2017
Copy link
Contributor

What does this PR do?

The fsdp config generated by accelerate config is all fsdp prefixed. If passed in as parameters, these parameters will not work. But passing in in the fsdp_config.json method, these parameters can work. This patch makes them behave consistently and can work.

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.

@github-actions github-actions bot marked this pull request as draft April 16, 2025 09:11
@github-actions
Copy link
Contributor

Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the Ready for review button (at the bottom of the PR page). This will assign reviewers and trigger CI.

@yuanwu2017 yuanwu2017 marked this pull request as ready for review April 17, 2025 01:12
@Rocketknight1
Copy link
Member

cc @SunMarc

Copy link
Contributor

@MekkCyber MekkCyber left a comment

Choose a reason for hiding this comment

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

Sounds good ! Thanks

@yuanwu2017
Copy link
Contributor Author

@ArthurZucker Please help to review.

@MekkCyber MekkCyber requested a review from SunMarc April 20, 2025 19:57
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, just a nit. Can you also add a small test ?

v = self.fsdp_config.pop(k)
self.fsdp_config[k[5:]] = v

if self.fsdp_config is not None:
Copy link
Member

Choose a reason for hiding this comment

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

check if fsdp_config is a dict also

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@yuanwu2017
Copy link
Contributor Author

Thanks, just a nit. Can you also add a small test ?

Done.
pytest tests/fsdp/test_fsdp.py
image

Comment on lines 203 to 204
for k, v in trainer.args.fsdp_config.items():
self.assertEqual(v, self.accelerate_fsdp_config[k])
Copy link
Member

Choose a reason for hiding this comment

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

The goal was to check that trainer.args.fsdp_config keys were correctly modified no ?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

Copy link
Member

Choose a reason for hiding this comment

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

I mean here you are checking the values not the keys

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use the keys of trainer.args.fsdp_config to retrieve the values of acclerate_fsdp_config, in fact, the key must have been verified. I added a key check before the value. Please review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

@SunMarc
Copy link
Member

SunMarc commented Apr 23, 2025

Thanks for adding the test. Just a minor nit, please do make style to fix the CI also and we can merge

@yuanwu2017
Copy link
Contributor Author

Done.

@yuanwu2017
Copy link
Contributor Author

@Rocketknight1 @ArthurZucker Please help to review and merge.

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

@SunMarc SunMarc merged commit a41b6d9 into huggingface:main Apr 28, 2025
20 checks passed
sushmanthreddy pushed a commit to sushmanthreddy/transformers that referenced this pull request Apr 28, 2025
* Fix the fsdp config cannot work issue.

Signed-off-by: yuanwu <[email protected]>

* Check the fsdp_config type

Signed-off-by: yuanwu <[email protected]>

* Add the accelerate_fsdp_config test

Signed-off-by: yuanwu <[email protected]>

* fix error of make style

Signed-off-by: yuanwu <[email protected]>

* Add key check

Signed-off-by: yuanwu <[email protected]>

---------

Signed-off-by: yuanwu <[email protected]>
Co-authored-by: Mohamed Mekkouri <[email protected]>
Co-authored-by: Marc Sun <[email protected]>
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request May 14, 2025
* Fix the fsdp config cannot work issue.

Signed-off-by: yuanwu <[email protected]>

* Check the fsdp_config type

Signed-off-by: yuanwu <[email protected]>

* Add the accelerate_fsdp_config test

Signed-off-by: yuanwu <[email protected]>

* fix error of make style

Signed-off-by: yuanwu <[email protected]>

* Add key check

Signed-off-by: yuanwu <[email protected]>

---------

Signed-off-by: yuanwu <[email protected]>
Co-authored-by: Mohamed Mekkouri <[email protected]>
Co-authored-by: Marc Sun <[email protected]>
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.

5 participants