From fb934bf4a086970a0f6c0dc5533d7439bd65b36c Mon Sep 17 00:00:00 2001 From: Simao Gomes Viana Date: Wed, 25 Mar 2026 14:10:02 +0100 Subject: [PATCH] ggml-vulkan: fall back to CPU when 16-bit storage is unavailable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, missing storageBuffer16BitAccess threw std::runtime_error("Unsupported device") which crashed the process on platforms where C++ exceptions propagate as uncaught aborts (Android). Some drivers also report the feature bit but don't enumerate VK_KHR_16bit_storage as a device extension — pushing it into device_extensions then causes vkCreateDevice to fail with ErrorExtensionNotPresent (another fatal abort on Android). Instead of throwing, set pipeline_failures so supports_op returns false for all ops and the backend scheduler routes everything to CPU. Only push VK_KHR_16bit_storage when the extension is actually enumerated. --- ggml/src/ggml-vulkan/ggml-vulkan.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vulkan.cpp index 8fa9d1da9..5689e7355 100644 --- a/ggml/src/ggml-vulkan/ggml-vulkan.cpp +++ b/ggml/src/ggml-vulkan/ggml-vulkan.cpp @@ -5253,12 +5253,18 @@ static vk_device ggml_vk_get_device(size_t idx) { #endif } - if (!vk11_features.storageBuffer16BitAccess) { - std::cerr << "ggml_vulkan: device " << GGML_VK_NAME << idx << " does not support 16-bit storage." << std::endl; - throw std::runtime_error("Unsupported device"); + if (!vk11_features.storageBuffer16BitAccess || !fp16_storage) { + GGML_LOG_WARN("ggml_vulkan: device %s%zu does not support 16-bit storage " + "(feature=%d, extension=%d), falling back to CPU\n", + GGML_VK_NAME, idx, + (int)vk11_features.storageBuffer16BitAccess, + (int)fp16_storage); + device->pipeline_failures.store(1, std::memory_order_relaxed); } - device_extensions.push_back("VK_KHR_16bit_storage"); + if (fp16_storage) { + device_extensions.push_back("VK_KHR_16bit_storage"); + } #ifdef GGML_VULKAN_VALIDATE device_extensions.push_back("VK_KHR_shader_non_semantic_info");