| 605 | self._synchronize_tied_weights() |
| 606 | |
| 607 | def _is_checkpointable(self, funcs): |
| 608 | # This is an unfortunate hack related to torch and deepspeed activation checkpoint implementations. |
| 609 | # Some layers like torch.nn.Embedding will not receive grads if checkpointed, which breaks things. |
| 610 | # I presume it's related to the discrete inputs that cannot require_grad? Need to revisit. |
| 611 | if self.__class__.__name__ in ('GPTModelPipe', 'GPT2ModelPipe'): |
| 612 | return all('ParallelTransformerLayerPipe' in f.__class__.__name__ for f in funcs) |
| 613 | if self.checkpointable_layers is not None: |
| 614 | return all(f.__class__.__name__ in self.checkpointable_layers for f in funcs) |
| 615 | |
| 616 | params = [f.parameters() for f in funcs if isinstance(f, torch.nn.Module)] |
| 617 | return any(len(list(p)) > 0 for p in params) |