don't use no_sync when deepspeed doesn't support it for certain zero stages (#35157)

* don't use no_sync when deepspeed doesn't support it for certain zero stages

* chore: lint

* fix no_sync context for deepspeed across all zero types

* chore: lint
This commit is contained in:
Wing Lian 2024-12-13 13:23:00 -05:00 committed by GitHub
parent 7237b3ecfc
commit add53e25ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2517,6 +2517,7 @@ class Trainer:
context = (
functools.partial(self.accelerator.no_sync, model=model)
if i != len(batch_samples) - 1
and self.accelerator.distributed_type != DistributedType.DEEPSPEED
else contextlib.nullcontext
)
with context():