MCPcopy Create free account
hub / github.com/AIS-SNU/Smart-Infinity / _is_checkpointable

Method _is_checkpointable

deepspeed/runtime/pipe/module.py:607–617  ·  view source on GitHub ↗
(self, funcs)

Source from the content-addressed store, hash-verified

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)

Callers 1

forwardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected