Skip to content

vulkan: tune KHR cooperative matrix support for Adreno GPUs - #29328

Merged
0cc4m merged 11 commits into
ggml-org:masterfrom
Raman-Raje:adreno_coopmat
Sep 24, 2026
Merged

0cc4m merged 11 commits into
ggml-org:masterfrom
Raman-Raje:adreno_coopmat

Conversation

@Raman-Raje

Copy link
Copy Markdown
Contributor

Overview

This PR enables VK_KHR_cooperative_matrix (coopmat) support in the Vulkan backend for Qualcomm Adreno GPUs that have hardware matrix cores. The initial target is Snapdragon 8 Elite Gen 6.

Coopmat is only enabled when the device exposes both VK_KHR_cooperative_matrix and VK_QCOM_cooperative_matrix_conversion. Adreno devices without these extensions keep their current behaviour and do not use coopmat.

Additional information

  • Adds a new vk_device_architecture::QUALCOMM_ADRENO value.
  • Qualcomm devices return coopmat support only when the architecture is QUALCOMM_ADRENO. Other Adreno GPUs are excluded.
  • Adds Adreno-specific medium warptiles (m_warptile, m_warptile_mmq) with 64-wide workgroups when coopmat is available.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: Yes. AI tools were used to help with testing and debugging.

@Raman-Raje
Raman-Raje requested a review from a team as a code owner September 23, 2026 17:03
@github-actions github-actions Bot added Vulkan Issues specific to the Vulkan backend ggml changes relating to the ggml tensor library for machine learning labels Sep 23, 2026
Comment thread ggml/src/ggml-vulkan/ggml-vulkan.cpp Outdated
device->mul_mat_l[i] = false;
device->mul_mat_m[i] = true;
device->mul_mat_s[i] = true;
device->mul_mat_s[i] = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it correct to disable these for non-coopmat qcom devices?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for non-coopmat Adreno there's no hardware minimum-tile constraint forcing s off, so disabling it there is unjustified. It should be !device->coopmat_support

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@0cc4m

0cc4m commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Is the PR title accurate? From the code it looks like it deactivates coopmat for non-Adreno Qualcomm devices instead, and it adds tuning for Adreno.

@Raman-Raje

Raman-Raje commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor Author

@0cc4m Coopmat should be enabled only for Adreno GPU's having matrix cores in hardware. For rest qualcomm devices it should be disabled.

@0cc4m

0cc4m commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

I don't disagree, but that's not what the title says. I assume currently coopmat is running on all Qualcomm devices, assuming they report coopmat support, but it's not running well?

@Raman-Raje Raman-Raje changed the title vulkan: enable KHR cooperative matrix support for Adreno GPUs vulkan: manage KHR cooperative matrix support for Adreno GPUs Sep 24, 2026
@Raman-Raje

Raman-Raje commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Updated the title. Manage is the correct word. Do you find any better alternative..?

@0cc4m 0cc4m changed the title vulkan: manage KHR cooperative matrix support for Adreno GPUs vulkan: tune KHR cooperative matrix support for Adreno GPUs Sep 24, 2026
return true;
}
case VK_VENDOR_ID_QUALCOMM:
return false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

@Raman-Raje Raman-Raje Sep 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This optimization needs a deeper analysis. For now return false to avoid calling the wrong shaders and breakdowns

Comment thread ggml/src/ggml-vulkan/ggml-vulkan.cpp Outdated
}
}
} else if(props.vendorID == VK_VENDOR_ID_QUALCOMM){
VK_LOG_DEBUG("ggml_vulkan: [DEBUG] Qualcomm Adreno GPU device=\""<< props.deviceName << "\")");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary. If you want a debug output for architectures it should be generic, not Qualcomm-only.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Forgot to remove this

@0cc4m
0cc4m merged commit 3423f94 into ggml-org:master Sep 24, 2026
16 of 21 checks passed
@BrewTestBot BrewTestBot mentioned this pull request Sep 24, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning Vulkan Issues specific to the Vulkan backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants