Commit graph

3962 commits

Author SHA1 Message Date
lhez
9fa7a33cbb
opencl: add multi token f32 GEMV for spec verify (#33098)
Some checks are pending
UI / Checks (push) Blocked by required conditions
UI / Build static output (push) Waiting to run
UI / Library checks (push) Waiting to run
UI / Voice checks (push) Waiting to run
UI / Harness checks (push) Waiting to run
Release / windows-cuda (13.5, arm64) (push) Blocked by required conditions
Release / windows-cuda (12.4, x64) (push) Blocked by required conditions
Release / windows-cuda (13.5, x64) (push) Blocked by required conditions
Release / windows-sycl (push) Blocked by required conditions
Release / ubuntu-24-sycl (fp16, ON) (push) Blocked by required conditions
Release / ubuntu-24-sycl (fp32, OFF) (push) Blocked by required conditions
Release / ubuntu-24-rocm (10.0.0, x64, gfx908;gfx90a;gfx942;gfx950;gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1200;gfx1201) (push) Blocked by required conditions
Release / ubuntu-26-zdnn (push) Blocked by required conditions
Release / ios-xcode (push) Blocked by required conditions
Release / ui-build (push) Blocked by required conditions
Server (sanitize) / server (RelWithDebInfo, ADDRESS) (push) Waiting to run
Server (sanitize) / server (RelWithDebInfo, UNDEFINED) (push) Waiting to run
Server (self-hosted) / server-cuda (push) Waiting to run
Server (self-hosted) / server-metal (push) Waiting to run
Server (self-hosted) / server-kleidiai (push) Waiting to run
Server (speculative decoding) / server-speculative (push) Waiting to run
Server / ubuntu (push) Waiting to run
Server / windows (push) Waiting to run
UI (self-hosted) / Build static output (push) Waiting to run
UI (self-hosted) / Checks (push) Blocked by required conditions
UI (self-hosted) / E2E Tests (push) Blocked by required conditions
UI Storybook / Deploy to Hugging Face Spaces (push) Waiting to run
UI / Chat-only build (push) Waiting to run
UI / Demo harness checks (push) Waiting to run
UI / E2E Tests (push) Blocked by required conditions
* opencl: add multi token F32 GEMV

Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>
Assisted-by: Codex

* opencl: let ne01 > 512 still use tiled GEMM

---------

Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>
2026-11-26 13:26:17 -08:00
Sv. Lockal
e087c6c4e7
hip : fix bf16 MFMA operand vector type for CDNA (#33086)
Follow-up to ggml-org/llama.cpp#30885: the CDNA MFMA bf16 builtins
also take short vectors, so LLVM 23 rejects __bf16 for gfx908, gfx90a,
gfx942 and gfx950.
2026-11-26 21:36:34 +01:00
Piotr Wilkin (ilintar)
2a335259ca
ggml/CUDA+HIP: Flash Attention with indexed bias (#33063)
* cuda : port indexed bias FA onto the refactored loaders

Replays the #32740 bias support on the shared typed tile loader, adds bias
in F32 to match the CPU reference and routes rows via KV_indirection.

* cuda : return zeros for a fully masked FA query row

An all -inf mask row has a zero softmax sum, which divided gave NaN. Guard
the tile, vec and results-combine divisions so it gives zeros, as ggml-cpu.

* Code review from Fable
* fixup! cuda : port indexed bias FA onto the refactored loaders
2026-11-26 21:13:03 +01:00
Shawn Gu
47d6192fce
opencl: add MoE int8 bin kernel host side changes for Adreno A850 (#33069) 2026-11-26 11:51:32 -08:00
Aman Gupta
0e4e925e8f
CUDA: fuse the Inkling 2 short conv, depth mix, loop controller, L2 clip and situ chains (#33060)
Some checks are pending
UI / Checks (push) Blocked by required conditions
UI / Library checks (push) Waiting to run
UI / Voice checks (push) Waiting to run
UI / Harness checks (push) Waiting to run
UI / Chat-only build (push) Waiting to run
UI / E2E Tests (push) Blocked by required conditions
Release / windows (arm64, vulkan, -G "Ninja Multi-Config" -DGGML_VULKAN=ON -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake, ggml-vulkan) (push) Blocked by required conditions
Release / windows (x64, vulkan, -DGGML_VULKAN=ON, ggml-vulkan) (push) Blocked by required conditions
Release / windows-cuda (13.5, arm64) (push) Blocked by required conditions
Release / windows-cuda (12.4, x64) (push) Blocked by required conditions
Release / windows-cuda (13.5, x64) (push) Blocked by required conditions
Release / windows-sycl (push) Blocked by required conditions
Release / ubuntu-24-sycl (fp16, ON) (push) Blocked by required conditions
Release / ubuntu-24-sycl (fp32, OFF) (push) Blocked by required conditions
Release / ubuntu-24-rocm (10.0.0, x64, gfx908;gfx90a;gfx942;gfx950;gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1200;gfx1201) (push) Blocked by required conditions
Release / ios-xcode (push) Blocked by required conditions
Release / ui-build (push) Blocked by required conditions
Server (sanitize) / server (RelWithDebInfo, ADDRESS) (push) Waiting to run
Server (sanitize) / server (RelWithDebInfo, UNDEFINED) (push) Waiting to run
Server (self-hosted) / server-metal (push) Waiting to run
Server (self-hosted) / server-cuda (push) Waiting to run
Server (self-hosted) / server-kleidiai (push) Waiting to run
Server (speculative decoding) / server-speculative (push) Waiting to run
Server / ubuntu (push) Waiting to run
Server / windows (push) Waiting to run
UI (self-hosted) / Build static output (push) Waiting to run
UI (self-hosted) / Checks (push) Blocked by required conditions
UI (self-hosted) / E2E Tests (push) Blocked by required conditions
UI Storybook / Deploy to Hugging Face Spaces (push) Waiting to run
UI / Build static output (push) Waiting to run
* model : inkling2 order the conv ops so backends can fuse them

* CUDA: fuse the Inkling 2 short conv, depth mix, loop controller, L2 clip and situ chains
2026-11-26 23:15:36 +08:00
Ruben Ortlam
46ba8b7008
vulkan: fix Windows driver RDNA1 architecture misclassification (#33123) 2026-11-26 15:56:30 +01:00
Aman Gupta
b671865c7b
CUDA: move the fusion code out of ggml-cuda.cu (#33087)
Move the fusion matchers, ggml_cuda_can_fuse, ggml_cuda_try_fuse and the
fusion alloc deps of graph_optimize into fusion.cu, unchanged.
fusion.cuh exports ggml_cuda_try_fuse and ggml_cuda_fusion_add_alloc_deps.
The GGML_CUDA_DISABLE_FUSION check is done by the two callers, and
ggml_cuda_is_view_or_noop moves to common.cuh since the compute loop
also uses it.
2026-11-26 18:58:44 +08:00
anujj
09c1410642
ggml : support a BF16 src1 in MUL_MAT and MUL_MAT_ID (CPU, CUDA) (#32533)
* ggml : support a BF16 src1 in MUL_MAT and MUL_MAT_ID (CPU, CUDA)

* ggml : fix MMVF expert offset overflow and tighten BF16 src1 gates

* ggml : strided BF16 src1 tests, explicit MUSA Q2_K rule, MMVF offset fix moved to its own PR

* cuda : move the MUL_MAT_ID MMVF rule into ggml_cuda_should_use_mmvf

* cuda : read a BF16 src1 in MMVF through a template parameter, for BF16 and FP8 weights only

* cuda : MMVF src1 pairs via ggml_cuda_cast, rename type to type_src0
2026-11-26 15:59:27 +05:30
Aman Gupta
51ab45e3c5
CUDA: fuse the top-k MoE weight norm with an additive sum bias (#32943)
Assisted-by: Claude Opus 5.5
2026-11-26 11:30:42 +02:00
Aman Gupta
caea914e9d
CUDA: loop over ne2/ne3 in non-contiguous concat (#33006)
The non-contiguous concat kernel mapped dst ne[2] and ne[3] directly to
gridDim.y and gridDim.z, which are limited to 65535. Larger tensors made
the launch fail with "invalid configuration argument". Cap the grid and
loop over the remaining rows in the kernel.

Fixes #32956

Assisted-by: Claude Opus 5.5
2026-11-26 11:29:58 +02:00
Pascal
e38ea719bd
CUDA: fix ROCm CI, do not pick the tile FA kernel for DKQ 576 with a GQA ratio not divisible by 4 (#33045)
* CUDA: flash attention tile kernel for DKQ 576 with a GQA ratio of 2

The tile kernel for 576/512 only had variants for GQA ratios that are
multiples of 4, while the kernel selection accepts any ratio from 2,
so an MLA attention with a ratio of 2 aborted on GPUs that use the
tile kernel, such as RDNA. Add the 2 column configuration, copied from
the 512/512 one of each table, and dispatch even ratios to it. Odd
ratios have no tile variant: the selection now reports them as
unsupported instead of picking the tile kernel. Cover the ratios 2
and 3 in test-backend-ops.

* CUDA: pass the K/V types to the tile kernel for 576 with a GQA ratio of 2

#32901 added the K and V types as template parameters of the tile kernel,
the ratio 2 dispatch for DKQ 576 still used the old parameter list.

* CUDA: report DKQ 576 with a GQA ratio not divisible by 4 as unsupported by the tile kernel

Use the selection instead of a new tile specialization, as suggested in
review: drop the 2 column variant and only pick the tile kernel for
576/512 when the GQA ratio is a multiple of 4, the ncols2 = 4 and 16
variants it has. The ncols2 = 4 variant cannot serve a ratio of 2, a
block reads a single K/V head.
2026-11-26 11:25:33 +02:00
Georgi Gerganov
2a59da5bf2 ggml : bump version to 1.1.1 (ggml/1703)
* ggml : bump version to 1.1.1

* authors : update
2026-11-26 09:38:27 +02:00
Todd Malsbary
267dda8180
sycl: Remove check for host waits in fattn-mkl from graph checks (#31208)
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
2026-11-26 00:40:10 -05:00
Max Krasnyansky
e0f884d405
ggml-hexagon 2.0 : support for int-hmx, automatic f32 -> f16 lowering, and generic dma pipelines (#32582)
* hexagon : add DMA pipeline, htp_tensor_read, and cache/mdev cleanup

- Add dma-proxy thread/ring for main-thread DMA offload (clamp n_hvx <= hw_nth - 2)
- Add syncht in hmx-queue after HMX VTCM stores

* hexagon : add F16/collapse graph lowering and fusion updates

* hexagon : update host kparams solver for W8A8 HMX, F16, and DMA

* hexagon : add INT-HMX W8A8 matmul, F16 support, and DMA writeback

- Use 64-col dual-acc (weight.b:deep + mxswapacc) across all arches and :cm activation layout
- Pre-issue chunk-0 weight DMA via dma_proxy, balance 4-row quad output threads, and defer output DMA pop

* hexagon : add HMX W8A8 Q8_0 KV flash attention and DMA writeback

hex-fa: cleanup dma_queue usage and mask buffers
hex-fa: fix new op tests and corner cases
hex-fa: cleanup kernel selection and solver
hex-fa: improve decode performance (split-kv)

* hexagon : add F16, DMA, and micro-kernel optimizations for unary/norm ops

* hexagon : add mixed F16/F32 and HVX optimizations for binary ops

* hexagon : add F16, DMA, and state fusion for gated-delta-net

Alsp pipeline GDN HMX/HVX with batched dispatch and spill-free inversion

* hexagon : add F16, token-major fusion, and DMA updates for SSM ops

* hexagon : add F16 and HVX optimizations for rope, softmax, and glu

rope: optimize init and add common fast-path

* hexagon : add F16, DMA, and spill fixes for argsort and top-k

* hexagon : add F16 lowering and optimizations for lightning-indexer and dsv4

* hexagon : add F16 and DMA updates for row and concat ops

* hexagon : convert simple ops to dma-pipeline, F16, and warning/mdev cleanup

* hexagon: add support for fusing MUL_MAT_NX with GLU ops (GEGLU,SWIGLU,...)

- Double-buffer vtcm_up/vtcm_wt_scales_up, add 0-spill direct loop0 FP16 GLU strip kernels, trim sub-ULP FP16 sigmoid terms
- Balance 4-row quad GLU threads, defer output DMA pop, and pre-issue chunk-0 weight DMA via dma_proxy

* tests : add F16/mixed-type and Hexagon op test cases

For now do not include ssm_conv tests that break ggml-metal

* hexagon : update trace and run scripts

* hexagon : update Snapdragon backend README and developer docs

Includes updated tensor tiling description (it is 32x4 now)

--
Co-authored-by: Ehsan Bateni <ebateni@qti.qualcomm.com>
Co-authored-by: Todor Boinovski <todorb@qti.qualcomm.com>
Co-authored-by: Trivikram Reddy <tamarnat@qti.qualcomm.com>
Co-authored-by: Yanzhao Wang <yanzhaow@qti.qualcomm.com>

Assisted-by: Antigravity
2026-11-25 20:59:59 -08:00
anujj
f8b7ed5250
cuda : fix int overflow of the MMF matrix offsets (#33044) 2026-11-26 10:19:40 +05:30
gianni-cor
55b2238be8
ggml : add TANH backward pass (#32136)
Build the gradient dy * (1 - y^2) from the forward output with existing
ops, no new op is needed. Add TANH to the gradient-checked unary ops.

Signed-off-by: gianni-cor <gianfranco.cordella@tether.io>
2026-11-26 12:38:00 +08:00
Clemens Wasser
a8ad690ca9
sycl: add gated delta net ESIMD kernel (#31762) 2026-11-25 21:38:28 -05:00
cwriter
aee03fbe80
sycl: fuse recurrent convolution windows (#31355) 2026-11-25 21:12:07 -05:00
Pascal
7135e2fd69
metal : spread the short mat-vec lanes over src1 rows (#33034)
* metal : spread the short mat-vec lanes over src1 rows

The short mat-vec kernel (K < 32) mapped its 32 lanes to 32 src0 rows
and handled one src1 row per threadgroup, so with few src0 rows most
lanes were idle. It now covers min(ne01, 32) src0 rows of 32/that src1
rows.

This is the weighted sum over the depth states of Inkling 2 since
#32855 (1-3 src0 rows, K = number of states, 2304 src1 rows).
Inkling-2-Mini UD-Q4_K_XL, M5 Max, master -> this PR:
  pp512 888 -> 1052 t/s, pp2048 771 -> 894 t/s, tg128 unchanged.
PPL and greedy output bit-identical, the graph is unchanged.

Tested: test-backend-ops -b MTL0 -o MUL_MAT (new small-K cases).

* cont : clean-up comment

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
2026-11-25 22:39:14 +01:00
bri-prism
8d35ba4f7b
metal : revert "metal: increase default command buffers on iPhone (#31815)" (#33050)
This reverts commit 1f3ea67fbf.
2026-11-25 20:28:59 +01:00
lhez
d9dae03443
opencl: Adreno E17 compiler quirks off by default (#33013) 2026-11-25 11:20:30 -08:00
Johannes Gäßler
94a1e4b722
CUDA: refactor & deduplicate FA data loading (#32901)
* CUDA: refactor & deduplicate FA data loading

* fix float2 indexing

* fix hip quality check
2026-11-25 18:47:26 +01:00
Pascal
c943331339
model : add hy_v4_flash on the DSA iSWA cache (#32960)
* model : add hy_v4_flash on the DSA iSWA cache

Tencent Hy4 flash is a hy_v4 trunk (iHC, gated MLA, sinks) with
sparse and sliding-window MLA layers, sandwich norms, latent routed
experts and deepseek41 Engram tables.

The sparse layers select their context with a pooled indexer: the
keys of 4 consecutive tokens are pooled by a per-channel softmax of a
gate plus a position bias, normed, and rotated at the position of the
first token. A token attends to the best scored pools of its sequence
plus its own pool.

The model runs on llama_kv_cache_dsa_iswa as dots3note does. The
indexer cache holds the projected value and gate of each token, and
the pools are rebuilt from the cells for every ubatch by
llama_kv_cache::set_input_kpool(), so there is no pooled state to
keep in sync with sequence edits, checkpoints or state save/restore.
The selection goes through ggml_top_k_mask with the pool members as
blocks and the token's own pool as extra cells.

Not covered yet: the MTP block (its tensors are skipped), the vision
tower, multiple KV streams, and backends without GGML_OP_TOP_K_MASK.

* convert : add hy_v4_flash

The converter of the hy_v4_flash model, without the vision parts.

The four Engram tables are written as one per_layer_token_embd
tensor of about 127 GB in BF16. Concatenating them with torch.cat
materializes the whole tensor at write time, so they are streamed one
table at a time in row chunks through the _StreamedBytes path of
deepseek41, which keeps the conversion within 100 GB of RAM.

* tests : add hy_v4_flash to test-llama-archs

A 4 layer fixture that alternates sparse and sliding-window layers,
with hyper-connections, one Engram module, an indexer on the sparse
layers and a latent width distinct from the expert width, so that a
transposed routed_down or routed_up is caught.

* kv-cache : do not shift the pooled indexer cache

The pooled indexer of hy_v4_flash caches the value and the gate of
each token, without a position: the pooled key is rotated in the
graph. A K-shift rotated these rows as if they were roped keys, which
broke the pooled keys after a context shift.

* tests : add the hy_v4_flash Metal fusion baseline

* model, mtmd : add hy_v4_flash vision

The vision tower of hy_v4_flash, with its projector in mtmd and its
converter.

The published files carry M-RoPE sections, so the text model runs the
interleaved M-RoPE path: the rope rows keep their reference order and
are reordered to NeoX halves in the graph. The tokens of an image share
their position, so the indexer pools now group consecutive tokens in
sequence order instead of consecutive positions, and a pooled key is
rotated at the four positions of its first member.

Without a backend that runs GGML_OP_TOP_K_MASK, the picked pools are
expanded to their cells and go through build_top_k_mask.

* CUDA: lightning indexer for 16 heads

hy_v4_flash scores its pools with 16 indexer heads, which the CUDA
backend did not support, so the scheduler ran the 12 sparse layers'
indexers on the CPU at every step. Both kernels already handle 16
heads: the mma kernel needs a multiple of 16 and the vector kernel
splits the heads in 4 passes.

* model : move the Hy4 flash Engram gathers before the token embeddings

With the gathers after build_inp_embd, the mixed embedding DUP and SET_ROWS
sat between two host nodes and stayed on the CPU. Those ops use every thread,
so all the CPU workers woke up on each decoded token for a 12K copy.
Gathering first lets the scheduler put them on the GPU, as in qwen4exp, and
leaves only small single threaded lookups on the host.

* llama : speed up the Hy4 flash pool inputs on long contexts

set_input_kpool deduplicated the pools through a map keyed by vectors even
with a single sequence, sorted cells that are already in order and scanned
every pool owner for each token. Dedup only when the ubatch has several
sequences, skip the sort when the cells are ordered and mark the earlier
pools of the token's sequence directly. At 129k cells the host cost of a
decode step drops from 4.0 ms to 0.5 ms, the logits are unchanged.

* llama : use a unified KV cache for Hy4 flash

The pools gather their members from a single KV stream, so a split cache
with several sequences hit an assert in the graph. Switch to the unified
cache with a warning, the sequences then share n_ctx.

* rm redundant code in mtmd

* clean up comments

---------

Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
2026-11-25 18:39:50 +01:00
Ravi Panchumarthy
244640b7f2
ggml-openvino: fix CI op tests and improve KV cache decode (#33002)
* ggml-openvino: write back consumed in-place nodes of op-test graphs

On the naive path every node of an op-test graph is a model output,
except an in-place node that another node reads: it got no output, so
its destination buffer was never written. GATED_DELTA_NET_CACHE_FUSION
copies the final state into the cache and then reads the copy, so the
cache kept its old contents.

Write such a node back through its view_src, as is already done when
nothing reads it. Model graphs are unchanged.

* ggml-openvino: keep the rest of the buffer in a partial in-place FILL

An in-place FILL on a view into part of a larger buffer produced only
the filled values. Its output stands for the whole in-place source, so
the write-back put those values at the start of the buffer and not at
the view's offset.

For a contiguous view with a static shape, build the whole buffer: the
elements before the view, the filled values, then the elements after
it. Add NodeContext::get_inplace_op_src() to detect the in-place case.

* ggml-openvino: fix softplus precision for large negative inputs

softplus was computed as relu(x) + log(1 + exp(-|x|)). When exp(-|x|)
is below the precision of 1 + exp(-|x|), the log returns 0 or one ulp,
so for x below about -16 in f32 the result was 0 or far off. The
SOFTPLUS test case with inputs in [-16.6, -16] fails on CPU and GPU.

Compute log1p(y) for y = exp(-|x|) with the series
y - y^2/2 + y^3/3 - y^4/4 when y < 0.01, where its relative error is
below 2e-9, and keep log(1 + y) above that.

* ggml-openvino: finer GPU KV rounding for decode batches

Rounding the GPU KV length up to a power of two makes a batch attend up
to twice the rows that hold data right after each power of two. Decode
reads every attended row, so long contexts lose decode speed.

The GPU plugin keeps memory for each attended length: several large
buffers for a prompt batch, about one copy of K and V for a decode
batch. Keep the power of two for prompt batches (more than 16 tokens
per sequence), and round decode batches up to a multiple of 2^k / 4 and
of 256. That is four lengths per power of two, with at most 25% masked
rows.

* ggml-openvino : keep the head axis of the 4-D KV cache static

* ggml-openvino: split two one-line lambdas per clang-format

The backend's .clang-format keeps a lambda on one line only when it is a
function argument (AllowShortLambdasOnASingleLine: Inline). The constant
helpers in the softplus and FILL translators are assigned to variables,
so clang-format splits them. Formatting only.

---------

Co-authored-by: Mustafa Cavus <mustafa.cavus@intel.com>
2026-11-25 07:53:56 -08:00
Georgi Gerganov
3125043613 ggml : bump version to 1.1.0 (ggml/1699)
* ggml : bump version to 1.1.0

* authors : update
2026-11-25 16:06:38 +02:00
Masashi Yoshimura
ab16df399f
webgpu : add log1p for softplus op (#33017) 2026-11-25 13:25:28 +01:00
Alexey Kopytko
6d5f648721
ggml-cpu : accept the flash_attn_ext indexed bias (#33016)
The reference implementation is in place, but the device rejected the op, so
test-backend-ops skipped all the indexed-bias cases. The spacemit FA path
leaves the op to the generic CPU path.
2026-11-25 11:48:31 +02:00
Aman Gupta
52f6e0247a
metal : commit the graph in chunks with one command buffer thread (#32947)
Assisted-by: Claude Opus 5.5
2026-11-25 11:42:34 +02:00
Aman Gupta
62d6c8cb3a
ggml: allow input async copies (#30685)
* ggml: allow input async copies

Copy the host inputs of a split with set_tensor_async followed by a
single synchronize, instead of one blocking copy per input. This is
opt-in per device through the new async_host_input cap, which only
CUDA sets. Other backends keep the current path.

The async path is used without pipeline parallelism only. With
pipeline parallelism, the input backend also waits on the slot event
before an async copy, since CUDA peer copies run on the source stream.
This replaces the synchronize on graph reuse in process_ubatch.

* remove sched change

* tests : add get_props to test-alloc dummy device

* tests : check that sched inputs can be overwritten after compute_async

* ggml : rename async_host_input to fast_async_host_input, address review comments
2026-11-25 16:56:15 +08:00
Aman Gupta
ea72294814
ggml: allow reserving scratch memory in graph_optimize (#31898)
* ggml: allow reserving scratch memory in graph_optimize

Add add_scratch to ggml_backend_graph_optimize_params. A backend can
reserve compute buffer memory that is allocated before a node `first`
and kept until a node `last` has been computed, e.g. for data that
several nodes share. The scheduler adds the scratch tensor to the graph
copy right before `first` and frees it with an alloc dep at `last`.

* ggml: clarify the lifetime of add_scratch memory

* ggml: build the pending scratch set from the scratch map
2026-11-25 10:34:49 +02:00
Michael Taylor
81ff0cab06
sycl: F8 e4m3 initial support SET_ROWS, CPY, ADD, MUL_MAT, MUL_MAT_ID (#31871) 2026-11-25 02:35:18 -05:00
Michael Taylor
cddaa915a4
SYCL : ROLL op handles permuted source (#31799) 2026-11-25 02:29:04 -05:00
Shawn Gu
e6443bd7eb
opencl: add clc coopmat moe kernel for q4_0/q4_1/q4_k/q5_0/q5_1/q5_k/q6_k/mxfp4 (#32971) 2026-11-24 16:42:30 -08:00
anujj
22b99122e1
cuda : fix int overflow of the MMVF matrix offsets (#32965) 2026-11-24 20:26:08 +01:00
velonica0
a1cee51c9d
ggml : fix SpacemiT flash attention null mask, ALiBi and softcap (#32182) 2026-11-24 20:47:34 +02:00
Marco Colombo
f20c5907c0
ggml-cpu: repack kernels for targets without dotprod (ARMv8.0 64-bit) for Q4_0/Q8_0 (#32142)
* ggml-cpu: optimized kernels for ARM v8.0 (without dotprod)

* ggml-cpu: fix comment and align to implementation

* ggml-cpu: exclude new kernels for apple arch
2026-11-24 16:18:37 +00:00
t-kusanagi
5fddd0b998
ggml-cpu: add SVE-optimized q5_0 and q5_1 dot-product kernels (#30867)
* Merged PR 5925: SVE suooprt for ggml_vec_dot_q5_0_q8_0, ggml_vec_dot_q5_1_q8_1

SVE suooprt for ggml_vec_dot_q5_0_q8_0, ggml_vec_dot_q5_1_q8_1

* perf(arm): optimize q5_0 q8_0 dot products with SVE

- Load high-bit masks directly from quantized blocks
- Replace lookup-table expansion with predicated SVE duplication
- Reduce scalar high-bit unpacking overhead

* fix(arm): load SVE masks through inline assembly

- Add a helper to load mask data as svbool_t with ldr
- Replace direct svbool_t pointer casts in the q5 dot-product path

* fix(arm): correct q5/q8 SVE bitmask handling

- Fix qh bit inversion in the SVE q5_0/q8_0 dot-product path
- Use the proper predicate-aware svnot_b_z mask logic for bit extraction
- Restore correct quantized compute behavior on ARM SVE targets

* fix(arm): simplify q5_1/q8_1 bitpack handling

- replace manual qh extraction with vector bitmask loads in the ARM SVE path
- remove temporary unpack buffers used during q5_1 dot-product assembly
- preserve the qh bit pattern while keeping the quantized dot-product logic intact

* fix(ggml-cpu): support SVE load on non-GNU compilers

- Add the existing GNU/Clang inline assembly path for SVE bool loading
- Provide a portable fallback for other compilers using SVE intrinsics
- Preserve current behavior on supported toolchains while improving compatibility

* fix(cpu): cast SVE input pointer before byte load

- fix SVE byte load by casting the uint32_t pointer to uint8_t*
- preserve correct mask generation in load_as_svbool on Arm SVE
- prevent undefined pointer aliasing in the SIMD vector path

* fix(arm): restrict q5 SVE kernels to supported vector lengths

- Limit q5 dot-product paths to 256-bit and 512-bit SVE vectors
- Assert when encountering unsupported vector lengths
- Localize the SVE predicate loader to the ARM quantization kernels

* perf(arm): optimize SVE q5 dot products for VL128

- Add an intrinsic predicate loader for SVE VL128 qh halves
- Replace table-based qh expansion in q5_0 and q5_1 paths
- Remove temporary qh expansion buffers
- Preserve direct predicate loads for wider SVE vector lengths

* fix(arm): correct SVE q5 predicate loading

- Unify predicate loading for q5 quantization paths
- Prevent out-of-bounds reads from 8-bit high-bit storage
- Remove unsupported VL512 q5 dot-product cases

* fix(arm): support SVE VL512 q5 dot products

- Bound qh predicate loads for SVE vectors at or above 512 bits
- Use the shared SVE vector-length helper
- Extend q5_0 and q5_1 dot products to VL512

* docs(arm): clarify SVE predicate loader limit

- Document that values beyond the first 32 bits of qh are undefined
- Warn that the loader may cause a SEGV for vector lengths above 1024

* perf(arm): reuse SVE vector length in quantized dot products

- Pass the cached vector length to SVE predicate loading
- Remove repeated SVE vector length queries
- Allow unsupported vector lengths to exit without assertions

* docs(arm): remove outdated SVE loader warning

- Remove obsolete VL > 1024 SEGV warning from load_as_svbool

* fix compilation errors

---------

Co-authored-by: Kato, Masaya 加藤 雅也 <kato.masaya@fujitsu.com>
Co-authored-by: Masaru Ito <masaru.ito.mi@jp.fujitsu.com>
2026-11-24 23:34:54 +08:00
Alexey Kopytko
d3c257a493
context : prevent excessive CPU polling without OpenMP (#32378)
* common : prevent polling while GPU computes (on Metal or without OpenMP)

* use AudioWorkIntervalCreate to keep the thread on P-cores

* Revert "use AudioWorkIntervalCreate to keep the thread on P-cores"

This reverts commit a7270d23c0.
2026-11-24 17:12:26 +02:00
Georgi Gerganov
3090e45a86
metal : reserve the top-k scratch only for short rows (#32942)
The bitonic top-k path is only faster for short rows. On M5 and M2 Ultra it
wins up to 128 columns; above that the radix path is faster. Use the radix
path for ncols > 128.

The radix path selects in place and needs no scratch, but the buffer type
always reserved 2*4 bytes per source element, which is 8 GiB for a
524288 x 2048 score. Reserve the bitonic worst case at the 128-column
threshold instead: 2*4*128*nrows, clamped to at least the output tensor size.
This keeps the allocation bounded and consistent with the bitonic path.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)
2026-11-24 16:34:08 +02:00
Ruben Ortlam
72cda4a222
vulkan: add chunked GDN replay support (#32721)
* vulkan: add replay support to chunked GDN shaders

* use atomicStore instead of atomicExchange for readability
2026-11-24 16:21:34 +02:00
losewayy
922cff91e9
cuda : fuse RMS_NORM + MUL + MROPE/IMROPE and tune block size (#32500)
* cuda : support MROPE/IMROPE and tune block size in rms_norm_mul_rope

* cuda : use 64 threads for multi-token ncols <= 256 in rms_norm_mul_rope

Assisted-by: Antigravity
2026-11-24 16:20:58 +02:00
Aman Gupta
9578bd3fe4
CUDA: ignore strides of size-1 dims in bin_bcast (#32854)
After collapsing contiguous dims, the stride of a trailing dim of size 1
becomes the size of the whole tensor. Its index is always 0, but the
uint32 stride asserts still fire once the tensor has more than 2^32
elements, e.g. the per-head relative-position mask add of inkling2 at
n_kv > ~87k with -ub 2048.

Fixes #32804

Assisted-by: Claude Opus 5.5
2026-11-24 14:48:02 +02:00
Eddie Zhou
4c92c5bfb7
CUDA: reduce all cooperative softmax partials when nsm > 256 (#32897)
* CUDA: reduce all cooperative softmax partials when nsm > 256

Fixes #32852

* CUDA: drop the remaining cooperative softmax grid size assert
2026-11-24 20:04:00 +08:00
Plasmatix Ultra
6fb428332e
CUDA: NVFP4 dequant, pack 8 blocks per CTA (#32875)
Launch dequantize_block_nvfp4 with dim3(32, 8) so each CTA covers 8 NVFP4 blocks (256 values), as the K-quants do.

Assisted-by: Claude Code

Co-authored-by: plasmatixultra <plasmatixultra@users.noreply.github.com>
2026-11-24 13:38:47 +02:00
Nikhil Jain
6ac648d7a9
webgpu : Fix indexing bug in softmax kernel (#32691)
* Only run webgpu CI on my fork

* Add webgpu only workflow

* resolve merge conflicts

* add row check for softmax

* add test

* Add test to test case eval
2026-11-24 13:37:56 +02:00
Takamichi Ohara
94165b288d
webgpu : add POOL_1D support (#32254) 2026-11-24 13:37:10 +02:00
thelittlefireman
a8ed778914
hip: use MMQ over MMVQ for Q4_K,N8 and NVFP4,N7-8 on VEGA20 (#32805) 2026-11-24 13:36:32 +02:00
uvos
6970118ef1
HIP: CDNA1 MMQ config without stream-k (#32837) 2026-11-24 13:35:00 +02:00
Aman Gupta
4af4bb6d8a
rpc : reuse one context for request tensors on the server (#32896) 2026-11-24 09:43:50 +02:00
Georgi Gerganov
b12f22d2f2
ggml : use a range-reduced log1p for softplus (#32655)
* metal : use a range-reduced log1p for softplus

Use the atanh series for x in [-0.5, 1] and precise::log(1 + x) otherwise.
This avoids the cancellation in log(1 + exp(x)) for negative inputs and does
not rely on fast-math folding of (1 + e) - 1.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

* tests : add a softplus test for negative inputs

Use inputs in [-16.6, -16.0], where log(1 + exp(x)) has up to ~2x
relative error. This catches both the old form and the fast-math-folded
compensated form.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)

* ggml : use log1pf in ggml_compute_softplus_f32

Use log1pf(expf(input)) so the host helper keeps the true value for
x < -16.64.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)
Co-authored-by: IsNot-10 <209144869@qq.com>

* vulkan : use a range-reduced log1p for softplus

Use the atanh series for x in [-0.5, 1] and log(1 + x) otherwise.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)
Co-authored-by: IsNot-10 <209144869@qq.com>

* opencl : use a range-reduced log1p for softplus

Use the atanh series for x in [-0.5, 1] and log(1 + x) otherwise.

Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB)
Co-authored-by: IsNot-10 <209144869@qq.com>

* vulkan : move log1p to utils.glsl

Move the range-reduced log1p out of unary.comp into utils.glsl so that
other ops such as topk_moe and ssm_scan can include it.  The body is
unchanged; only the call site in op_softplus is renamed.

Co-authored-by: IsNot-10 <209144869@qq.com>
Assisted-by: dsh:llama.cpp/ggml-org/Qwen3.8-Flash-Next-GGUF (MacBook, M5 Max, 128GB)

---------

Co-authored-by: IsNot-10 <209144869@qq.com>
2026-11-24 09:30:43 +02:00