Skip to content

Commit a498c75

Browse files
authored
vulkan: fix GPU deduplication logic. (ggml-org#19222)
* vulkan: fix GPU deduplication logic. As reported in ggml-org#19221, the (same uuid, same driver) logic is problematic for windows+intel igpu. Let's just avoid filtering for MoltenVK which is apple-specific, and keep the logic the same as before 88d23ad - just dedup based on UUID. Verified that MacOS + 4xVega still reports 4 GPUs with this version. * vulkan: only skip dedup when both drivers are moltenVk
1 parent 3409ab8 commit a498c75

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

ggml/src/ggml-vulkan/ggml-vulkan.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5561,9 +5561,9 @@ static void ggml_vk_instance_init() {
55615561
// Check if there are two physical devices corresponding to the same GPU
55625562
// This handles the case where the same GPU appears with different drivers (e.g., RADV + AMDVLK on Linux),
55635563
// see https://github.com/ggml-org/llama.cpp/pull/7582 for original deduplication.
5564-
// However, for MoltenVK on macOS, multiple GPUs on the same card may report the same UUID,
5565-
// see https://github.com/KhronosGroup/MoltenVK/issues/2683. Until this is fixed, we'll only deduplicate
5566-
// when drivers differ (same driver + same UUID = likely different GPUs)
5564+
// MoltenVK on macOS may report the same UUID for distinct GPUs on multi-GPU cards,
5565+
// see https://github.com/KhronosGroup/MoltenVK/issues/2683. Skip when both old/new
5566+
// driver is MoltenVK
55675567
auto old_device = std::find_if(
55685568
vk_instance.device_indices.begin(),
55695569
vk_instance.device_indices.end(),
@@ -5580,11 +5580,9 @@ static void ggml_vk_instance_init() {
55805580
old_id.deviceLUIDValid && new_id.deviceLUIDValid &&
55815581
std::equal(std::begin(old_id.deviceLUID), std::end(old_id.deviceLUID), std::begin(new_id.deviceLUID))
55825582
);
5583+
bool both_molten_vk = (new_driver.driverID == vk::DriverId::eMoltenvk && old_driver.driverID == vk::DriverId::eMoltenvk);
55835584

5584-
// Only deduplicate if same UUID AND different drivers
5585-
// (same driver + same UUID on MoltenVK = likely different GPUs on multi-GPU card)
5586-
bool different_driver = (old_driver.driverID != new_driver.driverID);
5587-
return same_uuid && different_driver;
5585+
return same_uuid && !both_molten_vk;
55885586
}
55895587
);
55905588
if (old_device == vk_instance.device_indices.end()) {

0 commit comments

Comments
 (0)