]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/log
pkg/ggml/sources/whisper.cpp
4 months agofix: rpc-server cache may not work in Windows environments (llama/22394)
unraido [Mon, 27 Apr 2026 14:25:09 +0000 (23:25 +0900)]
fix: rpc-server cache may not work in Windows environments (llama/22394)

* fix: create directory and log cache file name.

* Remove GGML_LOG_INFO conditional compilation.

---------

Co-authored-by: kotaro <redacted>
4 months agoggml : use 64 bytes aligned tile buffers (llama/21058)
Adrien Gallouët [Mon, 27 Apr 2026 06:30:55 +0000 (08:30 +0200)]
ggml : use 64 bytes aligned tile buffers (llama/21058)

| Model                            | Test   |   t/s OLD |   t/s NEW |   Speedup |
|:---------------------------------|:-------|----------:|----------:|----------:|
| qwen35 0.8B BF16                 | pp512  |    584.59 |    595.41 |      1.02 |
| qwen35 0.8B BF16                 | tg128  |     52.23 |     52.82 |      1.01 |
| qwen35 0.8B IQ2_M - 2.7 bpw      | pp512  |    260.64 |    261.70 |      1.00 |
| qwen35 0.8B IQ2_M - 2.7 bpw      | tg128  |     81.17 |     80.89 |      1.00 |
| qwen35 0.8B IQ2_XXS - 2.0625 bpw | pp512  |    302.36 |    302.56 |      1.00 |
| qwen35 0.8B IQ2_XXS - 2.0625 bpw | tg128  |     84.93 |     85.12 |      1.00 |
| qwen35 0.8B IQ3_XXS - 3.0625 bpw | pp512  |    263.22 |    260.01 |      0.99 |
| qwen35 0.8B IQ3_XXS - 3.0625 bpw | tg128  |     80.29 |     78.94 |      0.98 |
| qwen35 0.8B IQ4_NL - 4.5 bpw     | pp512  |    728.65 |    742.09 |      1.02 |
| qwen35 0.8B IQ4_NL - 4.5 bpw     | tg128  |     82.39 |     84.46 |      1.03 |
| qwen35 0.8B IQ4_XS - 4.25 bpw    | pp512  |    681.33 |    677.06 |      0.99 |
| qwen35 0.8B IQ4_XS - 4.25 bpw    | tg128  |     80.18 |     79.28 |      0.99 |
| qwen35 0.8B Q2_K_M               | pp512  |    413.28 |    415.94 |      1.01 |
| qwen35 0.8B Q2_K_M               | tg128  |     81.90 |     82.78 |      1.01 |
| qwen35 0.8B Q3_K_M               | pp512  |    493.17 |    495.08 |      1.00 |
| qwen35 0.8B Q3_K_M               | tg128  |     82.75 |     83.23 |      1.01 |
| qwen35 0.8B Q3_K_S               | pp512  |    429.35 |    427.64 |      1.00 |
| qwen35 0.8B Q3_K_S               | tg128  |     86.69 |     87.02 |      1.00 |
| qwen35 0.8B Q4_0                 | pp512  |    783.46 |    782.32 |      1.00 |
| qwen35 0.8B Q4_0                 | tg128  |     88.23 |     87.90 |      1.00 |
| qwen35 0.8B Q4_1                 | pp512  |    741.71 |    729.76 |      0.98 |
| qwen35 0.8B Q4_1                 | tg128  |     85.44 |     86.01 |      1.01 |
| qwen35 0.8B Q4_K_M               | pp512  |    676.24 |    681.31 |      1.01 |
| qwen35 0.8B Q4_K_M               | tg128  |     76.59 |     77.06 |      1.01 |
| qwen35 0.8B Q4_K_S               | pp512  |    683.12 |    688.81 |      1.01 |
| qwen35 0.8B Q4_K_S               | tg128  |     80.50 |     81.19 |      1.01 |
| qwen35 0.8B Q5_K_M               | pp512  |    635.33 |    642.11 |      1.01 |
| qwen35 0.8B Q5_K_M               | tg128  |     72.07 |     72.49 |      1.01 |
| qwen35 0.8B Q5_K_S               | pp512  |    660.95 |    658.18 |      1.00 |
| qwen35 0.8B Q5_K_S               | tg128  |     72.19 |     72.95 |      1.01 |
| qwen35 0.8B Q6_K                 | pp512  |    647.97 |    638.84 |      0.99 |
| qwen35 0.8B Q6_K                 | tg128  |     72.83 |     72.49 |      1.00 |
| qwen35 0.8B Q8_0                 | pp512  |    805.01 |    785.49 |      0.98 |
| qwen35 0.8B Q8_0                 | tg128  |     70.10 |     70.13 |      1.00 |

Signed-off-by: Adrien Gallouët <redacted>
4 months agoadd performance-portable tuning for register-tile and subgroup matmul (llama/22241)
Rithik Sharma [Sun, 26 Apr 2026 16:26:28 +0000 (09:26 -0700)]
add performance-portable tuning for register-tile and subgroup matmul (llama/22241)

4 months agoFix recurrent state serialization for partial reads and writes (llama/22362)
Gaurav Garg [Sun, 26 Apr 2026 11:34:40 +0000 (17:04 +0530)]
Fix recurrent state serialization for partial reads and writes (llama/22362)

The previous code worked only for full tensor reads and writes and was hitting `GGML_ASSERT(size == ggml_nbytes(tensor)); ` assert when tested with llama-server.

4 months agoCUDA: better coalesce data-access for contiguous concat (llama/22330)
Oliver Simons [Sun, 26 Apr 2026 07:21:45 +0000 (09:21 +0200)]
CUDA: better coalesce data-access for contiguous concat (llama/22330)

Also, distribute all elements across CTAs evenly instead of launching
one CTA per dim

4 months agoggml-cpu : re-enable fast gelu_quick_f16 (llama/22339)
Sigbjørn Skjæret [Sun, 26 Apr 2026 06:28:14 +0000 (08:28 +0200)]
ggml-cpu : re-enable fast gelu_quick_f16 (llama/22339)

4 months agoggml-cpu: optimize avx2 q6_k (llama/22345)
Eve [Sun, 26 Apr 2026 06:27:50 +0000 (06:27 +0000)]
ggml-cpu: optimize avx2 q6_k (llama/22345)

4 months agoopencl: add iq4_nl support (llama/22272)
lhez [Sun, 26 Apr 2026 04:21:58 +0000 (21:21 -0700)]
opencl: add iq4_nl support (llama/22272)

* opencl: add general support for iq4_nl

* opencl: add iq4_nl gemm/gemv for adreno

* opencl: pack 2 lut entries into a uint

4 months agohexagon: guard HMX clock request for v75+ platforms (llama/22377)
Trivikram Reddy [Sun, 26 Apr 2026 00:58:26 +0000 (19:58 -0500)]
hexagon: guard HMX clock request for v75+ platforms (llama/22377)

4 months agoCUDA: reduce MMQ stream-k overhead (llama/22298)
Johannes Gäßler [Sat, 25 Apr 2026 12:15:03 +0000 (14:15 +0200)]
CUDA: reduce MMQ stream-k overhead (llama/22298)

* CUDA: reduce MMQ stream-k overhead

* use 32 bit integers for kbc

4 months agometal : optimize Metal Tensor API usage for GGML_OP_MUL_MAT (llama/20962)
Developer-Ecosystem-Engineering [Sat, 25 Apr 2026 12:14:28 +0000 (05:14 -0700)]
metal : optimize Metal Tensor API usage for GGML_OP_MUL_MAT (llama/20962)

* Optimize Metal Tensor API usage for matmul2d

Separates the Metal Tensor API (matmul2d) path in kernel_mul_mm into its own standalone kernel, gated by GGML_METAL_HAS_TENSOR.

The legacy simdgroup_matrix kernel is preserved under #else.

Previously both paths were interleaved via #ifdef blocks within a single kernel, forcing the tensor path to share the legacy kernel's data layout and threadgroup memory scheme. Splitting the kernel enabled memory and dispatch optimizations that weren't possible when the two paths shared code structure.

* cont : cleanup

* cont : cleanup

* cont : cleanup

---------

Co-authored-by: Georgi Gerganov <redacted>
4 months agoOptimize Q4_0 mul_mat for Arc770, add scripts (llama/22291)
Neo Zhang [Sat, 25 Apr 2026 06:20:14 +0000 (14:20 +0800)]
Optimize Q4_0 mul_mat for Arc770, add scripts (llama/22291)

* opt arc770 for Q4_0

* add for Q4_0

* update the script

* add help script for windows

* update guide

* fix format issue

* convert from dos to unix for format issue

* fix missed -sm parameter

4 months agoggml-webgpu: support for SSM_SCAN and disable set_rows error checking (llama/22327)
Reese Levine [Sat, 25 Apr 2026 06:18:15 +0000 (23:18 -0700)]
ggml-webgpu: support for SSM_SCAN and disable set_rows error checking (llama/22327)

* Implement ssm_scan

* Remove blocking in graph_compute and check for set rows

* Fix bindings

* Update op support

4 months agoHexagon: Bump HMX Frequency to Max Corner (llama/22334)
Trivikram Reddy [Fri, 24 Apr 2026 20:55:17 +0000 (15:55 -0500)]
Hexagon: Bump HMX Frequency to Max Corner (llama/22334)

* hexagon: bump HMX freq to max corner

* hex-mm: fix error in log msg

4 months agoggml-webgpu: enable FLASH_ATTN_EXT on browser without subgroup matrix (llama/22199)
Zheyuan Chen [Fri, 24 Apr 2026 17:39:09 +0000 (10:39 -0700)]
ggml-webgpu: enable FLASH_ATTN_EXT on browser without subgroup matrix (llama/22199)

* ggml-webgpu: add tile flash attention fallback

* ggml-webgpu: add new fields and discard usage of mnk for tile version

* ggml-webgpu: modify the vec path to discard the mnk parameter

* ggml-webgpu: enable flash attention vec and tile version for broswer

* ggml-webgpu: stagging KV for flash attention tile version

* formatting

* turn on subgroup uniformity check

* remove Q_TILE as it is always 1 for vec path

* make row_max and exp_sum to local register

* make different bindings with same underlying buffer to have the same usage flags

* move path selection into the shader library and have the host consume a single flash-attn decision object.

* turn off skip_validation and address buffer overlapping when nwg==1

* formatting

* merge binding when kv overlap

4 months agohexagon: use DIRID 13 in libggml-htp.inf for modern InfVerif (llama/22306)
Mengsheng Wu [Fri, 24 Apr 2026 16:21:33 +0000 (00:21 +0800)]
hexagon: use DIRID 13 in libggml-htp.inf for modern InfVerif (llama/22306)

4 months agometal : print GPU description (llama/22318)
Georgi Gerganov [Fri, 24 Apr 2026 10:56:03 +0000 (13:56 +0300)]
metal : print GPU description (llama/22318)

4 months agoggml : minor coding style (llama/22308)
Georgi Gerganov [Fri, 24 Apr 2026 08:02:00 +0000 (11:02 +0300)]
ggml : minor coding style (llama/22308)

4 months agohexagon: add SOLVE_TRI op (llama/21974)
Mengsheng Wu [Fri, 24 Apr 2026 01:39:13 +0000 (09:39 +0800)]
hexagon: add SOLVE_TRI op (llama/21974)

* hexagon: add SOLVE_TRI op

* ggml: fix TODO description for solve_tri

* hexagon: rm unused variable/function warnings

* hexagon: chunk vs batch processingfor better thread utilization

* hexagon: vectorize partial f32 loads

* hexagon: move HVX f32 add/sub/mul wrappers to hvx-base.h

---------

Co-authored-by: Todor Boinovski <redacted>
4 months agofix(shader): handle the buffer aliasing for rms fuse (llama/22266)
Chen Yuan [Thu, 23 Apr 2026 23:32:59 +0000 (19:32 -0400)]
fix(shader): handle the buffer aliasing for rms fuse (llama/22266)

4 months agohexagon: add support for basic and extended Op profiling (llama/22269)
Max Krasnyansky [Thu, 23 Apr 2026 21:17:21 +0000 (14:17 -0700)]
hexagon: add support for basic and extended Op profiling (llama/22269)

* hexagon: restore HTP_OPMASK_QUEUE

* hexagon: honor OPMASK_SKIP_COMPUTE in hmx-matmul

* hex-prof: restore op profiling

* hex-prof: enable PMU

* hexagon: simplify and improve op-queuing with full profiling support

Add separate profile descriptors.

* hexagon: remove opsync and rename opmask into opstage

opsync is no longer needed since the profiler is fully async now.
opmask name was confusing and opstage is more accurate.

* hexagon: refactor opbatch queue handling

* hexagon: add iface hooks for enabling profiler from the host

