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

Function physical_cpu_groups

deepspeed/runtime/reflow/reflow_utils.py:188–201  ·  view source on GitHub ↗

Group available CPU IDs by the Linux package/core topology, without adding unavailable siblings.

(cpus)

Source from the content-addressed store, hash-verified

186
187
188def physical_cpu_groups(cpus):
189 """Group available CPU IDs by the Linux package/core topology, without adding unavailable siblings."""
190 groups = {}
191 for cpu in sorted(cpus):
192 topology = f"/sys/devices/system/cpu/cpu{cpu}/topology"
193 try:
194 with open(f"{topology}/physical_package_id") as handle:
195 package = int(handle.read())
196 with open(f"{topology}/core_id") as handle:
197 core = int(handle.read())
198 except (OSError, ValueError) as error:
199 raise ValueError("Reflow physical CPU placement requires readable Linux CPU topology") from error
200 groups.setdefault((package, core), []).append(cpu)
201 return list(groups.values())
202
203
204def partition_physical_cpus(cpus, ranks, position):

Callers 3

partition_physical_cpusFunction · 0.85
split_cpu_worker_coresFunction · 0.85
_isolate_rank_cpu_setsFunction · 0.85

Calls 2

readMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected