MCPcopy
hub / github.com/deepspeedai/DeepSpeed / CPU_Accelerator

Class CPU_Accelerator

accelerator/cpu_accelerator.py:25–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24# accelerator for Intel CPU
25class CPU_Accelerator(DeepSpeedAccelerator):
26
27 def __init__(self):
28 self._name = 'cpu'
29 self._compile_backend = "inductor"
30 if oneccl_imported_p:
31 self._communication_backend_name = 'ccl'
32 else:
33 # fallback to gloo if oneccl_binding_for_pytorch is not installed
34 self._communication_backend_name = 'gloo'
35 try:
36 import psutil
37 mem = psutil.Process().memory_info().rss
38 self.max_mem = mem
39 except ImportError as e:
40 self.max_mem = 0
41
42 def is_synchronized_device(self):
43 return True
44
45 def use_host_timers(self):
46 return self.is_synchronized_device()
47
48 def resolves_data_dependency(self):
49 return self.is_synchronized_device()
50
51 def handles_memory_backpressure(self):
52 return self.is_synchronized_device()
53
54 # Device APIs
55 def device_name(self, device_index=None):
56 return 'cpu'
57
58 def device(self, device_index=None):
59 return None
60
61 def set_device(self, device_index):
62 return
63
64 def current_device(self):
65 return os.environ.get('LOCAL_RANK', 0)
66
67 def current_device_name(self):
68 return 'cpu'
69
70 def device_count(self):
71 device_count = int(os.environ.get('LOCAL_SIZE', 0))
72 if device_count > 0:
73 return device_count
74 else:
75 from deepspeed.utils.numa import get_numa_cores
76 # Count NUMA node for number of cpu accelerators. On machine with HBM
77 # In flat mode, HBM is in separate NUMA node with no cores on this node.
78 # Ignore these NUMA nodes with no cores.
79 numa_core_lists = get_numa_cores()
80 if not numa_core_lists:
81 return 1
82 numa_count = 0

Callers 1

get_acceleratorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…