Skip to content

Cache IPC handles per peer to avoid cross-peer VA collision - v1.23.x (#11756) - #11876

Merged
edgargabriel merged 4 commits into
openucx:v1.23.xfrom
mshanthagit:pr/peer-cache-cherrypick-v1.23.x
Sep 2, 2026
Merged

edgargabriel merged 4 commits into
openucx:v1.23.xfrom
mshanthagit:pr/peer-cache-cherrypick-v1.23.x

Conversation

@mshanthagit

Copy link
Copy Markdown
Contributor

What?

Cherry-picking a merged PR from the master branch (#11756)

Why?

Fixes potential cross-peer VA collisions

How?

Adding per-peer IPC handles cache

@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

int ret;

pthread_rwlock_rdlock(&cache->lock);
/* A per-cache lock would be needed only if the caller holds no lock or

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale/misleading comment in uct_rocm_ipc_cache_map_region:

/* A per-cache lock would be needed only if the caller holds no lock or
 * just a read lock on the global remote-cache lock, allowing concurrent
 * access to this page table. */

The map path is always entered under the global write lock, so this hypothetical explanation about "no lock or just a read lock" reads as if there is an unlocked path in this function. Suggest tightening it to state the actual invariant, e.g. that the caller must hold the global write lock so the page table needs no additional locking. Not blocking.

@svc-nvidia-pr-review

Copy link
Copy Markdown

Test coverage: This is an internal flow change with no ROCm CI hardware; relying on existing IPC gtest coverage is reasonable. Worth confirming with the author that the existing IPC tests were run on a ROCm box, since the cache path is fully rewritten.

@mshanthagit
mshanthagit force-pushed the pr/peer-cache-cherrypick-v1.23.x branch from 2d1938f to 63da570 Compare September 1, 2026 17:58
@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

int ret;

pthread_rwlock_rdlock(&cache->lock);
/* A per-cache lock would be needed only if the caller holds no lock or

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment describes a per-cache lock that "would be needed only if the caller holds no lock or just a read lock," but the only caller (uct_rocm_ipc_cache_map_memhandle) always takes the global write lock. As written it reads like there is an optional/conditional locking path. Suggest simplifying to state plainly that the page table is protected by the global remote-cache write lock held by the caller, so no per-cache lock is required.

}

ucs_debug("ROCm IPC component cache initialized");
it = kh_put(rocm_ipc_rem_cache, hash, key, &ret);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In uct_rocm_ipc_remote_cache_get, the CUDA reference asserts ret != UCS_KH_PUT_KEY_PRESENT after kh_put (since a preceding kh_get missed under the write lock). ROCm drops that assertion. Not a correctness bug, but adding the same ucs_assertv_always keeps the two implementations in sync and would catch an unexpected key-present state.

@@ -7,16 +7,15 @@
#define ROCM_IPC_MD_H

#include <uct/base/uct_md.h>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After removing pthread_mutex_t lock from uct_rocm_ipc_component_t, nothing in this header uses pthread anymore. The #include <pthread.h> can be dropped (or replaced by the added <ucs/sys/sys.h> which is now the needed include for ucs_sys_ns_t).

@svc-nvidia-pr-review

Copy link
Copy Markdown

Informational: md_attr->rkey_packed_size = sizeof(uct_rocm_ipc_key_t) grows because pid/pid_ns were appended to the key. ROCm IPC is intra-node and both ends run the same build, and there is no version negotiation for these internal keys, so this is acceptable; noting only that mixed old/new builds on the same node would not interoperate.

Informational: The map hot path now always takes the global write lock (even on cache hits), serializing all peers, whereas the old ROCm code took a per-cache read lock on hits. This matches the CUDA design intentionally, so it's an accepted tradeoff rather than a defect.

Informational: The static-cleanup detach path can still ucs_fatal if the ROCr runtime is already finalized at shutdown, but this behavior is pre-existing (unchanged by this PR).

Test coverage: This is an internal flow change with no ROCm CI hardware; relying on existing IPC gtest coverage is reasonable. Worth confirming with the author that the existing IPC tests were run on a ROCm box, since the cache path is fully rewritten.

@mshanthagit
mshanthagit marked this pull request as ready for review September 1, 2026 18:12

@edgargabriel edgargabriel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a cherry-pick, ignoring auto-review suggestions

@edgargabriel
edgargabriel merged commit 49c31e1 into openucx:v1.23.x Sep 2, 2026
162 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants