MCPcopy Create free account
hub / github.com/FlashSampling/FlashSampling / _numa_bind

Function _numa_bind

src/fused_mm_sampling/tp_info.py:118–143  ·  view source on GitHub ↗

Pin this process to the CPU cores on the same NUMA node as the GPU. A binding failure (e.g. Modal's gVisor returning an empty CPU set) leaves the process unbound and produces inconsistent benchmark numbers, so we abort instead of warn. Missing torch.numa.binding (older torch) is still

(rank: int)

Source from the content-addressed store, hash-verified

116
117
118def _numa_bind(rank: int) -> None:
119 """Pin this process to the CPU cores on the same NUMA node as the GPU.
120
121 A binding failure (e.g. Modal's gVisor returning an empty CPU set) leaves
122 the process unbound and produces inconsistent benchmark numbers, so we
123 abort instead of warn. Missing torch.numa.binding (older torch) is still
124 tolerated since the platform simply does not support binding.
125 """
126 try:
127 from torch.numa.binding import (
128 AffinityMode,
129 NumaOptions,
130 _apply_numa_binding_to_current_thread,
131 )
132 except ImportError as e:
133 warnings.warn(
134 f"Rank {rank}: torch.numa.binding unavailable, skipping bind: {e}",
135 stacklevel=2,
136 )
137 return
138
139 _apply_numa_binding_to_current_thread(
140 gpu_index=rank,
141 numa_options=NumaOptions(affinity_mode=AffinityMode.NODE),
142 )
143 print(f"Rank {rank}: NUMA-bound to CPUs {sorted(os.sched_getaffinity(0))}", flush=True)
144
145
146def _find_free_port() -> int:

Callers 1

_distributed_workerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected