]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/log
pkg/ggml/sources/whisper.cpp
3 months agoopencl: OP_GATED_DELTA_NET (llama/23312)
ymcki [Thu, 28 May 2026 04:23:21 +0000 (12:23 +0800)]
opencl: OP_GATED_DELTA_NET (llama/23312)

* OP_GATED_DELTA_NET impl

* add back lanes_per_column declaration

* removed has_subgroup_arithmetic and has_subgroup_clustered_reduce

* removed trailing spaces and fixes indentation. Hard coded subgroup size for Adreno and Intel. Return not supported when K>1 state snapshot

* support for K>1 state snapshot

* removed picky indent multiple of 4 fixes

* removed return that won\'t be executed

3 months agoggml-webgpu: remove legacy constants (llama/23672)
Reese Levine [Wed, 27 May 2026 21:22:33 +0000 (14:22 -0700)]
ggml-webgpu: remove legacy constants (llama/23672)

3 months agohexagon: add support for Q4_1 in MUL_MAT and MUL_MAT_ID (llama/23647)
Max Krasnyansky [Wed, 27 May 2026 17:46:11 +0000 (10:46 -0700)]
hexagon: add support for Q4_1 in MUL_MAT and MUL_MAT_ID (llama/23647)

* hex-mm: add support for Q4_1 matmul/matvec, hvx-only for now

* hmx-mm: add support for Q4_1

* hex-mm: use Q8_1 dynamic quantization to avoid having to compute sums in the vec_dot

* hexagon: fix repack scratch buffer overflow

* hex-mm: fix Q4_1 repack buffer sizing

* hexagon: flip the build order for mm and fa (seems to help LTO)

* hex-mm: add vec_dot 4x1s and minor HMX cleanup after adding Q4_1

* hex-mm: fix fp16 vec_dot fallback to 2x1 and another issue that could cause incorrect output

* hexagon: resurrect early-wake and add support for polling for op-batch completions

With Q4_1 ggml-hexagon now claims pretty much the entire graphs which gives the CPU more time to chilax.
This is a good thing! But it does add extra latency for the pure benchmark runs.
Early wakeup helps recover the latency a bit in the normals runs and op-batch polling is just for benchmarking.

---------

Co-authored-by: Todor Boinovski <redacted>
3 months agoggml-webgpu: Fix how to dispatch WG to some ops (llama/23750)
Masashi Yoshimura [Wed, 27 May 2026 16:48:12 +0000 (01:48 +0900)]
ggml-webgpu: Fix how to dispatch WG to some ops (llama/23750)

3 months agovulkan: Switch MUL_MAT_VEC to 4 K per iteration for F16/32 (llama/22887)
Matt Corallo [Wed, 27 May 2026 15:19:23 +0000 (15:19 +0000)]
vulkan: Switch MUL_MAT_VEC to 4 K per iteration for F16/32 (llama/22887)

* vulkan: Switch MUL_MAT_VEC to 4 K per iteration for F16/32

Against mesa git, this shows a 4.8% performance improvement for
tg128 on Qwen3.5-9B:BF16 on Intel BMG.

Note that this breaks some tests until the last commit which fixes
OOB A reads.

* vulkan: Use aligned loads in mul_mat_vec when available

Against mesa git, this shows a 3.3% performance improvement for
tg128 on Qwen3.5-9B:BF16 on Intel BMG.

* Make explicit that `num_rows` is <= `NUM_ROWS` in mul_mat_vec

Mesa's UUB logic can't see through conditionals, limiting its
ability to understand the bounds on the `num_rows` field in the
cleanup run. Making it explicit that `num_rows` is, indeed, always
<= `NUM_ROWS` helps mesa make slightly better codegen.

Against mesa git, this currently shows a 1% performance improvement
in tg128 on Qwen3.5-9B:BF16 on Intel BMG.

* vulkan: Fix OOB A reads in MUL_MAT_VEC for odd sizes

There was a TODO to fix the OOB reads from the A matrix which we do
here.

It is within performance noise (+<0.1%) in tg128 for
Qwen3.5-9B:BF16 on Intel BMG.

3 months agovulkan: use GL_NV_cooperative_matrix_decode_vector for faster matmul (llama/23541)
Jeff Bolz [Wed, 27 May 2026 15:18:28 +0000 (10:18 -0500)]
vulkan: use GL_NV_cooperative_matrix_decode_vector for faster matmul (llama/23541)

3 months agovulkan: add REPEAT op support for f16 to f16. (llama/23298)
l8bloom [Wed, 27 May 2026 14:59:08 +0000 (16:59 +0200)]
vulkan: add REPEAT op support for f16 to f16. (llama/23298)

* feat: extend repeat op for vulkan

* feat: add repeat_f16 vulkan pipeline

* fix: ensure same dst and src types

* fix: use type_size instead of data types

* fix: use int16 and int32 for repeat shader op

* chore: rename repeat_f* to repeat_i*

* chore: rename repeat vulkan pipelines

3 months agoCUDA: restrict PDL to CTK >= 12.3 due to MSVC issues (llama/23742)
Oliver Simons [Wed, 27 May 2026 12:21:04 +0000 (14:21 +0200)]
CUDA: restrict PDL to CTK >= 12.3 due to MSVC issues (llama/23742)

3 months agovulkan: avoid preferring transfer queue on AMD UMA devices (llama/22455)
Winston Ma [Wed, 27 May 2026 09:48:40 +0000 (17:48 +0800)]
vulkan: avoid preferring transfer queue on AMD UMA devices (llama/22455)

3 months agoggml-zendnn : fixed naming of matmul function (llama/20964)
Vladislav [Tue, 26 May 2026 22:59:35 +0000 (01:59 +0300)]
ggml-zendnn : fixed naming of matmul function (llama/20964)

* ggml-zendnn: fixed naming of matmul function

* ggml-zendnn: fixed naming of mul_mat_id function

* ggml-zendnn: fixed print in  mul_mat_id

---------

Co-authored-by: plotnikov.v10 <redacted>
3 months agovulkan: optimize conv2d and implement coopmat1 support (llama/22620)
Jeff Bolz [Tue, 26 May 2026 13:48:05 +0000 (08:48 -0500)]
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

3 months agohexagon: add support for CONCAT op (llama/23648)
Max Krasnyansky [Tue, 26 May 2026 13:20:05 +0000 (06:20 -0700)]
hexagon: add support for CONCAT op (llama/23648)

* hexagon: add support for CONCAT with optimized concat_2d_transposed

qwen3.5 models are quite heavy on the CONCAT with large and transposed src1.

* hex-concat: use fastdiv in generic version

* hex-concat: make checks for transposed a bit more readable

* hex-concat: reoder dma ops for better pipelining

* hex-cont/cpy: optimize CPY and CONT ops

The primary change is to avoid scalar divs in the inner loops.
We were calling hvx_copy_uu(... type_size) where type_size is non a constexpr.
This causes runtime divs by that value which is normally just 4 or 2 (f32/f16).

* hex-get-rows: optimize GET_ROWS for large rows

We now use DMA for larger rows and also split them into chunks to improve perf for Qwen3.5 and other models
that do lots of GET_ROWS with huge (2MB+ rows).

Also bump the DMA queue depth now that we can take advantage of it.

* hex-concat: unroll the inner loops of concat_2d

* hex-concat: more updates to concat_2d to improve perf a bit further

* hex-cpy: fixed n_rows per thread checks in the copy ops

* hmx-fa: fix alignment issues while computing dma sizes

* hex-set-rows: add early returns for idle threads

* hvx-rope: minor optimization to replace loops with fastdiv logic

* hex-rope: replace scalar tail processing with HVX

* hex-rope: optimize rope cache init with HVX

Add hvx-utils sin/cos helpers that use an aprox method (similar to rsqrt, inverse, etc)
Use the helpers to optimize ROPE.

