Skip to content

Commit 49f300d

Browse files
authored
feat: add metadata bridge for Python CUDA export (#8604)
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. Physical buffer handoff remains a follow-up. --------- Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
1 parent df5202f commit 49f300d

10 files changed

Lines changed: 543 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: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
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+
_debug_array_metadata_dtype as _debug_array_metadata_dtype, # pyright: ignore[reportPrivateUsage]
6+
)
7+
from ._lib import ( # pyright: ignore[reportMissingModuleSource]
8+
cuda_available,
9+
export_device_array,
10+
)
511

6-
__all__ = ["cuda_available"]
12+
__all__ = ["cuda_available", "export_device_array"]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# SPDX-FileCopyrightText: Copyright the Vortex contributors
33

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

0 commit comments

Comments
 (0)