| 17 | |
| 18 | |
| 19 | class XPU_Accelerator(DeepSpeedAccelerator): |
| 20 | |
| 21 | def __init__(self): |
| 22 | self._name = 'xpu' |
| 23 | if oneccl_imported_p: |
| 24 | self._communication_backend_name = 'ccl' |
| 25 | else: |
| 26 | # changed to xccl if not using torch-CCL on XPU device |
| 27 | self._communication_backend_name = 'xccl' |
| 28 | self._compile_backend = "inductor" |
| 29 | self.aligned_tensors = [] |
| 30 | self.class_dict = None |
| 31 | |
| 32 | def is_synchronized_device(self): |
| 33 | return False |
| 34 | |
| 35 | def use_host_timers(self): |
| 36 | return self.is_synchronized_device() |
| 37 | |
| 38 | def resolves_data_dependency(self): |
| 39 | return self.is_synchronized_device() |
| 40 | |
| 41 | def handles_memory_backpressure(self): |
| 42 | return self.is_synchronized_device() |
| 43 | |
| 44 | # Device APIs |
| 45 | def device_name(self, device_index=None): |
| 46 | if device_index == None: |
| 47 | return 'xpu' |
| 48 | return 'xpu:{}'.format(device_index) |
| 49 | |
| 50 | def device(self, device_index=None): |
| 51 | return torch.device('xpu', device_index) |
| 52 | |
| 53 | def set_device(self, device_index): |
| 54 | torch.xpu.set_device(device_index) |
| 55 | |
| 56 | def current_device(self): |
| 57 | return torch.xpu.current_device() |
| 58 | |
| 59 | def current_device_name(self): |
| 60 | return 'xpu:{}'.format(torch.xpu.current_device()) |
| 61 | |
| 62 | def device_count(self): |
| 63 | return torch.xpu.device_count() |
| 64 | |
| 65 | def synchronize(self, device_index=None): |
| 66 | return torch.xpu.synchronize(device_index) |
| 67 | |
| 68 | # RNG APIs |
| 69 | def random(self): |
| 70 | return torch.xpu.random |
| 71 | |
| 72 | def set_rng_state(self, new_state, device_index=None): |
| 73 | if device_index == None: |
| 74 | return torch.xpu.set_rng_state(new_state) |
| 75 | return torch.xpu.set_rng_state(new_state, device_index) |
| 76 |
no outgoing calls
no test coverage detected
searching dependent graphs…