MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / CPU_Accelerator

Class CPU_Accelerator

accelerator/cpu_accelerator.py:165–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163
164# accelerator for Intel CPU
165class CPU_Accelerator(DeepSpeedAccelerator):
166
167 def __init__(self):
168 self._name = 'cpu'
169 self._compile_backend = "inductor"
170 if oneccl_imported_p:
171 self._communication_backend_name = 'ccl'
172 else:
173 # fallback to gloo if oneccl_binding_for_pytorch is not installed
174 self._communication_backend_name = 'gloo'
175 try:
176 import psutil
177 mem = psutil.Process().memory_info().rss
178 self.max_mem = mem
179 except ImportError as e:
180 self.max_mem = 0
181
182 def is_synchronized_device(self):
183 return True
184
185 def use_host_timers(self):
186 return self.is_synchronized_device()
187
188 def resolves_data_dependency(self):
189 return self.is_synchronized_device()
190
191 def handles_memory_backpressure(self):
192 return self.is_synchronized_device()
193
194 # Device APIs
195 def device_name(self, device_index=None):
196 return 'cpu'
197
198 def device(self, device_index=None):
199 return None
200
201 def set_device(self, device_index):
202 return
203
204 def current_device(self):
205 return os.environ.get('LOCAL_RANK', 0)
206
207 def current_device_name(self):
208 return 'cpu'
209
210 def device_count(self):
211 device_count = int(os.environ.get('LOCAL_SIZE', 0))
212 if device_count > 0:
213 return device_count
214 else:
215 from deepspeed.utils.numa import get_numa_cores
216 # Count NUMA node for number of cpu accelerators. On machine with HBM
217 # In flat mode, HBM is in separate NUMA node with no cores on this node.
218 # Ignore these NUMA nodes with no cores.
219 numa_core_lists = get_numa_cores()
220 if not numa_core_lists:
221 return 1
222 numa_count = 0

Calls

no outgoing calls