Skip to content

Commit 3a0d737

Browse files
committed
feat: add metadata bridge for Python CUDA export
Add a private metadata-only bridge on PyVortex arrays so the optional CUDA extension can reconstruct arrays through its own local Vortex session instead of passing Rust ArrayRef values across Python extension modules. The CUDA extension now parses the metadata tree, calls local array plugins for deserialization, and exports bufferless arrays through the Arrow C Device capsule path. The capsule ownership code handles live and consumed capsule names and releases Arrow resources on error paths. Physical buffer handoff remains a follow-up. Signed-off-by: "Alexander Droste" <alexander.droste@protonmail.com> Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
1 parent 33d6e07 commit 3a0d737

10 files changed

Lines changed: 541 additions & 9 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vortex-cuda/src/arrow/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,14 +543,14 @@ fn released_device_array(device_id: i64) -> ArrowDeviceArray {
543543
}
544544

545545
/// Release an Arrow C schema if it is live.
546-
fn release_schema(schema: &mut FFI_ArrowSchema) {
546+
pub fn release_schema(schema: &mut FFI_ArrowSchema) {
547547
if let Some(release) = schema.release {
548548
unsafe { release(schema) };
549549
}
550550
}
551551

552552
/// Release an Arrow device array if it is live.
553-
fn release_device_array(array: &mut ArrowDeviceArray) {
553+
pub fn release_device_array(array: &mut ArrowDeviceArray) {
554554
if let Some(release) = array.array.release {
555555
unsafe { release(&raw mut array.array) };
556556
}

vortex-python-cuda/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@ default = ["extension-module"]
2727
extension-module = []
2828

2929
[dependencies]
30+
arrow-schema = { workspace = true }
3031
pyo3 = { workspace = true, features = ["abi3", "abi3-py311"] }
32+
vortex = { workspace = true }
3133
vortex-cuda = { workspace = true }

vortex-python-cuda/pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ name = "vortex-data-cuda"
44
dynamic = ["version", "description", "authors"]
55
requires-python = ">= 3.11"
66
# The CUDA extension package must exactly match the base package version because the two extensions
7-
# exchange Vortex IPC buffers. Keep this in sync with the workspace package version; release
8-
# automation may rewrite it when publishing a non-workspace version.
7+
# exchange private Vortex vtable metadata. Future buffer-handoff support will extend this private
8+
# bridge. Keep this in sync with the workspace package version; release automation may rewrite it
9+
# when publishing a non-workspace version.
910
dependencies = ["vortex-data==0.1.0"]
1011
classifiers = [
1112
"Development Status :: 4 - Beta",
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# SPDX-FileCopyrightText: Copyright the Vortex contributors
33

4-
from ._lib import cuda_available # pyright: ignore[reportMissingModuleSource]
4+
from ._lib import ( # pyright: ignore[reportMissingModuleSource]
5+
cuda_available,
6+
debug_array_metadata_dtype,
7+
export_device_array,
8+
)
59

6-
__all__ = ["cuda_available"]
10+
__all__ = ["cuda_available", "debug_array_metadata_dtype", "export_device_array"]

vortex-python-cuda/python/vortex_cuda/_lib.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
# SPDX-FileCopyrightText: Copyright the Vortex contributors
33

44
def cuda_available() -> bool: ...
5+
def debug_array_metadata_dtype(array: object) -> str: ...
6+
def export_device_array(
7+
array: object, requested_schema: object | None = None, **kwargs: object
8+
) -> tuple[object, object]: ...

0 commit comments

Comments
 (0)