Revert gPid rank suffix and fix nolocal/vnode topology host assignment#2074
Closed
Regina8023 wants to merge 2 commits intometa-pytorch:mainfrom
Closed
Revert gPid rank suffix and fix nolocal/vnode topology host assignment#2074Regina8023 wants to merge 2 commits intometa-pytorch:mainfrom
Regina8023 wants to merge 2 commits intometa-pytorch:mainfrom
Conversation
…gmentMem test (meta-pytorch#2073) Summary: **Summary:** Fix `ExportMultiSegmentMem` test and `AsyncSocket` variable-length message receive bug. 1. `CtranMapper::regMem` has a `FB_CHECKABORT(segments.size() == 1)` that fatally aborts when called with a buffer backed by multiple physical segments (e.g., `kCuMemAllocDisjoint`). This test allocates disjoint memory with `CTRAN_IPC_INLINE_SEGMENTS + 1` physical segments, which always triggers the abort. The fix replaces `mapper->regMem`/`deregMem` with `RegCache::globalRegister`/`globalDeregister`, which natively support multi-segment buffers. 2. `AsyncSocket.cc`: Fix IOBuf under-reservation in computeTotalSize(). `IOBuf::reserve(minHeadroom, minTailroom)` sets an absolute minimum tailroom, not a delta. When `IOBuf::create(sizeof(IpcReq))` rounds capacity up (e.g., jemalloc gives 512 for a 500-byte request), partial tailroom remains after reading the header. The old code reserve(0, needed - tailroom) requested too few bytes — after the next read consumed the available tailroom, 0 bytes remained for subsequent reads, causing folly to error with getReadBuffer() returned empty buffer. Fix: `reserve(0, needed)` to guarantee enough tailroom for the full remaining payload. 3. Also renames the BUCK target from `regcache_init_none` to `regcache_dist_ut_init_none` to match the intended target name. Reviewed By: dsjohns2 Differential Revision: D100862851
Summary: ### Summary Reverts [D92879823](https://www.internalfb.com/diff/D92879823) which appended `:rank` to `gPid()` format (`hostname:pid:rank`). This contradicts the purpose of the IPC import cache (`ipcRemRegMap_`), which should be keyed by process identity (`hostname:pid`) since CUDA IPC handles are per-process, not per-rank. Using per-rank keys creates duplicate cache entries for ranks in the same process and causes key mismatches between `ipcRemRegMap_` (keyed by `gPid`) and `remImportMap_` (keyed by `localPeerId_` which is `hostname:pid`). D92879823 was a workaround for MCCL tests using NOLOCAL topology mode, where `initRankTopologyNolocal()` never assigned `rankState.host` (stayed `""`) or `rankState.pid` (stayed `-1`), causing all ranks to have identical `gPid = ":-1"`. The proper fix is to assign the synthetic hostname to `rankState.host` so that `gPid()` naturally returns unique values without needing the rank suffix. ### Changes **`CommStateX.cc`**: - `initRankTopologyNolocal()`: Assign `rankState.host = nolocalHost` (`"nolocal_node_<r>"`) so `gPid()` returns `"nolocal_node_0:-1"`, `"nolocal_node_1:-1"`, etc. — unique per rank without the `:rank` suffix. - `initRankTopologyVnode()`: Same fix — assign `rankState.host = vNodeHost` (`"vnode_node_<nodeId>"`) for consistency. - `gPid()`: Revert to `hostname:pid` format (remove `:rank` suffix), restoring alignment with `localPeerId_` and IPC cache key semantics. ### Why - **IPC handles are per-process**: `cudaIpcOpenMemHandle` returns the same mapped base regardless of which rank in the process calls it. `hostname:pid` is the natural process identifier. - **Deduplication**: With `hostname:pid`, same-process ranks share one cache entry with proper refcounting. With `hostname:pid:rank`, they create duplicate entries. Reviewed By: elvinlife Differential Revision: D100055198
Contributor
|
@Regina8023 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100055198. |
Contributor
|
This pull request has been merged in f6779a6. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Summary
Reverts D92879823 which appended
:ranktogPid()format (hostname:pid:rank). This contradicts the purpose of the IPC import cache (ipcRemRegMap_), which should be keyed by process identity (hostname:pid) since CUDA IPC handles are per-process, not per-rank. Using per-rank keys creates duplicate cache entries for ranks in the same process and causes key mismatches betweenipcRemRegMap_(keyed bygPid) andremImportMap_(keyed bylocalPeerId_which ishostname:pid).D92879823 was a workaround for MCCL tests using NOLOCAL topology mode, where
initRankTopologyNolocal()never assignedrankState.host(stayed"") orrankState.pid(stayed-1), causing all ranks to have identicalgPid = ":-1". The proper fix is to assign the synthetic hostname torankState.hostso thatgPid()naturally returns unique values without needing the rank suffix.Changes
CommStateX.cc:initRankTopologyNolocal(): AssignrankState.host = nolocalHost("nolocal_node_<r>") sogPid()returns"nolocal_node_0:-1","nolocal_node_1:-1", etc. — unique per rank without the:ranksuffix.initRankTopologyVnode(): Same fix — assignrankState.host = vNodeHost("vnode_node_<nodeId>") for consistency.gPid(): Revert tohostname:pidformat (remove:ranksuffix), restoring alignment withlocalPeerId_and IPC cache key semantics.Why
cudaIpcOpenMemHandlereturns the same mapped base regardless of which rank in the process calls it.hostname:pidis the natural process identifier.hostname:pid, same-process ranks share one cache entry with proper refcounting. Withhostname:pid:rank, they create duplicate entries.Reviewed By: elvinlife
Differential Revision: D100055198