Initialize device and construct model runner
(self)
| 66 | pass |
| 67 | |
| 68 | def init_device(self): |
| 69 | """ |
| 70 | Initialize device and construct model runner |
| 71 | """ |
| 72 | if paddle.is_compiled_with_custom_device("intel_hpu"): |
| 73 | # Set environment variable |
| 74 | self.device_ids = self.parallel_config.device_ids.split(",") |
| 75 | logger.info( |
| 76 | f"Using Intel HPU device with local rank => device id: {int(self.device_ids[self.local_rank])} as module id" |
| 77 | ) |
| 78 | intel_hpus_module_id = int(self.device_ids[self.local_rank]) |
| 79 | self.device = f"intel_hpu:{intel_hpus_module_id}" |
| 80 | paddle.device.set_device(self.device) |
| 81 | paddle.set_default_dtype(self.model_config.dtype) |
| 82 | |
| 83 | gc.collect() |
| 84 | paddle.device.cuda.empty_cache() |
| 85 | else: |
| 86 | raise RuntimeError(f"Not support device type: {self.device_config.device}") |
| 87 | |
| 88 | if self.local_rank == 0: |
| 89 | report_usage_stats(self.fd_config) |
| 90 | |
| 91 | set_random_seed(self.fd_config.model_config.seed) |
| 92 | # Construct model runner |
| 93 | self.model_runner: HPUModelRunner = HPUModelRunner( |
| 94 | fd_config=self.fd_config, |
| 95 | device=self.device, |
| 96 | device_id=self.device_ids[self.local_rank], |
| 97 | rank=self.rank, |
| 98 | local_rank=self.local_rank, |
| 99 | ) |
| 100 | |
| 101 | def exist_prefill(self): |
| 102 | """ |
nothing calls this directly
no test coverage detected