(self, mpu, replace_with_kernel_inject)
| 312 | |
| 313 | # TODO: remove this function and add this functionality to pydantic config checking |
| 314 | def _validate_args(self, mpu, replace_with_kernel_inject): |
| 315 | # TODO: to support SD pipeline we need to avoid this check for now |
| 316 | if replace_with_kernel_inject and not isinstance(self.module, Module): |
| 317 | raise ValueError(f"model must be a torch.nn.Module, got {type(self.module)}") |
| 318 | if not isinstance(self._config.tensor_parallel.tp_size, int) or self._config.tensor_parallel.tp_size < 1: |
| 319 | raise ValueError(f"mp_size must be an int >= 1, got {self._config.tensor_parallel.tp_size}") |
| 320 | |
| 321 | if mpu: |
| 322 | methods = ["get_model_parallel_group", "get_data_parallel_group"] |
| 323 | for method in methods: |
| 324 | if not hasattr(mpu, method): |
| 325 | raise ValueError(f"mpu is missing {method}") |
| 326 | if self._config.checkpoint is not None and not isinstance(self._config.checkpoint, (str, dict)): |
| 327 | raise ValueError(f"checkpoint must be None, str or dict, got {type(self._config.checkpoint)}") |
| 328 | |
| 329 | supported_dtypes = [None, torch.half, torch.int8, torch.float] |
| 330 | if self._config.dtype not in supported_dtypes: |
| 331 | raise ValueError(f"{self._config.dtype} not supported, valid dtype: {supported_dtypes}") |
| 332 | |
| 333 | if self.injection_dict is not None and not isinstance(self.injection_dict, dict): |
| 334 | raise ValueError(f"injection_dict must be None or a dict, got: {self.injection_dict}") |
| 335 | |
| 336 | def load_model_with_checkpoint(self, r_module): |
| 337 | self.mp_replace = ReplaceWithTensorSlicing( |
nothing calls this directly
no outgoing calls
no test coverage detected