3 months agoSYCL: implement ggml_sycl_pool_vmm (llama/22862)
Alexey Kopytko [Tue, 26 May 2026 04:59:00 +0000 (13:59 +0900)]
SYCL: implement ggml_sycl_pool_vmm (llama/22862)

* SYCL: implement ggml_sycl_pool_vmm

* Add an option to bypass VMM with GGML_SYCL_DISABLE_VMM

* Clean up debugging logging

* document GGML_SYCL_DISABLE_VMM

* Multi-stream MoE optimization

* Revert "Multi-stream MoE optimization"

This reverts commit 938929c3f13a562ec67c59e87cc5d38595444cce.

* Update common.hpp

Co-authored-by: Neo Zhang <redacted>
* Flip GGML_SYCL_DISABLE_VMM to GGML_SYCL_ENABLE_VMM

* add logging for GGML_SYCL_ENABLE_VMM when extension is not available (SYCL_EXT_ONEAPI_VIRTUAL_MEM macro)

* Apply suggestions from code review

Co-authored-by: Alexey Kopytko <redacted>
* Apply suggestion from @sanmai

* Apply suggestion from @sanmai

---------

Co-authored-by: Neo Zhang <redacted>
3 months agoggml-webgpu: Add MMVQ path for Q4/Q8/Q2_K/Q4_K and clean up legacy MUL_MAT pipeline...
Masashi Yoshimura [Tue, 26 May 2026 03:42:49 +0000 (12:42 +0900)]
ggml-webgpu: Add MMVQ path for Q4/Q8/Q2_K/Q4_K and clean up legacy MUL_MAT pipeline (llama/23594)

* ggml-webgpu: Add MMVQ path for Q4/Q8/Q2_K/Q4_K

* Fix to editorconfig checking pass

* Remove mul-mat-legacy pipeline

* Fix to use vendor name as is and add dot_product/vendor to shader_lib_ctx

3 months agoCheck batch_compute_passes before sending passes when not doing GPU profiling (llama...
Nikhil Jain [Tue, 26 May 2026 03:32:49 +0000 (20:32 -0700)]
Check batch_compute_passes before sending passes when not doing GPU profiling (llama/23457)

* Only run webgpu CI on my fork

* Add webgpu only workflow

* refactor batch_compute_passes to a per-thread variable, and submit individual passes when it is set to false and no GPU profiling is enabled

* restore build.yml

3 months agoCUDA: missing PDL sync for FWHT, better fallback (llama/23690)
Johannes Gäßler [Tue, 26 May 2026 03:05:51 +0000 (05:05 +0200)]
CUDA: missing PDL sync for FWHT, better fallback (llama/23690)

3 months agometal : add apple device id (llama/23566)
forforever73 [Mon, 25 May 2026 18:05:16 +0000 (02:05 +0800)]
metal : add apple device id (llama/23566)

Co-authored-by: lvyichen <redacted>
3 months agoCUDA: add fast walsh-hadamard transform (llama/23615)
Aman Gupta [Mon, 25 May 2026 13:12:10 +0000 (21:12 +0800)]
CUDA: add fast walsh-hadamard transform (llama/23615)

* CUDA: add fast walsh-hadamard transform

* review: add unrolls + change size_t -> int

* warp size 64

---------

Co-authored-by: Johannes Gäßler <redacted>
3 months agoci : add ignore for bindings/{ruby, go} in build.yml [no ci] (#3837)
Daniel Bevenius [Thu, 28 May 2026 16:06:04 +0000 (18:06 +0200)]
ci : add ignore for bindings/{ruby, go} in build.yml [no ci] (#3837)

This commit adds an ignore for bindings-ruby and bindings-go in
build.yml as these are handled by separate .yml file (separate jobs)
and don't need to trigger a full CI build.

3 months agoci : fix include paths for bindings-go job [no ci] (#3835)
Daniel Bevenius [Thu, 28 May 2026 12:53:34 +0000 (14:53 +0200)]
ci : fix include paths for bindings-go job [no ci] (#3835)

3 months agoci : add on push/pull_request paths ruby job (#3833)
Daniel Bevenius [Thu, 28 May 2026 12:41:48 +0000 (14:41 +0200)]
ci : add on push/pull_request paths ruby job (#3833)

* ci : add on push/pull_request paths ruby job

This commit adds paths to bindings-ruby to only build if changes where
made to bindings/ruby or to include/whisper.h.

* ci : add additional paths [no ci]

3 months agoci : renable arm64 docker builds (#3832)
Daniel Bevenius [Thu, 28 May 2026 10:09:13 +0000 (12:09 +0200)]
ci : renable arm64 docker builds (#3832)

This commit re-enables the arm64 docker images builds which were removed
in Commit 9366544991bfee59c927e7c23b1861c6c762e708
("ci : fix arm builds"). It also uses ubuntu-24.04-arm as the runner
which enables us to avoid QEMU.

Resolves: https://github.com/ggml-org/whisper.cpp/issues/2859

3 months agoci : set GGML_NATIVE=OFF for bindings-java (#3830)
Daniel Bevenius [Thu, 28 May 2026 05:21:25 +0000 (07:21 +0200)]
ci : set GGML_NATIVE=OFF for bindings-java (#3830)

* ci : set GGML_NATIVE=OFF for bindings-java

This commit attempts to address an issue with the bindings-java job
which is currently failing.

I've not been able to reproduce this locally my windows machine and I
suspect that what might be happning is that windows job compiles on a
runner where it has different CPU features, for example AVX512 and when
this dll is used on a different runner that does not have that feature
it will crash.

Refs: https://github.com/ggml-org/whisper.cpp/actions/runs/26496174929/job/78059073255?pr=3829

* ci : also disable BMI2

3 months agoci : only run docker jobs when pushed to master [no ci] (#3828)
Daniel Bevenius [Wed, 27 May 2026 06:46:23 +0000 (08:46 +0200)]
ci : only run docker jobs when pushed to master [no ci] (#3828)

3 months agodocs : add AGENTS.md and CONTRIBUTING.md [no ci] (#3826)
Daniel Bevenius [Wed, 27 May 2026 04:22:38 +0000 (06:22 +0200)]
docs : add AGENTS.md and CONTRIBUTING.md [no ci] (#3826)

* docs : add AGENTS.md and CONTRIBUTING.md [no ci]

This commit add AGENTS.md and CONTRIBUTING.md which are based on the
same files in llama.cpp. They have been modified slightly to fit with
whisper.cpp.

The motivation for this is to clarify the contribution policy in
whisper.cpp so that contributers can have a better understanding of the
expectations and requirements for contributing to the project.

3 months agocli : merge tokens split across UTF-8 boundaries in JSON output (#3751)
texasich [Tue, 26 May 2026 04:23:41 +0000 (23:23 -0500)]
cli : merge tokens split across UTF-8 boundaries in JSON output (#3751)

* cli : merge tokens split across UTF-8 boundaries in JSON output

When a multi-byte UTF-8 codepoint (most commonly a CJK character, 3 bytes)
is split across multiple whisper tokens, the -ojf/--output-json-full
writer emitted each token's partial bytes as its own JSON string, producing
invalid UTF-8 that chokes downstream parsers.

Merge adjacent tokens in output_json whenever the accumulated text still
ends on an incomplete UTF-8 sequence. The merged entry keeps the first
token's id/p/t_dtw and extends t1 to the last absorbed token, which
matches how segment text is assembled elsewhere.

Refs #1798

* fix: address review — add braces for consistency, use full issue URL

- Add braces to if/else chain for codebase consistency
- Use full URL for issue #1798 reference

Review: @danbev

---------

Co-authored-by: texasich <redacted>
Co-authored-by: texasich <redacted>
3 months agorelease : v1.8.5
Georgi Gerganov [Mon, 25 May 2026 10:06:33 +0000 (13:06 +0300)]
release : v1.8.5

3 months agobenches : update
Georgi Gerganov [Mon, 25 May 2026 10:05:30 +0000 (13:05 +0300)]
benches : update

3 months agosync : ggml
Georgi Gerganov [Mon, 25 May 2026 09:44:07 +0000 (12:44 +0300)]
sync : ggml

3 months agoggml : bump version to 0.13.0 (ggml/1510)
Georgi Gerganov [Mon, 25 May 2026 09:40:17 +0000 (12:40 +0300)]
ggml : bump version to 0.13.0 (ggml/1510)

3 months agoTP: fix ggml context size calculation (llama/22616)
Johannes Gäßler [Mon, 25 May 2026 09:37:25 +0000 (11:37 +0200)]
TP: fix ggml context size calculation (llama/22616)

* TP: fix ggml context size calculation, memory leak

* move split state cache back into the context

* revert to constant ggml context size for cgraphs

* increase headroom for statically allocated tensors

* remove obsolete include

3 months agoggml: `gguf_init_from_callback` and `gguf_init_from_buffer` (llama/22341)
Gilad S [Mon, 25 May 2026 09:33:29 +0000 (11:33 +0200)]
ggml: `gguf_init_from_callback` and `gguf_init_from_buffer` (llama/22341)

* ggml: implement `gguf_init_from_buffer`

* test: `gguf_init_from_buffer`

* fix: memory breakdown for a model loaded with `no_alloc` from a file is consistent with being loaded from a buffer

* fix: use `GGML_UNUSED`

Co-authored-by: Copilot <redacted>
* fix: remove `total_size` from `gguf_reader`

* fix: file offset calculation, rename `offset` to `data_offset`

Co-authored-by: Copilot <redacted>
* refactor: extract model loader bug fixes to another PR

* feat: add `gguf_init_from_callback`

* fix: always require a max expected size

* fix: change `gguf_reader_callback_t`'s `output` type to `void *`, change `max_expected_size` and offsets to `uint64_t`

* fix: harden against offset overflow in buffer read

* fix: remove seek behavior from the callback

* feat: `max_chunk_read == 0` means `SIZE_MAX`

* fix: seeking in a gguf file with no tensors

---------

Co-authored-by: Copilot <redacted>
3 months agoreadme : add AMD ROCm/HIP GPU build instructions (#3823)
Kaihui-AMD [Mon, 25 May 2026 09:27:42 +0000 (17:27 +0800)]
readme : add AMD ROCm/HIP GPU build instructions (#3823)

Signed-off-by: Kaihui-AMD <redacted>
3 months agotalk-llama : sync llama.cpp
Georgi Gerganov [Mon, 25 May 2026 09:18:31 +0000 (12:18 +0300)]
talk-llama : sync llama.cpp

3 months agosync : ggml
Georgi Gerganov [Mon, 25 May 2026 09:14:40 +0000 (12:14 +0300)]
sync : ggml

3 months agoggml : bump version to 0.12.1 (ggml/1508)
Georgi Gerganov [Mon, 25 May 2026 09:13:21 +0000 (12:13 +0300)]
ggml : bump version to 0.12.1 (ggml/1508)

3 months agoggml : Parallelize quant LUT init (llama/23595)
Jeff Bolz [Mon, 25 May 2026 07:15:46 +0000 (02:15 -0500)]
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.

3 months agoTP: fix entirely zero-sized slices per device (llama/23525)
Johannes Gäßler [Sun, 24 May 2026 06:19:33 +0000 (08:19 +0200)]
TP: fix entirely zero-sized slices per device (llama/23525)

3 months agoopencl: batch profiling to improve speed and prevent memory leaks (llama/23495)
shaofeiqi [Sun, 24 May 2026 06:11:43 +0000 (23:11 -0700)]
opencl: batch profiling to improve speed and prevent memory leaks (llama/23495)

3 months agohexagon: apply repl optimization in flash attn softmax as #22993 (llama/23455)
Yiwei Shao [Sun, 24 May 2026 02:56:59 +0000 (19:56 -0700)]
hexagon: apply repl optimization in flash attn softmax as #22993 (llama/23455)

3 months agoggml : Check the right iface method before using the fallback 2d get (llama/23514)
dskwe [Sat, 23 May 2026 10:49:24 +0000 (18:49 +0800)]
ggml : Check the right iface method before using the fallback 2d get (llama/23514)

3 months agovulkan: fix windows find_package of SPIRV-Headers (llama/23215)
Jeff Bolz [Sat, 23 May 2026 07:44:46 +0000 (02:44 -0500)]
vulkan: fix windows find_package of SPIRV-Headers (llama/23215)

* vulkan: fix windows find_package of SPIRV-Headers

* not windows-only

3 months agoopencl: generalize Adreno MoE kernels on M (llama/23449)
Shawn Gu [Sat, 23 May 2026 00:08:41 +0000 (17:08 -0700)]
opencl: generalize Adreno MoE kernels on M (llama/23449)

3 months agoSYCL: improve MoE prefill throughput (llama/23142)
Alexey Kopytko [Fri, 22 May 2026 12:50:17 +0000 (21:50 +0900)]
SYCL: improve MoE prefill throughput (llama/23142)

- change `k_copy_src1_to_contiguous` so that uses a precomputed contiguous mapping where all rows "owned" by an expert are in one slice with a know starts and ends
- switch the `O(n_as * n_routed_rows)` contraption to a counting sort-based procedure with `O(n_as + n_routed_rows)` complexity

3 months agosycl : Level Zero detection in ggml_sycl_init (llama/23097)
Alexey Kopytko [Fri, 22 May 2026 12:49:45 +0000 (21:49 +0900)]
sycl : Level Zero detection in ggml_sycl_init (llama/23097)

* [SYCL] Centralize Level Zero detection in ggml_sycl_init

* use the same wording

* get back the warning

3 months agoSYCL : gated_delta_net K>1 (llama/23174)
karavayev [Fri, 22 May 2026 12:48:56 +0000 (08:48 -0400)]
SYCL : gated_delta_net K>1 (llama/23174)

* sycl_gated_delta_net K>1

* editor_config

3 months agoSYCL: add BF16 to DMMV kernel path (~4x tg speedup on Intel Arc) (llama/21580)
Katostrofik [Fri, 22 May 2026 12:48:24 +0000 (08:48 -0400)]
SYCL: add BF16 to DMMV kernel path (~4x tg speedup on Intel Arc) (llama/21580)

* SYCL: add BF16 to DMMV kernel path for ~4x token generation speedup

BF16 models had no dedicated token generation kernel — they fell through
to the generic full-GEMM path, resulting in ~14% memory bandwidth
utilization on Intel Arc GPUs. This adds BF16 support to the DMMV
(dequantize mul-mat-vec) path, matching the existing F16 implementation.

Fixes #20478

* SYCL: fix BF16 DMMV out-of-bounds when ncols % 64 != 0

The qk=1 kernel (used for F16 and BF16) iterates with stride
2*GGML_SYCL_DMMV_X (= 64 on Intel targets where WARP_SIZE=16). When
ncols is a multiple of DMMV_X (32) but not of 2*DMMV_X (64), the last
warp iteration accesses elements at col >= ncols, producing NaN for the
final row and wrong values for interior rows.

Fix: tighten can_use_dequantize_mul_mat_vec to require ne[0] %
(2*DMMV_X) == 0 for F16/BF16 types, and update the ASSERT in the BF16
launcher to match. Quantized types use block-structured kernels with
different access patterns and keep the existing DMMV_X check.

Verified: test-backend-ops MUL_MAT passes 913/913 on Intel Arc Pro B70.
Previously failing: m=128/129 n=1 k=1056 cases (NaN and ERR > 0.0005).

Co-Authored-By: Claude Sonnet 4.6 <redacted>
---------

Co-authored-by: Claude Sonnet 4.6 <redacted>
3 months agoggml-zendnn : add Q8_0 quantization support (llama/23414)
Sachin Sharma [Fri, 22 May 2026 11:16:55 +0000 (16:46 +0530)]
ggml-zendnn : add Q8_0 quantization support (llama/23414)

* ggml-zendnn : add Q8_0 quantization support

* ggml-zendnn : sync with latest ZenDNN

* ggml-zendnn : address review comments for Q8_0

3 months agoCUDA: fix PDL CC check for JIT compilation (llama/23471)
Johannes Gäßler [Thu, 21 May 2026 21:35:29 +0000 (23:35 +0200)]
CUDA: fix PDL CC check for JIT compilation (llama/23471)

3 months agovulkan: fuse snake activation (mul, sin, sqr, mul, add) (llama/22855)
Pascal [Thu, 21 May 2026 17:39:42 +0000 (19:39 +0200)]
vulkan: fuse snake activation (mul, sin, sqr, mul, add) (llama/22855)

* vulkan: fuse snake activation (mul, sin, sqr, mul, add)

Add snake.comp shader with F32 / F16 / BF16 pipelines and
ggml_vk_snake_dispatch_fused. The matcher recognizes the naive 5 op
decomposition emitted by audio decoders (BigVGAN, Vocos) for snake
activation y = x + sin(a*x)^2 * inv_b and rewrites it to a single
elementwise kernel.

test_snake_fuse from the CUDA PR now also compares CPU naive vs
Vulkan fused across F32 / F16 / BF16.

* vulkan: address jeffbolznv review for fused snake activation

Rename T / C to ne0 / ne1 in the shader and push constants to match
the standard naming convention used across the Vulkan backend.

Tighten ggml_vk_can_fuse_snake: require x and dst to be contiguous
(the shader uses idx = i0 + i1 * ne0) and require a / inv_b to be
tightly packed on the broadcast dim (the shader reads data_a[i1]).

* vulkan: tighten snake fusion type checks for all operands (address jeffbolznv review)

* vulkan: reject snake fusion when ne[2] or ne[3] > 1 (address jeffbolznv review)

* vulkan: address 0cc4m review for fused snake activation

snake.comp is renamed to follow the ggml DATA_A_* / A_TYPE convention.
A_TYPE now applies to the activation tensor data_a instead of the
broadcast multiplier, and the bindings become data_a (A_TYPE), data_b
(float), data_c (float) and data_d (D_TYPE). A header at the top of
the shader maps each buffer to its role in y = x + sin(b * x)^2 * c.

On the C++ side, ggml_vk_can_fuse_snake reuses the existing snake_pattern
constant instead of duplicating the op list, sin_node is extracted as a
named local alongside the other chain nodes, and the broadcast operands
a and inv_b are now required to be GGML_TYPE_F32 to match the hardcoded
float bindings on data_b and data_c (the previous a->type == x->type
would silently reject any future BF16 or F16 chain once the supports_op
gate for SIN / SQR is lifted). ggml_vk_snake_dispatch_fused gets an
explicit GGML_TYPE_F32 case and GGML_ABORT on default in place of the
silent f32 fallback, and a stale comment about data_a[i1] / data_inv_b[i1]
is refreshed to match the new binding names.

3 months agofix(flash-attn): replace f32 with kv_type and q_type (llama/23372)
Chen Yuan [Thu, 21 May 2026 14:58:49 +0000 (10:58 -0400)]
fix(flash-attn): replace f32 with kv_type and q_type (llama/23372)

3 months agometal : optimize concat kernel and fix set kernel threads (llama/23411)
Georgi Gerganov [Thu, 21 May 2026 10:34:08 +0000 (13:34 +0300)]
metal : optimize concat kernel and fix set kernel threads (llama/23411)

* metal : fix GGML_OP_SET kernel threads

* tests : extend test_cpy to support different src/dst shapes

Extend test_cpy to support different source and destination tensor shapes
for CPY operations (reshaping), where the total number of elements must match.

- Renamed ne -> ne_src, added ne_dst parameter (default: use src shape)
- Added 50 new reshaping test cases covering 1D<->2D<->3D<->4D conversions
- Tests exercise 1024 boundary, small shapes, and large dimensionality changes
- Fixed dangling reference bug (storing & to temporary std::array)
- Updated all existing test calls with permute/transpose args for compatibility

Assisted-by: llama.cpp:local pi
* metal : optimize concat kernel with row batching for small widths

When ne0 < 256, batch multiple rows into a single threadgroup to improve
occupancy. This avoids underutilizing the GPU when processing narrow tensors.

- Dispatch nth = min(256, ne0) threads per group
- Calculate nrptg (rows per threadgroup) to fill up to 256 threads
- Update kernel index calculation to handle the row batching
- Add boundary check for i1 >= ne1

Assisted-by: llama.cpp:local pi
* tests : clean-up

* tests : refactor CPY shape tests to use dimension permutations

Replace 75 hardcoded test cases with a loop over permutations of
{3, 5, 7, 32} (total elements: 3360). Each src permutation is tested
against canonical sorted and reverse dst, skipping identical shapes.
Covers F32, F16, and Q4_0 (when both src and dst ne0 == 32).

Assisted-by: llama.cpp:local pi
3 months agoggml : Check the right iface method before using the fallback 2d get (llama/23306)
Matt Corallo [Thu, 21 May 2026 06:24:40 +0000 (06:24 +0000)]
ggml : Check the right iface method before using the fallback 2d get (llama/23306)

Probably no backends implement only one of 2d get/set, but this
might be annoying for some future backend developer trying to add
2d get/set.

3 months agohexagon: ssm-conv fix for large prompts (llama/23307)
Todor Boinovski [Thu, 21 May 2026 05:14:13 +0000 (22:14 -0700)]
hexagon: ssm-conv fix for large prompts (llama/23307)

* hexagon: remove gathers and better handling of vtcm in ssm-conv

* hexagon: relax ssm-conv gating requirements

* hexagon: add new prefill ssm-conv backend test

* hexagon: remove trailing white space

* hex-rope: uninline rope_cache_init, otherwise it breaks after rebaseing with SSM_CONV changes

---------

Co-authored-by: Max Krasnyansky <redacted>
3 months agoopencl: refactor backend initilization (llama/23318)
lhez [Wed, 20 May 2026 16:57:36 +0000 (09:57 -0700)]
opencl: refactor backend initilization (llama/23318)

* opencl: refactor initialization

* opencl: refactor GPU identification

* opencl: rename for consistency

* opencl: cache global mem size in dev_ctx

* opencl: adjust log level

* opencl: load argsort and flash_attn kernels in supports_op

* argsort kernel must be built for supports_op for querying the max
  workgroups
* flash_attn kernel has many variants, only load them when needed

3 months agovulkan: optimize operations in the IM2COL shader (llama/22685)
Daniele [Wed, 20 May 2026 15:15:13 +0000 (17:15 +0200)]
vulkan: optimize operations in the IM2COL shader (llama/22685)

* vulkan: optimize operations in the IM2COL shader

* Add comments and improve the code formatting

3 months agohexagon: HMX quantized matmul rework (llama/23368)
Max Krasnyansky [Wed, 20 May 2026 14:39:01 +0000 (07:39 -0700)]
hexagon: HMX quantized matmul rework (llama/23368)

* hmx-mm: update debug logging in hmx-mm

* hmx-mm: update dequant logic to use HVX_vector_x2/4

* hmx-mm: remove non-pipelined version of the quantize matmul

It seems that we don't reall need non-pipelined version

* hmx-mm: use activation depth mode and update naming

Co-authored-by: Kim-Chyan Gan <redacted>
* hex-mm: minor hmx matmul naming updates

* hmx-mm: remove unused vars

* snapdragon: scripts bump default ubatch-size to 1K

* hexagon: combine HMX and power and clock settings into a single set_power call

* hmx-mm: remove leftover of the scale repl helper

* hexagon: fix editconf error

---------

Co-authored-by: Kim-Chyan Gan <redacted>
3 months agoProgrammatic Dependent Launch (PDL) for more performance on newer NVIDIA GPUs (Hopper...
Andreas Kieslinger [Wed, 20 May 2026 11:59:02 +0000 (13:59 +0200)]
Programmatic Dependent Launch (PDL) for more performance on newer NVIDIA GPUs (Hopper+) (llama/22522)

* Adds initial PDL setup.

* Adds PDL barriers based on simple heuristic: place "sync" before first input pointer access, and "launch" after last write, e.g. to tensors like dst.

* Further optimization pass of the first half of kernels

* Optimized PDL barriers for the second batch of kernels

* Further refinements after rebase.

* Moves pdl logic to separate function, removes some whitespace

* Strips post-hoc PDL logic

* Adds stream capture PDL setup. Enrolls quantize_q8_1 to leverage pdl to
overlap execution with previous kernels

* Enrolls mul_mat_vec_q, rms_norm_f32 and k_bin_bcast (partly) into PDL

* Enrolls mmvf, rope, set-rows and topk kernels for gpt-oss into PDL

* Introduce ggml_cuda_kernel_launch, to abstract away cudaLaunchKernelEx,
to enable hip/musa compatibility

* Enrolls cpy_scalar_contiguous, k_get_rows_float and rms_norm_f32

* Enrolls flash_attn_combine_results

* Fix: Drops needless and broken check of CUDA arch for PDL. PDL either
works or is without effect.

* Enrolls flash-attention kernels to pdl

* Fix: inlines ggml_cuda_kernel_launch, and uses perfect forwarding for
kernels args. This fixes PDL.

* Perf: Enrolls k_bin_bcast variadic template invocation into PDL, via
and template alias and template expansion

* Enrolls all remaining kernels for qwen3-coder-next into PDL

* Remove all PDL LC calls to create a baseline

* Added LC according to internal guidance and tested kernel performance.

* Enrols missing qwen3-5 kernels passively into PDL.

* Kernel optimizations (LC signals) for qwen3.5

* Enrolls ssm-scan kernels into PDL

* Adds GGML_CUDA_PDL command line option to toggle PDL.

* Fix: Ada and lower compilation by guarding PDL calls correctly

* Cleanup: Removes commented out GGML_CUDA_PDL_LC

* Cleanup: Removes experimental comments

* Adds 90-virtual to build script so that Hopper GPUs can leverage PDL.

* Adds stricter checks to enable PDL, adds env-check to disable it, and removes now superfluous compile option to enable PDL.

* Fix: Correct PDL en/disablement based on device-side arch check. Host
side check is UB. Required moving from macros to inlined functions

* Fix: default-disable PDL. Enable by setting GGML_CUDA_ENABLE_PDL=1

* Enable PDL by default for Hopper+ devices

* Enrolls softcap_f32 and two flash_attn kernels into PDL.

* Improves flash attn PDL barrier placement

* Fix: Perf regression on ada; excludes ada and below from PDL launches

* Improves some sync barrier placements

* Drops superfluous constructor

* Adds #endif guard comments

* Reverts experimental change to top-k-moe.cu, which moved expensive allocations
in front of the PDL barrier. It did not have a meaningful impact.

* Exchanges GGML_CUDA_DISABLE_PDL with GGML_CUDA_PDL. IFF GGML_CUDA_PDL=0
PDL is disabled

* Revert "Drops superfluous constructor". Adds const to remaining
arguments

This reverts commit 12b1d250da0089ae02a9bb71bbb3fd6d70f6f2f1.

* Cleanup: Removes and fixes some comments and whitespace

* Clarifies comment of sync-barrier position

* Relocates and refactors PDL launch functions and accessories

* Adds error checking to the regular kernel launch path

* Drops "auto" in favor of "ggml_cuda_kernel_params"

* Adds "const" to ggml_cuda_kernel_launch_params

* [Whitespace] Adds final newline to common.cuh to make editorconfig CI job happy

3 months agometal : optimize pad + cpy (llama/23354)
Georgi Gerganov [Wed, 20 May 2026 06:42:00 +0000 (09:42 +0300)]
metal : optimize pad + cpy (llama/23354)

* metal : optimize pad

* metal : optinmize cpy

* cont : better row packing in threadgroup

3 months agoggml-cuda: tune RDNA3 Q6_K MMVQ nwarps (llama/23349)
ravel7524 [Wed, 20 May 2026 01:52:21 +0000 (03:52 +0200)]
ggml-cuda: tune RDNA3 Q6_K MMVQ nwarps (llama/23349)

3 months agoopencl: add MoE support for q4_k, q5_k, q6_k on Adreno (llama/23303)
shaofeiqi [Tue, 19 May 2026 21:29:00 +0000 (14:29 -0700)]
opencl: add MoE support for q4_k, q5_k, q6_k on Adreno (llama/23303)

* opencl: add q4_k moe support

* opencl: add q5_k moe support

* opencl: add q6_k moe support

* opencl: adjust format

---------

Co-authored-by: Li He <redacted>
3 months agohexagon: add MROPE and IMROPE support in HTP rope op (llama/23317)
Aparna M P [Tue, 19 May 2026 21:10:13 +0000 (02:40 +0530)]
hexagon: add MROPE and IMROPE support in HTP rope op (llama/23317)

3 months agohexagon: enable support for NORM op (llama/23319)
Aparna M P [Tue, 19 May 2026 16:48:21 +0000 (22:18 +0530)]
hexagon: enable support for NORM op (llama/23319)

3 months agoggml-webgpu : extend GDN for K>1 (llama/23299)
Reese Levine [Tue, 19 May 2026 06:45:41 +0000 (23:45 -0700)]
ggml-webgpu : extend GDN for K>1 (llama/23299)

3 months agosycl: add GGML_SYCL_USE_ASYNC_MEM_OP env toggle (llama/22153)
Intel AI Get-to Market Customer Success and Solutions [Tue, 19 May 2026 06:44:02 +0000 (23:44 -0700)]
sycl: add GGML_SYCL_USE_ASYNC_MEM_OP env toggle (llama/22153)

* sycl: add GGML_SYCL_USE_ASYNC_MEM_OP env toggle

Signed-off-by: Chun Tao <redacted>
* Use async mem ops for correctness when SYCL graphs are explicitly on.

Signed-off-by: Tao, Chun <redacted>
---------

Signed-off-by: Chun Tao <redacted>
Signed-off-by: Tao, Chun <redacted>
Co-authored-by: Chun Tao <redacted>
3 months agorpc : keep last_graph_uid in the device context (llama/23273)
Radoslav Gerganov [Tue, 19 May 2026 06:42:36 +0000 (09:42 +0300)]
rpc : keep last_graph_uid in the device context (llama/23273)

With the introduction of MTP we can have multiple compute contexts for
the same RPC device. In this case last_graph_uid is not updated properly
when contexts are being switched. This patch fixes this by moving
last_graph_uid to the device context, making sure it is always updated.

closes: #23242

3 months agohexagon: add support for TRI op (llama/22822)
Pranav Dhinakar [Mon, 18 May 2026 21:04:57 +0000 (14:04 -0700)]
hexagon: add support for TRI op (llama/22822)

* Hexagon: TRI HVX Kernel addition to ggml hexagon HTP ops and context

* addressed PR review comments for TRI op

* hexagon: clang format

* hex-unary: remove merge conflict markers

* hex-ggml: remove duplicate op cases (merge conflict)

* hex-ggml: fix editor config errors

---------

Co-authored-by: Todor Boinovski <redacted>
Co-authored-by: Max Krasnyansky <redacted>
3 months agoggml-hexagon: add PAD op HVX kernel (llama/23078)
Pranav Dhinakar [Mon, 18 May 2026 20:39:36 +0000 (13:39 -0700)]
ggml-hexagon: add PAD op HVX kernel (llama/23078)

* ggml-hexagon: add PAD op HVX kernel

Implements GGML_OP_PAD on the Hexagon HTP backend using HVX vectorized
kernels. Supports zero-padding and circular padding across all 4 tensor
dimensions.

* hex-ggml: remove duplicate op cases (merge conflict)

* hex-pad: fix editorconfig checks and macro alignment

---------

Co-authored-by: Max Krasnyansky <redacted>
3 months agosycl: scalar SWAR byte-subtract in Q6_K MMVQ dot product (llama/22156)
Intel AI Get-to Market Customer Success and Solutions [Mon, 18 May 2026 05:12:21 +0000 (22:12 -0700)]
sycl: scalar SWAR byte-subtract in Q6_K MMVQ dot product (llama/22156)

Signed-off-by: Chun Tao <redacted>
Co-authored-by: Chun Tao <redacted>
3 months agosycl: route small f32 matmuls to oneMKL, bypass oneDNN (llama/22150)
Intel AI Get-to Market Customer Success and Solutions [Mon, 18 May 2026 05:11:51 +0000 (22:11 -0700)]
sycl: route small f32 matmuls to oneMKL, bypass oneDNN (llama/22150)

Signed-off-by: Chun Tao <redacted>
Co-authored-by: Chun Tao <redacted>
3 months agofeat: Support d_conv=15 for ssm-conv.cu (llama/23017)
Gabe Goodhart [Sun, 17 May 2026 21:05:11 +0000 (15:05 -0600)]
feat: Support d_conv=15 for ssm-conv.cu (llama/23017)

Branch: ModalityConditionalAdapters
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
3 months agoCUDA: Continue directly including cuda/iterator (llama/23102)
Oliver Simons [Sun, 17 May 2026 16:00:10 +0000 (18:00 +0200)]
CUDA: Continue directly including cuda/iterator (llama/23102)

Cont of #22936, forgot to update one site

3 months agoggml-vulkan/CMakeLists: add a check for SPIRV-Headers (llama/22009)
Jan Ekström [Sun, 17 May 2026 11:12:11 +0000 (14:12 +0300)]
ggml-vulkan/CMakeLists: add a check for SPIRV-Headers (llama/22009)

* ci/run: set explicit SPIR-V Headers search path for macOS vulkan CI

For whatever reason, the files are under additional sub-path
`vulkan/` under the cmake directory, which does not match either
current LunarG macOS Vulkan SDK structure (`lib/cmake/SPIRV-Headers`),
nor what gets installed when you run the cmake build+install for
SPIRV-Headers itself on at least Linux (`share/cmake/SPIRV-Headers`).

This allows for SPIRV-Headers to be found, as currently the CI
runner's setup does not seem to include the relevant path in
list of search locations.

* ggml-vulkan/CMakeLists: add a check for SPIRV-Headers

This is installed by the project if it is built and installed.
Receiving an error during the configuration step is generally
preferred to receiving an error in the middle of a build.

3 months agovulkan: add cpy bf16 -> f32 pipelines (llama/22677)
Pascal [Sun, 17 May 2026 09:31:20 +0000 (11:31 +0200)]
vulkan: add cpy bf16 -> f32 pipelines (llama/22677)

3 months agovulkan: Support unaligned tensors for ROPE (llama/22637)
Jeff Bolz [Sun, 17 May 2026 09:30:16 +0000 (04:30 -0500)]
vulkan: Support unaligned tensors for ROPE (llama/22637)

3 months agovulkan: fuse SSM_CONV + BIAS + SILU (llama/22653)
Jeff Bolz [Sun, 17 May 2026 08:25:50 +0000 (03:25 -0500)]
vulkan: fuse SSM_CONV + BIAS + SILU (llama/22653)

3 months agovulkan: removed duplicate #include <memory> in headers (llama/23144)
Winston Ma [Sat, 16 May 2026 17:57:35 +0000 (01:57 +0800)]
vulkan: removed duplicate #include <memory> in headers (llama/23144)

3 months agoggml.h: correct ggml_silu_back arg docstring (a=dy, b=x) (ggml/1500)
Ori Pekelman [Thu, 21 May 2026 12:00:16 +0000 (12:00 +0000)]
ggml.h: correct ggml_silu_back arg docstring (a=dy, b=x) (ggml/1500)

3 months agoggml-alloc: fix out-of-bounds read in ggml_dyn_tallocr_remove_block (ggml/1492)
Dev-X25874 [Thu, 21 May 2026 11:58:08 +0000 (17:28 +0530)]
ggml-alloc: fix out-of-bounds read in ggml_dyn_tallocr_remove_block (ggml/1492)

3 months agoggml : bump version to 0.12.0 (ggml/1494)
Georgi Gerganov [Sat, 16 May 2026 12:59:09 +0000 (15:59 +0300)]
ggml : bump version to 0.12.0 (ggml/1494)

3 months agollama + spec: MTP Support (llama/22673)
Aman Gupta [Sat, 16 May 2026 12:06:23 +0000 (20:06 +0800)]
llama + spec: MTP Support (llama/22673)

* spec: support MTP

* fix batch size

* rename files

* cont : simplify (llama/7)

* MTP: clean-up (llama/9)

* MTP: clean-up

* review: use llama_context_type instead of llama_graph_type

* review: remove llama_model_has_mtp

* review: fix convert issues

* convert: fix pycheck

* review: formatting

* use `mtp-` for identifying mtp models

* convert: fix mtp conversion

* mtp -> draft-mtp

* remove unused llama_arch

* add need_embd in speculative

* llama: allow partial seq_rm for GDN models for speculative decoding

Currently speculative checkpoint needs to restart from a checkpoint
after some draft tokens are not accepted, this leads to some wastage in
running the target again. This PR adds the ability to rollback upto
`draft_max` by storing the GDN intermediates.

* fix pending state

* vulkan: add GDN partial rollback

* meta: extend check to axis 1

* metal: add GDN partial rollback

Extend the gated delta net kernel to store intermediate states for
partial rollback support on the Metal backend.

- Add K (snapshot slot count) as a function constant
- Read input state from slot 0 of the 3D state tensor
- Write intermediate states to different slots during token loop
- For K=1, maintain backward-compatible single-slot behavior

Ref: https://github.com/ggml-org/llama.cpp/commit/8c05923630110223669f069af2000e9cf10c02bc

Assisted-by: llama.cpp:local pi
* delta_net_base: use ggml_pad instead of new_tensor

* review: add need_rs_seq

* review: rename part_bounded to n_rs

* review: deslop comments

* review: rename, add asserts

* server : adjust checkpoint logic (llama/11)

* server : adjust checkpoint logic

* cont : rm asserts

* server-context: fix early exit

* spec : fix compatibility with n-gram and add TODOs (llama/13)

* metal : cleanup

* llama : fix faulty bitwise check in recurrent memory

* server : disable RS-based MTP in combination with other spec types

* spec : add TODOs

* cont : fix comment

* cont : update comment

* common : fix logic for ngram + mtp compat

* llama-memory: enable checkpointing with partial rollback

* cont: add test-case for loading into a dirty ctx

* llama-memory-recurrent: clear rs_idx in clear

* download: fix mtp path

* llama-arch: fix enorm op

* docs: update docs

* conversion: fix type annotations

---------

Co-authored-by: Georgi Gerganov <redacted>
3 months agoggml-hexagon: cpy: add contiguous fast-path in reshape copy (llama/23076)
Pranav Dhinakar [Thu, 14 May 2026 23:55:54 +0000 (16:55 -0700)]
ggml-hexagon: cpy: add contiguous fast-path in reshape copy (llama/23076)

3 months agoHIP: RDNA3 mma FA, faster AMD transpose, tune AMD (llama/22880)
Johannes Gäßler [Thu, 14 May 2026 20:58:58 +0000 (22:58 +0200)]
HIP: RDNA3 mma FA, faster AMD transpose, tune AMD (llama/22880)

Adds RDNA3 support to the CUDA mma FA kernel. To make the RDNA3 tensor cores work with the FP16 accumulation for VKQ the tiles they need to be 32 logical units long in direction of the attention head; for head sizes 80 and 112 that are not exactly divided by 32 the regular length of 16 with FP32 accumulation is used instead. The longer tiles also enable more efficient transposition for a warp size of 32 which is why it's also used for RDNA4. However, this scrambles the data layout of the accumulators along the attention head dimension. To prevent accidental misuse I added another entry to ggml_cuda_mma::data_layout.

I also tuned the kernel parameters for RDNA3, RDNA4, and CDNA1 in general, during which I discovered that the kernel can be made to work for head sizes up to 256 for CDNA. For RDNA3/4 I was not able to get better performance that the tile kernel for head sizes > 128.

3 months agoggml-webgpu: makes the flash attn vec path subgroup-aware (llama/23040)
Zheyuan Chen [Thu, 14 May 2026 16:31:36 +0000 (09:31 -0700)]
ggml-webgpu: makes the flash attn vec path subgroup-aware (llama/23040)

* ggml-webgpu: makes the flash attn vec path compile and size its split/reduce work from the device’s reported subgroup range instead of assuming 32 subgroup size.

* ggml-webgpu: remove the extra max_wg_size >= max_subgroup_size guard. Remove hardcoded 32 when determine the value of reduce_wg_size and vec_nwg_cap

3 months agologs : reduce (llama/23021)
Georgi Gerganov [Thu, 14 May 2026 10:05:52 +0000 (13:05 +0300)]
logs : reduce (llama/23021)

* logs : reduce

* args : fix envs

* server : fix build

* common : print verbosity level at start

* server : clean-up logs

* server : print prompt processing timings + sampling params

* minor : whitespaces

3 months agoggml-cpu: Add IME2 Instruction Support for the SpacemiT Backend (llama/22863)
alex-spacemit [Thu, 14 May 2026 09:39:30 +0000 (17:39 +0800)]
ggml-cpu: Add IME2 Instruction Support for the SpacemiT Backend (llama/22863)

3 months agovulkan: fix matmul integer pipeline selection (llama/23005)
Ruben Ortlam [Thu, 14 May 2026 08:36:54 +0000 (10:36 +0200)]
vulkan: fix matmul integer pipeline selection (llama/23005)

* vulkan: fix matmul integer pipeline selection

* gate pipeline creation with the right bools

3 months agoSYCL: fix multi-GPU system RAM exhaustion by using Level Zero allocations (llama...
Katostrofik [Thu, 14 May 2026 05:39:14 +0000 (01:39 -0400)]
SYCL: fix multi-GPU system RAM exhaustion by using Level Zero allocations (llama/21597)

* SYCL: fix multi-GPU system RAM exhaustion by using Level Zero allocations

Replace sycl::malloc_device with zeMemAllocDevice for GPU memory allocation
in the SYCL backend. sycl::malloc_device triggers the xe kernel driver's
DMA-buf/TTM path which mirrors every VRAM allocation 1:1 in system RAM.
zeMemAllocDevice uses the SVM/P2P path with no host staging.

On a dual Intel Arc Pro B70 system (64GB VRAM, 64GB RAM), a 15.6 GiB model
consumed 60 GiB of system RAM via sycl::malloc_device, causing OOM crashes.
With zeMemAllocDevice, the same workload uses ~6.7 GiB of system RAM with
no performance regression.

All Level Zero calls include automatic fallback to the original SYCL
allocation path if Level Zero interop is unavailable.

* SYCL: address review feedback - remove try/catch, check device types, deduplicate

- Remove try/catch from malloc/free/memcpy helpers, check backend and
  device type upfront instead (ggml_sycl_is_level_zero, ggml_sycl_is_dgpu)
- Move shared helpers (is_level_zero, is_dgpu, free_device) to common.cpp
  and declare in common.hpp to eliminate code duplication
- Use SYCL_CHECK(CHECK_TRY_ERROR()) for fallback sycl::free calls
- Guard dev2dev_memcpy L0 path to dGPU-to-dGPU only, preserving the
  host-staged path for iGPU-to-dGPU transfers
- Add Windows Level Zero SDK path detection (LEVEL_ZERO_V1_SDK_PATH)
  in CMakeLists.txt (co-authored with @arthw)

* SYCL: add build/runtime flags for Level Zero, address review feedback

Implements the architecture suggested by @arthw: compile-time and runtime
flags to cleanly separate Level Zero and SYCL memory API paths.

- Add GGML_SYCL_SUPPORT_LEVEL_ZERO cmake option (default ON). All Level
  Zero code is wrapped in #ifdef so the build works on systems without
  the Level Zero SDK installed (e.g. CPU-only CI servers). Both the
  loader library and headers are checked before enabling.

- Add GGML_SYCL_ENABLE_LEVEL_ZERO runtime env var (default 1). Controls
  whether Level Zero or SYCL memory APIs are used. Only one API style is
  used per session, no mixing. If Level Zero is enabled but the devices
  don't support the Level Zero backend, it auto-disables with a warning.

- Remove Level Zero code from dpct_malloc. It was unused (dpct::device_memory
  is not called anywhere in the backend) and used try/catch for flow control.

- Update SYCL.md with documentation for both new parameters.

Tested on Intel Arc Pro B70 (32GB), single-GPU and dual-GPU, with both
GGML_SYCL_SUPPORT_LEVEL_ZERO=ON and OFF builds. AI-assisted development
(Claude). Code reviewed and tested on my hardware.

* SYCL: unify Level Zero malloc/free call sites, address review feedback

Move ggml_sycl_malloc_device to common.cpp alongside ggml_sycl_free_device.
Both functions are now unconditionally available — Level Zero code is
#ifdef'd inside the functions, not at call sites. All call sites use
uniform SYCL_CHECK(CHECK_TRY_ERROR()) wrapping with no #ifdef blocks.

Addresses arthw's review: wrap all malloc/free in SYCL_CHECK for stack
traces on failure, eliminate duplicated #ifdef/else patterns at 6 call
sites (-29 lines net).

Co-Authored-By: Claude Opus 4.6 (1M context) <redacted>
* SYCL: add Level Zero SDK to CI, fix device check and missed alloc paths

Add Level Zero SDK installation to Ubuntu and Windows SYCL CI jobs
so the Level Zero code path is compiled and tested in CI.

Fix two bugs found during extended dual-GPU testing (no
ONEAPI_DEVICE_SELECTOR set):

- The Level Zero backend check was iterating all SYCL devices
  including CPU. The OpenCL CPU device caused Level Zero to be
  disabled for the GPUs, defeating the fix on multi-GPU systems.
  Added is_gpu() filter so only GPU devices are checked.

- sycl_ext_malloc_device/sycl_ext_free (tensor reorder temp buffers)
  were still calling sycl::malloc/sycl::free directly, bypassing the
  Level Zero path. Routed through ggml_sycl_malloc_device/free_device
  for consistency with the other device memory call sites.

Co-Authored-By: Claude Opus 4.6 (1M context) <redacted>
* SYCL: address arthw review feedback on Level Zero memory API structure

- Move ggml_sycl_malloc_device to static function in ggml-sycl.cpp;
  only ggml_sycl_free_device (used by common.cpp) stays in common.cpp
- Switch both helpers to use g_ggml_sycl_enable_level_zero global
  instead of per-call queue backend checks
- Remove #ifdef wrapper from global definition; always declare at 0,
  add #else branch in init block so it stays 0 when L0 not compiled in
- Update init loop comment to explain GPU-only device check
- CMakeLists: message(STATUS) before the if block; align option wording

AI-assisted implementation. Reviewed and tested on dual Intel Arc Pro
B70 (32 GB each): test-backend-ops OK on both GPUs, single/dual-GPU
Q4_K_M and Q8_0 bench correct, zeMemAllocDevice GTT delta confirmed
<5 MiB per 4 GiB allocation (vs ~4 GiB shadow with sycl::malloc_device).

Co-Authored-By: Claude Sonnet 4.6 <redacted>
* SYCL: remove unused cstdio/cstdlib includes from common.cpp

Leftover from the deleted ggml_sycl_queue_supports_level_zero helper.

Co-authored-by: Claude Sonnet 4.6 <redacted>
* Apply suggestions from code review

Co-authored-by: Neo Zhang <redacted>
* SYCL: preserve Level Zero allocation path during early malloc

* ci: fix Level Zero package conflict in Intel Docker build

* ci: find Level Zero loader in oneAPI package step

* ci: allow Windows SYCL package without Level Zero DLL

---------

Co-authored-by: Claude Opus 4.6 (1M context) <redacted>
Co-authored-by: Neo Zhang <redacted>
3 months agocmake : add CMakePresets.json [no ci] (#3808)
Daniel Bevenius [Mon, 25 May 2026 09:25:15 +0000 (11:25 +0200)]
cmake : add CMakePresets.json [no ci] (#3808)

This commit adds a CMakePresets.json file similar to the one in
llama.cpp.

The motivation for this is that this provides sharable named
configuration which can be used with cmake --preset <name>.

It also allows for extendins these preset with a
CMakeUserPresets.json for specific hardware (like CPUs),
architectures, and toolchains etc.

3 months agofix: in bindings/ruby/test/jfk_reader/jfk_reader in jfk_reader.c (#3756)
OrbisAI Security [Mon, 25 May 2026 06:19:23 +0000 (11:49 +0530)]
fix: in bindings/ruby/test/jfk_reader/jfk_reader in jfk_reader.c (#3756)

* fix: V-002 security vulnerability

Automated security fix generated by Orbis Security AI

* fix(ruby): use Ruby allocator macros in jfk_reader and fix memory leak

- Replace calloc/free with ALLOC_N/xfree to match Ruby binding conventions
  (ALLOC_N handles overflow checking and raises NoMemoryError on failure)
- Free temporary samples buffer after conversion loop (was leaked)
- Add NULL check for fopen return value with rb_raise
- Add comment clarifying n_samples is a compile-time constant

Co-Authored-By: Claude Opus 4.6 <redacted>
* fix(ruby): return false instead of rb_raise in memory_view callback

rb_memory_view_get_func_t callbacks should communicate errors via
return value (false), not exceptions. rb_memory_view_get has no
exception-handling wrapper around get_func calls.

Co-Authored-By: Claude Opus 4.6 <redacted>
* replacing ALLOC_N with rb_protect as ALLOC_N raises Ruby exceptions

---------

Co-authored-by: Claude Opus 4.6 <redacted>
3 months agocommon : fix server /inference fails to decode in-memory audio (regression) (#3818)
Pascal [Fri, 22 May 2026 06:27:35 +0000 (08:27 +0200)]
common : fix server /inference fails to decode in-memory audio (regression) (#3818)

* common: add memory buffer overload of read_audio_data

whisper-server /inference without --convert passed the uploaded file
bytes to read_audio_data as a filename, so ma_decoder_init_file tried
to open a path starting with "RIFF" and failed. every request returned
HTTP 400 "Invalid request" on builds without WHISPER_FFMPEG, which is
the default.

factor the PCM extraction into a shared helper and add an overload that
decodes straight from a memory buffer via ma_decoder_init_memory, which
the function already used for the stdin path. server now calls it with
the upload content. the filename overload behavior is unchanged.

3 months agoci : use github ubuntu-22.04-arm runner instead of qemu (#3815)
Daniel Bevenius [Thu, 21 May 2026 08:59:58 +0000 (10:59 +0200)]
ci : use github ubuntu-22.04-arm runner instead of qemu (#3815)

* ci : use github ubuntu-22.04-arm runner instead of qemu

This commit updates the ubuntu-22-gcc-arm64 job to use a arm github
runner instead of QEMU.

The motivation for this is that we get intermittent failure specifically
related to QEMU. For example:
```console
Segmentation fault (core dumped)
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault (core dumped)
dpkg: error processing package libc-bin (--configure):
installed libc-bin package post-installation script subprocess returned error exit status 139
Processing triggers for ca-certificates (20240203~22.04.1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Errors were encountered while processing:
libc-bin
E: Sub-process /usr/bin/dpkg returned an error code (1)
```
This is an attempt to try to avoid QEMU and hence avoid this issue.

* ci : remove QEMU where possible

3 months agowhisper : set bench data for each iteration (#3812)
Daniel Bevenius [Tue, 19 May 2026 06:58:43 +0000 (08:58 +0200)]
whisper : set bench data for each iteration (#3812)

* whisper : set bench data for each iteration

This commit updates whisper_bench_ggml_mul_mat_str to intialize the
tensors data for each iteration.

The motivation for this is that is currently possible for a previous
run's results, F32 values, to leak into the next run. When it is time
for the F16 iteration then F32 results can cause NaN values to appear
in the tensor values causing the F16 iteration to fail.

Refs:https://github.com/ggml-org/whisper.cpp/actions/runs/25901678402/job/76152894644?pr=3735

* ci : set GGML_NATIVE=OFF if x86_64

This commit sets GGML_NATIVE=OFF for x86_64 architectures.

The motivation for this is to try to get CI to pass and the theory is
that the libggml-cpu.so library in the ccache might have been built by a
runner that supports a different instruction set. When another runner
that does not support that instruction set tries to use it, it will fail
with a segmentation fault.

I'm not sure about this yet but going to try this out and if it does not
work I'll ssh into the runner to debug further.

3 months agoexamples : fix memory leak in read_audio_data (#3810)
petterreinholdtsen [Mon, 18 May 2026 10:16:39 +0000 (12:16 +0200)]
examples : fix memory leak in read_audio_data (#3810)

This commit addresses a memory leak in the `read_audio_data` function
where it is currently possible that a call to `ma_decoder_init_file`
succeeds and the function returns early without calling
`ma_decoder_uninit`. A similar situation can occur with
`ma_decoder_init_memory`.

Refs: https://bugs.debian.org/1124796

Co-authored-by: Daniel Bevenius <redacted>
3 months agoserver : Return speaker information in JSON (#3782)
Andreas Lubbe [Mon, 18 May 2026 07:18:04 +0000 (09:18 +0200)]
server : Return speaker information in JSON (#3782)

3 months agoserver: add support for carry_initial_prompt (#3781)
Andreas Lubbe [Fri, 15 May 2026 12:03:17 +0000 (14:03 +0200)]
server: add support for carry_initial_prompt (#3781)

* Add support for carry_initial_prompt on the server

* Update README

3 months agotalk-llama : sync llama.cpp
Georgi Gerganov [Thu, 14 May 2026 08:53:43 +0000 (11:53 +0300)]
talk-llama : sync llama.cpp

3 months agosync : ggml
Georgi Gerganov [Thu, 14 May 2026 08:53:30 +0000 (11:53 +0300)]
sync : ggml

3 months agoggml-webgpu: only use subgroup-matrix path when head dims are divisible by sg_mat_k...
Zheyuan Chen [Wed, 13 May 2026 22:12:40 +0000 (15:12 -0700)]
ggml-webgpu: only use subgroup-matrix path when head dims are divisible by sg_mat_k / sg_mat_n (llama/23020)

3 months agoFix for issue #22974. Cast intermediate results to float before adding and casting...
scutler-nv [Wed, 13 May 2026 20:36:14 +0000 (13:36 -0700)]
Fix for issue #22974. Cast intermediate results to float before adding and casting the result to the destination type. Avoids half+half operator ambiguity. (llama/22994)