Skip to content

Commit

Permalink
Update training_args.py to remove the runtime error (huggingface#25920)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sahel-sh authored and parambharat committed Sep 26, 2023
1 parent 8bd6f07 commit 4e76838
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/transformers/training_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -1546,10 +1546,10 @@ def __post_init__(self):
warnings.warn("`--fsdp_config` is useful only when `--fsdp` is specified.")
with io.open(self.fsdp_config, "r", encoding="utf-8") as f:
self.fsdp_config = json.load(f)
for k, v in self.fsdp_config.items():
for k in list(self.fsdp_config.keys()):
if k.startswith("fsdp_"):
self.fsdp_config[k.replace("fsdp_", "")] = v
del self.fsdp_config[k]
v = self.fsdp_config.pop(k)
self.fsdp_config[k[5:]] = v

if self.fsdp_min_num_params > 0:
warnings.warn("using `--fsdp_min_num_params` is deprecated. Use fsdp_config instead ", FutureWarning)
Expand Down

0 comments on commit 4e76838

Please sign in to comment.