LLM inference in C/C++
C++ ggml
vulkan: prefer host-visible memory buffers on UMA devices (#22930)
Winston Ma32120c10e33b
diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vulkan.cppindex 59582e4f0f..243ab76ee7 100644--- a/ggml/src/ggml-vulkan/ggml-vulkan.cpp+++ b/ggml/src/ggml-vulkan/ggml-vulkan.cpp@@ -3080,8 +3080,10 @@ static vk_buffer ggml_vk_create_buffer_device(vk_device& device, size_t size) {buf = ggml_vk_create_buffer(device, size, {vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent,vk::MemoryPropertyFlagBits::eDeviceLocal});} else if (device->uma) {- // Fall back to host memory type- buf = ggml_vk_create_buffer(device, size, {vk::MemoryPropertyFlagBits::eDeviceLocal,+ // On UMA, prefer host-visible memory so direct tensor borrowing works.+ // If unavailable, fall back to device-local memory.+ buf = ggml_vk_create_buffer(device, size, {vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent,+ vk::MemoryPropertyFlagBits::eDeviceLocal,vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent});} else if (device->disable_host_visible_vidmem) {if (device->allow_sysmem_fallback) {