100 Commits
Author SHA1 Message Date
Jeff BolzandGeorgi Gerganov 83105b7c3c vulkan: extend topk_moe fusion to support sqrt(softplus) (llama/26124) 2026-08-04 13:37:47 +03:00
Jeff BolzandGeorgi Gerganov 23feefc7c7 vulkan: Support quantized concat (llama/25684) 2026-08-04 13:37:47 +03:00
Jeff BolzandGeorgi Gerganov df03e266f1 vulkan: Workaround compiler bug in conv2d coopmat2 path (llama/24924)
* vulkan: Workaround compiler bug in conv2d coopmat2 path

* apply same workaround to CONV_3D

* Apply suggestion from @jeffbolznv
2026-06-26 16:03:57 +03:00
Jeff BolzandGeorgi Gerganov 792da0ecdb vulkan: Apply bias before softmax in FA, to avoid overflow (llama/24909) 2026-06-26 16:03:57 +03:00
Jeff BolzandGeorgi Gerganov 3fc2c57a63 vulkan: support all backend tests for SQR/SQRT/SIN/COS/CLAMP/LEAKY_RELU/NORM (llama/24582)
* vulkan: make SQR/SQRT/SIN/COS/CLAMP/LEAKY_RELU use unary.comp

* vulkan: make NORM support noncontig

* add noncontiguous row test cases for norm/l2_norm, handle this in the CPU backend and l2_norm.comp

* fix supports_op for cuda and webgpu
2026-06-26 16:03:57 +03:00
Jeff BolzandGeorgi Gerganov 1fdbfb19eb vulkan: Support GET_ROWS_BACK (llama/24883) 2026-06-26 16:03:57 +03:00
Jeff BolzandGeorgi Gerganov c25eb26c32 vulkan: support CONV_3D (llama/24612)
* vulkan: support CONV_3D

This is a pretty direct port of conv2d_mm.comp to CONV_3D, done by codex
and cleaned up by me.

* disable slower perf tests
2026-06-26 16:03:57 +03:00
Jeff BolzandGeorgi Gerganov cc0d00f610 vulkan: make mul_mm ALIGNED a spec constant (llama/24689)
This trims down some of the shader variant explosion and reduces binary size.
2026-06-26 16:03:57 +03:00
Jeff BolzandGeorgi Gerganov 93c02083bd vulkan: Support gated_delta_net with S_v=16 (llama/24581) 2026-06-19 12:53:43 +03:00
Jeff BolzandGeorgi Gerganov d77b2f704c vulkan: support more CONCAT types (llama/24579) 2026-06-19 12:53:43 +03:00
Jeff BolzandGeorgi Gerganov 1216e0957b vulkan: support non-contig unary/glu ops (llama/24215)
* vulkan: support non-contig unary/glu ops

Change unary/glu ops to pass in all strides and use fastdiv for the index
calculation. Put all unary ops in one file, similar to glu, to share the
code. codex went ahead and added expm1 without me asking, but I had to
make it do a real precision analysis rather than just making stuff up.

unary.comp initially couldn't use generic_unary_head because there wasn't
space for xielu's additional constants. Fixing this required packing the
fastdiv 'L' values.

* attempt to workaround compiler bug

* resolve conflict from #23991

* use expm1
2026-06-19 12:53:43 +03:00
Jeff BolzandGeorgi Gerganov afd559279c vulkan: ifdef eMesaHoneykrisp (build fix) (llama/24479)
Fixes build/CI after #24306.
2026-06-15 10:33:53 +03:00
Jeff BolzandGeorgi Gerganov dc794303d8 vulkan: reduce iq1 shared memory usage for mul_mm (llama/24287) 2026-06-15 10:33:53 +03:00
Jeff BolzandGeorgi Gerganov fbf720dc9f vulkan: Use cm2 decode_vector for mul_mat_id B matrix loads (llama/23991)
This allows vec4 loads of the B elements. Also increase BK to 64 when this is
enabled. Neither of these alone is consistently faster, but together these give
a nice speedup.

