(self, backend, compile_kwargs, schedule)
| 5888 | return init_autotp(self.module) |
| 5889 | |
| 5890 | def get_deepcompile_backend(self, backend, compile_kwargs, schedule): |
| 5891 | from deepspeed.compile.init_z1_and_2 import init_z1_and_2 |
| 5892 | from deepspeed.compile.init_z3 import init_z3 |
| 5893 | |
| 5894 | if self.zero_optimization_stage() != ZeroStageEnum.optimizer_states \ |
| 5895 | and self.zero_optimization_stage() != ZeroStageEnum.weights \ |
| 5896 | and self.zero_optimization_stage() != ZeroStageEnum.gradients: |
| 5897 | logger.info( |
| 5898 | 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." |
| 5899 | ) |
| 5900 | return None |
| 5901 | |
| 5902 | compile_config = self._config.compile_config |
| 5903 | if (("zero_optimization" in self.config and "offload_optimizer" in self.config["zero_optimization"] |
| 5904 | and "offload_param" in self.config["zero_optimization"]) |
| 5905 | and self._config.zero_config.offload_param.device == "cpu" |
| 5906 | and self._config.zero_config.offload_optimizer.device == "cpu"): |
| 5907 | compile_config.offload_parameters = True |
| 5908 | if self.zero_optimization_stage() == ZeroStageEnum.optimizer_states: |
| 5909 | return init_z1_and_2(self, backend, compile_config, compile_kwargs, schedule) |
| 5910 | elif self.zero_optimization_stage() == ZeroStageEnum.gradients: |
| 5911 | return init_z1_and_2(self, backend, compile_config, compile_kwargs, schedule, use_z2=True) |
| 5912 | elif self.zero_optimization_stage() == ZeroStageEnum.weights: |
| 5913 | return init_z3(self, backend, compile_config, compile_kwargs, schedule) |
| 5914 | return None |
| 5915 | |
| 5916 | def get_deepspeed_compile_backend(self, backend, compile_kwargs, schedule): |
| 5917 | from deepspeed.compile.backend import opt_passes |
no test coverage detected