Also move all the PMU setup stuff out of the hex-utils since it's not inteded for normal use.

* hexagon: make profiler mode configurable

On older devices getting PMU counters is expensive so it's now optional.

* hexagon: add support for setting profiler pmu events from env

* hexagon: simplify profiler output (no need to print buffs, etc)

* hexagon: simplify pmu counter formating

* hexagon: add a simple profile post-proc tool

* hex-prof: add support for reading logs from stdin

* hexagon: document GGML_HEXAGON_PROFILE

* hex-prof: update default width for dims field

* hex-prof: fix linter warnings and errors

* Update ggml/src/ggml-hexagon/htp/htp-ops.h

Co-authored-by: Sigbjørn Skjæret <redacted>
* Update scripts/snapdragon/ggml-hexagon-profile.py

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

Co-authored-by: Trivikram Reddy <redacted>
Co-authored-by: Sigbjørn Skjæret <redacted>
4 months agometal : fix event synchronization (llama/22260)
Georgi Gerganov [Thu, 23 Apr 2026 05:22:49 +0000 (08:22 +0300)]
metal : fix event synchronization (llama/22260)

4 months agoggml-base: use MATH_LIBRARY variable instead of hardcoded 'm' (llama/22239)
Georgi Gerganov [Thu, 23 Apr 2026 05:22:08 +0000 (08:22 +0300)]
ggml-base: use MATH_LIBRARY variable instead of hardcoded 'm' (llama/22239)

Fixes #22237 — the find_library(MATH_LIBRARY m) result was being
discarded and the target linked against the literal 'm' string.

This prevents users from overriding the math library (e.g. for AMD AOCL)
via CMake variables. Now the discovered MATH_LIBRARY is used directly.

4 months agosycl : fused MoE mul_mat_vec_q for TG (llama/21920)
abotsis [Thu, 23 Apr 2026 05:18:56 +0000 (23:18 -0600)]
sycl : fused MoE mul_mat_vec_q for TG (llama/21920)

* sycl : fused MoE mul_mat_vec_q for TG

Create an MMVQ kernel so ggml_sycl_mul_mat_id can consolidate
n_experts_used matmuls in a single kernel launch. The kernel
also reads expert IDs directly, removing a per-call host sync.

This is similar to the CUDA backend's ggml_cuda_mul_mat_vec_q*
paths.

All types supported in the current MMVQ are supported here as well:
Q2_K, Q3_K, Q4_K, Q5_K, Q6_K, Q4_0, Q4_1, Q5_0, Q5_1, Q8_0

It will fall back to the existing per-expert path when src0 has been rewritten
by opt_for_reorder(), and for any shape the fused path doesn't handle.

test-backend-ops passes for supported type/shape combos.

Benchmark: Qwen3-Next-35B-A3B Q4_K_M on Intel Arc B70 (SYCL0),
baseline 707c0b7a6, 16k context, -fa 0.

  build/bin/llama-bench -hf unsloth/Qwen3.5-35B-A3B-GGUF:Q4_K_M \
    -p 1024 -n 128 -d 16384 -ngl 99 -fa 0 -ub 2048 -r 2 -dev SYCL0

Before (3 runs on 707c0b7a6):

  | test            |            run 1 |            run 2 |            run 3 |
  | --------------- | ----------------:| ----------------:| ----------------:|
  | pp1024 @ d16384 |   533.26 ±  4.87 |   535.20 ±  2.78 |   524.27 ±  3.10 |
  | tg128  @ d16384 |    33.47 ±  0.02 |    33.31 ±  0.02 |    33.17 ±  0.05 |

After (3 runs on 707c0b7a6 + this patch):

  | test            |            run 1 |            run 2 |            run 3 |
  | --------------- | ----------------:| ----------------:| ----------------:|
  | pp1024 @ d16384 |   534.06 ±  0.97 |   531.95 ±  0.02 |   520.94 ± 20.10 |
  | tg128  @ d16384 |    45.85 ±  0.21 |    45.95 ±  0.45 |    46.22 ±  0.12 |

disclosure: Claude wrote it, but I reviewed and understand the implementation
(albeit my C is a little rusty).

* sycl: also support nvfp4 and mxfp4 expert types

* sycl: terser comments/nested dispatch in response to review

* sycl: more comment cleanup in mmvq.cpp/hpp

---------