In ggml-vulkan.cpp, we need to make sure the B matrix alignment and stride are
multiples of 4.
2026-06-15 10:33:53 +03:00
Jeff BolzandGeorgi Gerganov 71d80aa49e vulkan: don't hold the device mutex while compiling pipelines (llama/23641)
* vulkan: don't hold the device mutex while compiling pipelines

We need to hold a lock while we traverse all pipelines and lazily initialize
them, but we don't need to hold it while the pipeline is being compiled. And
it doesn't need to be the same lock as the device mutex. We call load_shaders
each time a pipeline is needed, so we only need to compile that one pipeline
(and, for example, don't want to end up compiling a pipeline that another
thread should be compiling).

* remove 'needed'
2026-06-08 14:36:36 +03:00
Jeff BolzandGeorgi Gerganov b896e91f18 vulkan: fast path for walsh-hadamard transform (llama/23687)
* vulkan: fast path for walsh-hadamard transform

* disable for intel due to segfault
2026-05-29 09:47:30 +03:00
Jeff BolzandGeorgi Gerganov 1b590bbb9a vulkan: use GL_NV_cooperative_matrix_decode_vector for faster matmul (llama/23541) 2026-05-29 09:47:30 +03:00
Jeff BolzandGeorgi Gerganov a0efd13f0f vulkan: optimize conv2d and implement coopmat1 support (llama/22620)
* vulkan: add CONV_SHAPE_64x128 for medium-K conv2d

* vulkan: skip conv2d bounds checks when shapes align with tile sizes

* vulkan: use WG_SIZE=128 for CONV_SHAPE_64x32 conv2d

* vulkan: stage cm2 conv2d accumulator through shmem before global store

* vulkan: add coopmat1 conv2d path

* fallback when using too much shared memory. clean up comments

* Require 16x16x16 and subgroup size 32 or 64

* check whether shared memory is sufficient before overwriting conv2d params with coopmat1 values
2026-05-29 09:47:30 +03:00
Jeff BolzandGeorgi Gerganov a369b3949c ggml : Parallelize quant LUT init (llama/23595)
- Use OpenMP to parallelize iq2xs_init_impl and iq3xs_init_impl.
- Move the OpenMP detection from ggml-cpu to ggml-base.
- Update OpenMP dependencies in ggml-config.cmake.in.
2026-05-25 12:26:07 +03:00
Jeff BolzandGeorgi Gerganov 6b85d73b33 vulkan: fix windows find_package of SPIRV-Headers (llama/23215)
* vulkan: fix windows find_package of SPIRV-Headers

* not windows-only
2026-05-25 12:26:07 +03:00
Jeff BolzandGeorgi Gerganov e417ce7aeb vulkan: Support unaligned tensors for ROPE (llama/22637) 2026-05-25 12:26:07 +03:00
Jeff BolzandGeorgi Gerganov c7dd64c606 vulkan: fuse SSM_CONV + BIAS + SILU (llama/22653) 2026-05-25 12:26:07 +03:00
Jeff BolzandGeorgi Gerganov 20895abdbd vulkan: Check shared memory size for mmq shaders (llama/22693) 2026-05-14 21:26:48 +03:00
Jeff BolzandGeorgi Gerganov c0c1f994b7 vulkan: Support asymmetric FA in scalar/mmq/coopmat1 paths (llama/22589) 2026-05-14 21:26:48 +03:00
Jeff BolzandGeorgi Gerganov 95053f68e4 vulkan: Support asymmetric FA in coopmat2 path (llama/21753)
* vulkan: Support asymmetric FA in coopmat2 path

There has been some recent interest/experimentation with mixed quantization
types for FA. I had originally designed the cm2 FA shader with this in mind
(because I didn't realize it wasn't supported at the time!), this change
adds the missing pieces and enables it.

Also support Q1_0 since people have been trying that out (seems crazy, but
who knows).

We should be able to do similar things in the coopmat1/scalar path, but
there's another change open against the scalar path and I don't want to
conflict.

