]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/log
pkg/ggml/sources/whisper.cpp
4 months agohexagon: optimize HMX matmul operations (llama/21071)
nullname [Thu, 16 Apr 2026 20:48:34 +0000 (04:48 +0800)]
hexagon: optimize HMX matmul operations (llama/21071)

* optimize hmx_mat_mul functions by calculating row and column tiles upfront

* refactor core_dot_chunk_fp16 to use size_t for tile counts and improve readability

* wip

* set scale outside of loop

* wip

* refactor core_mma_chunk_fp16 and mat_mul_qk_0_d16a32 to use size_t for tile counts

* wip

* wip

* refactor transfer_output_chunk_fp16_to_fp32 to use size_t for dimensions

* refactor core_dot_chunk_fp16 to use size_t for tile row stride calculation

* wip

* refactor hmx_mat_mul functions to use hvx_vec_splat_f16 for column scales initialization

* refactor hmx_mat_mul_permuted_w16a32_batched to streamline scale setting and locking

* refactor core_dot_chunk_fp16 to improve tile stride calculations for output

* refactor hmx_mat_mul functions to use Q6_V_vsplat_R for column scales initialization

* fix compiling error

* wip

* optimize row and column tile indexing in core_mma_chunk_fp16 function

* wip

* Revert "wip"

This reverts commit cde679eff79c4a28dd2d89d32f710015e09592b6.

* Add size limit check for HAP_mmap in htp_iface_mmap and drop_mmap functions

* wip

4 months agoopencl: add q5_K gemm and gemv kernels for Adreno (llama/21595)
shaofeiqi [Thu, 16 Apr 2026 19:08:33 +0000 (12:08 -0700)]
opencl: add q5_K gemm and gemv kernels for Adreno (llama/21595)

4 months agoggml: add graph_reused (llama/21764)
Aman Gupta [Thu, 16 Apr 2026 09:21:28 +0000 (17:21 +0800)]
ggml: add graph_reused (llama/21764)

* ggml: add graph_reused

* use versioning instead of reuse flag

* increment version with atomic

* use top bits for split numbering

* add assert

* move counter to ggml.c

* set uid in split_graph only

* fix windows

* address further review comments

* get next_uid rather than doing bit manipulation

* rename + add comment about uid

4 months agometal: Implement ROLL op (llama/21946)
Kusha Gharahi [Thu, 16 Apr 2026 08:54:37 +0000 (03:54 -0500)]
metal: Implement ROLL op (llama/21946)

* nix: support unified apple-sdk

* Impl roll op for Metal

* Revert "nix: support unified apple-sdk"

This reverts commit abfa473360471532c547de8b202c780507924d4b.

* update ops.md

* update op docs

4 months agoggml-cpu: add 128-bit RVV implementation for Quantization Vector Dot (llama/20633)
rehan-10xengineer [Thu, 16 Apr 2026 08:15:15 +0000 (13:15 +0500)]
ggml-cpu: add 128-bit RVV implementation for Quantization Vector Dot (llama/20633)

* ggml-cpu: add 128-bit impls for i-quants, ternary quants

* ggml-cpu: add 128-bit impls for iq2_xs, iq3_s, iq3_xxs, tq2_0

Co-authored-by: Rehan Qasim <redacted>
* ggml-cpu: refactor; add rvv checks

---------

Co-authored-by: taimur-10x <redacted>
Co-authored-by: Rehan Qasim <redacted>
4 months agoggml : implemented simd_gemm kernel for riscv vector extension (llama/20627)
rehan-10xengineer [Thu, 16 Apr 2026 08:14:26 +0000 (13:14 +0500)]
ggml : implemented simd_gemm kernel for riscv vector extension (llama/20627)

Co-authored-by: Rehan Qasim <redacted>
4 months agoggml-webgpu: compute pass batching and removing profiling overhead (llama/21873)
Reese Levine [Thu, 16 Apr 2026 08:12:19 +0000 (01:12 -0700)]
ggml-webgpu: compute pass batching and removing profiling overhead (llama/21873)

* Update register tiling matmul to use f32 accumulation

* fix profiling code

* Fix register tiling matmul for chrome, i'm blaming dawn

* Update batch tuning value for iOS

* compile fix

* Fix use of new load function

* Move to a single query set for GPU profiling

* Move to batching compute passes when not profiling

* Refactor build_multi

* remove iOS throttling now that we're batching compute passes

4 months agoFix Q8_0 reorder: garbage on 2nd prompt + crash on full VRAM (llama/21638)
Katostrofik [Thu, 16 Apr 2026 05:34:05 +0000 (01:34 -0400)]
Fix Q8_0 reorder: garbage on 2nd prompt + crash on full VRAM (llama/21638)

* [SYCL] Fix Q8_0 reorder: add missing dequantize path for GEMM

The Q8_0 reorder optimization (#21527) was missing a reorder-aware
dequantizer for the GEMM code path used during prompt processing.
After token generation reordered Q8_0 weights (via DMMV/MMVQ), the
next prompt processing pass would read them with the standard
dequantizer, producing garbage output.

Add dequantize_block_q8_0_reorder() and wire it into both
ggml_get_to_fp16_sycl() and ggml_get_to_fp32_sycl(), matching the
pattern already used by Q4_0, Q4_K, and Q6_K.

Fixes #21589

AI (Claude) was used to assist with root cause investigation and
writing the kernel code. All code was human-reviewed and tested
on real hardware.

* SYCL: fix reorder crash when device memory is full

The reorder optimization allocates a temporary buffer the full size of
the weight tensor on the device. When VRAM is nearly full (large models
on a single GPU), this allocation fails and the subsequent memcpy crashes
on a NULL pointer.

Fix: try device allocation first, fall back to host memory if device
memory is full. The reorder kernel still works correctly reading from
host memory over PCIe. This is slower for the one-time reorder (~21 t/s
vs ~38 t/s on Intel Arc Pro B70), but the optimization is preserved for
all subsequent inference. If both device and host allocation fail, skip
the reorder and fall back to the unoptimized kernel path.

Also fixes a bug where opt_for_reorder() marked tensors as reordered
even when the reorder was skipped due to allocation failure. This caused
DMMV/MMVQ kernels to read the original AoS data as if it were SoA,
producing garbage output or NaN results.

Tested on Intel Arc Pro B70 (32GB) with Q8_0, Q4_K_M models. Coding was
AI-assisted (Claude), reviewed and tested on hardware by a human.

Fixes #20478

* SYCL: add RAII temp buffer class + macro guard for host fallback

Replace sycl_ext_malloc_with_fallback/sycl_ext_free_fallback free
functions with sycl_reorder_temp_buffer RAII class. The host_fallback
bool is now a private member, and cleanup happens automatically at
scope exit.

Add GGML_SYCL_HOST_MEM_FALLBACK cmake option (default ON) to guard
the host memory fallback code path. Device access to host memory
requires Linux kernel 6.8+ (Ubuntu 26.04+); users on older kernels
can set -DGGML_SYCL_HOST_MEM_FALLBACK=OFF to disable it.

Addresses arthw's review on PR #21638.

Co-Authored-By: Claude Opus 4.6 (1M context) <redacted>
* SYCL: document GGML_SYCL_HOST_MEM_FALLBACK build option in SYCL.md

Co-Authored-By: Claude Opus 4.6 (1M context) <redacted>
* SYCL: add reorder-aware DMMV dequantizers for Q4_K and Q6_K

Q4_K and Q6_K had reorder support for MMVQ and GEMM paths but not
DMMV. When the DMMV path encountered reordered data it would abort.

Add DMMV kernels that read from the SOA reorder layout for both
types. Same math as the non-reorder versions, different memory
access pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <redacted>
---------

Co-authored-by: Claude Opus 4.6 (1M context) <redacted>
4 months agovulkan: optimize im2col (llama/21713)
Ruben Ortlam [Wed, 15 Apr 2026 17:04:51 +0000 (19:04 +0200)]
vulkan: optimize im2col (llama/21713)

* vulkan: improve im2col memory write layout

* cap workgroups

* minimal device tuning

* use vendor_id instead of subgroup size

4 months agocuda: Q1_0 initial backend (llama/21629)
Pasha Khosravi [Wed, 15 Apr 2026 16:38:38 +0000 (09:38 -0700)]
cuda: Q1_0 initial backend (llama/21629)

* [cuda] initial Q1_0 backend

* remove unused code, fix AMD MMA guard

* attempt to support dp4a

* Apply suggestions from code review

Co-authored-by: Johannes Gäßler <redacted>
---------

Co-authored-by: Johannes Gäßler <redacted>
4 months agoggml-webgpu: Fix dequantization helpers to not pass in pointers (llama/21872)
Reese Levine [Wed, 15 Apr 2026 16:14:40 +0000 (09:14 -0700)]
ggml-webgpu: Fix dequantization helpers to not pass in pointers (llama/21872)

* Fix dequantization helpers to not pass in pointers

* Increase XIELU precision

4 months agoCUDA: require explicit opt-in for P2P access (llama/21910)
Johannes Gäßler [Wed, 15 Apr 2026 14:01:46 +0000 (16:01 +0200)]
CUDA: require explicit opt-in for P2P access (llama/21910)

4 months agoCUDA: manage NCCL communicators in context (llama/21891)
Johannes Gäßler [Wed, 15 Apr 2026 13:58:40 +0000 (15:58 +0200)]
CUDA: manage NCCL communicators in context (llama/21891)

* CUDA: manage NCCL communicators in context

* add check that all backends are CUDA

* remove unused vector, limit init to > 1 GPUs

* fix warnings

* fix cuda device, cache allreduce

4 months agorpc : add native RDMA transport for RPC backend (RoCEv2) (llama/20590)
Valeriy Dubov [Wed, 15 Apr 2026 13:44:02 +0000 (16:44 +0300)]
rpc : add native RDMA transport for RPC backend (RoCEv2) (llama/20590)

4 months agodocs: more extensive RoPE documentation [no ci] (llama/21953)
Xuan-Son Nguyen [Wed, 15 Apr 2026 12:45:16 +0000 (14:45 +0200)]
docs: more extensive RoPE documentation [no ci] (llama/21953)

* more extensive ggml_rope documentation

* add more docs

* nits

4 months agohexagon: optimization for HMX mat_mul (llama/21554)
Yiwei Shao [Tue, 14 Apr 2026 21:09:03 +0000 (14:09 -0700)]
hexagon: optimization for HMX mat_mul (llama/21554)

* hexagon: add async HMX worker

Introduce hmx-worker (dedicated thread for HMX compute) to overlap HMX
matmul with HVX dequant/DMA stages in the pipeline path, replacing the
previous synchronous HMX calls that blocked the main thread.

* hexagon: cost-based VTCM chunk search for out-stationary matmul

* hexagon: fix futex race in hmx_worker_drain
Store the boolean to local variable avoid atomic load twice

* hex-mm: hmx optimize scatter/transpose and use HMX intrinsics

* hex-vmem: drop vmem limit a touch under 3GB on v73

* hexagon: add fwd declaration of htp_context

* hex-hmx: replace hmx-worker with hmx-queue that mimics dma-queue interface

Simplifies the overall implemantion, reduces thread wakeup roundtrips.

* hex-mm: add debug log to hmx work func called from hmx-queue

* Update hmx-queue.h

Co-authored-by: Max Krasnyansky <redacted>
---------

Co-authored-by: Kim-Chyan Gan <redacted>
Co-authored-by: Max Krasnyansky <redacted>
Co-authored-by: Max Krasnyansky <redacted>
4 months agoggml : remove ggml-ext.h (llama/21869)
Xuan-Son Nguyen [Tue, 14 Apr 2026 14:32:58 +0000 (16:32 +0200)]
ggml : remove ggml-ext.h (llama/21869)

* ggml: correct placement of ggml-ext.h

* ggml : remove ggml-ext.h

---------

Co-authored-by: Georgi Gerganov <redacted>
4 months agometal : fix FA support logic (llama/21898)
Georgi Gerganov [Tue, 14 Apr 2026 14:32:29 +0000 (17:32 +0300)]
metal : fix FA support logic (llama/21898)

4 months agovulkan: Programmatically add RoundingModeRTE to all shaders when the device supports...
Jeff Bolz [Tue, 14 Apr 2026 13:17:45 +0000 (15:17 +0200)]
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

4 months agoci : re-enable mac workflows (llama/21894)
Georgi Gerganov [Tue, 14 Apr 2026 12:58:09 +0000 (15:58 +0300)]
ci : re-enable mac workflows (llama/21894)

* ci : re-enable mac workflows

* vulkan : fix compile warning

4 months agometal : add XIELU unary op (llama/20802)
Seyoung Jeong [Tue, 14 Apr 2026 12:43:59 +0000 (21:43 +0900)]
metal : add XIELU unary op (llama/20802)

4 months agoggml : fix ARM NEON nvfp4 dot product on non-dotprod targets (llama/21559)
Richard Davison [Tue, 14 Apr 2026 11:23:45 +0000 (13:23 +0200)]
ggml : fix ARM NEON nvfp4 dot product on non-dotprod targets (llama/21559)

4 months agocmake: fix CMP0194 warning on Windows with MSVC (llama/21630)
texasich [Tue, 14 Apr 2026 10:47:56 +0000 (05:47 -0500)]
cmake: fix CMP0194 warning on Windows with MSVC (llama/21630)

* cmake: fix CMP0194 warning on Windows with MSVC

Set CMP0194 policy to NEW before project() call in ggml/CMakeLists.txt to suppress the "MSVC is not an assembler for language ASM" warning introduced in CMake 4.1.

The ggml project enables ASM globally for Metal (macOS) and KleidiAI (ARM) backends. On Windows/MSVC, no assembler sources are used, but CMake 4.1+ warns because cl.exe is not a valid ASM compiler.

This follows the same pattern used in ggml-vulkan (CMP0114, CMP0147).

Closes ggml-org/llama.cpp#20311

* cmake: apply cisc's formatting suggestion

---------

Co-authored-by: texasich <redacted>
4 months agoggml-webgpu: Update register tiling matmul to use f32 accumulation (llama/21644)
Reese Levine [Tue, 14 Apr 2026 10:46:41 +0000 (03:46 -0700)]
ggml-webgpu: Update register tiling matmul to use f32 accumulation (llama/21644)

* Update register tiling matmul to use f32 accumulation

* fix profiling code

* Fix register tiling matmul for chrome, i'm blaming dawn

* Update batch tuning value for iOS

* compile fix

* Fix use of new load function

4 months agovulkan: Support GGML_TYPE_NVFP4 (llama/21455)
Jeff Bolz [Tue, 14 Apr 2026 09:34:23 +0000 (11:34 +0200)]
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.

4 months agovulkan: Flash Attention DP4A shader for quantized KV cache (llama/20797)
Ruben Ortlam [Mon, 13 Apr 2026 12:21:31 +0000 (14:21 +0200)]
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

4 months agoCUDA: Limit DeviceSegmentedSort to immediate mode (llama/21718)
Oliver Simons [Mon, 13 Apr 2026 09:14:06 +0000 (11:14 +0200)]
CUDA: Limit DeviceSegmentedSort to immediate mode (llama/21718)

* CUDA: Limit DeviceSegmentedSort to immediate mode

DeviceSegmentedSort is currently not capturable in a cuda graph. Hence,
we have to go for the slower DeviceSegmentedRadixSort in that case.

Perf numbers on RTX Pro 6000 Blackwell Max-Q:
DeviceSegmentedRadixSort in graph mode (i.e. CUDA Graphs)

  ARGSORT(type=f32,ne=[2048,512,1,1],order=1):                 12291 runs -   105.94 us/run -     8192 kB/run -   73.75 GB/s
  ARGSORT(type=f32,ne=[4096,512,1,1],order=1):                 10245 runs -   115.08 us/run -    16384 kB/run -  135.77 GB/s
  ARGSORT(type=f32,ne=[8192,512,1,1],order=1):                  5125 runs -   221.22 us/run -    32768 kB/run -  141.26 GB/s
  ARGSORT(type=f32,ne=[16384,512,1,1],order=1):                 2565 runs -   430.98 us/run -    65536 kB/run -  145.02 GB/s
  ARGSORT(type=f32,ne=[32768,512,1,1],order=1):                 1028 runs -  1185.83 us/run -   131072 kB/run -  105.41 GB/s
  ARGSORT(type=f32,ne=[65536,512,1,1],order=1):                  387 runs -  2748.62 us/run -   262144 kB/run -   90.95 GB/s

DeviceSegmentedSort in immediate mode

  ARGSORT(type=f32,ne=[2048,512,1,1],order=1):                 16388 runs -    71.17 us/run -     8192 kB/run -  109.78 GB/s
  ARGSORT(type=f32,ne=[4096,512,1,1],order=1):                 12294 runs -    81.38 us/run -    16384 kB/run -  192.00 GB/s
  ARGSORT(type=f32,ne=[8192,512,1,1],order=1):                  5125 runs -   240.81 us/run -    32768 kB/run -  129.77 GB/s
  ARGSORT(type=f32,ne=[16384,512,1,1],order=1):                 2565 runs -   406.60 us/run -    65536 kB/run -  153.71 GB/s
  ARGSORT(type=f32,ne=[32768,512,1,1],order=1):                 1285 runs -   873.23 us/run -   131072 kB/run -  143.15 GB/s
  ARGSORT(type=f32,ne=[65536,512,1,1],order=1):                  516 runs -  2288.46 us/run -   262144 kB/run -  109.24 GB/s

* Add test case for dispatch to DeviceSegmentedRadixSort

We currently lack a way to force graph mode in CUDA, patch callback to
invoke ggml_backend_compare_graph_backend twice to enforce each test to
run in graph mode

4 months agoRemove extra conditional check on debug mode. (llama/21798)
Masashi Yoshimura [Mon, 13 Apr 2026 03:13:04 +0000 (12:13 +0900)]
Remove extra conditional check on debug mode. (llama/21798)

4 months agosycl: disable Q1_0 in backend and cleanup unused variables (llama/21807)
Akarshan Biswas [Mon, 13 Apr 2026 01:44:58 +0000 (07:14 +0530)]
sycl: disable Q1_0 in backend and cleanup unused variables (llama/21807)

4 months agomtmd: add Gemma 4 audio conformer encoder support (llama/21421)
Stephen Cox [Sun, 12 Apr 2026 12:15:26 +0000 (00:15 +1200)]
mtmd: add Gemma 4 audio conformer encoder support (llama/21421)

* mtmd: add Gemma 4 audio conformer encoder support

Add audio processing for Gemma 4 E2B/E4B via a USM-style Conformer.

Architecture:
- 12-layer Conformer: FFN → Self-Attention → Causal Conv1D → FFN → Norm
- Subsampling Conv Projection: 2x Conv2D(stride=2) with LayerNorm
- Full self-attention with sinusoidal RPE and sliding window mask (24)
- Logit softcapping at 50.0, ClippableLinear clamping
- Output: 1024 → 1536 → RMSNorm → multimodal embedder

Mel preprocessing (dedicated mtmd_audio_preprocessor_gemma4a):
- HTK mel scale, 128 bins, magnitude STFT, mel_floor=1e-3
- Standard periodic Hann window (320 samples), zero-padded to FFT size
- Semicausal left-padding (frame_length/2 samples)
- Frame count matched to PyTorch (unfold formula)
- No pre-emphasis, no Whisper-style normalization
- Mel cosine similarity vs PyTorch: 0.9998

Key fixes:
- Tensor loading dedup: prevent get_tensor() from creating duplicate
  entries in ctx_data. Fixed with std::set guard.
- ClippableLinear clamp_info loading moved after per-layer tensors.
- Sliding window mask (24 positions) matching PyTorch context_size.
- Skip Whisper normalization for Gemma4 mel output.

Tested on E2B and E4B with CPU and Vulkan backends.
Transcribes: "Glad to see things are going well and business is starting
to pick up" (matching ground truth).

Ref: #21325

4 months agoCUDA: skip compilation of superfluous FA kernels (llama/21768)
Johannes Gäßler [Sat, 11 Apr 2026 16:52:11 +0000 (18:52 +0200)]
CUDA: skip compilation of superfluous FA kernels (llama/21768)

4 months agoopencl: add basic support for q5_k (llama/21593)
shaofeiqi [Sat, 11 Apr 2026 08:46:19 +0000 (01:46 -0700)]
opencl: add basic support for q5_k (llama/21593)

* opencl: add general q5_k mv

* opencl: add flattened Q5_K mv and general Q5_K mm

* opencl: fix Q5_K unit tests

4 months agoggml : fix a few instances of missing GGML_TYPE_Q1_0 cases (llama/21716)
Sigbjørn Skjæret [Sat, 11 Apr 2026 06:45:00 +0000 (08:45 +0200)]
ggml : fix a few instances of missing GGML_TYPE_Q1_0 cases (llama/21716)

4 months agoCUDA: also store node->src ne/nb for graph equality (llama/21736)
Aman Gupta [Sat, 11 Apr 2026 02:30:30 +0000 (10:30 +0800)]
CUDA: also store node->src ne/nb for graph equality (llama/21736)

4 months agohexagon: improved Op queuing, buffer and cache management (llama/21705)
Max Krasnyansky [Fri, 10 Apr 2026 22:47:43 +0000 (15:47 -0700)]
hexagon: improved Op queuing, buffer and cache management (llama/21705)

* hexagon: introduce op request batching and rewrite buffer managment

The host now prepares batches of requests and dispatches them via a single dspqueue message.

Buffers are mapped explicitly by NPU while processing batches.

* hex-dma: disable l2 bypass since to work around new issue due to no flushes between Ops

* hex-utils: add explicit l2flush and l2clear helpers

* hex-opreq: use fine-grain per tensor l2 management

* hex-opreq: avoid redundant invalidates for tensors we already flushed

* hex-opreq: update debug messages

* htp-opreq: reuse ops_context

* hex-opreq: do not flush or invalidate cache lines beyond buffer boundry

* hex-opreq: fix errors in log message

* Revert "hex-opreq: do not flush or invalidate cache lines beyond buffer boundry"

This reverts commit 8b7f0a55a750a6430ce4eb1874c7feb3d720056d.

* hexagon: limit l2 flushes to 1MB which covers l2 cache

* hex-opreq: limit cache flush to 4MB

Looks like 4MB cont. vitual space should cover the 1MB cache.

* hexagon: drop cache flush size to 2MB

* hex-opreq: start reworking opreq packing

* hex-opreq: introduce new way of packing opbatch where tensors are stored separately

* hex-opreq: add a simple fastrpc call to force unmap all buffers

* hex-l2flush: somehow 2MB does not seem robust, also cleanup step size to use line-size

* hex-opreq: bump opreq batch size to 256

* hex-mm: place src1 spad at the top of vtcm for easy reuse

* hex-ops: introduce internal types and disable src1 reuse for now

Nothing new just formalizing the repack / qyn.quant types we've been using.

* htp-opreq: use tensor pointers instead of copies

* hex-opreq: introduce more robust way for tracking vtcm/spad reuse

This removes the SKIP_QUANTIZE flag that became fragile with the addition of HMX and other ops.

* hex-cumsum: fix error post opreq merge

* hex-opreq: move request batch handling into the session

Prepping everything for using dspqueue buffers and doing that inside the session is much cleaner.

* hex-mm: yet another fix for src1 reuse when we're mixing hmx/hvx

* hex-bufs: introduce pinned mmapings and use non-pinned ones for model buffers

* hex-buf: add support for allocating shared/pinned buffer for opreqs

* hex-opbatch: make opbatches configurable

* hex-naming: better name for ggml_hexagon_shared_buffer

* hex-naming: add session->c_name() helper

* hex-opbatch: start using shm but still copy for now

* hex-opbatch: use shared buffer for packing opbatch

* hex-opbatch: beter naming for opbatch related classes and code

* hex-opbatch: reuse batched tensors with same data/dims/strides

* hex-opbatch: update logging

* hex-opbatch: add support for vmem limit for op batching

* hex-opbatch: update htp side to properly support dynamic mmap/unmap

* hex-opbatch: add OB and OQ params for run-completion script and fix the asserts in batch processing

* hex-opbatch: fixed src1 handling in act ops

* hex-act: fix empty src1 handling in swiglu and friends

Simplify preamble macro while at it

* hex-mm: minor fix vtcm and dma handling in matmul

cleaning up some left-overs from merges

* hex-opbatch: allocate extra 1KB for dspqueue overhead

* hexagon: fix softmax for non-aligned tensors and cleanup vtcm alloc

* hex-mm: properly handle hmx_disabled flag

* hex-ops: update comments

* hex-ops: add debug output for get/set-rows

* hex-mmap: optimize un/mapping of buffers

* hex-opreq: global cache flush and invalidate beyond 128KB threshold

* hex-ops: add super simple opfilter regex for debugging

If an Op matches the regex hex backend will reject it.

* hex-opbatch: wireup newer ops missed in merge and update main switch to detect this in future

* hexagon: improved vtcm acquision to remove inter-op overhead

Fully compatible with QNN-HTP coex

* hex-mm: fixed hvx fallback path

* hex-mm: lower the vmem threshold a bit further to ~3GB

* hexagon: update debug & error logs

This also fixes an issue with newer llvm merging repack and non-repack
functions. We use those pointer to distinguish between buffer types.

* hexagon: move ops context into main context

Just a cleanup. We don't need separate contexts at this point.

* hex-opbatch: cleanup naming and headers for opbatch and related descriptors

* hex-fa: it's now better to enable FA during TG to reduce graph splits

* hexagon: remove GGML_HEXAGON_EXPERIMENTAL env var

It's no longer useful. Please use more flexible GGML_HEXAGON_OPFILTER to disable Ops
if needed for debugging or validation.

* hexagon: fixed editorconfig check

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

Co-authored-by: Sigbjørn Skjæret <redacted>
---------

Co-authored-by: Trivikram Reddy <redacted>
Co-authored-by: Sigbjørn Skjæret <redacted>
4 months agoggml-webgpu: support non-square subgroup matrix configs for Intel GPUs (llama/21669)
Rithik Sharma [Fri, 10 Apr 2026 17:52:38 +0000 (10:52 -0700)]
ggml-webgpu: support non-square subgroup matrix configs for Intel GPUs (llama/21669)

4 months agoggml-webgpu: address quantization precision and backend lifecycle managment (llama...
Chen Yuan [Fri, 10 Apr 2026 17:52:01 +0000 (13:52 -0400)]
ggml-webgpu: address quantization precision and backend lifecycle managment (llama/21521)

* ggml(webgpu): fix the busy-polls in Emscripten  in the waitAny after #20618, and remove the busy webgpu log

* Merge with upstream

* Fix GET_ROWS packed integer NaN when using f16 as memory buffer in shader quants

* Update Unary wgsl EXP and EXPM1 for f16 stability

* Fix GET_ROWS IQ4_XS strcut for NaN f16 canonicalization

* Fix numerical percision for unary sqrt when working with f16

* Fix NaN canonicalization for packed integers using f16

* Update err threshold for binary div ops when using f16

* backend: Keep one Dawn/WebGPU instance alive for the lifetime of the static backend

* clean: uncomment existing code logs

* clean: clean the unncessary debug info

* Refactor and generalize dequant helpers

* Remove deprecated quant structs

* Refactor shader defines to reduce repetition

* Remove error override for F16 type

* fix: fix the accidential removal of the proper initialization of ctx

* clean: clean legacy and format code

* fix: did not modify tests ops

---------

Co-authored-by: Jeremy J. Hartmann <redacted>
4 months agovulkan: Support Q1_0 (llama/21539)
Jeff Bolz [Fri, 10 Apr 2026 06:35:27 +0000 (01:35 -0500)]
vulkan: Support Q1_0 (llama/21539)

* vulkan: Support Q1_0

* use get_dm

4 months agoCUDA: fuse muls (llama/21665)
Aman Gupta [Fri, 10 Apr 2026 02:24:09 +0000 (10:24 +0800)]
CUDA: fuse muls (llama/21665)

4 months agoHIP: add CDNA4 (gfx950) architecture support for MI350X/MI355X (llama/21570)
andyluo7 [Thu, 9 Apr 2026 19:13:32 +0000 (22:13 +0300)]
HIP: add CDNA4 (gfx950) architecture support for MI350X/MI355X (llama/21570)

Add AMD Instinct MI350X/MI355X (gfx950, CDNA4) support:

- vendors/hip.h: Add CDNA4 preprocessor define for __gfx950__
- common.cuh: Add GGML_CUDA_CC_CDNA4 and GGML_CUDA_CC_IS_CDNA4 macros
- mma.cuh: Route CDNA4 to compatible MFMA instructions:
  * f32 matmul: mfma_f32_16x16x4f32 (xf32 variant unavailable on gfx950)
  * bf16 matmul: mfma_f32_16x16x16bf16_1k (same as CDNA3)
  * int8 matmul: mfma_i32_16x16x32_i8/32x32x16 (same as CDNA3)
- mmq.cuh: Include CDNA4 in stream-k kernel dispatch

CDNA4 is largely compatible with CDNA3 except:
- No xf32 MFMA (mfma_f32_16x16x8_xf32) — routes to f32 path
- Different FP8 format (e4m3fn vs e4m3_fnuz) — not changed here

Tested on AMD Instinct MI355X (gfx950), ROCm 7.0.1:
- Build: compiles cleanly with -DAMDGPU_TARGETS=gfx950
- llama-bench (Qwen2.5-1.5B Q4_K_M, single GPU):
  * f16+FA: 40,013 tok/s prefill, 254 tok/s decode
  * q8_0+FA: functional
- Flash attention: works correctly
- MMQ: works correctly with stream-k dispatch

Co-authored-by: Andy Luo <redacted>
4 months agoggml: backend-agnostic tensor parallelism (experimental) (llama/19378)
Johannes Gäßler [Thu, 9 Apr 2026 14:42:19 +0000 (16:42 +0200)]
ggml: backend-agnostic tensor parallelism (experimental) (llama/19378)

* ggml: backend-agnostic tensor parallelism

* support for GPT-OSS, Qwen 3 MoE

* partial Vulkan fix

* add support for 4/8 GPUs

* unconditional peer access

* re-use buffers + ggml contexts

* fix output pattern

* NCCL support

* GGML: HIP: add RCCL support

* Remove shfl and AllReduce from backend interface

* move allocation workaround out of ggml-alloc.c

* 2d tensor set/get support

* Fix the seg fault without NCCL

* Apply suggestion from JohannesGaessler

* support for tensor dims % n_devs != 0

* fix view_offs scaling

* arbitrary num. of GPUs/tensor split

* fix compilation

* better granularity estimate

* Support device-specific host buffer types if all underlying backends expose the same type. This allows using pinned memory instead of pageable memory for CUDA.

Fix compilation errors.

* partial Qwen 3 Next support

* Fix qwen3 30b (llama/8)

* Fix crash with Qwen-30B-A3B Q4_0

Qwen-30B-A3B Q4_0 has an intermediate dimension of 768. Using a granularity of 256 forces an uneven split between GPUs, which is not supported by the current implementation.

* Decide block size based on tensor quantization type

* Fix crashes due to KV cache serialization (llama/9)

KV cache serialization requires non-zero offsets on the tensor. Add support in the meta backend to set/get a tensor with a non-zero offset.

* metal : fix build (llama/7)

* static memory allocations, fix usage count

* fix tensor granularity

* more even memory distribution

* use BF16 for allreduce

* rebase fixup

* better error message for unsupported architectures

* Fix device mismatch during scatter of allReduce. (llama/11)

There is a mismatch between the dst buffer device and the backend device, causing the use of sync copies

* Enable the previous allreduce implementation. It is better in both perf and stability (llama/12)

* delay AllReduce for Moe for less I/O

* build : clean-up compile warnings

* backend : move most of the meta backend API to ggml-backend-impl.h

* cont : hide unused public API in the implementation

* llama : use llama_device + remove ggml_backend_dev_is_meta()

* ggml-backend : remove unused alloc include

* minor : remove regex include

* ggml : introduce ggml-ext.h for staging new APIs

* rebase fixup

* fix tests

* llama : more robust logic for determining Meta devices (llama/16)

* llama : more robust logic for determining Meta devices

* cont : fix devs size check

Co-authored-by: Johannes Gäßler <redacted>
* cont : fix log type

Co-authored-by: Johannes Gäßler <redacted>
---------

Co-authored-by: Johannes Gäßler <redacted>
* disable roundtrip for meta backend

* fix arch selection

* Qwen 3.5 support

* fix Gemma 4 MoE

* fix OpenVino, SYCL

* fix test-llama-archs for CPU-only builds

* Fix Qwen 3.5 MoE

* disable meta backend tests for WebGPU

* tests : filter CPU-based devices from the Meta backend tests (llama/17)

* meta : formatting, naming, indentation (llama/18)

* formatting : llama-model.cpp

* formatting : ggml-ext.h

* formatting : ggml-backend-meta.cpp

* meta : add TODO

* add documentation

* better error messages

* fix GPT-OSS

---------

Co-authored-by: Carl Philipp Klemm <redacted>
Co-authored-by: Gaurav Garg <redacted>
Co-authored-by: Georgi Gerganov <redacted>
4 months agoggml : check return value of CUB calls used in argsort and top-k (they all return...
fairydreaming [Thu, 9 Apr 2026 13:17:11 +0000 (15:17 +0200)]
ggml : check return value of CUB calls used in argsort and top-k (they all return cudaError_t) (llama/21676)

Co-authored-by: Stanisław Szymczyk <redacted>
4 months agometal : add missing mm-id specializations for q1_0 (llama/21662)
Georgi Gerganov [Thu, 9 Apr 2026 07:54:00 +0000 (10:54 +0300)]
metal : add missing mm-id specializations for q1_0 (llama/21662)

4 months agosycl : add flash-attn support for head size 512 (llama/21654)
Akarshan Biswas [Thu, 9 Apr 2026 06:36:48 +0000 (12:06 +0530)]
sycl : add flash-attn support for head size 512 (llama/21654)

* sycl : add flash-attn support for head size 512

This patch extends the SYCL Flash Attention implementation to support head sizes (DKQ/DV) of 512.

Changes:
- Added DKQ/DV 512 cases to both tile and vector Flash Attention kernels.
- Updated kernel selection logic to allow vector kernels for head sizes up to 512 (previously 256).
- Removed unused/redundant AMD and RDNA-specific configuration functions in `fattn-tile.hpp`.
- Refactored `ggml_backend_sycl_buffer_init_tensor` to use a switch statement for clearer tensor extra buffer initialization.
- Added necessary template instances for the new 512 head size across various quantization types.

* remove defunct mxfp4 reorder from setting buffer type

4 months agovulkan: unify type macros to use Vx instead of _VECx (llama/21605)
Ruben Ortlam [Thu, 9 Apr 2026 05:31:51 +0000 (07:31 +0200)]
vulkan: unify type macros to use Vx instead of _VECx (llama/21605)

4 months agoCUDA: also store `node->src->data` ptrs for equality check (llama/21635)
Aman Gupta [Wed, 8 Apr 2026 17:01:56 +0000 (01:01 +0800)]
CUDA: also store `node->src->data` ptrs for equality check (llama/21635)

* CUDA: also store node->src->data ptrs for equality check

* address review comments

4 months agofix: free ctx_copy in ggml_opt_free to plug per-training-session leak (llama/21592)
RealOrko [Wed, 8 Apr 2026 15:40:15 +0000 (16:40 +0100)]
fix: free ctx_copy in ggml_opt_free to plug per-training-session leak (llama/21592)

* fix: free ctx_copy in ggml_opt_free to plug per-training-session leak

ggml_opt_alloc populates opt_ctx->ctx_copy via a free+init pair every
time the allocated graph shape changes. The last ctx_copy from the
final ggml_opt_alloc call survives until ggml_opt_free is invoked,
but ggml_opt_free was only freeing ctx_static and ctx_cpu, never
ctx_copy. Each opt_ctx lifetime therefore leaks the final per-batch
context — ~900 KB for a typical GNN training session in
sindarin-pkg-tensor, surfaced via AddressSanitizer.

ctx_copy is nullptr-initialized and ggml_free() handles NULL safely,
so the new release is guard-free.

* Update ggml/src/ggml-opt.cpp

Co-authored-by: Johannes Gäßler <redacted>
---------

Co-authored-by: realorko <redacted>
Co-authored-by: Johannes Gäßler <redacted>
4 months agowebgpu : Query for adapter support when registering WebGPU backend (llama/21579)
Reese Levine [Wed, 8 Apr 2026 13:08:29 +0000 (06:08 -0700)]
webgpu : Query for adapter support when registering WebGPU backend (llama/21579)

4 months agometal: Q1_0 backend (llama/21528)
Pasha Khosravi [Wed, 8 Apr 2026 13:07:47 +0000 (06:07 -0700)]
metal: Q1_0 backend (llama/21528)

* initial Q1_0 Metal backend

* tuning q1_0 metal kernels

* add Q1_0 to test-backend-ops

* add Q1_0<->F32 copy test

* Apply suggestions from code review

Co-authored-by: Georgi Gerganov <redacted>
---------

Co-authored-by: Georgi Gerganov <redacted>
4 months agoCUDA: make cuda graphs props check faster (llama/21472)
Aman Gupta [Wed, 8 Apr 2026 01:05:51 +0000 (09:05 +0800)]
CUDA: make cuda graphs props check faster (llama/21472)

* CUDA: compute fast hash instead of expensive props check

* use seen node

* use memcp

4 months agoggml-cuda: ds_read_b128 for q4_0 and q4_1 mmq kernels (llama/21168)
iacopPBK [Tue, 7 Apr 2026 19:47:42 +0000 (21:47 +0200)]
ggml-cuda: ds_read_b128 for q4_0 and q4_1 mmq kernels (llama/21168)

* ds_read_b128 for q4_0 and q4_1 mmq kernels

     Current for loop generates ds_read_b32 instructions with hip compiler, the new solution generates ds_read_b128 instructions for the same operation, saving some LDS bandwidth. Tested on MI50 and RX6800XT, its faster on both.

* Vectorized lds load update: used ggml_cuda_get_max_cpy_bytes and ggml_cuda_memcpy_1 functions for generic implementation

* Explicit for loop in mmq, renamed vec into tmp

* Fixed max_cpy usage in the loading loop

* Fixed typo in q4_1 kernel

* Update ggml/src/ggml-cuda/mmq.cuh

Co-authored-by: Johannes Gäßler <redacted>
* Update ggml/src/ggml-cuda/mmq.cuh

Co-authored-by: Johannes Gäßler <redacted>
* Update ggml/src/ggml-cuda/mmq.cuh

Co-authored-by: Johannes Gäßler <redacted>
* Renoved trailing white line 500

* Update mmq.cuh removed other whitelines

* Remove trailing whitespaces

---------

Co-authored-by: iacopPBK <redacted>
Co-authored-by: Johannes Gäßler <redacted>
Co-authored-by: iacopPBK <redacted>
4 months agoggml-webgpu: parameterize submission size and add iOS specific limits (llama/21533)
Reese Levine [Tue, 7 Apr 2026 17:30:01 +0000 (10:30 -0700)]
ggml-webgpu: parameterize submission size and add iOS specific limits (llama/21533)

* Work towards removing bitcast

* Move rest of existing types over

* Add timeout back to wait and remove synchronous set_tensor/memset_tensor

* move to unpackf16 for wider compatibility

* cleanup

* Remove deadlock condition in free_bufs

* Start work on removing parameter buffer pools

* Simplify and optimize further

* simplify profile futures

* Fix stride

* Try using a single command buffer per batch

* formatting

* Add parameters for different browsers in-flight submissions

* Update handling of batch size too

* Throttle ios as much as possible

* Increase timeout for llvm-pipe testing

4 months agoCUDA: check for buffer overlap before fusing (llama/21566)
Aman Gupta [Tue, 7 Apr 2026 16:57:04 +0000 (00:57 +0800)]
CUDA: check for buffer overlap before fusing (llama/21566)

* CUDA: check for buffer overlap before fusing

* use ggml_cuda_check_fusion_memory_ranges

4 months agoggml : deprecate GGML_OP_ADD1 (llama/21363)
Georgi Gerganov [Tue, 7 Apr 2026 12:28:27 +0000 (15:28 +0300)]
ggml : deprecate GGML_OP_ADD1 (llama/21363)

* ggml : deprecate GGML_OP_ADD1

* cont : remove tests

* cont : re-enable vulkan check

4 months agoggml: Vulkan build, Linux -- output error string for errno on fork failure (#20868...
Tom Overlund [Tue, 7 Apr 2026 11:54:55 +0000 (07:54 -0400)]
ggml: Vulkan build, Linux -- output error string for errno on fork failure (#20868) (llama/20904)

4 months agovulkan: add FA dequant for q4_1, q5_0, q5_1, iq4_nl (llama/21029)
mkoker [Tue, 7 Apr 2026 11:41:29 +0000 (07:41 -0400)]
vulkan: add FA dequant for q4_1, q5_0, q5_1, iq4_nl (llama/21029)

Add dequantize4() implementations for Q4_1, Q5_0, Q5_1, and IQ4_NL
in the flash attention base shader. Register them in the shader
generator, pipeline creation, and enable in the scalar/coopmat1 FA
support check.

4 months agoggml-cuda : fix CDNA2 compute capability constant for gfx90a (MI210) (llama/21519)
Antoine Viallon [Tue, 7 Apr 2026 10:18:55 +0000 (12:18 +0200)]
ggml-cuda : fix CDNA2 compute capability constant for gfx90a (MI210) (llama/21519)

GGML_CUDA_CC_CDNA2 was set to 0x910
Fix by setting the constant to 0x90a to match the actual gfx90a ISA.

4 months agoAdd Q8_0 reorder optimization (~3x tg speedup on Intel Arc) (llama/21527)
PMZFX [Tue, 7 Apr 2026 08:12:49 +0000 (04:12 -0400)]
Add Q8_0 reorder optimization (~3x tg speedup on Intel Arc) (llama/21527)

Extend the existing reorder optimization to Q8_0. The reorder
separates scale factors from weight data for coalesced memory
access -- was implemented for Q4_0/Q4_K/Q6_K but Q8_0 was missing.

On Arc Pro B70 (Xe2), Q8_0 tg goes from 4.88 to 15.24 t/s (3.1x)
on Qwen3.5-27B. BW utilization: 21% -> 66%.

The key fix beyond the kernels: Q8_0 was missing from the type
check in ggml_backend_sycl_buffer_init_tensor() that allocates
the extra struct carrying the reorder flag -- so the optimization
was silently skipped.

AI (Claude) was used to assist with root cause investigation and
writing the kernel code. All code was human-reviewed and tested
on real hardware.

Fixes: #21517
4 months agoggml-webgpu: Add the support of `MUL_MAT_ID` (llama/21147)
Masashi Yoshimura [Mon, 6 Apr 2026 20:08:46 +0000 (05:08 +0900)]
ggml-webgpu: Add the support of `MUL_MAT_ID` (llama/21147)

* Add mul_mat_id support to WebGPU

* Apply suggestion from @reeselevine

---------

Co-authored-by: Reese Levine <redacted>
4 months agoggml: add Q1_0 1-bit quantization support (CPU) (llama/21273)
Pasha Khosravi [Mon, 6 Apr 2026 18:55:21 +0000 (11:55 -0700)]
ggml: add Q1_0 1-bit quantization support (CPU) (llama/21273)

* ggml: add Q1_0 and Q1_0_g128 1-bit quantization support (CPU)

* add generic fallback for x86

* remove Q1_0 (group size 32)

* rename Q1_0_g128 => Q1_0

* fix Q1_0 LlamaFileType Enum

* Fix trailing spaces; add generic fallback for othre backends

* Apply suggestions from code review

Co-authored-by: Sigbjørn Skjæret <redacted>
* fix /r/n spacing + arch-fallback

---------

Co-authored-by: Sigbjørn Skjæret <redacted>
4 months agoWrite an optimized flash_attn_stream_k_fixup kernel (llama/21159)
Gaurav Garg [Mon, 6 Apr 2026 18:34:29 +0000 (00:04 +0530)]
Write an optimized flash_attn_stream_k_fixup kernel (llama/21159)

* Write an optimized flash_attn_stream_k_fixup kernel

Write a specialized and more optimized kernel for cases where nblocks_stream_k is multiple of ntiles_dst.
Make nblocks_stream_k to multiple of ntiles_dst if nblocks_stream_k > 2 * ntiles_dst

* Use the new kernel only for nblocks_stream_k_raw > 4 * ntiles_dst to make sure we have enough concurrency on GPUs

* Address review comments

* Address review comments

* Revert variable names to original

4 months agosycl : handle other FA case (llama/21377)
Neo Zhang [Mon, 6 Apr 2026 10:28:00 +0000 (18:28 +0800)]
sycl : handle other FA case (llama/21377)

4 months agohexagon: slight optimization for argosrt output init (llama/21463)
Yarden Tal [Mon, 6 Apr 2026 01:30:25 +0000 (04:30 +0300)]
hexagon: slight optimization for argosrt output init (llama/21463)

4 months agoggml-webgpu: move from parameter buffer pool to single buffer with offsets (llama...
Reese Levine [Fri, 3 Apr 2026 18:40:14 +0000 (11:40 -0700)]
ggml-webgpu: move from parameter buffer pool to single buffer with offsets (llama/21278)

* Work towards removing bitcast

* Move rest of existing types over

* Add timeout back to wait and remove synchronous set_tensor/memset_tensor

* move to unpackf16 for wider compatibility

* cleanup

* Remove deadlock condition in free_bufs

* Start work on removing parameter buffer pools

* Simplify and optimize further

* simplify profile futures

* Fix stride

* Try using a single command buffer per batch

* formatting

4 months agoggml-zendnn : add MUL_MAT_ID op support for MoE models (llama/21315)
Vishal Singh [Fri, 3 Apr 2026 09:19:08 +0000 (14:49 +0530)]
ggml-zendnn : add MUL_MAT_ID op support for MoE models (llama/21315)

* ggml-zendnn : add MUL_MAT_ID op support for MoE models
- Add MUL_MAT_ID op acceleration for Mixture-of-Experts models
- MUL_MAT_ID op fallback to CPU backend if total experts > 32
- Point ZenDNN lib to latest bits ZenDNN-2026-WW13

* ggml-zendnn : add braces to sgemm failure condition for consistency

Co-authored-by: Aaron Teo <redacted>
---------

Co-authored-by: Aaron Teo <redacted>
4 months agorpc : reuse compute graph buffers (llama/21299)
Radoslav Gerganov [Fri, 3 Apr 2026 07:28:09 +0000 (10:28 +0300)]
rpc : reuse compute graph buffers (llama/21299)

Reuse the buffer for the ggml context which is used for creating the
compute graph on the server side. This partially addresses a memory leak
created by the CUDA backend due to using buffer addresses as cache
keys.

ref: #21265
ref: #20315

4 months agoggml-webgpu: add vectorized flash attention (llama/20709)
Zheyuan Chen [Thu, 2 Apr 2026 17:40:42 +0000 (10:40 -0700)]
ggml-webgpu: add vectorized flash attention (llama/20709)

* naive vectorized version

* add vectorized flash attention

* update vec version

* remove unused path and shader

* remove unused helper functions

* add comments

* remove pad path

* ggml-webgpu: fix flash-attn vec nwg=1 path and tighten vec specialization

* change back to vec4

* enable multi split

* enable vec path when:
- Q->ne[1] < 20
- Q->ne[0] % 32 == 0
- V->ne[0] % 4 == 0
- K->type == f16

* update flast_attn_vec_split.wgsl to reduce redundant workgroup barrier usage and use select

* enable vec path for q4 and q8

* flash-attn vec nwg=1 fast path (skip tmp/reduce staging)

* use packed f16 K loads in flash-attn vec split

* use packed f16 K loads in flash-attn vec split on host side

* tune flash-attn vec f16 VEC_NE by head dim

* cleanup

* cleanup

* keep host side clean

* cleanup host side

* change back to original host wait/submit behavior

* formatting

* reverted param-buffer pool r ecfactor

* add helper functions

* ggml-webgpu: move flash-attn vec pipeline caching back into shader lib

* ggml-webgpu: remove duplicate functions

* ggml-webgpu: reserve flash-attn vec scratch in dst buffer allocation

* ggml-webgpu: revert unrelated change

* ggml-webgpu: revert deleted comment

* disable uniformity check

* remove unnecessary change

* Update ggml/src/ggml-webgpu/wgsl-shaders/flash_attn_vec_split.wgsl

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

---------

Co-authored-by: Reese Levine <redacted>
4 months agosycl : fix llama_kv_cache hang when kv_cache is huge: 5GB (llama/21283)
Neo Zhang [Thu, 2 Apr 2026 07:08:32 +0000 (15:08 +0800)]
sycl : fix llama_kv_cache hang when kv_cache is huge: 5GB (llama/21283)

4 months agoggml : bump version to 0.9.11 (ggml/1456)
Georgi Gerganov [Thu, 2 Apr 2026 07:37:26 +0000 (10:37 +0300)]
ggml : bump version to 0.9.11 (ggml/1456)

4 months agohexagon : add cumsum op support (llama/21246)
Todor Boinovski [Thu, 2 Apr 2026 00:44:02 +0000 (17:44 -0700)]
hexagon : add cumsum op support (llama/21246)

* hexagon : add cumsum op support

* hexagon: enable dma for cumsum op

* Fix line-ending

---------

Co-authored-by: Max Krasnyansky <redacted>
4 months agoopencl: fix leak in Adreno q8_0 path (llama/21212)
lhez [Wed, 1 Apr 2026 19:54:58 +0000 (12:54 -0700)]
opencl: fix leak in Adreno q8_0 path (llama/21212)

4 months agoCUDA: fix FA kernel selection logic (llama/21271)
Johannes Gäßler [Wed, 1 Apr 2026 19:28:19 +0000 (21:28 +0200)]
CUDA: fix FA kernel selection logic (llama/21271)

4 months agohexagon: improve RMS_NORM and DIV accuracy (llama/21251)
Aparna M P [Wed, 1 Apr 2026 15:43:08 +0000 (21:13 +0530)]
hexagon: improve RMS_NORM and DIV accuracy (llama/21251)

* hexagon-rms_norm: fix RMS_NORM for non-aligned tensor sizes

Co-authored-by: Krishna Sridhar <redacted>
* hexagon-div: perform DIV in fp16 domain for lower dsp archs

---------

Co-authored-by: Krishna Sridhar <redacted>
4 months agosycl : support nvfp4 type in mul_mat (llama/21227)
Neo Zhang [Wed, 1 Apr 2026 10:54:15 +0000 (18:54 +0800)]
sycl : support nvfp4 type in mul_mat (llama/21227)

4 months agoggml-cuda: Add generic NVFP4 MMQ kernel (llama/21074)
Michael Wand [Wed, 1 Apr 2026 10:04:58 +0000 (03:04 -0700)]
ggml-cuda: Add generic NVFP4 MMQ kernel (llama/21074)

* Introduced NVFP4 generic MMQ kernel

* Added extra FP8 guard, hope to solve ci HIP failure

* Rename tiles and use HIP_FP8_AVAILABLE

* Removed remaning FP8 straggler and added const int

* Const

* Removed DECL_MMQ_CASE artifact

* Removed newline

* Removed space after else

* Changed HIP FP8 NVFP4 conversion gate

* Added new line to bottom of mmq.cu 270

* Removed extra spaces

* Removed single space in front of else on line 814

* Added NVFP4 to generate cu script so HIP can see it, further tightened logic

* Include generated mmq-instance-nvfp4.cu

* Added NVFP4 mmq to HIP Check ignore list

* Update ggml/src/ggml-cuda/mmq.cuh

Changed to Q3_K tile to read MMQ_MMA_TILE_X_K_NVFP4

Co-authored-by: Johannes Gäßler <redacted>
* Update ggml/src/ggml-cuda/mmq.cuh

Changed to Q3_K tile to read MMQ_MMA_TILE_X_K_NVFP4 in tile assert

Co-authored-by: Johannes Gäßler <redacted>
* Update ggml/src/ggml-cuda/mmq.cuh

Added function name ending for end if

Co-authored-by: Johannes Gäßler <redacted>
* Added function names to closing endif

Co-authored-by: Johannes Gäßler <redacted>
---------

Co-authored-by: Johannes Gäßler <redacted>
4 months agoggml : bump version to 0.9.10 (ggml/1454)
Georgi Gerganov [Wed, 1 Apr 2026 13:01:45 +0000 (16:01 +0300)]
ggml : bump version to 0.9.10 (ggml/1454)

4 months agoCUDA/HIP: Fix kernel slection for mmvq mmid kernel to align host selection with devic...
uvos [Wed, 1 Apr 2026 08:21:20 +0000 (10:21 +0200)]
CUDA/HIP: Fix kernel slection for mmvq mmid kernel to align host selection with device launch bounds (llama/21238)

The conditions cc == GGML_CUDA_CC_VOLTA || cc >= GGML_CUDA_CC_ADA_LOVELACE and cc >= GGML_CUDA_CC_TURING match all non-nvidia devices. This causes us to attempt to launch the kernel for batch sizes with larger configurations than our launch bounds on HIP devices. This pr fixes the conditionals in get_mmvq_mmid_max_batch.

Fixes #21191

4 months agoggml : fix RWKV ops thread assignment (llama/21226)
Georgi Gerganov [Wed, 1 Apr 2026 08:10:25 +0000 (11:10 +0300)]
ggml : fix RWKV ops thread assignment (llama/21226)

4 months agoggml-cpu: fix fallback for RVV kernels without zvfh (llama/21157)
Taimur Ahmad [Wed, 1 Apr 2026 08:10:03 +0000 (13:10 +0500)]
ggml-cpu: fix fallback for RVV kernels without zvfh (llama/21157)

* ggml-cpu: refactor sgemm; fix rvv checks

* ggml-cpu: refactor rvv kernels; set zvfbfwma default to off

4 months agoCUDA: Add Flash Attention Support for Head Dimension 512 (llama/20998)
Anav Prasad [Wed, 1 Apr 2026 07:07:24 +0000 (07:07 +0000)]
CUDA: Add Flash Attention Support for Head Dimension 512 (llama/20998)

* flash attention support for head dimension 512 added

* FA D=512 - match 576 configs, limit ncols2, revert vec cap

* fix HIP tile kernel build for D=512

* fix HIP tile kernel occupancy for D=512 on AMD

* Apply suggestions from code review

Co-authored-by: Johannes Gäßler <redacted>
* fix tile FA compilation

---------

Co-authored-by: Johannes Gäßler <redacted>
4 months agoggml webgpu: quantized buffers to u32 + wider browser/device support (llama/21046)
Reese Levine [Wed, 1 Apr 2026 05:38:24 +0000 (22:38 -0700)]
ggml webgpu: quantized buffers to u32 + wider browser/device support (llama/21046)

* Work towards removing bitcast

* Move rest of existing types over

* Add timeout back to wait and remove synchronous set_tensor/memset_tensor

* move to unpackf16 for wider compatibility

* cleanup

* Remove deadlock condition in free_bufs

4 months agoggml-webgpu: port all AOT operators to JIT (llama/20728)
Abhijit Ramesh [Wed, 1 Apr 2026 09:58:53 +0000 (12:58 +0300)]
ggml-webgpu: port all AOT operators to JIT (llama/20728)

* port cpy pipeline to shader lib with JIT compilation
* port glu pipeline to shader lib with JIT compilation
* port rope pipeline to shader lib with JIT compilation
* port soft_max pipeline to shader lib with JIT compilation
* removed unused functions from embed_wgsl.py which were used for
old AOT template expansion

4 months agoCANN: fix multi-thread set_tensor race conditions (llama/20151)
hipudding [Tue, 31 Mar 2026 14:00:51 +0000 (22:00 +0800)]
CANN: fix multi-thread set_tensor race conditions (llama/20151)

* CANN: fix multi-thread set_tensor race conditions

When ollama calls ggml_backend_tensor_set from multiple threads (each
writing a different chunk of the same tensor), the CANN backend had
three concurrency issues:

1. Quantized tensors (Q4_0/Q8_0) require a full-tensor format transform
   before uploading to device. Per-chunk transforms produced corrupt data.

2. ND-to-NZ weight conversion requires complete tensor data on device.
   Per-chunk conversion operated on incomplete data.

3. The global g_nz_workspaces array had unprotected concurrent access.

Fix by introducing a TensorSetTracker that accumulates write progress
per tensor. For quantized tensors, raw data is staged in a host buffer
and the transform + upload is deferred until all chunks arrive. For NZ
weights, chunks are uploaded directly but conversion is deferred. The
tracker and its staging buffer are released immediately after
post-processing completes.

Add per-device mutex to g_nz_workspaces to prevent data races.

* CANN: fix L2_NORM ignoring eps parameter

The L2_NORM implementation was not using the eps parameter from
op_params, causing incorrect results when eps is large (e.g. 10.0).
The CPU reference computes scale = 1/fmaxf(norm, eps), so add a
Clamp step to clamp the norm to at least eps before dividing.

* ggml/cann: compare op_params for POOL_2D in ACL graph cache matching

When ACL graph mode is enabled, the graph LRU cache checks whether a
cached graph matches the current computation graph. Previously,
GGML_OP_POOL_2D was not included in the op_params comparison, so two
POOL_2D nodes with different pooling parameters (kernel size, stride,
padding) but identical tensor shapes and addresses could incorrectly
reuse a cached graph, leading to wrong results or aclnn errors.

Add GGML_OP_POOL_2D to the list of ops that require op_params matching
in ggml_graph_node_properties::has_matching_properties().

* cann: fix ACL graph cache matching by adding tensor type and unconditional op_params comparison

The ACL graph LRU cache was incorrectly reusing cached graphs for
operations with different tensor types or op_params, causing test
failures for CPY (f16 vs bf16), POOL_2D, L2_NORM, NORM_MUL_ADD,
RMS_NORM_MUL_ADD, and ADD_RMS_NORM.

Changes:
- Add node_type and src_type[] fields to ggml_graph_node_properties
  so the cache can distinguish tensors with different types but
  identical ne/nb (e.g. f16 and bf16 both have 2-byte elements)
- Compare op_params unconditionally for all ops instead of only for
  SCALE/UNARY/GLU/ROPE/POOL_2D

4 months agosycl : enhance fattn perf (llama/21185)
Neo Zhang [Tue, 31 Mar 2026 10:31:50 +0000 (18:31 +0800)]
sycl : enhance fattn perf (llama/21185)

4 months agoopencl: add q4_K gemm and gemv kernels for Adreno (llama/20919)
shaofeiqi [Mon, 30 Mar 2026 19:19:16 +0000 (12:19 -0700)]
opencl: add q4_K gemm and gemv kernels for Adreno (llama/20919)

* opencl: add q4_K gemm and gemv kernels for Adreno

* opencl: fix whitespace

* opencl: add workarounds for compiler bugs on older devices

* opencl: handle fp16 denorm on X Elite

* opencl: fix kernel build error

* opencl: fix whitespace

* opencl: make q4_K cvt kernels signature consistent

---------

Co-authored-by: Li He <redacted>
4 months agoCUDA : Fix CUB's argsort when nrows % block_size == 0 CCCL < 3.1 (llama/21181)
Oliver Simons [Mon, 30 Mar 2026 14:20:00 +0000 (16:20 +0200)]
CUDA : Fix CUB's argsort when nrows % block_size == 0 CCCL < 3.1 (llama/21181)

* CUDA: Fix CUB's argsort when nrows % block_size == 0 CCCL < 3.1

We wrongly calculated offset_grid as `ceildiv(nrows, block_size)`,
while it must be `ceildiv(nrows + 1, block_size)`. As a consequence, we
had uninitialized values in `offset_iterator[nrows]` for the case when
`nrows % block_size == 0`.

Fixes #21162

* Reduce nrows in test case to 256, don't need 768

4 months agorpc : fix misleading error log (llama/21184)
Radoslav Gerganov [Mon, 30 Mar 2026 14:05:11 +0000 (17:05 +0300)]
rpc : fix misleading error log (llama/21184)

When RPC is running with a remote backend which doesn't have init_tensor
function (like CPU and Metal), the server log gets full with error
messages saying that init_tensor is being called with null buffer which
is incorrect. This patch fixes this.

4 months agoOptimize MOE GEMV kernel for BS > 1. (llama/20905)
Gaurav Garg [Sun, 29 Mar 2026 16:35:18 +0000 (22:05 +0530)]
Optimize MOE GEMV kernel for BS > 1. (llama/20905)

* Optimize MOE GEMV kernel for BS > 1.

The previous MOE kernel for BS > 1 had too many thread blocks (nrows_x, nchannels_dst, ncols_dst), with very little work per block. block of (32, 4) was doing inner dot product for a single row.

New mul_mat_vec_q_moe kernel is dedicated for MoE multi-token kernel with grid (ceil(nrows_x/rpb), nchannels_dst), block (warp_size, ncols_dst). Each warp handles two rows independently with warp-level reduction only (no shared memory sync).

This change doesn't increase any compilation time as a single template instance is needed per type. This also simplifies the original GEMV kernel and gets rid of `is_multi_token_id` specialization.

* Remove em-dashes

* Cherry-pick changes from @am17an PR https://github.com/ggml-org/llama.cpp/pull/20885 to enable small_k optimization only for cases where it benefits

Increase max batch size for MMVQ kernels for MUL_MAT_ID to 8

* Make the max batch size for MOE GEMV kernel configurable based on GPU arch and datatype

---------

Co-authored-by: Aman Gupta <redacted>
4 months agohexagon: dma optimizations (mostly fixing regressions) (llama/21137)
Max Krasnyansky [Sun, 29 Mar 2026 13:40:13 +0000 (06:40 -0700)]
hexagon: dma optimizations (mostly fixing regressions) (llama/21137)

* hex-fa: add simple dma cache for Mask

I noticed that we were refetch the mask rows over and over.
This simple cache avoids that.

* hex-dma: unset in-order desc bit which caused signficant perf regression

We don't rely on true in order processing of the DMA descriptors anywhere.
Turns out this mode caused significant regression of around 3-4 TPS during token gen.

* hex-rope: update comment to clarify that we don't need in-order DMA completions

4 months agoggml : bump version to 0.9.9 (ggml/1449)
Georgi Gerganov [Mon, 30 Mar 2026 15:34:29 +0000 (18:34 +0300)]
ggml : bump version to 0.9.9 (ggml/1449)

4 months agobench : sync submit-results URL to ggml-org (#3769)
jinweihan [Mon, 20 Apr 2026 05:12:57 +0000 (22:12 -0700)]
bench : sync submit-results URL to ggml-org (#3769)

The project moved from ggerganov/ to ggml-org/ and the README already
references the new URL in both places it mentions issue #89 (README.md
and examples/bench/README.md). Syncing the two remaining hardcoded URLs
in examples/bench/bench.cpp and examples/bench.wasm/emscripten.cpp.

The old URL still redirects, so this is cosmetic.

4 months agowhisper : add stateless VAD detect + explicit state reset for streaming (#3677)
Daniel Worthington-Bodart [Fri, 17 Apr 2026 11:36:27 +0000 (12:36 +0100)]
whisper : add stateless VAD detect + explicit state reset for streaming (#3677)

whisper_vad_detect_speech resets LSTM state on every call, which is
correct for batch processing but prevents temporal continuity when
calling per-chunk in a streaming loop.

Add whisper_vad_detect_speech_no_reset (skips buffer clear) and
whisper_vad_reset_state (explicit clear between utterances).
Existing whisper_vad_detect_speech is now a thin wrapper — zero
behavior change for current callers.

Co-authored-by: Claude Opus 4.6 (1M context) <redacted>
5 months agosync : ggml
Georgi Gerganov [Sun, 29 Mar 2026 10:23:24 +0000 (13:23 +0300)]
sync : ggml

5 months agovulkan: add noncontiguous GLU support (llama/21081)
Ruben Ortlam [Sat, 28 Mar 2026 07:44:56 +0000 (08:44 +0100)]
vulkan: add noncontiguous GLU support (llama/21081)

* vulkan: add noncontiguous GLU support

* fix compile issue

5 months agohexagon: support for IQ4_NL and MXFP4 (llama/21018)
Yiwei Shao [Fri, 27 Mar 2026 16:22:41 +0000 (09:22 -0700)]
hexagon: support for IQ4_NL and MXFP4 (llama/21018)

* ggml-hexagon: add IQ4_NL and MXFP4 HMX matmul support

- Add IQ4_NL quantization type support to Hexagon backend (buffer
  set/get tensor repack, mul_mat, mul_mat_id dispatch)
- Implement HVX IQ4_NL vec_dot kernels (1x1, 2x1, 2x2) with
  LUT-based 4-bit index to int8 kvalue dequantization
- Add MXFP4 HMX dequantization path with E8M0 scale conversion,
  including batch-4 fast path and single-tile fallback
- Unify quantized row size / scale offset logic to handle Q4_0,
  Q8_0, IQ4_NL, and MXFP4 in the DMA fetch path

* ggml-hexagon: fix SKIP_QUANTIZE src1 address mismatch in mixed-quant models

* Fix the pragma indent

5 months agorpc : proper handling of data pointers to CPU buffers (llama/21030)
Radoslav Gerganov [Fri, 27 Mar 2026 08:59:35 +0000 (10:59 +0200)]
rpc : proper handling of data pointers to CPU buffers (llama/21030)

The compute graph may contain tensors pointing to CPU buffers. In these
cases the buffer address is serialized as 0 and sent over the wire.
However, the data pointer is serialized as-is and this prevents proper
validation on the server side. This patches fixes this by serializing
the data pointer as 0 for non-RPC buffers and doing proper validation on
the server side.

closes: #21006

5 months agometal : Fix dimension constraint violation in matmul2d descriptor (llama/21048)
ren [Fri, 27 Mar 2026 07:05:21 +0000 (00:05 -0700)]
metal : Fix dimension constraint violation in matmul2d descriptor (llama/21048)

Updates Metal tensor API test probe to fix the dimension constraint violation in the matmul2d descriptor (at least one value must be a multiple of 16).

5 months agohip: use fnuz fp8 for conversion on CDNA3 (llama/21040)
uvos [Thu, 26 Mar 2026 22:06:33 +0000 (23:06 +0100)]
hip: use fnuz fp8 for conversion on CDNA3 (llama/21040)

5 months agoopencl: allow large buffer for adreno (llama/20997)
lhez [Thu, 26 Mar 2026 15:52:21 +0000 (08:52 -0700)]
opencl: allow large buffer for adreno (llama/20997)

5 months agofix(ggml): correct RISC-V ISA string canonical ordering for RVV in CMake (llama/20888)
ihb2032 [Thu, 26 Mar 2026 11:08:41 +0000 (19:08 +0800)]
fix(ggml): correct RISC-V ISA string canonical ordering for RVV in CMake (llama/20888)

Signed-off-by: ihb2032 <redacted>