From 8a7549fe74109f06290264121871ff2f3371df61 Mon Sep 17 00:00:00 2001 From: Eve <139727413+netrunnereve@users.noreply.github.com> Date: Sat, 13 Sep 2025 22:41:05 -0400 Subject: [PATCH 1/3] remove unsupported vulkan devices --- ggml/src/ggml-vulkan/ggml-vulkan.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vulkan.cpp index 4ccc498f3a2..1f18e98d37c 100644 --- a/ggml/src/ggml-vulkan/ggml-vulkan.cpp +++ b/ggml/src/ggml-vulkan/ggml-vulkan.cpp @@ -4621,6 +4621,29 @@ static void ggml_vk_instance_init() { } } + // Remove any unsupported devices + size_t num_unsupported = 0; + for (size_t i = 0; i < vk_instance.device_indices.size();) { + vk::PhysicalDevice vkdev = devices[vk_instance.device_indices[i]]; + + VkPhysicalDeviceFeatures2 device_features2; + device_features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; + + VkPhysicalDeviceVulkan11Features vk11_features; + vk11_features.pNext = nullptr; + vk11_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES; + device_features2.pNext = &vk11_features; + + vkGetPhysicalDeviceFeatures2(vkdev, &device_features2); + if (!vk11_features.storageBuffer16BitAccess) { + vk_instance.device_indices.erase(vk_instance.device_indices.begin() + i); + num_unsupported++; + } else + i++; + } + if (num_unsupported > 0) + GGML_LOG_DEBUG("ggml_vulkan: Removed %zu unsupported Vulkan devices.\n", vk_instance.device_indices.size()); + if (vk_instance.device_indices.empty()) { GGML_LOG_INFO("ggml_vulkan: No devices found.\n"); return; From 11c74f5bbfc37db6e6f85d184ebdca69dbcebfb2 Mon Sep 17 00:00:00 2001 From: Eve <139727413+netrunnereve@users.noreply.github.com> Date: Sun, 14 Sep 2025 13:04:11 -0400 Subject: [PATCH 2/3] make this happen during selection instead --- ggml/src/ggml-vulkan/ggml-vulkan.cpp | 41 +++++++++++----------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vulkan.cpp index 1f18e98d37c..21e11c3786c 100644 --- a/ggml/src/ggml-vulkan/ggml-vulkan.cpp +++ b/ggml/src/ggml-vulkan/ggml-vulkan.cpp @@ -4423,8 +4423,8 @@ static void ggml_vk_print_gpu_info(size_t idx) { static bool ggml_vk_instance_validation_ext_available(); static bool ggml_vk_instance_portability_enumeration_ext_available(const std::vector& instance_extensions); - static bool ggml_vk_instance_debug_utils_ext_available(const std::vector & instance_extensions); +static bool ggml_vk_device_is_supported(const vk::PhysicalDevice vkdev); static void ggml_vk_instance_init() { if (vk_instance_initialized) { @@ -4540,7 +4540,7 @@ static void ggml_vk_instance_init() { new_driver.pNext = &new_id; devices[i].getProperties2(&new_props); - if (new_props.properties.deviceType == vk::PhysicalDeviceType::eDiscreteGpu || new_props.properties.deviceType == vk::PhysicalDeviceType::eIntegratedGpu) { + if ((new_props.properties.deviceType == vk::PhysicalDeviceType::eDiscreteGpu || new_props.properties.deviceType == vk::PhysicalDeviceType::eIntegratedGpu) && ggml_vk_device_is_supported(devices[i])) { // Check if there are two physical devices corresponding to the same GPU auto old_device = std::find_if( vk_instance.device_indices.begin(), @@ -4621,29 +4621,6 @@ static void ggml_vk_instance_init() { } } - // Remove any unsupported devices - size_t num_unsupported = 0; - for (size_t i = 0; i < vk_instance.device_indices.size();) { - vk::PhysicalDevice vkdev = devices[vk_instance.device_indices[i]]; - - VkPhysicalDeviceFeatures2 device_features2; - device_features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; - - VkPhysicalDeviceVulkan11Features vk11_features; - vk11_features.pNext = nullptr; - vk11_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES; - device_features2.pNext = &vk11_features; - - vkGetPhysicalDeviceFeatures2(vkdev, &device_features2); - if (!vk11_features.storageBuffer16BitAccess) { - vk_instance.device_indices.erase(vk_instance.device_indices.begin() + i); - num_unsupported++; - } else - i++; - } - if (num_unsupported > 0) - GGML_LOG_DEBUG("ggml_vulkan: Removed %zu unsupported Vulkan devices.\n", vk_instance.device_indices.size()); - if (vk_instance.device_indices.empty()) { GGML_LOG_INFO("ggml_vulkan: No devices found.\n"); return; @@ -12761,6 +12738,20 @@ static bool ggml_vk_instance_debug_utils_ext_available( UNUSED(instance_extensions); } +static bool ggml_vk_device_is_supported(const vk::PhysicalDevice vkdev) { + VkPhysicalDeviceFeatures2 device_features2; + device_features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; + + VkPhysicalDeviceVulkan11Features vk11_features; + vk11_features.pNext = nullptr; + vk11_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES; + device_features2.pNext = &vk11_features; + + vkGetPhysicalDeviceFeatures2(vkdev, &device_features2); + + return vk11_features.storageBuffer16BitAccess; +} + static bool ggml_vk_khr_cooperative_matrix_support(const vk::PhysicalDeviceProperties& props, const vk::PhysicalDeviceDriverProperties& driver_props, vk_device_architecture arch) { switch (props.vendorID) { case VK_VENDOR_ID_INTEL: From 8b60f7a71e6ee15dfa60975d983f50324976454e Mon Sep 17 00:00:00 2001 From: Eve <139727413+netrunnereve@users.noreply.github.com> Date: Tue, 16 Sep 2025 20:28:45 -0400 Subject: [PATCH 3/3] pass by reference --- ggml/src/ggml-vulkan/ggml-vulkan.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vulkan.cpp index 3cd81bb1ce2..1f1136382e3 100644 --- a/ggml/src/ggml-vulkan/ggml-vulkan.cpp +++ b/ggml/src/ggml-vulkan/ggml-vulkan.cpp @@ -4424,7 +4424,7 @@ static void ggml_vk_print_gpu_info(size_t idx) { static bool ggml_vk_instance_validation_ext_available(); static bool ggml_vk_instance_portability_enumeration_ext_available(const std::vector& instance_extensions); static bool ggml_vk_instance_debug_utils_ext_available(const std::vector & instance_extensions); -static bool ggml_vk_device_is_supported(const vk::PhysicalDevice vkdev); +static bool ggml_vk_device_is_supported(const vk::PhysicalDevice & vkdev); static void ggml_vk_instance_init() { if (vk_instance_initialized) { @@ -12738,7 +12738,7 @@ static bool ggml_vk_instance_debug_utils_ext_available( UNUSED(instance_extensions); } -static bool ggml_vk_device_is_supported(const vk::PhysicalDevice vkdev) { +static bool ggml_vk_device_is_supported(const vk::PhysicalDevice & vkdev) { VkPhysicalDeviceFeatures2 device_features2; device_features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;