* reorder cases
2026-05-02 15:02:42 +03:00
Jeff BolzandGeorgi Gerganov 35fa508360 vulkan: add barrier after writetimestamp (llama/21865) 2026-04-30 11:29:22 +03:00
Jeff BolzandGeorgi Gerganov 85bbc82209 vulkan: Support F16 OP_FILL (llama/22177) 2026-04-30 11:29:14 +03:00
Jeff BolzandGeorgi Gerganov 45365fa111 vulkan: Programmatically add RoundingModeRTE to all shaders when the device supports it (llama/21572)
* vulkan: Programmatically add RoundingModeRTE to all shaders when the device supports it

* use FetchContent to get SPIRV-Headers

* Fetch spirv-headers unconditionally

* remove fetchcontent, rely on installed headers

* fix ubuntu job

* Update docs/build.md
2026-04-30 11:29:08 +03:00
Jeff BolzandGeorgi Gerganov cdeaa34174 vulkan: Support GGML_TYPE_NVFP4 (llama/21455)
This adds nvfp4 support for get_rows, dequant, and mul_mat(_id). For
mul_mat, it does not add support for the dp4/q8_1 path, it's all via
fp16/fp32.
2026-04-30 11:29:07 +03:00
Jeff BolzandGeorgi Gerganov 458ad1d93e vulkan: Support Q1_0 (llama/21539)
* vulkan: Support Q1_0

* use get_dm
2026-04-30 11:29:05 +03:00
Jeff BolzandGeorgi Gerganov 49b505bcc5 vulkan: change gated_delta_net to shard a column across a subgroup (llama/20662)
* vulkan: change gated_delta_net to shard a column across a subgroup

This is based on https://github.com/ggml-org/llama.cpp/pull/20391, I used an
LLM to port the CUDA code to Vulkan, and guided to it to make various fixes to
work with Vulkan (e.g. handling different subgroup sizes, unknown mapping of
subgroup to invocation id, using subgroupAdd optionally, etc.).

This fixes a perf regression from the transposing of the values in memory
(!20443).

* vulkan: Spread columns across fewer lanes to reduce the number of workgroups
2026-03-29 15:04:36 +03:00
Jeff BolzandGeorgi Gerganov 86e312d61d vulkan: fix l2_norm epsilon handling (llama/20350) 2026-03-16 13:10:15 +02:00
Jeff BolzandGeorgi Gerganov 6c5e3aac3e vulkan: fix OOB check in flash_attn_mask_opt (llama/20296) 2026-03-16 13:10:15 +02:00
Jeff BolzandGeorgi Gerganov 4b0653a792 vulkan: Fix data races in coopmat1 mul_mat(_id) (llama/20084)
* vulkan: Fix data races in coopmat1 mul_mat(_id)

Add barriers between coopmat store and regular loads. We sort of got away with
this because it was the same subgroup accessing the values, but it's still a
race and may not work.

* switch to subgroup control barriers
2026-03-16 13:10:15 +02:00
Jeff BolzandGeorgi Gerganov fb55b2654b vulkan: check for memory overlap before doing fusion (llama/19768)
* vulkan: check for memory overlap before doing fusion

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

* address feedback
2026-02-27 20:57:58 +02:00
Jeff BolzandGeorgi Gerganov dcc877688d vulkan: fix coopmat1 without bf16 support (llama/19793) 2026-02-27 20:57:58 +02:00
Jeff BolzandGeorgi Gerganov 344eae3d22 vulkan: fix data race in mul_mat_id shader (llama/19790) 2026-02-27 20:57:58 +02:00
Jeff BolzandGeorgi Gerganov f1da0a26f5 vulkan: split mul_mat into multiple dispatches to avoid overflow (llama/19509)
* vulkan: split mul_mat into multiple dispatches to avoid overflow

The batch dimensions can be greater than the max workgroup count limit,
in which case we need to split into multiple dispatches and pass the base
index through a push constant.

Fall back for the less common p021 and nc variants.

* address feedback
2026-02-27 20:57:58 +02:00
Jeff BolzandGeorgi Gerganov cc448def01 vulkan: support L2_NORM with contiguous rows (llama/19604) 2026-02-15 21:44:37 +02:00
Jeff BolzandGeorgi Gerganov 197e9ab6eb vulkan: support GGML_OP_SET (llama/19584) 2026-02-15 21:44:37 +02:00
Jeff BolzandGeorgi Gerganov ec57bf407c vulkan: restore -inf check in FA shaders (llama/19582) 2026-02-15 21:44:37 +02:00
Jeff BolzandGeorgi Gerganov cea22b3075 vulkan: For coopmat2 FA, use fp16 accumulators for the final result (llama/19376)
The cpu and cuda backends use fp16 for the VKQ accumulator type, this change
does the same for vulkan. This helps particularly with large head sizes which
are very register-limited.

I tried this for the coopmat1 path and it slowed down a bit. I didn't try for
scalar.

I applied the softmax bias that the cuda backend uses to avoid overflow,
although I was not able to reproduce the original bug without it.
2026-02-08 09:29:10 +02:00
Jeff BolzandGeorgi Gerganov c1b63354bb vulkan: make FA mask/softcap enables spec constants (llama/19309)
* vulkan: make FA mask/softcap enables spec constants

* don't specialize for sinks

* bump timeout a little bit
2026-02-08 09:29:10 +02:00
Jeff BolzandGeorgi Gerganov a567c140a3 vulkan: Preprocess FA mask to detect all-neg-inf and all-zero. (llama/19281)
Write out a 2-bit code per block and avoid loading the mask when it
matches these two common cases.

Apply this optimization when the mask is relatively large (i.e. prompt
processing).
2026-02-08 09:29:10 +02:00
Jeff BolzandGeorgi Gerganov 5a786f7648 vulkan: Set k_load_shmem to false when K is too large (llama/19301) 2026-02-08 09:29:10 +02:00
Jeff BolzandGeorgi Gerganov e0a3f393ad vulkan: fix non-contig rope (llama/19299) 2026-02-08 09:29:10 +02:00
Jeff BolzandGeorgi Gerganov b7e323f40b vulkan: Remove transfer_ctx, do everything in compute_ctx. (llama/18945)
* vulkan: Remove transfer_ctx, do everything in compute_ctx.

We had a bug where a set_tensor_async (using transfer_ctx) didn't get
submitted before the graph_compute (using compute_ctx) that came after
it. To avoid this sort of issue, just do everything in compute_ctx.

Remove transfer_cmd_pool, which was already unused.

* fix crash with perf logger
2026-01-30 15:56:40 +02:00
Jeff BolzandGeorgi Gerganov b2bc4d810b vulkan: support flash attention GQA/split_k with small batches (llama/18938) 2026-01-30 15:56:40 +02:00
Jeff BolzandGeorgi Gerganov 660d943ff8 vulkan: Use mul_mat_vec_id for small values of n (llama/18918)
Change ggml_vk_mul_mat_vec_id_q_f16 to loop over the batch dimension and
update the indexing calculations in get_offsets.

Mat-vec is faster than mat-mat for small values of n. We don't get the same
reuse of the weights as in the non-ID path, but with this the cost is linear
in n rather than n>1 being far slower than n==1.
2026-01-30 15:56:40 +02:00
Jeff BolzandGeorgi Gerganov 4b155e9bfb vulkan: Check maxStorageBufferRange in supports_op (llama/18709)
* vulkan: Check maxStorageBufferRange in supports_op

* skip maxStorageBufferRange check when shader64BitIndexing is enabled
2026-01-30 15:56:40 +02:00
Jeff BolzandGeorgi Gerganov ab1828dc1c vulkan: change memory_logger to be controlled by an env var (llama/18769) 2026-01-14 09:11:59 +02:00
Jeff BolzandGeorgi Gerganov aedf332ec5 vulkan: Use VK_EXT_shader_64bit_indexing to handle large mat_mul(_id) (llama/18678)
This fixes incoherent output in Llama-4-Maverick-17B-128E-PAB-Q8_0, which
has a mul_mat_id with an A matrix that's Q8_0 8192 x 5120 x 128.

This should work when the number of blocks in the A matrix is less than 2^32
(for mul_mat_vec or mul_mm_cm2), or for mul_mm I think the limit is like
2^32*LOAD_VEC_A elements.

- Divide batch_stride by QUANT_K earlier, so the block index calculation works in 32b.
- Each vk_pipeline_struct has a linked list of pipelines that will allow it to handle
variants. So far this change just adds a single use case for this, compiling with the
e64BitIndexingEXT flag.
- Use the 64b indexing variant when the A matrix is larger than maxStorageBufferRange.

64-bit indexing has some cost - around 3-5% in MoE models, so it's worth the effort
to avoid enabling it unconditionally.
2026-01-14 09:11:59 +02:00
Jeff BolzandGeorgi Gerganov 0bc0e5616e vulkan: fix push constant size for quantize_q8_1 (llama/18687)
I added an assert to catch further mismatches, and it found several.
Fix those, too.
2026-01-14 09:11:59 +02:00
Jeff BolzandGeorgi Gerganov 678c660e62 vulkan: optimize ssm_scan (llama/18630)
* vulkan: optimize ssm_scan

* fix warp vs subgroup naming
2026-01-14 09:11:59 +02:00
Jeff BolzandGeorgi Gerganov a91ab72bd9 vulkan: reject ops when a tensor is too large to allocate (llama/18646) 2026-01-14 09:11:59 +02:00
Jeff BolzandGeorgi Gerganov dbec71f6cf vulkan: support buffer_from_host_ptr (llama/18467)
* vulkan: support buffer_from_host_ptr

* hacky use of buffer_from_host_ptr for directio

* disable buffer_from_host_ptr cap

* use external memory for ggml_vk_host_malloc, revert model loader changes

* disable external_memory_host for MoltenVK

* take buffer memory types into account

* don't use external_memory_host for ggml_vk_host_malloc
2026-01-14 09:11:59 +02:00
Jeff BolzandGeorgi Gerganov 52ba45e2b8 vulkan: fix topk_moe_sigmoid_norm_bias failures in GLM-4.6 (llama/18582) 2026-01-14 09:11:59 +02:00
Jeff BolzandGeorgi Gerganov 0a99b4c377 vulkan: handle quantize_q8_1 overflowing the max workgroup count (llama/18515)
* vulkan: handle quantize_q8_1 overflowing the max workgroup count

* vulkan: Fix small tile size matmul on lavapipe

* fix mul_mat_id failures
2026-01-14 09:11:59 +02:00
Jeff BolzandGeorgi Gerganov 9d83865607 vulkan: Optimize GGML_OP_CUMSUM (llama/18417)
* vulkan: Optimize GGML_OP_CUMSUM

There are two paths: The preexisting one that does a whole row per workgroup
in a single shader, and one that splits each row into multiple blocks and does
two passes. The first pass computes partials within a block, the second adds
the block partials to compute the final result. The multipass shader is used
when there are a small number of large rows.

In the whole-row shader, handle multiple elements per invocation.

* use 2 ELEM_PER_THREAD for AMD/Intel

* address feedback
2026-01-14 09:11:59 +02:00
Jeff BolzandGeorgi Gerganov b7ff521e71 vulkan: Implement mmvq for iq1_s/iq1_m (llama/18450) 2026-01-14 09:11:59 +02:00
Jeff BolzandGeorgi Gerganov b1f65a4a7e vulkan: extend topk_moe to handle sigmoid w/exp_probs_b for nemotron (llama/18295)
* vulkan: extend topk_moe to handle sigmoid w/exp_probs_b for nemotron

Also handle GGML_OP_SCALE at the end (nemotron, deepseek2).

Fewer pipeline variants and spec constants, just use push constants.

In test_topk_moe, change exp_probs_b to be 1D, matching real networks.

Update test-backend-ops and ggml-backend to allow verifying multiple outputs
in a fusion test (topk_moe has two outputs). Previously only the final node
was verified.

* change test_topk_moe to allow results in arbitrary order

* disable sigmoid fusion for moltenvk
2026-01-14 09:11:59 +02:00
Jeff BolzandGeorgi Gerganov 015b618d96 vulkan: preprocess mul_mat_id experts and discard workgroups more quickly (llama/18352)
Run a preprocess to count how many times each expert is used, and use this to
quickly discard workgroups that aren't needed.
2025-12-31 17:52:09 +02:00
Jeff BolzandGeorgi Gerganov e37c8ed94e vulkan: optimize decodeFuncB in coopmat2 mul_mat_id shader (llama/18349)
* vulkan: Use BK=32 for coopmat2 mul_mat_id

* vulkan: optimize decodeFuncB in coopmat2 mul_mat_id shader

Disable robustness, remove the OOB check in decodeFuncB, and initialize the
row_ids to zero to avoid OOB access.

Don't slice/offset the B matrix to ic * BN, only to adjust the coord back down
to the range [0, BN) in decodeFuncB. Instead just slice with a row offset of
zero and remove the '& (BN - 1)'. This allows the compiler to common some of
the shared memory loads.
2025-12-31 17:52:09 +02:00
Jeff BolzandGeorgi Gerganov 331c6ccd31 vulkan: Use BK=32 for coopmat2 mul_mat_id (llama/18332) 2025-12-31 17:52:09 +02:00
Jeff BolzandGeorgi Gerganov 181e36f194 vulkan: Support UPSCALE w/antialias (llama/18327) 2025-12-31 17:52:09 +02:00
Jeff BolzandGeorgi Gerganov 67473fef57 vulkan: handle rope with large number of rows (llama/18306) 2025-12-31 17:52:09 +02:00
Jeff BolzandGeorgi Gerganov f863735caa vulkan: fix command buffer corruption in ggml_backend_vk_event_wait (llama/18302) 2025-12-31 17:52:09 +02:00
Jeff BolzandGeorgi Gerganov dbbe6c11b5 vulkan: Extend rope fusions to allow mrope (llama/18264)
Extend the test-backend-ops tests as well.
2025-12-31 17:52:09 +02:00
Jeff BolzandGeorgi Gerganov 98e59a43d1 vulkan: Implement set_tensor_async and the event interfaces (llama/18047)
The goal is to enable the async loading code paths in
llama_model_loader::load_all_data, originally from #7896. This works and the
loads themselves are faster, but with host visible vidmem I think the cost of
allocating/mapping vidmem moves and becomes more expensive, and I don't see a
benefit by default. But with GGML_VK_DISABLE_HOST_VISIBLE_VIDMEM=1 I do see a
significant improvement in model loading time.
2025-12-31 17:52:09 +02:00
Jeff BolzandGeorgi Gerganov b893e0813a vulkan: fix im2col overflowing maxworkgroupcount (llama/18180) 2025-12-31 17:52:09 +02:00
Jeff BolzandGeorgi Gerganov f407c5e562 vulkan/cuda: fix topk_moe with exp_probs_b (llama/18071)
I updated test_topk_moe to more closely match llm_graph_context::build_moe_ffn
and added coverage for exp_probs_b and some other missing combinations. This
exposed a bug in both CUDA and Vulkan backends where they were assuming the
input to argsort and the input to get_rows are the same. I'd like to optimize
this graph in another change, but for now just get it functional.

CUDA also had a bug where it got n_experts from the wrong place, leading to
GGML_ASSERT failures in some of the new tests.
2025-12-31 17:52:09 +02:00
Jeff BolzandGeorgi Gerganov ad6ee3865d vulkan: support GGML_UNARY_OP_XIELU (llama/18062) 2025-12-31 17:52:09 +02:00
Jeff BolzandGeorgi Gerganov 3cd141f1a9 vulkan: in graph_optimize, try to group ADD operations (llama/18060)
I saw the adds not staying together in the new nemotron 3 nano model.
2025-12-31 17:52:09 +02:00
Jeff BolzandGeorgi Gerganov 195d8d0c65 vulkan: Add perf logger mode with concurrency (llama/17944)
This implements a variation of the perf logger where rather than timing each
operation individually with effectively a barrier in between, we put the
timing boundaries where we already synchronize and time the groups of work
that normally overlap. This can be useful to help understand whether
individual operations need to be optimized, or if the group is already running
efficiently.