Co-authored-by: Debian <redacted>
4 months agoggml-webgpu: add support for im2col (llama/22259)
Chen Yuan [Thu, 23 Apr 2026 03:17:41 +0000 (23:17 -0400)]
ggml-webgpu: add support for im2col (llama/22259)

* shader(im2col): implement the im2col shader

* shader(im2col): clean the formatting issues

* shader(im2col): clean the editorconfig checker warning

* fix(shader): address the workgroup issues of im2col and conv2d

4 months agoCUDA: fuse relu + sqr (llama/22249)
Anav Prasad [Thu, 23 Apr 2026 02:28:56 +0000 (02:28 +0000)]
CUDA: fuse relu + sqr (llama/22249)

4 months agoHIP: flip GGML_HIP_GRAPHS to default on (llama/22254)
uvos [Thu, 23 Apr 2026 00:34:31 +0000 (02:34 +0200)]
HIP: flip GGML_HIP_GRAPHS to default on (llama/22254)

In #11362 hip graph was disabled by default as, at the time, its performance impact was negative. Due to improvements in rocm and our usage and construction of graphs this is no longer true, so lets change the default.

4 months agoImplement async tensor api and event api (llama/22099)
Nikhil Jain [Wed, 22 Apr 2026 17:52:01 +0000 (10:52 -0700)]
Implement async tensor api and event api (llama/22099)

* Only run webgpu CI on my fork

* Implement set_tensor_async

* Implement synchronize api

* Implement event creation and deletion API

* Cleanup

* Cleanup

* Comment out jobs for local CI run

* Add webgpu only workflow

* Delete .github/workflows/build-webgpu.yml

* Cleanup

* Cleanup

* Update API with function handlers

* Run clang-format

* Replace one-shot buffer with a direct queue.WriteBuffer using the buffer context

4 months agoggml-webgpu: Add fused RMS_NORM + MUL (llama/21983)
Masashi Yoshimura [Wed, 22 Apr 2026 17:51:40 +0000 (02:51 +0900)]
ggml-webgpu: Add fused RMS_NORM + MUL (llama/21983)

* fused rms_norm_mul + mul

* Add GGML_WEBGPU_DISABLE_FUSION for being able to disable kernel fusion.

* Decouple num_fused_ops from webgpu_context; misc cleanup

* Fix eps handling and remove disable_fusion.

* Fix not to use c++20 initializers.

4 months agosycl: Improve mul_mat_id memory efficiency and add BF16 fast path (llama/22119)
Akarshan Biswas [Wed, 22 Apr 2026 12:32:56 +0000 (18:02 +0530)]
sycl: Improve mul_mat_id memory efficiency and add BF16 fast path (llama/22119)

* sycl: size mul_mat_id staging buffers by routed rows

Previously src1_contiguous/dst_contiguous in ggml_sycl_mul_mat_id were
sized to ggml_nelements(src1/dst), which over-allocates when ne12 > 1
and can fail with UR_RESULT_ERROR_OUT_OF_HOST_MEMORY on Level Zero for
MoE models (notably with --cpu-moe). Size them by the actual number of
routed rows (ids->ne[1] * n_ids) instead.

* sycl: add bf16 mul_mat fast path via DNNL

When src0 is BF16 (commonly the case for lm_head / output.weight), the
existing f16 path is skipped because bf16 isn't covered, and the f32
fallback dequantizes the entire src0 slab to f32 in a single pool alloc
(row_diff*ne00 floats). For large-vocab models this can reach several
GB and fail with UR_RESULT_ERROR_OUT_OF_HOST_MEMORY on Level Zero.

Add a bf16xbf16 -> f32 DNNL matmul fast path that uses the bf16 storage
in place and only materializes a small src1 bf16 conversion buffer. bf16
matmul accumulates in f32, so it's correct even when the op requests
GGML_PREC_F32 (as lm_head does).

- gemm.hpp: map bfloat16 to dnnl::memory::data_type::bf16.
- convert.{hpp,cpp}: expose ggml_get_to_bf16_sycl for f32/f16/bf16 -> bf16.
- ggml-sycl.cpp: take the bf16 path early in ggml_sycl_op_mul_mat_sycl
  when DNNL and GGML_SYCL_HAS_BF16 are both available.

4 months agoggml-webgpu(shader): support conv2d kernels. (llama/21964)
Chen Yuan [Wed, 22 Apr 2026 03:18:57 +0000 (23:18 -0400)]
ggml-webgpu(shader): support conv2d kernels. (llama/21964)

