llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders
Jeff Bolz 1bacb9f625
vulkan: further optimize mul_mat_vec using larger loads (#10387)
* vulkan: Use pipeline_robustness to disable robustness in mul_mat_vec.

Add some early returns for nonexistent rows in mul_mat_vec shaders. These
can only be hit when dispatching a 2D grid of workgroups. Fix the logic
for the 2D grid of workgroups to round up.

Enable the pipeline robustness extension if it's available, and use it to
disable robustness for these pipelines. The instructions to do the bounds
checking contend for the same ALU resources as the bit twiddling dequant
instructions.

* vulkan: Add GLSL structure aliases for quant types to allow larger loads

In Vulkan it's not possible to cast pointer types, so instead you have to
declare an aliased binding for the memory with a different type. This
commit adds aliases for the quant formats using 16b ints, and in a few
places where the struct size is a multiple of 4 also using 32b ints.
Currently only q4_k's aliases are used, but others will be used in
subsequent commits.

* vulkan: use larger loads in q5_k and q6_k shaders.

Similar to the optimization I did in q4_k recently, this vectorizes some loads
and reduces the number of bit twiddling instructions.

* vulkan: use larger K step per iteration in mul_mat_vec.

Add vec4 dequantization functions, and use them to do K=8 per iteration in
mul_mat_vec. This uses 16b loads for the quant values and 128b loads for B
which helps reduce the load on the memory system.

The K_PER_ITER==2 logic is still there, just for F16/F32, and really only
because they support unaligned sizes.

Tweak the num_iters/unrolling logic to be simpler and catch a couple missed
unrolling opportunities.
2024-11-20 08:11:00 +01:00
..
acc.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
add.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
argsort.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
clamp.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
CMakeLists.txt ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
concat.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
contig_copy.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
copy.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
cos.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
dequant_f32.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
dequant_funcs.comp vulkan: further optimize mul_mat_vec using larger loads (#10387) 2024-11-20 08:11:00 +01:00
dequant_head.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
dequant_iq4_nl.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
dequant_q2_k.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
dequant_q3_k.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
dequant_q4_0.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
dequant_q4_1.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
dequant_q4_k.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
dequant_q5_0.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
dequant_q5_1.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
dequant_q5_k.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
dequant_q6_k.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
dequant_q8_0.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
diag_mask_inf.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
div.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
gelu_quick.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
gelu.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
generic_binary_head.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
generic_head.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
generic_unary_head.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
get_rows_quant.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
get_rows.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
group_norm.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
im2col.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
leaky_relu.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
mul_mat_split_k_reduce.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
mul_mat_vec_base.comp vulkan: further optimize mul_mat_vec using larger loads (#10387) 2024-11-20 08:11:00 +01:00
mul_mat_vec_nc.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
mul_mat_vec_p021.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
mul_mat_vec_q2_k.comp vulkan: further optimize mul_mat_vec using larger loads (#10387) 2024-11-20 08:11:00 +01:00
mul_mat_vec_q3_k.comp vulkan: further optimize mul_mat_vec using larger loads (#10387) 2024-11-20 08:11:00 +01:00
mul_mat_vec_q4_k.comp vulkan: further optimize mul_mat_vec using larger loads (#10387) 2024-11-20 08:11:00 +01:00
mul_mat_vec_q5_k.comp vulkan: further optimize mul_mat_vec using larger loads (#10387) 2024-11-20 08:11:00 +01:00
mul_mat_vec_q6_k.comp vulkan: further optimize mul_mat_vec using larger loads (#10387) 2024-11-20 08:11:00 +01:00
mul_mat_vec.comp vulkan: further optimize mul_mat_vec using larger loads (#10387) 2024-11-20 08:11:00 +01:00
mul_mm.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
mul.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
norm.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
pad.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
pool2d.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
relu.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
repeat.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
rms_norm.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
rope_head.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
rope_neox.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
rope_norm.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
scale.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
silu.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
sin.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
soft_max.comp vulkan: Optimize soft_max (#10301) 2024-11-19 08:25:17 +01:00
square.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
sum_rows.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
tanh.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
timestep_embedding.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
types.comp vulkan: further optimize mul_mat_vec using larger loads (#10387) 2024-11-20 08:11:00 +01:00
upscale.comp ggml : build backends as libraries (#10256) 2024-11-14 18:04:35 +01:00
vulkan-shaders-gen.cpp vulkan: further optimize mul_mat_vec using larger loads (#10387) 2024-11-20 08:11:00 +01:00