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)
| 116 | |
| 117 | |
| 118 | def _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 | |
| 146 | def _find_free_port() -> int: |
no outgoing calls
no test coverage detected