* 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

* shader(conv2d): add conv2d shader kernels and pass f32 and f16 tests

* shader(conv2d): fix the out of bounds memory access in the weight indexing

* shader(conv2d): clean unused variables and optimize the computation

* merge: use the new entries function

* clean: address the formatting issues

* clean: address the warning issues

* clear: clean the shader editorconfig-checker issues

* clear: clean the shader editorconfig-checker with utf-8

---------

Co-authored-by: Jeremy J. Hartmann <redacted>
4 months agohexagon: add support for FILL op (llama/22198)
Aparna M P [Tue, 21 Apr 2026 23:24:20 +0000 (04:54 +0530)]
hexagon: add support for FILL op (llama/22198)

Co-authored-by: Max Krasnyansky <redacted>
4 months agoggml-webgpu: reset CPU/GPU profiling time when freeing context (llama/22050)
Masashi Yoshimura [Tue, 21 Apr 2026 23:05:21 +0000 (08:05 +0900)]
ggml-webgpu: reset CPU/GPU profiling time when freeing context (llama/22050)

* Reset the CPU/GPU profiling time when freeing context.

* move GPU profiling time from global context to webgpu_context.

4 months agoHexagon: DAIG op (llama/22195)
Shreya Jain [Tue, 21 Apr 2026 21:16:04 +0000 (14:16 -0700)]
Hexagon: DAIG op (llama/22195)

* hexagon: Add DIAG op

* hexagon: add HVX support and DMA double buffering

* hexagon: fix fatal error

* hexagon: remove as many pragma(s) as possible

4 months agohexagon: fix missing v79 entry in libggml-htp.inf (llama/22194)
Mengsheng Wu [Tue, 21 Apr 2026 20:53:44 +0000 (04:53 +0800)]
hexagon: fix missing v79 entry in libggml-htp.inf (llama/22194)

4 months agoopenvino: driver setup, CI split, thread safety, and NPU optimizations (llama/21944)
Zijun Yu [Tue, 21 Apr 2026 15:58:34 +0000 (23:58 +0800)]
openvino: driver setup, CI split, thread safety, and NPU optimizations (llama/21944)

* Thread safety per request only

* Fix ROPE yarn case

* Fix sticky stateful config

* Use i4/i8 directly for symmetric quant

* Use weightless caching

* Add WeightlessCacheAttribute to reduce NPU memory usage

* Gelu tanh support (llama/125)

* Imrope support (llama/126)

* fix(openvino): explicit ov::Tensor frees in ggml_backend_openvino_free

* add GPU,NPU support in OV Dockerfile

* add build-openvino.yml ci

* Fix sticky stateful config

* add concurrency to ov-gpu ci runs. Move OV CI to build-openvino.yml

* fix thread-safety of shared runtime context

* rope type abstraction for frontend translations

* fix editorconfig

---------

Co-authored-by: Mustafa Cavus <redacted>
Co-authored-by: Dan Hoffman <redacted>
Co-authored-by: Ravi Panchumarthy <redacted>
4 months agometal : workaround macOS GPU interactivity watchdog (llama/22216)
Georgi Gerganov [Tue, 21 Apr 2026 14:24:55 +0000 (17:24 +0300)]
metal : workaround macOS GPU interactivity watchdog (llama/22216)

4 months agovulkan: Support F16 OP_FILL (llama/22177)
Jeff Bolz [Tue, 21 Apr 2026 09:01:56 +0000 (11:01 +0200)]
vulkan: Support F16 OP_FILL (llama/22177)

4 months agoggml : bump version to 0.10.0 (ggml/1463)
Georgi Gerganov [Tue, 21 Apr 2026 08:02:56 +0000 (11:02 +0300)]
ggml : bump version to 0.10.0 (ggml/1463)

4 months agoggml-cuda: flush legacy pool on OOM and retry (llama/22155)
leonardHONG [Mon, 20 Apr 2026 21:30:38 +0000 (05:30 +0800)]
ggml-cuda: flush legacy pool on OOM and retry (llama/22155)

* ggml-cuda: flush legacy pool on OOM and retry

Signed-off-by: 梁厚宏 <redacted>
* Address review comments: add explicit sync, update destructor, clean up MUSA macros

Signed-off-by: 梁厚宏 <redacted>
---------

