[Interop] Prototype Vulkan opaque-FD import for CUDA and AMDGPU - #904
Draft
rglebovamd wants to merge 1 commit into
Draft
[Interop] Prototype Vulkan opaque-FD import for CUDA and AMDGPU#904rglebovamd wants to merge 1 commit into
rglebovamd wants to merge 1 commit into
Conversation
hughperkins
reviewed
Sep 3, 2026
| The `copy` parameter is supported on `to_numpy()` and `to_torch()` for `ScalarField`, `MatrixField` (and `VectorField`), `StructField`, `qd.Tensor`, and all `Ndarray` types. See [Zero-copy interop via DLPack](#zero-copy-interop-via-dlpack) for the support matrix and lifetime rules. | ||
|
|
||
|
|
||
| ## Prototype Vulkan external-memory import |
Collaborator
There was a problem hiding this comment.
please remove the word 'prototype' from the doc
hughperkins
reviewed
Sep 3, 2026
| ## Prototype Vulkan external-memory import | ||
|
|
||
| `quadrants.interop.VkImport` is a Linux-only prototype for importing a Vulkan | ||
| `VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD` allocation into the active CUDA or |
Collaborator
There was a problem hiding this comment.
.md docs should not be line-wrapped
hughperkins
reviewed
Sep 3, 2026
| in both directions and may require imported/exported binary or timeline | ||
| semaphores rather than device-wide host synchronization. | ||
|
|
||
| ### Current limitations |
hughperkins
reviewed
Sep 3, 2026
| uses device-wide synchronization and assumes the Vulkan queue is flushed by the | ||
| producer/consumer call sequence. | ||
|
|
||
| A production implementation must define specification-valid memory visibility |
Collaborator
There was a problem hiding this comment.
replace 'A production implementation' with 'FIXME:'
hughperkins
reviewed
Sep 3, 2026
|
|
||
| `release_to_vulkan()` completes compute-device work before Vulkan consumes the | ||
| allocation. `acquire_from_vulkan()` completes the current prototype's ownership | ||
| boundary before compute reads Vulkan-written memory. The prototype currently |
hughperkins
reviewed
Sep 3, 2026
| @@ -0,0 +1,382 @@ | |||
| """Prototype Linux Vulkan opaque-FD import for API review and validation. | |||
|
|
|||
| The implementation intentionally uses ctypes and device-wide synchronization. | |||
Collaborator
There was a problem hiding this comment.
comments should be 120c wrapped, not 80c
Add a Linux-only review prototype for importing Vulkan opaque-FD allocations into the active CUDA or AMDGPU backend and exposing the mapped logical range through DLPack. The constructor uses transactional FD ownership and validates allocation, offset, logical size, shape, and dtype before consuming the caller handle. The prototype uses device-wide synchronization; production synchronization may require external semaphores or stream integration.
rglebovamd
force-pushed
the
rglebov/vkimport-prototype
branch
from
September 3, 2026 18:27
ebad6e3 to
7f3b81f
Compare
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.
Context
The Nyx AMD/ROCm integration needs an API-neutral way to import Vulkan external-memory allocations into the active Quadrants CUDA or AMDGPU backend. Nyx exports an opaque FD plus the full allocation size, logical payload size, and byte offset. The Genesis plugin should not select or call CUDA/HIP directly.
This is the quick prototype requested for API/design review. It is intentionally a draft, Linux-only, and not presented as the final production implementation.
Prototype approach
quadrants.interop.VkImport.VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FDthrough CUDA Driver or HIP based on the active Quadrants backend.release_to_vulkan()andacquire_from_vulkan()ownership-boundary methods.close().Validation performed
Using the Nyx integration on AMD and NVIDIA:
Important prototype limitations / review questions
ctypes?VkImportobject to outlive every tensor view and uses a no-op DLPack deleter. What ownership model should the final API expose?release_to_vulkan()/acquire_from_vulkan()names before the Nyx plugin pins them.Test
The Nyx plugin PRs remain drafts until this API is finalized, released/pinned, and the real CUDA/AMD conformance matrix passes.
Semaphore capability note
Both tested Vulkan devices report timeline-semaphore support and CUDA exposes the required external-semaphore functions. However, the ROCm 7.2 HIP headers explicitly document
hipImportExternalSemaphore,hipSignalExternalSemaphoresAsync, andhipWaitExternalSemaphoresAsyncas unsupported on Linux. The public API should therefore keep semaphores optional and retain a device/queue synchronization fallback for the initial AMD Linux path unless runtime probing shows the HIP documentation is stale.