Commit Graph
31 Commits
Author SHA1 Message Date
Ruben OrtlamandGeorgi Gerganov b47f39dba2 vulkan: disable FA mask_opt on GCN to improve performance (llama/24362)
* vulkan: disable FA mask_opt on GCN to improve performance

* reenable mask opt over attention head size 256
2026-07-10 13:06:42 +03:00
Ruben OrtlamandGeorgi Gerganov 06492a14a3 vulkan: for small AMD GPUs, reduce submission threshold based on CU count (llama/25240) 2026-07-10 13:06:42 +03:00
Ruben OrtlamandGeorgi Gerganov ba36235565 vulkan: use flops instead of weight tensor size for submission heuristic (llama/25005)
* vulkan: extract flops calculation into function

* use flops instead of matmul src0 tensor size for submission threshold

* use unsigned ints
2026-07-10 13:06:42 +03:00
Ruben OrtlamandGeorgi Gerganov d54eb4fe2e vulkan: fix step operator for 0 input (llama/25036) 2026-07-10 13:06:42 +03:00
Ruben OrtlamandGeorgi Gerganov 201f69ce6a Revert "cuda: reset cuda context after reading memory size (llama/23935)" (llama/24715)
This reverts commit 0f7fada56bea32c9e0db3874b801d887ff6c4529.
2026-06-19 12:53:43 +03:00
Ruben OrtlamandGeorgi Gerganov dc195118ef vulkan: add pipeline barriers for memcpy read operations (llama/23770)
* vulkan: add pipeline barriers for memcpy read/write operations

* remove unnecessary host write pipeline barriers
2026-06-19 12:53:43 +03:00
Ruben OrtlamandGeorgi Gerganov 686bc802d1 vulkan: add v_dot2_f32_f16 support in matrix-matrix multiplication and Flash Attention (llama/24123)
* vulkan: add support for valve fp16 dot2 extension

* use macro for dot2 path choice

* properly check for the feature

* add dot_product abstraction to reduce preprocessor branching
2026-06-15 10:33:53 +03:00
Ruben OrtlamandGeorgi Gerganov 782f1226c8 cuda: reset cuda context after reading memory size (llama/23935)
* cuda: reset device in get_memory function if no backend is active

* also count device and host buffers

* exclude hip and musa from counting and device reset

* use device mutex instead of atomic

* undo backend_free function move
2026-06-15 10:33:53 +03:00
Ruben OrtlamandGeorgi Gerganov 1777deff4c vulkan: check coopmat2 features before reporting support (llama/24186) 2026-06-08 14:36:36 +03:00
Ruben OrtlamandGeorgi Gerganov 5a1feed8ca vulkan: add fwht support for Intel with shmem reduction (llama/23964)
* vulkan: add fwht support for Intel with shmem reduction

* don't use N as workgroup size

* disable subgroup shuffle on MoltenVK AMD

* disable fwht shader on Intel Windows due to driver bug
2026-06-08 14:36:36 +03:00
Ruben OrtlamandGeorgi Gerganov 4317ddbe2b vulkan: add Flash Attention support for BFloat16 KV cache (llama/23420)
* vulkan: add flash attention bf16 kv support

* vulkan: bf16 FA coopmat1 support

* vulkan: bf16 FA coopmat2 support

* fix FA bf16 f32 fallback

* fix FA bf16 coopmat1 shader

* fix FA bf16 coopmat2 shader

* code cleanup

* cleanup comment change

* address feedback

* add O_TYPE for cm2 FA

* use O_TYPE for gqaStore function

* reduce BFLOAT16 ifdefs
2026-06-08 14:36:36 +03:00
Ruben OrtlamandGeorgi Gerganov 97ba44338f vulkan: fix matmul integer pipeline selection (llama/23005)
* vulkan: fix matmul integer pipeline selection