Signed-off-by: 梁厚宏 <redacted>
4 months agoTensor-parallel: Fix delayed AllReduce on Gemma-4 MoE (llama/22129)
Gaurav Garg [Mon, 20 Apr 2026 16:25:39 +0000 (21:55 +0530)]
Tensor-parallel: Fix delayed AllReduce on Gemma-4 MoE (llama/22129)

* Fix delayed AllReduce on Gemma-4 MoE

Skip forward past nodes that don't consume the current one, and allow a chain of MULs.

* Check for all sources before skipping nodes

* Address review comments

4 months agoTP: fix 0-sized tensor slices, AllReduce fallback (llama/21808)
Johannes Gäßler [Mon, 20 Apr 2026 16:09:39 +0000 (18:09 +0200)]
TP: fix 0-sized tensor slices, AllReduce fallback (llama/21808)

* TP: fix 0-sized tensor slices, AllReduce fallback

* fix layer structure <-> GPU count aliasing

* add missing std::fill

* fix CUDA device set, max ggml ctx size

4 months agoggml-cpu: Optimized x86 and generic cpu q1_0 dot (follow up) (llama/21636)
pl752 [Mon, 20 Apr 2026 16:02:54 +0000 (21:02 +0500)]
ggml-cpu: Optimized x86 and generic cpu q1_0 dot (follow up) (llama/21636)

* Implemented optimized q1_0 dot for x86 and generic

* Removed redundant helper definition

* Removed two redundant instructions from AVX q1_0 dot

* Fixed inconsistency with fp16 conversion for generic q1_0 dot and deduplicated generic fallback

* Style cleanup around AVX q1_0 dot

* Replaced explicitly unrolled blocks with inner for loop for q1_0

* Replaced scalar ARM q1_0 impl with new generic one

4 months agoggml-webgpu: updated matrix-vector multiplication (llama/21738)
neha-ha [Mon, 20 Apr 2026 14:37:17 +0000 (07:37 -0700)]
ggml-webgpu: updated matrix-vector multiplication (llama/21738)

* merged properly, but slow q3_k and q5_k with u32 indexing

* Start on new mat-vec

* New format float paths working

* Working q4_0

* Work on remaining legacy q-types

* port k-quants to new matvec

* remove old shader

* Remove old constants, format

* remove accidental file

---------

Co-authored-by: Neha Abbas <redacted>
Co-authored-by: Reese Levine <redacted>
4 months agoFix reorder MMVQ assert on unaligned vocab sizes (llama/22035)
Katostrofik [Mon, 20 Apr 2026 05:39:45 +0000 (01:39 -0400)]
Fix reorder MMVQ assert on unaligned vocab sizes (llama/22035)

* [SYCL] Fix reorder MMVQ assert on unaligned vocab sizes

The reorder mul_mat_vec_q dispatchers for Q4_0, Q8_0, Q4_K, and Q6_K
asserted that block_num_y was a multiple of 16 subgroups. Models with
a vocab size not divisible by 16 (for example HY-MT at 120818) aborted
on model load when the output projection tripped the assert.

I replaced the assert with padding: block_num_y now rounds up to a
whole number of subgroup-sized workgroups. The kernel already has the
row bounds check (`if (row >= nrows) return;`) so the extra padded
threads early-exit cleanly. Row values are uniform across a subgroup
so the collective reduce stays safe.

For aligned vocab sizes the padded block_num_y equals the old value,
so the kernel launch is identical and there is no regression.

Thanks to @arthw for flagging the relationship to #21527.

Fixes #22020.

AI assisted coding, tested on Intel B70 hardware.

* sycl: use WARP_SIZE for num_subgroups in reorder MMVQ launches

Replaces the hardcoded 16 with WARP_SIZE in the four reorder_mul_mat_vec
launch helpers (Q4_0, Q8_0, Q4_K, Q6_K). Compile-time no-op on the Intel
target where WARP_SIZE is 16, but makes the relationship to subgroup
size explicit. Per review by @NeoZhangJianyu on #22035.

Assisted by Claude.

4 months agoCUDA: refactor mma data loading for AMD (llama/22051)
Johannes Gäßler [Sun, 19 Apr 2026 16:26:59 +0000 (18:26 +0200)]
CUDA: refactor mma data loading for AMD (llama/22051)

* CUDA: refactor mma data loading for AMD

* fix CDNA MMQ occupancy

