Skip to content

vulkan: add UMA dual-access mode for zero-copy CPU access on iGPUs#1

Closed
essentialols wants to merge 1 commit into
masterfrom
vulkan-uma-dual-access
Closed

vulkan: add UMA dual-access mode for zero-copy CPU access on iGPUs#1
essentialols wants to merge 1 commit into
masterfrom
vulkan-uma-dual-access

Conversation

@essentialols

@essentialols essentialols commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Enable direct CPU access to GPU buffer contents on UMA devices without copies
  • On AMD APU iGPUs, CPU and GPU share LPDDR5 -- lets CPU read/write GPU buffers directly

Changes (+38 lines, 1 file: ggml-vulkan.cpp)

  1. is_host callback: reports buffers as host-accessible on UMA when dual-access enabled (was NULL)
  2. get_base: returns real host-mapped pointer instead of sentinel vk_ptr_base
  3. vk_tensor_offset: computes offsets from actual buffer base

Gating

GGML_VK_UMA_DUAL_ACCESS env var (opt-in). Only on UMA devices. Zero change when unset.

Context

PR ggml-org#22930 already allocates buffers with DEVICE_LOCAL+HOST_VISIBLE+HOST_COHERENT on UMA, so the memory IS host-mapped. But get_base returns a sentinel and is_host is NULL, preventing upper layers from using direct access. This patch bridges that gap.

On UMA (Unified Memory Architecture) devices like AMD APU iGPUs, CPU
and GPU share the same physical memory. This patch enables the CPU to
directly access GPU buffer contents without copies by:

1. Reporting Vulkan device buffers as host-accessible via the is_host
   callback when the device is UMA and dual-access mode is enabled
2. Returning the real host-mapped pointer from get_base instead of the
   sentinel vk_ptr_base, enabling direct CPU reads/writes
3. Computing tensor offsets from the actual buffer base address rather
   than the sentinel, so CPU-side pointer arithmetic is correct

Gated behind GGML_VK_UMA_DUAL_ACCESS env var. When unset, behavior
is identical to before (is_host returns false, get_base returns the
sentinel). Only effective on UMA devices (integrated GPUs).

This eliminates unnecessary GPU-to-CPU transfer operations on iGPUs
where both processors already see the same physical memory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant