(self, backend, compile_kwargs, schedule)
| 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 |
no test coverage detected