Commit graph

1454 commits

Author SHA1 Message Date
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
Pascal
98cc730cc8
tests : relax the DEPTH_MIX tolerance to the mul_mat one (#33141) 2026-11-26 20:10:25 +01: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
Radoslav Gerganov
4ba835c637
tests : add RPC support to test-llama-archs (#33112)
Running test-llama-archs with an RPC device is quite useful as an
integration test for the RPC backend. Here is a sample run with the
Vulkan backend:

ggml-rpc-server -d Vulkan1
test-llama-archs --rpc 127.0.0.1:50052 -b RPC0
2026-11-26 14:57:25 +02:00
Pascal
7365e4793c
tests : take the test-fusion moe flag from the fixture name (#33104)
* tests : take the test-fusion moe flag from the fixture name

The moe flag came from the arch name, so the dense and MoE fixtures
of an arch shared a baseline key, and MoE-only archs were keyed as
dense. Read it from the -dense/-moe suffix written by
test-llama-archs and regenerate the Metal baseline. Only the moe
column changes, no count moves.

* Apply suggestion from ggerganov

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
2026-11-26 14:44:02 +02: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
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
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
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
Seohyun Choi
5a09582d80
model : add RAON-1-mini-preview support (#32176)
* vocab : add RAON pre-tokenizer and NFC normalization
* model : add RAON hybrid attention and mHC graph
* convert : add MXFP8 weight dequantization
* convert : add RAON HF to GGUF conversion and schema
* chat : add the RAON chat template
* tests : add RAON vocab regression files for test-tokenizer-0
* llama-quant : add RAON quantization rules for attention projections
* vocab : move RAON to the standard tokenizer list and remove its dedicated tokenizer test
* convert : move MTP layer check to filter_tensors and correct comment on _KEEP_UNQUANTIZED
* convert : add orphan-scale gurad for MXFP8 scales
* model : remove redundant graph expansion, use require() for RDA head size validation, and add comment for MLA latent normalization
* llama : share KDA conv1d between Raon and Kimi K3
* convert : remove redundant MXFP8 dequantization
* model : align RAON MoE call formatting with other models
* tests : remove RAON quantization test
* model : match RAON MoE weight normalization to the HF reference
* set expert_weights_norm_eps to 1e-20, which introduced in commit 5c008e0
* tests : add Metal fusion test for Raon

Assisted-by: Codex
Assisted-by: Claude Opus 5.5

---------

Co-authored-by: Dong Won Kim <63934649+ddwkim@users.noreply.github.com>
Co-authored-by: Hyeonghwan Kim (김형환) <kim2h7903@krafton.com>
Co-authored-by: Seohyun Choi <seohyun.choi@krafton.com>
Co-authored-by: Piotr Wilkin <piotr.wilkin@syndatis.com>
2026-11-25 19:38:12 +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
Chipmunk
679d8677b2
llama : fix seq state restore with ON_DEVICE (#30318) 2026-11-25 16:48:55 +01:00
Adrien Gallouët
98f870c220
llama : honor metaspace_prepend_scheme for SPM (#31986)
* llama : honor metaspace_prepend_scheme for SPM

This fixes chat prompts for Nanbeige4.3-33B

Signed-off-by: Adrien Gallouët <angt@huggingface.co>

* Add global escaped_space

Signed-off-by: Adrien Gallouët <angt@huggingface.co>

---------

Signed-off-by: Adrien Gallouët <angt@huggingface.co>
2026-11-25 14:59:00 +01: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
Martin Emrich
61d456a232
common : accept boolean "value": true JSON schema (#32908)
* accept boolean "true" JSON schema

... as sent e.g. by "RAGFlow".

* revert over-eager tests
2026-11-25 10:35:44 +02: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
cddaa915a4
SYCL : ROLL op handles permuted source (#31799) 2026-11-25 02:29:04 -05:00
Rajarshi Datta
79c69f4b06
tests : fix MSVC static build of test-batch-alloc and test-server-component (#32870)
Fixes #32868
2026-11-25 00:20:46 +01: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
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
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
losewayy
d141011c25
vulkan: support state size 96 in ssm_scan (#32162)
* vulkan: support state size 96 in ssm_scan

Assisted-by: Claude Code

* vulkan: specialize ssm_scan state size

Assisted-by: Codex

* vulkan: clarify ssm_scan constant names

Assisted-by: Codex
2026-11-24 08:25:31 +01:00
Aman Gupta
d35dc4d9e6
GDN: use replay instead of rollback (#31669)
* GDN: use replay instead of rollback [WIP]

* memory : move rs_max with the sequence when find_slot swaps cells

find_slot swapped pos/src/rs_pend/seq_id of the cell it moves out of the
way, but not rs_max, so that sequence inherited the rollback depth of the
cell's previous owner. A smaller value made seq_rm refuse the rollback
(#31656), a larger one made snapshot mode restore the previous owner's
snapshots.

With rs_replay the pending columns are copied along with the state, so
rs_max follows the sequence. Without it only the final state is copied and
the snapshots stay behind, so the moved sequence gets rs_max 0.

* delta_net: drop the graph replay fallback

The graph fallback ran the replay as two gdn ops and copied the
committed state from the replay gdn when keep, from the main gdn
otherwise. Backends whose graph_optimize reorders nodes (Metal,
Vulkan) then give keep and non keep ubatches a different node order
for the same node count, and the scheduler reallocates on every
switch (abort under GGML_SCHED_DEBUG_REALLOC).

The replay now always runs in the gdn op. A device without the replay
in its gdn op leaves the op to the CPU through the scheduler, as for
any unsupported op. This removes LLAMA_RS_REPLAY=2, the replay probe,
rs_replay_fused and the rep_mask input.

* metal: replay the pending gated delta net tokens in the kernel

The gated delta net kernel replays the pending tokens of each seq
before the new ones, with the same state update as the main loop and
no attention output. With keep, it writes the state after the replay
and skips the final state.

The replay is a function constant of the pipeline, keep is a kernel
argument as on CUDA. The pending buffers fall back to src0 when the
op has no replay.

* vulkan: replay the pending gated delta net tokens in the shader

The gated delta net shader replays the pending tokens of each seq
before the new ones, with the same state update as the main loop and
no attention output. With keep, it writes the state after the replay
and skips the final state.

The replay is a specialization constant of the pipeline, keep is a
push constant as on CUDA. The pending buffers bind q when the op has
no replay. The result checker clones the op with its replay sources.

* webgpu: replay the pending gated delta net tokens in the shader

The gated delta net shader replays the pending tokens of each seq
before the new ones, with the same state update as the main loop and
no attention output. With keep, it writes the state after the replay
and skips the final state.

The replay is a define of the pipeline, keep is a param as on CUDA.
The replay count goes through workgroupUniformLoad, so that the loop
around the workgroup barriers stays uniform.

* delta_net: share the replay conv window views across layers

Each replay layer took its own view of the rs_rep_cols input. The
scheduler copies every view of a host input as a separate split input,
so a verify graph uploaded one copy per layer. The views of the delta
net and the PLE conv windows are now built once per graph, like the
s_copy views.

* vulkan: clamp the gated delta net replay count to n_pend

The replay count comes from a buffer, so the shader bounds it to the
pending rows before looping over them. The pipeline array comment now
names the replay index next to the other ones.

Address review from 0cc4m.

* hex-gdn: add support for replay

Enable replay in HVX path
Enable replay in HMX path

* gdn: fix rebase conflicts (missing cparams, etc)

* llama : drop the fused GDN probes brought back by the rebase

il parameter of build_delta_net. The rebase kept them (unused, auto_fgdn
was always false), so restore master's version of that code.

* delta_net : replay for the KDA models and Clover-MoE

Clover-MoE has the Qwen 3.5 layout and only needs the arch gate.

Kimi K3, Kimi K3.1, GLM5-Next and BailingMoE3 keep the q, k and v conv
windows one after the other in a row. With replay the row holds three
channels-first histories [d_inner, window + pending]:
build_conv_state_replay takes the gathered rows of the layer and the
block index. The pending gate rows hold S_v gates per head (KDA).

GLM5-Next gets the -sm tensor split rules for the replay rows.

Tested with test-llama-archs models: logits match snapshots bit for bit
with random rollbacks (CUDA, Vulkan, CPU), no graph re-plans, and
test-llama-context passes in both modes.

* cuda : same KDA update in the gated delta net main and replay loops

The KDA main loop called expf(g) twice inline, the replay loop reads
g from registers. On sm_89 nvcc fused the two loops differently, so a
replayed state was a few ulp off the state of the first pass. Compute
g into registers in the main loop too: replay matches snapshots bit for
bit on sm_89, and the sm_120 output does not change.

* opencl: support replay in GDN

* llama : replay inputs for the hybrid iswa rel memory input

build_inp_mem_hybrid_iswa_rel came in with the rebase: pass hparams and
cparams to build_rs_inp_impl and fill the replay inputs in set_input,
like the other hybrid inputs.

* webgpu: keep the gated delta net replay within the storage buffer limit

* delta_net : add ggml_gated_delta_net_ext, replay is the only rollback

ggml_gated_delta_net_ext takes the optional replay inputs and always
outputs one state. ggml_gated_delta_net(..., K) is back to its master
signature and is deprecated; both build the same op, so the backends
are unchanged.

The delta-net models (qwen35, qwen35moe, qwen4exp, clover-moe and the
KDA models) now always replay the kept tokens when n_rs_seq > 0. The
LLAMA_RS_REPLAY env flag and the snapshot branch of
build_recurrent_attn are removed.

test-backend-ops drops the K > 1 snapshot cases and the K parameter of
the gated delta net tests. The cache fusion test copies the single
state.

* ggml-cpu : spacemit: leave the gdn replay to the generic kernel

The RVV gated delta net kernel does not read the replay inputs. Return
false when op param 1 (n_pend) is set, so that the generic kernel runs
the op.

* vulkan : fill views at any offset

ggml_vk_fill bound dst without allowing a misaligned offset, so a fill
of a view whose offset is not a multiple of
minStorageBufferOffsetAlignment aborted. The recurrent state zeroing in
build_rs hits this with the wider replay conv rows on devices with a
64-byte alignment.

Bind dst from the aligned offset below it and pass the element offset
in KY. test_fill gets an offset to fill a view in place.

---------

Co-authored-by: Pascal <admin@serveurperso.com>
Co-authored-by: Max Krasnyansky <maxk@qti.qualcomm.com>
Co-authored-by: Li He <lih@qti.qualcomm.com>
2026-11-23 15:06:02 -08:00
Georgi Gerganov
ab789a246c
metal : batch concat rows and copy them in vector chunks (#32824)
* metal : batch concat rows and copy them in vector chunks

The concat kernel copied one element per thread, so wide rows with many rows ran at a
fraction of the memory bandwidth. Batch several rows per threadgroup and copy the
contiguous dim-0 elements in 4-element chunks when the row is contiguous.

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

* test : cover concat vector and misaligned row paths

Assisted-by: dsh:llama.cpp/ggml-org/Qwen3.8-Flash-Next-GGUF (RTX 5090 32GB, DDR5 128GB)

* metal : hoist the concat src1 row offset into scalars

Assisted-by: dsh:llama.cpp/ggml-org/Qwen3.8-Flash-Next-GGUF (RTX 5090 32GB, DDR5 128GB)

* metal : peel to align the concat vector copy

Assisted-by: dsh:llama.cpp/ggml-org/Qwen3.8-Flash-Next-GGUF (RTX 5090 32GB, DDR5 128GB)

* metal : vectorize concat rows along any dimension

Assisted-by: dsh:llama.cpp/ggml-org/Qwen3.8-Flash-Next-GGUF (RTX 5090 32GB, DDR5 128GB)

* metal : specialize concat with function constants

Assisted-by: dsh:llama.cpp/ggml-org/Qwen3.8-Flash-Next-GGUF (RTX 5090 32GB, DDR5 128GB)

* metal : drop the concat row-batch dispatch

Batching several rows per threadgroup reduces the number of threads by
the batch factor. On machines with a large GPU this leaves too few
requests in flight and the copy becomes latency bound:

  M5 Ultra (36 CPU)   f16 [1024,8,256,1] d=0   8.1 us -> 17.2 us
                      f32 [4096,8,256,1] d=0  35.4 us -> 118.5 us
                      f16 [4096,8,256,1] d=2  50.9 us -> 102.0 us

An interleaved sweep of the (nth, nrptg) dispatch over the concat perf
cases on an M2 Ultra and an M5 Ultra shows that the base dispatch is
best or tied for every shape once the rows are vectorized, and that the
gains of the previous commit come from the vector copy alone:

  M2 Ultra  f16 [1024,8,256,1] d=0  32.4 us -> 17.0 us
  M5 Ultra  f16 [1024,8,256,1] d=0  13.3 us ->  8.1 us

Keep the vector copy and the function-constant specialization, and
return to the original dispatch.

Assisted-by: dsh:llama.cpp/ggml-org/Qwen3.8-Flash-Next-GGUF (RTX 5090 32GB, DDR5 128GB)

* metal : revert the concat function constants

Specializing the concat kernel on the concat dimension and on whether a
row is split across threadgroups with function constants makes the
strided scalar path slower. Interleaved over the concat perf cases on an
M5 Ultra, the specialized kernel is not faster than the plain one, and
it costs up to 18% on shapes that are already at the memory bandwidth
limit:

  f32 [2050,8,256,1] b=255 d=0  21.0 us -> 25.1 us
  f32 [2050,8,256,1] b=256 d=2  31.1 us -> 36.7 us
  f16 [4096,8,256,1] b=256 d=2  31.2 us -> 36.7 us

Revert the specialization and keep copying rows with the runtime
arguments. The concat change is now limited to the kernel itself.

Assisted-by: dsh:llama.cpp/ggml-org/Qwen3.8-Flash-Next-GGUF (RTX 5090 32GB, DDR5 128GB)
2026-11-23 21:01:41 +02:00
Piotr Wilkin (ilintar)
239242322d
ggml: compact bias on the existing FLASH_ATTN_EXT (#32740)
* compact bias on the existing FLASH_ATTN_EXT for CUDA, ROCm and Vulkan
* fixup! compact bias on the existing FLASH_ATTN_EXT for CUDA, ROCm and Vulkan
* remove the Vulkan support from this PR
* move the CUDA/HIP and Inkling 2 graph changes out of this PR
* CPU reference implementation of the indexed bias
* move the indexed bias test to test-backend-ops, add the bias in F32 on CPU
* incorporate review remarks
2026-11-23 18:17:11 +01:00
Ed Addario
30ec35ae2e
quantize: add option to automatically choose optimal quant types to reach a file/bpw target size at lowest error (#15550)
* Refactor pareto optimise and convexify
* Refactor lagrange_penalty()
* Refactor quantisation checks into its own function
* Exit loop if no better solution found
* Replace slope with cross product
* Adjust for small vector size
* Simplify candidates sorting
* Add comments to explain magic numbers
* Increase scale multiplier
* Move is_iq() into a lambda and remove unused variables
* Combine quant types
* Reduce bpw range
* Refactor outlier trimming
* Tighten worker allocator
* Check for direction reversal
* Simplify dequantisation
* Calculate bpw over all tensors
* Compute rows based on tensor shape and slice count
* Prioritise important tensors
* Select quantization type if target_bpw is set unless user specifies type and threads
* Relax lambda clamping
* Add signal handler
* Add save_bpw_state()
* Add load_bpw_state()
* Add delete_bpw_state()
* Persist progress
* Uninstall signal handler and cleanup
* Fix trimming logic
* Generate model ID hash
* Remove bias mode computation
* Remove --no-bias option
* Automatically determine if bias error is significant
* Reduce compute time by parallelising tensor processing - courtesy of https://github.com/ddh0
* Add quant types
* Add --keep-bpw-state option
* Refactor signal handlers
* Update quant types
* Minor refactoring
* Add tensor type and depth heuristics
* Add option to override bpw state file name
* Minor refactoring
* Finetune heuristics
* Update usage
* Fix lambda capture
* Update epsilon specifier
* Finetune heuristics
* Simplify tensor selection
* Read statistics from imatrix
* Add Euclidean-Cosine score to identify important tensors
* Improved is_important() logic
* Fix lambda capture bug in Windows and initialise candidate_types struct
* Remove processing statistics_data
* Add --disable-tensor-importance option
* Use more descriptive option naming
* Relax target bpw range
* Increase importance boost for final pass
* Add B/F16 to get_ftype()
* Process bpw targets up to B/F16
* Improve state checkpoint filename
* Add code comments
* Update usage()
* Update README.md
* Change checkpoint file magic
* Prepare for future optimization algorithms
* Add parse_target_size()
* Add --target-size option
* Implement target_size logic
* Update usage()
* Refactor parameter names
* Refactor option names
* Update parameter names
* Improve file handling
* Remove file deletion
* Refactor variable names
* Update usage()
* Add use_wce option
* Read statistics_data from imatrix
* Add experimental entropy-modulated weighted cosine error (WCE)
* Performance optimisations (AI assisted)
* Memory optimisations (AI assisted)
* Update output log
* Fix state file name generation and simplify_pareto() lambda capture
* Change tensor importance score logic
* Refactor is_quantizable()
* Improve WCE to be magnitude-aware
* Expected Output Error MSE
* Fix scale factor overwrite bug
* Test removing unused headers
* Remove wce flag
* Angle-aware/Magnitude-aware (MSE/WCE) hybrid error estimation
* Revert to weighted cosine error estimation
* Enhanced scaling factor
* Use centered‑normalized importance scaling factor (CNIF)
* Remove redundant logs
* Improve state file handling
* Update usage instructions
* Update ftype parsing logic
* Flag experimental features subject to future removal
* Fix --target-size description
* Fix "casts away qualifiers" compiler warning
* Exclude user defined tensors (--tensor-type) from the Lagrangian optimization
(courtesy of https://github.com/AesSedai)
* TurboQuant bias factor for inner-product sensitive tensors
* TurboQuant outlier mitigation
* Refactor TurboQuant improvements
* Fix remap tensor bug
* Remove --importance-pct option
* Refactor llama_model_quantize_params to expose a pure C interface
* Consolidate load/save process and remove --save-state flag
* Minor log output changes
* Use the tensor statistics' schema
* Add quant types
* Release finished tensors mmap allocation
* Reuse sample buffers
* Fix C2327 error when target compilation is a MS platform
* Minor refactoring and AI assisted optimizations
* Add uv.lock
* Minor refactoring and AI assisted optimizations
* Add Halko, Martinsson & Tropp randomized SVD condition number estimator
* Add kappa squashing functio
* Remove unnecessary includes
* Add required include
* Update python dependencies
* Fine-tune kappa mapping parameters
* Fine-tune CNIF beta parameters
* Fix fallback counter error
* Move to libllama and unmap weights offloaded to backend
* Remove unmap weights offloaded to backend
* Add winsorization
* Add adaptive tensor boosting
* Minor cosmetic changes
* Refactor processing of unused kv tensors
* Minor cosmetic change
* Implement --max-buffer-size in target_bpw_type()
* Fix 32-block fallback case
* tensor_type_override_for() DRY refactoring
* Fix typo and remove unused option
* Fix #28491 linking bug when compiling with BUILD_SHARED_LIBS=OFF
* Remove GGML_USE_METAL conditional macro and let the optimizer decide\
* Add --target-exclude
* Remove and ignore uv.lock
* Fix pinned tensors safety limits calculation
* Fix truncation error
* Add downwards greedy upgrade
* Add target bpw/size tests
* Guard imatrix schema
* Update --target-bpw/size descriptions and README.md
* Harden state checkpoint's file operations
* Link model and imatrix to state checkpoint
* Enforce and consume stats schema data
* Add stats schema tests
* Refactor signal handlers out of lib and harden the logic
* Improve handling of pinned tensors
* Add tests
* Add include to keep ubuntu-webgpu happy
* Moving new API entries to prevent brittle downstream apps failing
* Fix miscellaneous issues
2026-11-23 18:06:26 +01:00
Georgi Gerganov
87f816e87f
metal : support BF16/F32 src1 for MUL_MAT and MUL_MAT_ID (#32677)
* llama, metal : support BF16 src1 for MUL_MAT and MUL_MAT_ID

Add GGML_PREC_BF16 handling for src1 on the Metal backend when the tensor
API is available: MUL_MAT with an F32 src0 stages the A tile as bfloat, and
MUL_MAT_ID stages src1 as bfloat instead of F16. The tensor path keeps src1
in F32 when it reads the operand directly.

Add a temporary LLAMA_MOE_AMAX_SKIP env var that disables the graph-level
amax rescaling for the MoE down projection and sets the BF16 src1 hint
instead. Apply the hint inside build_lora_mm_id so it reaches the matmul
before the per-expert scale and LoRA nodes wrap it.

Add MUL_MAT_ID src1 BF16 test cases to test-backend-ops.

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

* metal : support BF16 src1 without the tensor API

Allow GGML_PREC_BF16 when the device has bfloat, not only when it has the
Metal4 tensor API.

Add legacy _prec_bf16 kernels for MUL_MAT and MUL_MAT_ID that stage src1 as
bfloat in the threadgroup and run the simdgroup multiply with bfloat A and B.
The F16 MUL_MAT_ID kernel uses half A on the tensor path and bfloat A on the
legacy path.

Cast the quantized dequantize outputs to the destination element type: the
older Metal compiler on M2 rejects implicit float to bfloat.

Tested on M2 Ultra (legacy): MUL_MAT_PREC_SRC1 24/24 and
MUL_MAT_ID_PREC_SRC1_BF16 30/30. Flint Q4_K_M with LLAMA_MOE_AMAX_SKIP=1:
pp512 -2.1%, tg128 +25.5% vs master. On M5 Max: pp512 +2.1%, tg128 +22.2%.

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

* metal : derive matrix types with value_type helpers

Add value_type_4x4/value_type_2x4/value_type_8x8 helpers and use them in the MUL_MAT and MUL_MAT_ID kernels so the templates take only the underlying types and derive the matrix types. Add TODOs for the remaining kernels.

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

* metal : derive matrix types in the remaining kernels

Use the value_type_* helpers in the flash-attention, top-k-mask, mul-mv and
count-equal kernels to derive the matrix/vector types from the underlying
scalar types, and simplify the FA_TYPES macros.

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

* metal : enable BF16 in the tensor API metallib

The tensor API requires macOS 26, where bfloat is always available, so
define GGML_METAL_HAS_BF16 when compiling the tensor metallib. This makes
the bfloat specializations of the value_type helpers visible to
fa_tensor.metal and includes the prec_bf16 kernels in the prebuilt tensor
metallib.

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

* metal : support GGML_PREC_F32 for src1 in MUL_MAT and MUL_MAT_ID

Split the tensor-API and legacy simdgroup mul_mm/mul_mm_id kernels into
separate files and library kinds, following the fa_tensor.metal example.
The legacy kernels, including the new _prec_f32 variants that stage src0
and src1 as float in shared memory, are compiled into the default mul_mm
library; the tensor variants live in a separate mul_mm_tensor library
kind and carry a _tensor host-name infix. Tensor devices run F32 src1
matmuls on the simdgroup path instead of the tensor API, which rounds
float operands to a reduced precision. This removes the MUL_MM_SG kind
and the #undef GGML_METAL_HAS_TENSOR compile. Add
MUL_MAT_ID_PREC_SRC1_F32 tests.

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

* cont : indentation

* llama : move the MoE amax skip into the precision policy

Add llm_arch_mmid_down_bf16() for the architectures whose MoE down
projection uses the graph-level amax rescaling. Extract the precision
policy setup from load_tensors() into llama_model_base::load_prec_policy(),
and move the LLAMA_MOE_AMAX_SKIP handling there: it sets prec_src1 = BF16
for ffn_down_exps before the per-tensor policy is loaded. build_moe_ffn()
now skips the amax rescaling when the policy requests BF16.

Apply the policy with the original weight so cached experts get it, drop
the prec_src1 parameter from build_lora_mm_id(), and remove the prec_src1
serialization from the model saver.

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

* cont : minor
2026-11-23 18:46:12 +02:00
Vladislav Merkulov
a8f8294c45
tests : update Qwen3.6-27B snapshot (#32845) 2026-11-23 11:45:31 +01:00
Leon
f5e6915c28
webgpu : add ROLL support (#31887)
* webgpu : add ROLL support

* tests : keep ROLL cases portable across backends
2026-11-23 09:56:54 +02:00
Aldehir Rojas
dd53f70d08
chat : improve inkling parser/grammar (#32833) 2026-11-23 09:54:42 +02:00
Aman Gupta
7778de0c3f
tests : compare only the guaranteed GDN snapshot slots (#32820) 2026-11-23 10:32:56 +08:00
Alexey Kopytko
f4f6f2e7db
ggml-backend : generic fallback in ggml_backend_tensor_memset (#32574) 2026-11-23 09:48:16 +09:00
Xuan-Son Nguyen
253671d882
chat: fix LFM2.5-VL template detection (#32843) 2026-11-23 01:20:22 +01:00
yoch
94f3af3d09
mtmd: speed up shared audio FFT (#32815)
Some checks are pending
Release / ubuntu-24-openvino (push) Blocked by required conditions
Release / windows-openvino (push) Blocked by required conditions
Release / windows-cpu / arm64 (push) Blocked by required conditions
Release / windows-cpu / x64 (push) Blocked by required conditions
Release / windows-rocm (10.0.0, x64, gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201) (push) Blocked by required conditions
Release / windows (arm64, opencl-adreno, -G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" -DGGML_OPENCL=ON -DGGML_OPENCL_USE_ADRENO_KERNELS=ON, ggml-opencl) (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-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-metal (push) Waiting to run
Server (self-hosted) / server-cuda (push) Waiting to run
Server (self-hosted) / server-kleidiai (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 / 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 / E2E Tests (push) Blocked by required conditions
* mtmd: speed up shared audio FFT

Replace recursive radix-2 splitting with iterative stages and
batch the existing odd-size DFT across subsequences, preserving
the previous operation order.

Input buffers now hold only N real values for FFT
or 2N interleaved floats for inverse FFT.

Add test_audio_fft for forward and inverse transforms.

Assisted-by: Claude

* nits

---------

Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
2026-11-22 22:04:24 +01:00
George Burton
f505c30b92
mtmd: fix qwen3a audio tail (#32697)
* add: test to reporduce error reported in https://github.com/ggml-org/llama.cpp/issues/32689

* fix: remove extra tokens from zero-padding of Qwen3-Omni / Qwen3-ASR audio

* add: qwen3a_tokens_for_frames instead of magic numbers

* refactor: only ggml_pad when required

* refactor: move qwen3a_tokens_for_frames as static member of mtmd_graph_qwen3a and add test

* remove: trailing empty line

---------

Co-authored-by: george burton <georgeburton@georges-MacBook-Air.local>
2026-11-22 21:22:46 +01:00
Aldehir Rojas
1014775c8a
chat : implement token aware parsing (#29307) 2026-11-22 11:36:03 -06:00
gianni-cor
ad50351f50
ggml : add SIGMOID backward pass (#32126)
* ggml : add SIGMOID backward pass

Sigmoid is used in Qwen3.5 hybrid models and had no backward pass.
Bump RPC protocol patch version for the new op.

Signed-off-by: gianni-cor <gianfranco.cordella@tether.io>

* replace assert with ggml_assert

Co-authored-by: Johannes Gäßler <johannesg@5d6.de>

* ggml : keep sigmoid backward checks in release builds

Assisted-by: Codex

* ggml : preserve existing operation IDs when adding SIGMOID_BACK

Assisted-by: Codex

---------

Signed-off-by: gianni-cor <gianfranco.cordella@tether.io>
Co-authored-by: Johannes Gäßler <johannesg@5d6.de>
2026-11-22 13:33:13 +02:00
Michael
42f6a58fd1
chat : trigger lazy grammar on bare JSON tool calls (#32497)
Models like Llama 3.x emit tool calls as plain {"name": ...} JSON without a start marker, so with tool_choice=auto no grammar was produced at all. Use a pattern trigger on the opening of the call object instead.

Assisted-by: Claude Code
2026-11-22 12:19:04 +01:00
Alexey Kopytko
9c10c94e16
ggml : fix nonzero clear on WebGPU and non-UMA devices (#32727) 2026-11-22 20:10:42 +09:00
Revertron
8a97fa98ab
vulkan : support non-contiguous src in SCALE (#32735)
Assisted-By: Opus 5.5
2026-11-22 07:28:46 +01:00
Alexey Kopytko
b052049276
vulkan : fix memset for unaligned ranges for non-UMA devices (#32725)
See https://github.com/ggml-org/llama.cpp/pull/32574
2026-11-22 10:11:39 +09:00
Aldehir Rojas
afe77e18fa
chat : pass reasoning_effort = none if supported (#32763) 2026-11-21 15:27:25 -06:00
Xuan-Son Nguyen
19bc41dbb4
model: apply .scale tensors automatically + fix correctness (#32669)
* model: apply .scale tensors automatically

* rm build_moe_ffn "_s" overload

* use llama_prec_policy

* fix ci

* build_lora_mm_id: rm w_s
2026-11-21 16:30:01 +01:00
Frosty40
e50c254a22
sycl: bound CONV_TRANSPOSE_1D input iteration (#31109)
Used angelX to optimize SYCL/drama 3 coordination, results are as follows

Each output reads only inputs with i*s0 <= idx < i*s0 + K, in the same ascending order as before.

Arc Pro B70, oneAPI 2026.1, test-backend-ops perf, base 9b56ccf00 vs patch, median of 3 same-boot A/B/A rounds, A/A 1.000-1.001:

| input [ne0, ne1] | kernel [K, OC, IC] | s0 | base us | patch us | speedup |
|---|---|---|---|---|---|
| [16, 1536] | [16, 768, 1536] | 8 | 3910.57 | 1348.59 | 2.90x |
| [128, 768] | [16, 384, 768] | 8 | 37735.00 | 1665.26 | 22.66x |
| [1024, 384] | [8, 192, 384] | 4 | 270371.75 | 1471.74 | 183.71x |
| [4096, 192] | [4, 96, 192] | 2 | 534614.63 | 752.74 | 710.23x |

Shapes are the drama 3 codec decoder upsampling stack, added as perf cases. Chained 4-layer stack at 1/4/24 input frames: base 66.3/847.4/28638.5 ms, patch 2.3/6.7/30.7 ms. Kernel numbers, not end-to-end TTS latency.

Correctness: test-backend-ops -o CONV_TRANSPOSE_1D 116/116 on base and patch, and 116/116 rebased on 3f03b1772. Seeded output dump (7.46 MB) byte-identical to base.

Full test-backend-ops aborts on base and patch alike at the non-F32 SWIGLU_OAI assert (element_wise.cpp:1187, see #30857). With only those cases excluded: 20145/20173 on base and patch, and every patch-run failure also fails on base.

Co-authored-by: Titaniumtown <titaniumtown@proton.me>
2026-11-21 16:20:29 +02:00
Xuan-Son Nguyen
c622f623fc
mtmd: support kyutai/hibiki realtime full-duplex (#32491)
* mtmd: support hibiki realtime duplex

* fix and clean up

* fix long session quality

* fix ci

* tests : add the moshi fusion baseline for Metal

The Metal fusion check found 5 RMS_NORM+MUL fusions in the new moshi
arch and no baseline for them.

---------

Co-authored-by: Pascal <admin@serveurperso.com>
2026-11-21 14:25:19 +01:00