Nx.Vulkan.VulkanoBackend (nx_vulkan v0.1.0)

Copy Markdown View Source

Pure-Rust (vulkano) Nx.Backend implementation. Sibling of Nx.Vulkan.Backend (C++ spirit-backed); same compute fabric, different memory-management story.

Tensors are represented by:

%Nx.Vulkan.VulkanoBackend{ref: ResourceArc<VulkanoTensor>,
                          shape: tuple, type: {kind, bits}}

The ref is a Rustler resource owning an Arc<Subbuffer<u8>> in vulkano. When the BEAM GCs the Elixir reference, vulkano's Drop runs vkDestroyBuffer + vkFreeMemory. Stale-handle bugs (where a freed VkBuf* is read back at the C++ layer) are structurally impossible: the Subbuffer cannot outlive its Buffer.

Status — storage-only baseline

This module implements just the storage callbacks required for tensors to round-trip host↔GPU without crashing:

  • init/1, from_binary/3, to_binary/2
  • backend_copy/3, backend_transfer/3, backend_deallocate/1
  • inspect/2, constant/3, iota/3, eye/2

Compute ops (add / multiply / sum / matmul / …) are not yet implemented. To use this backend for actual computation, configure Nx to fall back via Nx.BinaryBackend for ops, or call Nx.backend_transfer(t, Nx.BinaryBackend) before computing.

The next port chunk will add per-op compute NIFs to Nx.Vulkan.NativeV and wire them here.