* gate pipeline creation with the right bools
2026-05-25 12:26:07 +03:00
0c7c3ba570 vulkan: add get/set tensor 2d functions (llama/22514)
* vulkan: add get/set_tensor_2d functions

* fix backend interface comments

* Update ggml/src/ggml-metal/ggml-metal.cpp

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
2026-05-01 13:07:35 +03:00
Ruben OrtlamandGeorgi Gerganov 7fe6b8e171 vulkan: optimize im2col (llama/21713)
* vulkan: improve im2col memory write layout

* cap workgroups

* minimal device tuning

* use vendor_id instead of subgroup size
2026-04-30 11:29:10 +03:00
Ruben OrtlamandGeorgi Gerganov 0f99a47177 vulkan: Flash Attention DP4A shader for quantized KV cache (llama/20797)
* use integer dot product for quantized KV flash attention

* small improvements

* fix SHMEM_STAGING indexing

* add missing KV type quants

* fixes

* add supported quants to FA tests

* readd fast paths for <8bit quants

* fix mmq gate and shmem checks
2026-04-30 11:29:07 +03:00
Ruben OrtlamandGeorgi Gerganov 1d555510de vulkan: unify type macros to use Vx instead of _VECx (llama/21605) 2026-04-30 11:29:04 +03:00
Ruben OrtlamandGeorgi Gerganov 759f0084b4 vulkan: add noncontiguous GLU support (llama/21081)
* vulkan: add noncontiguous GLU support

* fix compile issue
2026-03-29 15:04:36 +03:00
Ruben OrtlamandGeorgi Gerganov 16ca5e6fb1 vulkan: disable mmvq on Intel Windows driver (llama/20672)
* vulkan: disable mmvq on Intel Windows driver

* improve comment
2026-03-29 15:04:36 +03:00
Ruben OrtlamandGeorgi Gerganov 0ad6ceef59 vulkan: async and event fixes (llama/20518)
* vulkan: fix event wait submission, event command buffer reset

* fix event command buffer reset validation error

* also reset command buffers before reuse

* use timeline semaphores instead of fences for event_synchronize

* don't use initializer list for semaphore wait info

* use multiple events to avoid reset issues

* fix event reuse issue with multiple vectors

* add semaphore wait condition also if compute_ctx already exists

* remove event pending stage
2026-03-29 15:04:36 +03:00
Ruben OrtlamandGeorgi Gerganov 49adc8b470 vulkan: allow graphics queue only through env var (llama/20599)
* vulkan: avoid graphics queue on non-RADV AMD drivers

* avoid graphics queues on small GPUs

* change to only use graphics queue if overridden with env var GGML_VK_ALLOW_GRAPHICS_QUEUE

* reenable transfer queue if graphics queue is not used
2026-03-29 15:04:36 +03:00
Ruben OrtlamandGeorgi Gerganov 724ea71cf9 vulkan: fix flash attention dot product precision (llama/20589) 2026-03-29 15:04:36 +03:00
Ruben OrtlamandGeorgi Gerganov cd02195b8f vulkan: use graphics queue on AMD (llama/20551)
* vulkan: use graphics queue on AMD for slightly better performance

* disable async transfer queue on AMD
2026-03-16 13:10:15 +02:00
Ruben OrtlamandGeorgi Gerganov 890c047e30 vulkan: skip zero size tensors in backend copies (llama/20233) 2026-03-16 13:10:15 +02:00
Ruben OrtlamandGeorgi Gerganov 923a292429 vulkan: tune MMVQ for Intel Windows (llama/19988) 2026-03-16 13:10:15 +02:00
Ruben OrtlamandGeorgi Gerganov 2a9649c420 vulkan: improve partial offloading performance on AMD (llama/19976)
* vulkan: fix and enable cpy_tensor_async function

* use transfer_queue for async transfers on AMD, synchronize with timeline semaphore

* update offload_op logic

* fix missing transfer submission

* disable async transfer queue on AMD GCN

* revert op batch size change

