Skip to content

Commit c43f56e

Browse files
efiksfacebook-github-bot
authored andcommitted
[training] Adding NUMA support for pytorch (pytorch#150597)
Summary: X-link: pytorch/FBGEMM#3926 X-link: facebookresearch/FBGEMM#1014 Add entry point and environment variable to control NUMA binding / assigment for distributed pytorch runs (training). Test Plan: build and run tests for modified libraries locally Differential Revision: D72321369
1 parent 60a45eb commit c43f56e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Diff for: torch/_utils_internal.py

+5
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,8 @@ def record_chromium_event_internal(
274274
event: dict[str, Any],
275275
):
276276
return None
277+
278+
def maybe_enable_numa_binding(
279+
device_type: Optional[str] = None, device_id: Optional[int] = None
280+
):
281+
return None

Diff for: torch/distributed/distributed_c10d.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@
4444
Store,
4545
Work,
4646
)
47-
from torch._utils_internal import set_pytorch_distributed_envs_from_justknobs
47+
from torch._utils_internal import (
48+
maybe_enable_numa_binding,
49+
set_pytorch_distributed_envs_from_justknobs,
50+
)
4851
from torch.monitor import _WaitCounter
4952
from torch.overrides import handle_torch_function, has_torch_function
5053
from torch.utils._typing_utils import not_none
@@ -1669,6 +1672,14 @@ def init_process_group(
16691672
# default map below.
16701673
backend = Backend.default_device_backend_map.get(device_id.type)
16711674

1675+
1676+
# If device_id is provide try to bind current process to the
1677+
# NUMA node attached to the device
1678+
if device_id is not None:
1679+
maybe_enable_numa_binding(device_type=device_id.type, device_id=device_id.index)
1680+
else:
1681+
maybe_enable_numa_binding()
1682+
16721683
# If we still cannot figure it out, e.g.
16731684
# >>> init_process_group()
16741685
# we set it to `undefined` and rely on lazy init.

0 commit comments

Comments
 (0)