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

Update training_args.py to remove the runtime error #25920

Merged

Conversation

sahel-sh
Copy link
Contributor

@sahel-sh sahel-sh commented Sep 2, 2023

This cl iterates through a list of keys rather than dict items while updating the dict elements. Fixes the following error: File "..../transformers/training_args.py", line 1544, in post_init for k, v in self.fsdp_config.items():
RuntimeError: dictionary keys changed during iteration

What does this PR do?

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.

This cl iterates through a list of keys rather than dict items while updating the dict elements. Fixes the following error:
File "..../transformers/training_args.py", line 1544, in post_init
for k, v in self.fsdp_config.items():
RuntimeError: dictionary keys changed during iteration
@sahel-sh
Copy link
Contributor Author

sahel-sh commented Sep 2, 2023

Steps to reproduce it:
Use a fsdp config file with json keys starting with "fsdp_", for example the config file below:
{
"fsdp_auto_wrap_policy": "FULL_SHARD",
"fsdp_transformer_layer_cls_to_wrap": "LlamaDecoderLayer"
}
The runtime error happens since the code is updating a dictionary to remove "fsdp_" from its keys while iterating over it.

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!

cc @muellerzr @pacman100

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@amyeroberts amyeroberts merged commit aea7614 into huggingface:main Sep 5, 2023
@sahel-sh sahel-sh deleted the fix_trainer_args_runtime_err branch September 12, 2023 18:40
parambharat pushed a commit to parambharat/transformers that referenced this pull request Sep 26, 2023
This cl iterates through a list of keys rather than dict items while updating the dict elements. Fixes the following error:
File "..../transformers/training_args.py", line 1544, in post_init
for k, v in self.fsdp_config.items():
RuntimeError: dictionary keys changed during iteration
blbadger pushed a commit to blbadger/transformers that referenced this pull request Nov 8, 2023
This cl iterates through a list of keys rather than dict items while updating the dict elements. Fixes the following error:
File "..../transformers/training_args.py", line 1544, in post_init
for k, v in self.fsdp_config.items():
RuntimeError: dictionary keys changed during iteration
EduardoPach pushed a commit to EduardoPach/transformers that referenced this pull request Nov 18, 2023
This cl iterates through a list of keys rather than dict items while updating the dict elements. Fixes the following error:
File "..../transformers/training_args.py", line 1544, in post_init
for k, v in self.fsdp_config.items():
RuntimeError: dictionary keys changed during iteration
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.

3 participants