Repository navigation
Vulkan: route large matmuls to medium tile on Adreno - #24877
Conversation
sync with master
The llama-cli was breaking for longer promts sizes for q4_0 quantized networks. Causing due to insufficient shared memory.
|
Hi @Raman-Raje, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
|
The code should be checking against the shared memory limit already. How much shared memory does the device support? Which specific shader is causing an issue? What is your command line to reproduce the failure? |
Raman-Raje
left a comment
There was a problem hiding this comment.
Removed the dead code
There was a problem hiding this comment.
Thanks @jeffbolznv.
Llama-cli fails when the batch exceeds 64 with a long (>200 token) prompt; with batch ≤ 64 the same long prompts work fine.
./llama-cli -m models/Llama-3B-Q4_0.gguf -p <prompt with 200 tokens>
The large q4_0 matmul tile. For non-coopmat devices, ggml_vk_guess_matmul_pipeline routes M,N > 64 to mmp->l, so the large tile gets selected at that point and breaks on Adreno. Forcing the medium tile (mul_mat_l = false) fixes it.
|
So the shared memory thing was just the AI guessing? Please share the exact symptoms you're seeing, and also run with the vulkan validation layers enabled if possible. |
|
Without changes: vulkan debug shader log: wich changes works fine |
|
Why also disable the small pipeline? That was done for MoltenVK due to correctness issues. |
UPdated changes |
|
@jeffbolznv please review |
jeffbolznv
left a comment
There was a problem hiding this comment.
It would be nice to understand the failure better, but there's a chance it's just a compiler bug so I'm OK with this.
Sync with main
|
This is not gonna get merged if you keep changing it, I have to retrigger the CI every time. |
|
it was closed by mistake. Will avoid it. Thanks |
|
@0cc4m Is anything missing from my side to merge this..? |
|
No, thank you for the reminder. |
* [Vulkan] Fixes llama-cli breaking over longer promts sizes The llama-cli was breaking for longer promts sizes for q4_0 quantized networks. Causing due to insufficient shared memory. * Removed the un-used Adreno device * Updated matmul for small pipeline.
* [Vulkan] Fixes llama-cli breaking over longer promts sizes The llama-cli was breaking for longer promts sizes for q4_0 quantized networks. Causing due to insufficient shared memory. * Removed the un-used Adreno device * Updated matmul for small pipeline.
Overview
On Qualcomm Adreno GPUs (Vulkan backend), inference with q4_0 models breaks, once the prompt grows past ~200 tokens and the batch exceeds 32. Short prompts
work fine.
Additional information
For non-coopmat devices, ggml_vk_guess_matmul_pipeline picks the tile by M/N:
M,N <= 32 -> small, <= 64 -> medium, otherwise -> large. With a long prompt the large q4_0 tile gets selected, and that shader fails on Adreno.
The per-type guard (ggml_vk_matmul_shmem_support) doesn't disable the large tile here because its computed footprint (~16.9 KB) is under the reported maxComputeSharedMemorySize, so the large tile stays enabled and is hit at runtime.
Before: crashes/hangs on long prompts with q4_0 on Adreno.
After: long-prompt inference completes; short prompts unchanged.
Requirements
I have read and agree with the contributing guidelines
AI usage disclosure: NO