GGML_VK_PERF_LOGGER_CONCURRENT=1 enables the new mode (when
GGML_VK_PERF_LOGGER is also set).

GGML_VK_SYNC_LOGGER=1 replaces the ENABLE_SYNC_LOGGING compile time switch.
2025-12-31 17:52:09 +02:00
Jeff BolzandGeorgi Gerganov af2c8cba6f vulkan: Fix data race/hang in scalar/cm1 flash attention (llama/17887) 2025-12-18 08:20:56 +02:00
Jeff BolzandGeorgi Gerganov b901ebe4a3 vulkan: support get_rows for i32 (llama/17941) 2025-12-18 08:20:56 +02:00
Jeff BolzandGeorgi Gerganov f33446643e vulkan: support GGML_OP_DIAG (llama/17893) 2025-12-18 08:20:56 +02:00
Jeff BolzandGeorgi Gerganov 939d3085e9 vulkan: Multi-pass softmax for large number of cols (llama/17892)
When the number of cols is large, split each row across multiple workgroups.
There are three phases that communicate partial results through temp buffers:
(1) compute max partials
(2) take max of partials, compute sum(exp(x-max)) partials
(3) sum partials, compute scaled result
2025-12-18 08:20:56 +02:00
Jeff BolzandGeorgi Gerganov 13bb296dbf vulkan: Allow non-pow2 n_experts in topk_moe (llama/17872) 2025-12-18 08:20:56 +02:00
Jeff BolzandGeorgi Gerganov 898f876fe2 vulkan: perf_logger improvements (llama/17672)
* vulkan: perf_logger improvements

- Move perf_logger from device to ctx.
- Add an env var to control the frequency we dump the stats. If you set a very
large value, it just dumps when the ctx is destroyed.
- Add a fusion info string to the tracking, only log one item per fused op.
- Fix MUL_MAT_ID flops calculation.

* fix vector sizes
2025-12-12 17:53:21 +02:00
Jeff BolzandGeorgi Gerganov c66c71e9f4 vulkan: Use one row per workgroup for f32 mmv (llama/17711)
The MoE models have a mul_mat_vec with very small m (32, 64, 128) right before
the topk_moe selection. Running multiple rows per wg doesn't utilize the SMs
well. I think even for larger m, f32 is so bandwidth-limited that running
multiple rows doesn't help.
2025-12-12 17:53:20 +02:00
Jeff BolzandGeorgi Gerganov 875d861473 vulkan: support solve_tri with larger N/K values (llama/17781)
Split N into chunks to fit into shared memory.
If K > 128, use a larger workgroup with enough invocations.
Add perf tests matching qwen3next.
2025-12-12 17:53:20 +02:00
Jeff BolzandGeorgi Gerganov 64a3f573e0 vulkan: add more num_blocks instantiations in rms_norm (llama/17701) 2025-12-12 17:53:19 +02:00
Jeff BolzandGeorgi Gerganov 0484147ab2 vulkan: fix top_k bug when there are ties in the input (llama/17659)
* vulkan: Reduce temporary memory usage for TOP_K

- Compute row size for the temp buffer based on the output of the first pass.
- Update shader addressing math to use the output row size
- Pass the output row size as "ncols_output", what used to be "ncols_output" is now "k"

For the common case of K=40 and src0=(200000,1,1,1), this reduces the temporary buffer
from about 3.2MB to 500KB.

* vulkan: fix top_k bug when there are ties in the input

I noticed by inspection a bug in the vulkan top_k shader where if the least
value in the top_k appears multiple times we could end up writing those extra
copies out rather than some larger values (if the larger values are on higher
numbered threads).

I rewrote the test verification to handle this case, where the final index set
is not necessarily the same.

* Update tests/test-backend-ops.cpp

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
2025-12-12 17:53:19 +02:00
Jeff BolzandGeorgi Gerganov 7e97d3b069 vulkan: enable mmvq for q2_k on NVIDIA (llama/17675) 2025-12-12 17:53:18 +02:00
Jeff BolzandGeorgi Gerganov 32ba1ec8e0 vulkan: set all memory allocations to high priority (llama/17624)
* vulkan: set all memory allocations to high priority

