[WIP][UR][CUDA][TEST] Add P2P initialization to multi-device test#21311
Draft
[WIP][UR][CUDA][TEST] Add P2P initialization to multi-device test#21311
Conversation
6adf0fa to
bdf212d
Compare
bdf212d to
8218555
Compare
Fix CUDA adapter to properly map P2P access errors: - Map CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED to UR_RESULT_ERROR_INVALID_OPERATION - Map CUDA_ERROR_PEER_ACCESS_NOT_ENABLED to UR_RESULT_ERROR_INVALID_OPERATION Initialize P2P access in urEnqueueKernelLaunchIncrementMultiDeviceTest: - Add urUsmP2PEnablePeerAccessExp calls in SetUp() for cross-device memcpy - Add urUsmP2PDisablePeerAccessExp calls in TearDown() for cleanup - Skip P2P operations for duplicate device handles (single GPU case) - Accept INVALID_OPERATION for already-enabled or unsupported pairs This fixes test failures on multi-GPU CUDA systems where P2P must be explicitly enabled before cross-device USM memory operations. Fixes #19033
eb4568d to
06a8429
Compare
Changes: - Track enabled P2P pairs in member variable enabledP2PPairs - SetUp: Only record pairs WE successfully enabled (both SUCCESS) - TearDown: Disable P2P bidirectionally for our pairs, ignore errors - Removes global P2P state dependency between test instances Works for both: - 2 physical GPUs duplicated 4× (8 logical devices) - 8 distinct physical GPUs Fixes #19033
The CUDA adapter was using cuMemcpyAsync() for all USM memory copies, including cross-device copies. However, CUDA requires cuMemcpyPeerAsync() for peer-to-peer copies between different devices, even when P2P access is enabled via cuCtxEnablePeerAccess(). This change: - Detects cross-device copies by querying CU_POINTER_ATTRIBUTE_CONTEXT for both source and destination pointers - Uses cuMemcpyPeerAsync() when contexts differ (cross-device copy) - Falls back to cuMemcpyAsync() for same-device or host-device copies This fixes the urEnqueueKernelLaunchIncrementMultiDeviceTest which chains kernel launches and cross-device memcpy operations. Fixes: #19033
In single-context multi-device setup on CUDA, pointer attributes cannot reliably distinguish cross-device copies because all allocations share the same CUDA context and may report device ordinal 0. Solution: When context has >1 device, try cuMemcpyPeerAsync for all device pairs until one succeeds. Falls back to cuMemcpyAsync if none work or if single-device context. This is a workaround - proper solution would track allocation metadata.
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.
Initialize P2P access between device pairs in
urEnqueueKernelLaunchIncrementMultiDeviceTest to enable cross-device USM memcpy operations on CUDA.
This is a test commit to validate the fix on multi-GPU hardware.