MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / get_deepcompile_backend

Method get_deepcompile_backend

deepspeed/runtime/engine.py:5993–6017  ·  view source on GitHub ↗
(self, backend, compile_kwargs, schedule)

Source from the content-addressed store, hash-verified

5991 return init_autotp(self.module)
5992
5993 def get_deepcompile_backend(self, backend, compile_kwargs, schedule):
5994 from deepspeed.compile.init_z1_and_2 import init_z1_and_2
5995 from deepspeed.compile.init_z3 import init_z3
5996
5997 if self.zero_optimization_stage() != ZeroStageEnum.optimizer_states \
5998 and self.zero_optimization_stage() != ZeroStageEnum.weights \
5999 and self.zero_optimization_stage() != ZeroStageEnum.gradients:
6000 logger.info(
6001 f"Currently DeepCompile supports ZeRO stage 1, 2, or 3 only, but ZeRO stage is set to {self.zero_optimization_stage()}. Falling back to the torch compiler."
6002 )
6003 return None
6004
6005 compile_config = self._config.compile_config
6006 if (("zero_optimization" in self.config and "offload_optimizer" in self.config["zero_optimization"]
6007 and "offload_param" in self.config["zero_optimization"])
6008 and self._config.zero_config.offload_param.device == "cpu"
6009 and self._config.zero_config.offload_optimizer.device == "cpu"):
6010 compile_config.offload_parameters = True
6011 if self.zero_optimization_stage() == ZeroStageEnum.optimizer_states:
6012 return init_z1_and_2(self, backend, compile_config, compile_kwargs, schedule)
6013 elif self.zero_optimization_stage() == ZeroStageEnum.gradients:
6014 return init_z1_and_2(self, backend, compile_config, compile_kwargs, schedule, use_z2=True)
6015 elif self.zero_optimization_stage() == ZeroStageEnum.weights:
6016 return init_z3(self, backend, compile_config, compile_kwargs, schedule)
6017 return None
6018
6019 def get_deepspeed_compile_backend(self, backend, compile_kwargs, schedule):
6020 from deepspeed.compile.backend import opt_passes

Callers 1

Calls 3

init_z1_and_2Function · 0.90
init_z3Function · 0.90

Tested by

no test coverage detected