Skip to content

Commit

Permalink
remove the obsolete code related to fairscale FSDP (#26651)
Browse files Browse the repository at this point in the history
* remove the obsolete code related to fairscale FSDP

* apple review suggestion
  • Loading branch information
statelesshz authored Oct 30, 2023
1 parent 5fbed2d commit d751dbe
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
6 changes: 0 additions & 6 deletions src/transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1850,12 +1850,6 @@ def _inner_training_loop(

if is_sagemaker_mp_enabled() and args.fp16:
self.optimizer.clip_master_grads(args.max_grad_norm)
elif hasattr(self.optimizer, "clip_grad_norm"):
# Some optimizers (like the sharded optimizer) have a specific way to do gradient clipping
self.optimizer.clip_grad_norm(args.max_grad_norm)
elif hasattr(model, "clip_grad_norm_"):
# Some models (like FullyShardedDDP) have a specific way to do gradient clipping
model.clip_grad_norm_(args.max_grad_norm)
elif self.use_apex:
# Revert to normal clipping otherwise, handling Apex or full precision
nn.utils.clip_grad_norm_(
Expand Down
5 changes: 1 addition & 4 deletions src/transformers/training_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -1384,10 +1384,7 @@ def __post_init__(self):

if self.bf16:
if self.half_precision_backend == "apex":
raise ValueError(
" `--half_precision_backend apex`: GPU bf16 is not supported by apex. Use"
" `--half_precision_backend cuda_amp` instead"
)
raise ValueError(" `--half_precision_backend apex`: GPU bf16 is not supported by apex.")

if self.lr_scheduler_type == SchedulerType.REDUCE_ON_PLATEAU:
if self.evaluation_strategy == IntervalStrategy.NO:
Expand Down

0 comments on commit d751dbe

Please sign in to comment.