* gate by env var
2025-12-12 17:53:18 +02:00
Jeff BolzandGeorgi Gerganov 86cb5ab93f vulkan: Reduce temporary memory usage for TOP_K (llama/17623)
- Compute row size for the temp buffer based on the output of the first pass.
- Update shader addressing math to use the output row size
- Pass the output row size as "ncols_output", what used to be "ncols_output" is now "k"

For the common case of K=40 and src0=(200000,1,1,1), this reduces the temporary buffer
from about 3.2MB to 500KB.
2025-12-12 17:53:15 +02:00
Jeff BolzandGeorgi Gerganov dbf8766ffa vulkan: improve topk perf for large k, fix overflow in unit tests (llama/17582) 2025-12-12 17:53:12 +02:00
Jeff BolzandGeorgi Gerganov 7a20963140 vulkan: Implement GGML_OP_TRI (llama/17503)
* vulkan: Implement GGML_OP_TRI

* check types match
2025-12-12 17:53:11 +02:00
Jeff BolzandGeorgi Gerganov 3727a36c48 vulkan: Implement SOLVE_TRI (llama/17486)
* vulkan: Implement SOLVE_TRI

* load B matrix through shared memory

* use FLOAT_TYPE
2025-12-12 17:53:10 +02:00
Jeff BolzandGeorgi Gerganov 310db24fca vulkan: use a fixed 1KB buffer for the add_rms_fusion opt (llama/17514) 2025-12-12 17:53:10 +02:00
Jeff BolzandGeorgi Gerganov c8050e5fdc vulkan: allow graph_optimize for prompt processing workloads (llama/17475) 2025-12-12 17:53:09 +02:00
Jeff BolzandGeorgi Gerganov d8b61e05f8 vulkan: Implement top-k (llama/17418)
* vulkan: Implement top-k

Each pass launches workgroups that each sort 2^N elements (where N is usually 7-10)
and discards all but the top K. Repeat until only K are left. And there's a fast
path when K==1 to just find the max value rather than sorting.

* fix pipeline selection

* vulkan: Add N-ary search algorithm for topk

* microoptimizations
2025-12-12 17:53:09 +02:00
Jeff BolzandGeorgi Gerganov 208450048c vulkan: Implement GGML_OP_CUMSUM (llama/17479) 2025-12-12 17:53:08 +02:00
Jeff BolzandGeorgi Gerganov 273e4fe7ae vulkan: Use fewer rows for scalar FA when HS is not a multiple of 16 (llama/17455) 2025-12-12 17:53:07 +02:00
Jeff BolzandGeorgi Gerganov 553d57a4e7 vulkan: more FA details in vk_perf_logger (llama/17443) 2025-12-12 17:53:07 +02:00
Jeff BolzandGeorgi Gerganov deb4958add vulkan: remove a couple unnecessary switches (llama/17419) 2025-12-12 17:53:06 +02:00
Jeff BolzandGeorgi Gerganov cdc1a776be vulkan: disable async for older Intel devices (llama/17369)
* vulkan: disable async for older Intel devices

* update detection logic

* use name string for detection
2025-12-12 17:53:05 +02:00
Jeff BolzandGeorgi Gerganov 95d0b0b0cf vulkan: support larger argsort (llama/17313)
* vulkan: support larger argsort

This is an extension of the original bitonic sorting shader that puts the
temporary values in global memory and when more than 1024 threads are needed
it runs multiple workgroups and synchronizes through a pipelinebarrier.

To improve the memory access pattern, a copy of the float value is kept with
the index value. I've applied this same change to the original shared memory
version of the shader, which is still used when ncols <= 1024.

* Reduce the number of shader variants. Use smaller workgroups when doing a single pass, for a modest perf boost

* reduce loop overhead

* run multiple cols per invocation, to reduce barrier overhead
2025-12-12 17:53:04 +02:00
Jeff BolzandGeorgi Gerganov ae8865c6e6 vulkan: Add copy_transpose shader (llama/17371) 2025-12-12 17:53:04 +02:00