Skip to content

Commit e75cb0c

Browse files
shauray8mryabsgugger
authored
fix type annotations for arguments in training_args (#24550)
* testing * example script * fix typehinting * some tests * make test * optional update * Union of arguments * does this fix the issue * remove reports * set default to False * documentation change * None support * does not need None * Fix typing annotations for FSDP and DeepSpeed in TrainingArguments (#24549) * Fix typing annotations for FSDP and DeepSpeed in TrainingArguments * Change dict to Dict * Revert "Fix typing annotations for FSDP and DeepSpeed in TrainingArguments" (#24574) Revert "Fix typing annotations for FSDP and DeepSpeed in TrainingArguments (#24549)" This reverts commit c5e29d4. * Fix typing annotations for FSDP and DeepSpeed in TrainingArguments (#24549) * Fix typing annotations for FSDP and DeepSpeed in TrainingArguments * Change dict to Dict * merge * hacky fix * fixup --------- Co-authored-by: Max Ryabinin <mryabinin0@gmail.com> Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
1 parent 0c41765 commit e75cb0c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/transformers/training_args.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ class TrainingArguments:
406406
When resuming training, whether or not to skip the epochs and batches to get the data loading at the same
407407
stage as in the previous training. If set to `True`, the training will begin faster (as that skipping step
408408
can take a long time) but will not yield the same results as the interrupted training would have.
409-
sharded_ddp (`bool`, `str` or list of [`~trainer_utils.ShardedDDPOption`], *optional*, defaults to `False`):
409+
sharded_ddp (`bool`, `str` or list of [`~trainer_utils.ShardedDDPOption`], *optional*, defaults to `''`):
410410
Use Sharded DDP training from [FairScale](https://github.com/facebookresearch/fairscale) (in distributed
411411
training only). This is an experimental feature.
412412
@@ -421,7 +421,7 @@ class TrainingArguments:
421421
422422
If a string is passed, it will be split on space. If a bool is passed, it will be converted to an empty
423423
list for `False` and `["simple"]` for `True`.
424-
fsdp (`bool`, `str` or list of [`~trainer_utils.FSDPOption`], *optional*, defaults to `False`):
424+
fsdp (`bool`, `str` or list of [`~trainer_utils.FSDPOption`], *optional*, defaults to `''`):
425425
Use PyTorch Distributed Parallel Training (in distributed training only).
426426
427427
A list of options along the following:
@@ -969,7 +969,7 @@ class TrainingArguments:
969969
)
970970
},
971971
)
972-
sharded_ddp: str = field(
972+
sharded_ddp: Optional[Union[List[ShardedDDPOption], str]] = field(
973973
default="",
974974
metadata={
975975
"help": (
@@ -980,7 +980,7 @@ class TrainingArguments:
980980
),
981981
},
982982
)
983-
fsdp: str = field(
983+
fsdp: Optional[Union[List[FSDPOption], str]] = field(
984984
default="",
985985
metadata={
986986
"help": (
@@ -1005,8 +1005,8 @@ class TrainingArguments:
10051005
default=None,
10061006
metadata={
10071007
"help": (
1008-
"Config to be used with FSDP (Pytorch Fully Sharded Data Parallel). The value is either a"
1009-
"fsdp json config file (e.g., `fsdp_config.json`) or an already loaded json file as `dict`."
1008+
"Config to be used with FSDP (Pytorch Fully Sharded Data Parallel). The value is either a"
1009+
"fsdp json config file (e.g., `fsdp_config.json`) or an already loaded json file as `dict`."
10101010
)
10111011
},
10121012
)
@@ -1019,11 +1019,11 @@ class TrainingArguments:
10191019
)
10201020
},
10211021
)
1022-
deepspeed: Optional[str] = field(
1022+
deepspeed: Optional[Union[str, Dict]] = field(
10231023
default=None,
10241024
metadata={
10251025
"help": (
1026-
"Enable deepspeed and pass the path to deepspeed json config file (e.g. ds_config.json) or an already"
1026+
"Enable deepspeed and pass the path to deepspeed json config file (e.g. `ds_config.json`) or an already"
10271027
" loaded json file as a dict"
10281028
)
10291029
},

0 commit comments

Comments
 (0)