* fix CDNA3 mma

* fix RDNA3 compile

4 months agoHIP: Remove unesscary NCCL_CHECK (llama/21914)
uvos [Sun, 19 Apr 2026 10:59:44 +0000 (12:59 +0200)]
HIP: Remove unesscary NCCL_CHECK (llama/21914)

4 months agoggml : reduce CPU overhead in meta backend (llama/22041)
Gaurav Garg [Sun, 19 Apr 2026 09:48:35 +0000 (15:18 +0530)]
ggml : reduce CPU overhead in meta backend (llama/22041)

* cache subgraph splits when cgraph is unchanged

Skip per-call subgraph construction in ggml_backend_meta_graph_compute when the same ggml_cgraph is used consecutively.

Assign uid to every sub-graph so that CUDA's fast uid check path hits too.

* Address review comments

* Keep the scope as is

* Rename last_uid and last_n_subgraphs field. Remove last_max_tmp_size field. Refactor code.

* Address review comments

* Update ggml/src/ggml-backend-meta.cpp

Co-authored-by: Johannes Gäßler <redacted>
* Update ggml/src/ggml-backend-meta.cpp

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

Co-authored-by: Johannes Gäßler <redacted>
4 months agocmake: remove CMP0194 policy to restore MSVC builds (llama/21934)
texasich [Sun, 19 Apr 2026 07:25:05 +0000 (02:25 -0500)]
cmake: remove CMP0194 policy to restore MSVC builds (llama/21934)

#21630 added the CMP0194 NEW policy to silence a CMake warning, but on Windows runners it caused CMake to prefer the MinGW toolchain for ASM and broke MSVC builds.

Reverting only that policy block restores the previous working behavior. The CMake 4.1+ warning comes back, but that is cosmetic and does not break any platform.

Reported-by: oobabooga
Refs: #21630

Co-authored-by: texasich <redacted>
4 months agorpc : refactor the RPC transport (llama/21998)
Radoslav Gerganov [Sun, 19 Apr 2026 07:21:53 +0000 (10:21 +0300)]
rpc : refactor the RPC transport (llama/21998)

* rpc : refactor the RPC transport

Move all transport related code into a separate file and use the
socket_t interface to hide all transport implementation details.

* fix win32

* better socket_t construction

4 months agoggml-backend-meta: add multi-segment read support in get_tensor (llama/22063)
SamareshSingh [Sat, 18 Apr 2026 08:04:51 +0000 (03:04 -0500)]
ggml-backend-meta: add multi-segment read support in get_tensor (llama/22063)

4 months agoggml-webgpu: fix compiler warnings and refactor FlashAttention encoding (llama/21052)
Reese Levine [Fri, 17 Apr 2026 16:17:11 +0000 (09:17 -0700)]
ggml-webgpu: fix compiler warnings and refactor FlashAttention encoding (llama/21052)

* Update workflows to remove dependence on llvmpipe

* Try setting Dawn_DIR

* remove c++20 initializers

* Move to proper guid

* Try avoiding segfaults on vulkan backend process exit

* Remove compiler warnings on parameter casting

* Fix soft_max and update reg_tile accumulation to f32 for better precision

* Refactor flash_attn a bit

* remove c++20 initializers and format

* Increase div precision for NVIDIA

* revert div precision and comment out ggml-ci node for now

* Formatting

* Try debugging on a failing CI node

* Revert "Try debugging on a failing CI node"

This reverts commit 1971e33cba919915e12bcfd5828abfbd54ca942e.

4 months agoCUDA: use LRU based eviction for cuda graphs (llama/21611)
Aman Gupta [Fri, 17 Apr 2026 15:24:21 +0000 (23:24 +0800)]
CUDA: use LRU based eviction for cuda graphs (llama/21611)

* CUDA: use a ring-buffer for cuda graphs

* bump limit to 128

* use LRU eviction

* better naming

* do periodic clean-up

4 months agoopencl: refactor q8_0 set_tensor and mul_mat host side dispatch for Adreno (llama...
lhez [Fri, 17 Apr 2026 05:28:33 +0000 (22:28 -0700)]
opencl: refactor q8_0 set_tensor and mul_mat host side dispatch for Adreno (llama/21938)

* opencl: refactor q8_0 gemm/gemv Adreno dispatch

* opencl: refactor q8_0 set_tensor

* opencl: fix whitespace

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