* fix cpy_tensor_async checks
2026-03-16 13:10:15 +02:00
Ruben OrtlamandGeorgi Gerganov e722ee1bf5 vulkan: fix fp16 Flash Attention on Windows AMD RDNA2 and below (llama/19921) 2026-02-27 20:57:58 +02:00
Ruben OrtlamandGeorgi Gerganov 90800b5aa5 Vulkan Scalar Flash Attention Refactor (llama/19625)
* vulkan: allow using fp16 in scalar flash attention shader

* split rows inside of subgroups for faster synchronization

* use row_split when Br >= 4, change reductions to use shared memory if row_split == 1

* use f32 scalar FA if f16 is not supported by device

* fix amd workgroup size issue

* optimize masksh use

* add medium rows FA shader Br size

* fixes

* add padding to mask shmem buffer

* cache q values into registers for KQ

* fuse lf accumulation, pf and v accumulation into a loop

* stage K loads through shmem

* stage V loads through shmem

* only stage through shmem on Nvidia

* default to Bc 32

* also stage V through shmem when this is done for K

* dynamic subgroups for intel

* use vectorized stores

* use float_type for dequantize4 functions

* use smaller scalar rows size for smaller rows count

* relax flash attention split_k condition to allow non-gqa use

* use minimal subgroup size on Intel

* fix shmem support function

* fix rebase issues

* fixes

* Bc 4 for scalar FA is not a valid configuration

* Use wave32 on AMD RDNA for scalar FA

* add Intel shader core count lookup-table

* fix regressions

* device tuning

* tmpsh size fix

* fix editorconfig

* refactor fa tuning logic into a single place

* fix gqa opt logic

* fix block_rows with small n_rows

* amd tuning

* fix hsk=72/80 issue

* tuning

* allow condition skipping for column check

* use float16 for Of if available

* address feedback

* fix bad RDNA performance on head size <= 128 by limiting occupancy

* allow printing pipeline stats

* cleanup and fixes

* limit occupancy for GCN for small batch FA with large HSK

* disable f16 FA for GCN AMD GPUs on the proprietary driver
2026-02-27 20:57:58 +02:00
Ruben OrtlamandGeorgi Gerganov 3f68f30907 vulkan: fix MMQ shader push constants and multi-dispatch (llama/19732) 2026-02-27 20:57:58 +02:00
Ruben OrtlamandGeorgi Gerganov aa34558b6f vulkan: disable coopmat1 fa on Nvidia Turing (llama/19290) 2026-02-08 09:29:10 +02:00
Ruben OrtlamandGeorgi Gerganov 33148bb523 Vulkan Flash Attention Coopmat1 Refactor (llama/19075)
* vulkan: use coopmat for flash attention p*v matrix multiplication

* fix P loading issue

* fix barrier position

* remove reduction that is no longer needed

* move max thread reduction into loop

* remove osh padding

* add bounds checks and padding

* remove unused code

* fix shmem sizes, loop duration and accesses

* don't overwrite Qf, add new shared psh buffer instead

* add missing bounds checks

* use subgroup reductions

* optimize

* move bounds check, reduce barriers

* support other Bc values and other subgroup sizes

* remove D_split

* replace Of register array with shared memory Ofsh array

* parallelize HSV across the rowgroups

* go back to Of in registers, not shmem

* vectorize sfsh

* don't store entire K tile in shmem

* fixes

* load large k tiles to shmem on Nvidia

* adapt shared memory host check function to shader changes

* remove Bc 32 case

* remove unused variable

* fix missing mask reduction tmspsh barrier

* fix mask bounds check

* fix rowmax f16 under/overflow to inf

* fix flash_attn_cm2 BLOCK_SIZE preprocessor directives
2026-01-30 15:56:40 +02:00
Ruben OrtlamandGeorgi Gerganov 49762e8fb3 vulkan: work around Intel fp16 bug in mmq (llama/18814) 2026-01-30 15:56:40 +02:00