]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/log
pkg/ggml/sources/llama.cpp
2 months agosync : ggml
Georgi Gerganov [Thu, 11 Jun 2026 16:33:33 +0000 (19:33 +0300)]
sync : ggml

2 months agoggml : bump version to 0.15.0 (ggml/1539)
Georgi Gerganov [Thu, 11 Jun 2026 16:32:38 +0000 (19:32 +0300)]
ggml : bump version to 0.15.0 (ggml/1539)

2 months agovulkan: add fast path for contiguous buffer transfers (#23973)
Winston Ma [Thu, 11 Jun 2026 13:46:25 +0000 (21:46 +0800)]
vulkan: add fast path for contiguous buffer transfers (#23973)

2 months agovulkan: use medium matmul tile on Asahi Linux (#24306)
Kevin Liu [Thu, 11 Jun 2026 13:43:04 +0000 (09:43 -0400)]
vulkan: use medium matmul tile on Asahi Linux (#24306)

* vulkan: use medium matmul tile on Asahi Linux

* vulkan: switch Apple detection to Honeykrisp driver id

2 months agoserver: skip unused log lines on router mode (#24463)
Xuan-Son Nguyen [Thu, 11 Jun 2026 09:36:35 +0000 (11:36 +0200)]
server: skip unused log lines on router mode (#24463)

2 months agovocab : adopt leading TemplateProcessing special token as BOS (#24428)
o7si [Thu, 11 Jun 2026 07:37:23 +0000 (15:37 +0800)]
vocab : adopt leading TemplateProcessing special token as BOS (#24428)

2 months agovocab : refactor normalizer flags into options struct, add strip_accents (#24371)
o7si [Thu, 11 Jun 2026 07:36:50 +0000 (15:36 +0800)]
vocab : refactor normalizer flags into options struct, add strip_accents (#24371)

* vocab : refactor normalizer flags into options struct, add strip_accents

* Update src/llama-vocab.h

Co-authored-by: Sigbjørn Skjæret <redacted>
* Update src/llama-vocab.cpp

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

Co-authored-by: Sigbjørn Skjæret <redacted>
2 months agoserver : skip checkpoints beyond pos_next (#24411)
Aldehir Rojas [Thu, 11 Jun 2026 07:18:12 +0000 (02:18 -0500)]
server : skip checkpoints beyond pos_next (#24411)

* server : skip checkpoints beyond pos_next

* cont : update comment + TODO + ref

---------

Co-authored-by: Georgi Gerganov <redacted>
2 months agovendor : update LibreSSL to 4.3.2 (#24397)
Adrien Gallouët [Wed, 10 Jun 2026 20:28:03 +0000 (22:28 +0200)]
vendor : update LibreSSL to 4.3.2 (#24397)

Signed-off-by: Adrien Gallouët <redacted>
2 months agoRemove padding and multiple D2D copies for MTP (#24086)
Gaurav Garg [Wed, 10 Jun 2026 17:51:16 +0000 (23:21 +0530)]
Remove padding and multiple D2D copies for MTP (#24086)

* Make ggml_gated_delta_net take only the initial recurrent state (D, 1, n_seqs) and passes the snapshot count K as an op parameter instead of inferring it from state->ne[1].

Remove the padding hack and copy all emitted snapshots into the recurrent cache with a single strided ggml_cpy

* Make GDN changes in all backends. Address review comments.

* Fix CI build errors

2 months agochat: fix LFM2/LFM2.5 ignoring json_schema (#24377)
Tarek Dakhran [Wed, 10 Jun 2026 12:41:41 +0000 (14:41 +0200)]
chat: fix LFM2/LFM2.5 ignoring json_schema (#24377)

The LFM2 specialized template handler only built a grammar for tool-calling,
silently ignoring json_schema from response_format.

2 months agoCUDA: Fix ssm_scan_f32 data-races (#24360)
Oliver Simons [Wed, 10 Jun 2026 12:27:08 +0000 (14:27 +0200)]
CUDA: Fix ssm_scan_f32 data-races (#24360)

* Add missing syncthreads before resuing cub_temp_storage

__syncthreads() is required before being allowed to resue TempStorage
smem:
https://nvidia.github.io/cccl/unstable/cub/api/classcub_1_1BlockLoad.html#_CPPv4I0EN3cub9BlockLoad4LoadEv20RandomAccessIteratorRA14ItemsPerThread_1Ti

* Add one more missing __syncthreads

Could also double-buffer, but alternative is to simply ensure all
threads have read smem* before writing to it again in the next loop
iteration

* Remove unused smem from ssm_scan_f32

3 months agoci : bump komac version (#24396)
Sigbjørn Skjæret [Wed, 10 Jun 2026 07:45:20 +0000 (09:45 +0200)]
ci : bump komac version (#24396)

3 months agospeculative : fix "ngram-map-k4v" name in logging (#24253)
ddh0 [Wed, 10 Jun 2026 07:31:35 +0000 (02:31 -0500)]
speculative : fix "ngram-map-k4v" name in logging (#24253)

This is a non-functional change.

When using `--spec-type ngram-map-k4v`, the log messages at startup and
runtime say `ngram-map-k`. Added logic in the in the constructor of
`common_speculative_impl_ngram_map_k` to pass the correct
`COMMON_SPECULATIVE_TYPE_NGRAM_MAP_K4V` when `config.key_only` is
`false`.

After this change, the log messages use the correct name.

3 months agowebui: implement pinned conversations support (#21387)
Rémy Mathieu [Tue, 9 Jun 2026 19:33:22 +0000 (21:33 +0200)]
webui: implement pinned conversations support (#21387)

* webui: implement pinned conversations support

* webui: linter/prettier pass

* Fix the unused handleMobileSidebarItemClick from the component.

* the search should find pinned conversations as well

Co-authored-by: Pascal <redacted>
---------

Co-authored-by: Pascal <redacted>
3 months agograph: Fix granite speech model inference by applying embedding scale when deepstack...
Aarnav Pai [Tue, 9 Jun 2026 17:46:27 +0000 (23:16 +0530)]
graph: Fix granite speech model inference by applying embedding scale when deepstack is not used (#24357)

* llama-graph : apply embedding scale when deepstack is not used

* nits: remove non-existant hunyuan-vl from the tests

* apply suggestion from @gabe-l-hart

---------

Co-authored-by: Xuan Son Nguyen <redacted>
3 months agoci : fix windows release (#24369)
Sigbjørn Skjæret [Tue, 9 Jun 2026 16:42:23 +0000 (18:42 +0200)]
ci : fix windows release (#24369)

3 months agoui: add opt-in run_javascript frontend tool (#24244)
Pascal [Tue, 9 Jun 2026 16:02:31 +0000 (18:02 +0200)]
ui: add opt-in run_javascript frontend tool (#24244)

* ui: add opt-in run_javascript frontend tool

Expose a run_javascript tool to the model, executed entirely in the
browser through the existing agentic loop. Code runs in a Web Worker
inside a sandboxed iframe with an opaque origin, isolated from the
WebUI and its API. Console output, errors and the return value are
fed back as the tool result. The parent enforces a hard timeout by
removing the iframe, which terminates the worker.

Disabled by default, toggle in Settings > Developer.

* ui: address review feedback from allozaur

Use the JsonSchemaType enum for the tool definition parameter types
instead of raw string literals, extending it with STRING and NUMBER.

Move the worker shim and the iframe harness html into their own files
so the service no longer carries inline source blobs.

Replace the remaining magic strings with constants: SANDBOX_EMPTY_OUTPUT
and SANDBOX_TRUNCATION_NOTICE, and reuse NEWLINE_SEPARATOR for joins.

* ui: move sandbox worker shim to a raw imported file

Replace the inline worker template string with a real sandbox-worker.js
imported as raw text, and build the iframe harness from it in
sandbox-harness.ts. The raw worker ships as a string, not a module, so
it is excluded from eslint and the typecheck program.

3 months agomtmd: build_vit batching (#24352)
Saba Fallah [Tue, 9 Jun 2026 14:32:08 +0000 (16:32 +0200)]
mtmd: build_vit batching (#24352)

3 months agovulkan: reduce iq1 shared memory usage for mul_mm (#24287)
Jeff Bolz [Tue, 9 Jun 2026 11:27:38 +0000 (06:27 -0500)]
vulkan: reduce iq1 shared memory usage for mul_mm (#24287)

3 months agovulkan: add `v_dot2_f32_f16` support in matrix-matrix multiplication and Flash Attent...
Ruben Ortlam [Tue, 9 Jun 2026 11:27:04 +0000 (13:27 +0200)]
vulkan: add `v_dot2_f32_f16` support in matrix-matrix multiplication and Flash Attention (#24123)

* vulkan: add support for valve fp16 dot2 extension

* use macro for dot2 path choice

* properly check for the feature

* add dot_product abstraction to reduce preprocessor branching

3 months agoui: Fix excessive style recalculation on hover (#24243)
Nick Towle [Tue, 9 Jun 2026 10:52:20 +0000 (03:52 -0700)]
ui: Fix excessive style recalculation on hover (#24243)

3 months agomtmd: refactor video subproc handling (#24316)
Xuan-Son Nguyen [Tue, 9 Jun 2026 10:15:12 +0000 (12:15 +0200)]
mtmd: refactor video subproc handling (#24316)

* mtmd: refactor video subproc handling

* Update tools/mtmd/mtmd-helper.cpp

Co-authored-by: Mikko Juola <redacted>
---------

Co-authored-by: Mikko Juola <redacted>
3 months agoserver: log prompts to directory (#22031)
jacekpoplawski [Tue, 9 Jun 2026 10:09:07 +0000 (12:09 +0200)]
server: log prompts to directory (#22031)

* server: log prompts to directory

Add `--log-prompts-dir` to write each prompt to a separate text file in
the specified directory.

* Apply suggestion from @ngxson

---------

Co-authored-by: Xuan-Son Nguyen <redacted>
3 months agoui: fix mobile chat form overflow and bust stale bundle cache (#24158)
Pascal [Tue, 9 Jun 2026 09:12:58 +0000 (11:12 +0200)]
ui: fix mobile chat form overflow and bust stale bundle cache (#24158)

3 months agoggml : add GGML_OP_COL2IM_1D (#24206)
Pascal [Tue, 9 Jun 2026 09:01:37 +0000 (11:01 +0200)]
ggml : add GGML_OP_COL2IM_1D (#24206)

* cpu: add GGML_OP_COL2IM_1D

Add the overlap-add (scatter-add) step of a 1D transposed convolution.
A ConvTranspose1d factorizes as a GEMM followed by col2im: a weight
pre-permuted to [IC, K*OC] is contracted against the [IC, T_in] input
with mul_mat to produce a column matrix [K*OC, T_in], and col2im_1d
scatters those columns back into the [T_out, OC] signal, with
T_out = (T_in - 1)*s0 + K - 2*p0.

Keeping the contraction as a plain mul_mat leaves the heavy work on the
optimized (and quantizable) matmul kernels, so col2im_1d only does the
cheap overlap-add.

CPU uses a gather formulation parallelized over output channels,
supporting F32, F16 and BF16 with an F32 accumulator.

* tests: add backend coverage for GGML_OP_COL2IM_1D

Add test_col2im_1d next to the conv_transpose_1d cases, covering F32,
F16 and BF16 across eight geometries: the canonical kernel = 2*stride
DAC upsampling shape, overlap, no overlap, cropping (p0 = 1 and
p0 = stride/2), kernel < stride with zeroed gaps, kernel not a
multiple of stride, and a single column unfold.

Perf mode gets three real vocoder stage shapes reporting memory
bandwidth. max_nmse_err relaxes to 5e-4 for F16 and BF16.

* cpu: harden GGML_OP_COL2IM_1D

ggml_col2im_1d validates s0, oc, p0 and input contiguity at graph
build time, before the oc division, protecting every backend at once.
The kernel asserts the contiguity its flat indexing assumes and its
doc states the full output length including the crop term.

The kernel parallelizes over the time axis: the split stays balanced
down to OC = 1, where the previous channel split was single threaded.
Values are bit identical on the three real vocoder chains, two out of
three improve.

* tests: extend the GGML_OP_COL2IM_1D grid

The eval grid grows to eleven geometries: OC = 1 (mono output stage),
K = 1 with stride > 1 (sparse scatter, every gap position zeroed) and
a crop down to T_out = 2 where all the gather bounds act at once.

* tests: add col2im_1d equivalence test

tests/test-col2im-1d.cpp proves mul_mat + col2im_1d matches the
native ggml_conv_transpose_1d on the CPU backend, F32 bit exact, F16
and BF16 through casts of the column matrix. test-backend-ops cannot
cover this for a CPU only op since the CPU backend is its own
reference there.

* rpc: bump protocol patch version for GGML_OP_COL2IM_1D

GGML_OP_COUNT goes from 96 to 97 with the new op, which trips the
static_assert in ggml-rpc.h. Bump RPC_PROTO_PATCH_VERSION since the
op is appended and no existing op code shifts.

3 months agoserver : do not clear slots without unified KV cache (#24190)
fiesh [Tue, 9 Jun 2026 07:45:16 +0000 (09:45 +0200)]
server : do not clear slots without unified KV cache (#24190)

* Always export idle slots to RAM

Without this, a slot's VRAM cache may not be written to RAM.  If this
slot happens to be busy then later on, this triggers needless
preprocessing in another slot.

* cont : clean-up

---------

Co-authored-by: Christoph Weiss <redacted>
Co-authored-by: Georgi Gerganov <redacted>
3 months agomodels : fix plamo2 attention_key/value_length regression (#24317)
Sigbjørn Skjæret [Tue, 9 Jun 2026 07:26:44 +0000 (09:26 +0200)]
models : fix plamo2 attention_key/value_length regression (#24317)

3 months agoggml-cpu : fix rms_norm_back wrong output under in-place aliasing (#24305)
Yash Raj Pandey [Tue, 9 Jun 2026 07:24:27 +0000 (03:24 -0400)]
ggml-cpu : fix rms_norm_back wrong output under in-place aliasing (#24305)

* ggml-cpu : fix rms_norm_back wrong output under in-place aliasing

* cont : clean-up comment

---------

Co-authored-by: Georgi Gerganov <redacted>
3 months agoRemove case for GGML_TYPE_Q4_K in mvvq.cu (#23528)
ravel7524 [Tue, 9 Jun 2026 05:46:23 +0000 (07:46 +0200)]
Remove case for GGML_TYPE_Q4_K in mvvq.cu (#23528)

3 months agoggml-webgpu: Add clang-format job (#24308)
Reese Levine [Tue, 9 Jun 2026 03:54:24 +0000 (20:54 -0700)]
ggml-webgpu: Add clang-format job (#24308)

* Add clang-format job

* try local formatting

3 months agoggml-webgpu: Improve prefill speeds for k-quants + refactor matmul for Q4/Q5/Q8 and...
Masashi Yoshimura [Mon, 8 Jun 2026 22:19:56 +0000 (07:19 +0900)]
ggml-webgpu: Improve prefill speeds for k-quants + refactor matmul for Q4/Q5/Q8 and k-quants (#24225)

* ggml-webgpu: Improve prefill speeds + refactor matmul for quants

* Fixes for editroconfig checker

3 months agomtp: support for gemma-4 E2B and E4B assistants (#24282)
Max Krasnyansky [Mon, 8 Jun 2026 20:48:52 +0000 (13:48 -0700)]
mtp: support for gemma-4 E2B and E4B assistants (#24282)

* models: update converter to support smaller assistants

* models: add masked_embd tensors to gemma4-assist arch

* gemma-4: remove temp debug for conversion

* gemma-4-mtp: filter out masked_embedding tensors during conversion

3 months agoserver : do not parse when flushing http headers (#24281)
Aldehir Rojas [Mon, 8 Jun 2026 18:32:41 +0000 (13:32 -0500)]
server : do not parse when flushing http headers (#24281)

3 months agograph: guard iswa kq_mask on its own buffer (#24294)
Pascal [Mon, 8 Jun 2026 17:20:28 +0000 (19:20 +0200)]
graph: guard iswa kq_mask on its own buffer (#24294)

A SWA-only draft head (e.g. StepFun MTP) leaves the base sub-cache
empty, so its kq_mask buffer stays null and asserts at load. Guard
each mask on its own buffer in set_input and can_reuse, base and swa.

Co-authored-by: Georgi Gerganov <redacted>
3 months ago[ggml-webgpu] Handle buffer overlap / buffer aliasing for concat operator (#24000)
Nikhil Jain [Mon, 8 Jun 2026 15:07:31 +0000 (08:07 -0700)]
[ggml-webgpu] Handle buffer overlap / buffer aliasing for concat operator (#24000)

* Only run webgpu CI on my fork

* Add webgpu only workflow

* handle buffer overlap case for concat operator

* restore build-webgpu.yml

Co-Authored-By: Claude Sonnet 4.6 <redacted>
* Run clang-format

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

---------

Co-authored-by: Claude Sonnet 4.6 <redacted>
Co-authored-by: Reese Levine <redacted>
3 months ago[ggml-webgpu] Implement 2D workgroups for scale, binary, and unary ops (#24044)
Nikhil Jain [Mon, 8 Jun 2026 15:07:15 +0000 (08:07 -0700)]
[ggml-webgpu] Implement 2D workgroups for scale, binary, and unary ops (#24044)

* Only run webgpu CI on my fork

* Add webgpu only workflow

* Implement 2d workgroups for more operations

* fix

* Fix type

* Move back to global_invocation_id

3 months agodocker: install ffmpeg in the released image (#24302)
Xuan-Son Nguyen [Mon, 8 Jun 2026 14:59:57 +0000 (16:59 +0200)]
docker: install ffmpeg in the released image (#24302)

3 months agomtmd : add video input support (#24269)
Xuan-Son Nguyen [Mon, 8 Jun 2026 11:40:12 +0000 (13:40 +0200)]
mtmd : add video input support (#24269)

* wip

* ok: lazy bitmap API

* remember to free lazy text

* wip

* add mtmd_helper_video

* support video input on server (base64 input)

* add MTMD_VIDEO config

* add timestamp

* update CLI

* cli: allow auto-completion for video

* add --video arg

* fix build

* update docs

* rename as suggested

3 months agosync : ggml
Georgi Gerganov [Mon, 8 Jun 2026 09:56:07 +0000 (12:56 +0300)]
sync : ggml

3 months agoggml : bump version to 0.14.0 (ggml/1533)
Georgi Gerganov [Mon, 8 Jun 2026 09:51:59 +0000 (12:51 +0300)]
ggml : bump version to 0.14.0 (ggml/1533)

3 months agocli: fix spinner not show during prompt processing (#24283)
Xuan-Son Nguyen [Mon, 8 Jun 2026 09:11:45 +0000 (11:11 +0200)]
cli: fix spinner not show during prompt processing (#24283)

3 months agovulkan: Use cm2 decode_vector for mul_mat_id B matrix loads (#23991)
Jeff Bolz [Mon, 8 Jun 2026 08:40:37 +0000 (03:40 -0500)]
vulkan: Use cm2 decode_vector for mul_mat_id B matrix loads (#23991)

This allows vec4 loads of the B elements. Also increase BK to 64 when this is
enabled. Neither of these alone is consistently faster, but together these give
a nice speedup.

In ggml-vulkan.cpp, we need to make sure the B matrix alignment and stride are
multiples of 4.

3 months agocuda: reset cuda context after reading memory size (#23935)
Ruben Ortlam [Mon, 8 Jun 2026 08:22:44 +0000 (10:22 +0200)]
cuda: reset cuda context after reading memory size (#23935)

* cuda: reset device in get_memory function if no backend is active

* also count device and host buffers

* exclude hip and musa from counting and device reset

* use device mutex instead of atomic

* undo backend_free function move

3 months agoHIP: add gfx1152 and gfx1153 to RDNA3.5 (#24129)
Harkirat Gill [Mon, 8 Jun 2026 06:33:23 +0000 (02:33 -0400)]
HIP: add gfx1152 and gfx1153 to RDNA3.5 (#24129)

3 months agometal : fix im2col 1D case (audio models) (#24220)
Xuan-Son Nguyen [Mon, 8 Jun 2026 06:03:18 +0000 (08:03 +0200)]
metal : fix im2col 1D case (audio models) (#24220)

3 months ago[SYCL] Update compute runtime version to 26.x in docker (#24070)
Neo Zhang [Mon, 8 Jun 2026 02:35:18 +0000 (10:35 +0800)]
[SYCL] Update compute runtime version to 26.x in docker (#24070)

* update compute runtime from 25 to 26 in docker

* add comment with old driver for multiple GPUs

3 months agocommon : relax sampler name matching (#23744)
ddh0 [Sun, 7 Jun 2026 20:48:11 +0000 (15:48 -0500)]
common : relax sampler name matching (#23744)

* common : relax sampler name matching

Currently, in some cases, the alternative names for samplers (like
`top-k` and `min-p` instead of the canonical `top_k` and `min_p`) are
not always recognized by the `common_sampler_types_from_names` function
in `common/sampling.cpp`.

This PR changes the signature of this function to remove the `bool
allow_alt_names` flag, and removes all occurences of the flag from call
sites. Therefore, the function will now always match all known names.

I also changed the logic of the function to unconditionally check the
provided sampler names against both the canonical and alternative names,
and to be case-insensitive.

This fixes an issue I was seeing wherein samplers specified in the
`llama-server` UI were not recognized as valid when the alternative
names were used.

* add more alt names

* cont. fix

* cast to unsigned char for correctness

* common : unify sampler name mapping

* annotate canonical vs. alt sampler name mappings per @CISC

* Update common/sampling.cpp

Co-authored-by: Sigbjørn Skjæret <redacted>
* common : auto-generate sampler name aliases per @ngxson

* use merged map for matching

* use `.merge` instead of iterating

* nit: simplify comment

* nit: use insert everywhere, not index assignment

---------

Co-authored-by: Sigbjørn Skjæret <redacted>
3 months agoconvert : fix conversion for Mistral-Medium-3.5-128B (#24268)
David Friehs [Sun, 7 Jun 2026 19:41:39 +0000 (21:41 +0200)]
convert : fix conversion for Mistral-Medium-3.5-128B (#24268)

Mistral explicitly sets `moe` and `llama_4_scaling` to `null` in
params.json, breaking `key in dict` checks during conversion. Replace
with `dict.get(key) is not None` where this matters.

Fixes `convert-hf-to-gguf.py --mistral-format Mistral-Medium-3.5-128B`

3 months agokv-cache : avoid kv cells copies (#24277)
Georgi Gerganov [Sun, 7 Jun 2026 18:42:54 +0000 (21:42 +0300)]
kv-cache : avoid kv cells copies (#24277)

3 months agokv-cache: follow the source cache size when sharing cells (#24267)
Pascal [Sun, 7 Jun 2026 15:33:00 +0000 (17:33 +0200)]
kv-cache: follow the source cache size when sharing cells (#24267)

A fitted target context can end up smaller than the draft default, the
oversized assistant views then overflow the shared K/V tensors and trip
the ggml_view_4d size assert during graph reserve.

3 months agollama : add Gemma4 MTP (#23398)
Aman Gupta [Sun, 7 Jun 2026 12:50:54 +0000 (20:50 +0800)]
llama : add Gemma4 MTP (#23398)

3 months agospec : fix vocab compatibility check (#24256)
Sigbjørn Skjæret [Sun, 7 Jun 2026 11:43:52 +0000 (13:43 +0200)]
spec : fix vocab compatibility check (#24256)

3 months agoarg: Skip mmproj download when user supplied mmproj (#24239)
konradmb [Sun, 7 Jun 2026 09:18:44 +0000 (11:18 +0200)]
arg: Skip mmproj download when user supplied mmproj (#24239)

3 months agoconvert : fix Gemma4 with no audio encoder (#24242)
Sigbjørn Skjæret [Sun, 7 Jun 2026 06:43:05 +0000 (08:43 +0200)]
convert : fix Gemma4 with no audio encoder (#24242)

3 months agodocker : bump cuda13 to 13.3.0 (#24228)
Sigbjørn Skjæret [Sun, 7 Jun 2026 06:31:58 +0000 (08:31 +0200)]
docker : bump cuda13 to 13.3.0 (#24228)

3 months agocommon/chat : fix LFM2/LFM2.5 reasoning round-trip and <think> leak (#24234)
Tarek Dakhran [Sat, 6 Jun 2026 20:39:21 +0000 (22:39 +0200)]
common/chat : fix LFM2/LFM2.5 reasoning round-trip and <think> leak (#24234)

* common/chat : fix LFM2 reasoning round-trip and stray <think> leak
* Gate by reasoning format and whether the template supports <think>

3 months agomtmd: support "frame merge" for qwen-vl-based models (#21858)
Xuan-Son Nguyen [Sat, 6 Jun 2026 19:17:25 +0000 (21:17 +0200)]
mtmd: support "frame merge" for qwen-vl-based models (#21858)

* feat: add video support for Qwen3.5

* various clean up

* revise the design

* fix llava-uhd case

* nits

* nits 2

---------

Co-authored-by: andrewmd5 <redacted>
3 months agocompletion : remove useless statics (#24226)
Adrien Gallouët [Sat, 6 Jun 2026 10:16:16 +0000 (12:16 +0200)]
completion : remove useless statics (#24226)

Signed-off-by: Adrien Gallouët <redacted>
3 months agocompletion : fix format specifier in LOG_INF (#24213)
Adrien Gallouët [Sat, 6 Jun 2026 09:24:27 +0000 (11:24 +0200)]
completion : fix format specifier in LOG_INF (#24213)

Signed-off-by: Adrien Gallouët <redacted>
3 months agomtmd, server: add "placeholder bitmap" for counting tokens , add */input_tokens API...
Xuan-Son Nguyen [Sat, 6 Jun 2026 09:06:51 +0000 (11:06 +0200)]
mtmd, server: add "placeholder bitmap" for counting tokens , add */input_tokens API (#23913)

* mtmd: add "placeholder bitmap" for counting tokens w/o preprocessing

* fast path skip preproc for placeholder

* fix build

* correct the api

* add server endpoint + tests

* add object name

* update docs

* add proxy handling

* fix build

* fix audio input path

* use is_placeholder in process_mtmd_prompt()

* nits

* nits (2)

* docs: clarify chat/completions/input_tokens is not official

* fix merge problem

3 months agovulkan: check coopmat2 features before reporting support (#24186)
Ruben Ortlam [Sat, 6 Jun 2026 07:11:35 +0000 (09:11 +0200)]
vulkan: check coopmat2 features before reporting support (#24186)

3 months agomodel : rename local n_layer_all variable (#24209)
Sigbjørn Skjæret [Sat, 6 Jun 2026 04:07:20 +0000 (06:07 +0200)]
model : rename local n_layer_all variable (#24209)

3 months agocontext : fix off-by-one comparisons to n_gpu_layers (#24208)
Sigbjørn Skjæret [Sat, 6 Jun 2026 04:06:47 +0000 (06:06 +0200)]
context : fix off-by-one comparisons to n_gpu_layers (#24208)

3 months agoopencl: improve get_rows, cpy, concat and q6_k flat gemv (#24160)
lhez [Fri, 5 Jun 2026 20:45:25 +0000 (13:45 -0700)]
opencl: improve get_rows, cpy, concat and q6_k flat gemv (#24160)

* opencl: allow multiple workgroups for large rows

* opencl: improve small cpy

* opencl: packed concat for small input

* opencl: tweak flat q6_K gemv, increase N_DST and remap threads

3 months agocommon/chat : unify and fix LFM2/LFM2.5 tool parser (#24178)
Tarek Dakhran [Fri, 5 Jun 2026 19:31:56 +0000 (21:31 +0200)]
common/chat : unify and fix LFM2/LFM2.5 tool parser (#24178)

3 months agovulkan: add fwht support for Intel with shmem reduction (#23964)
Ruben Ortlam [Fri, 5 Jun 2026 17:44:40 +0000 (19:44 +0200)]
vulkan: add fwht support for Intel with shmem reduction (#23964)

* vulkan: add fwht support for Intel with shmem reduction

* don't use N as workgroup size

* disable subgroup shuffle on MoltenVK AMD

* disable fwht shader on Intel Windows due to driver bug

3 months agomodel: fix build failed (#24193)
Xuan-Son Nguyen [Fri, 5 Jun 2026 16:12:27 +0000 (18:12 +0200)]
model: fix build failed (#24193)

3 months agomodel, mtmd: Granite4 Vision (#23545)
Gabe Goodhart [Fri, 5 Jun 2026 15:44:59 +0000 (09:44 -0600)]
model, mtmd: Granite4 Vision (#23545)

* feat(convert): Get language model conversion working for 4.1 vision

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat(convert): Skip multimodal tensors for GraniteMoeHybrid (vision 4.0)

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Disable vocab padding for non-hybrid models that use GraniteMoeHybrid

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Plumb python-side vision projector names and mappings

There are several awkward things here:

1. Most of these are essentially identical to the audio qformer tensors. On
the c++ side, that's mapped using the prefix, so the rest of the GGUF
name needs to align, but on the python side there's no prefix notion, so
they all get duplicated.
2. There are a couple of net-new tensors for vision, in particular
PROJ_NORM. In both speech and vision, the QF_PROJ_NORM is qualified as
belonging to the qformer portion, but the GGUF name is simply proj_norm
which conflicts with the ideal name for this new PROJ_NORM that is not
qualified as part of the qformer. To get around this, I used
"proj_layernorm" as the GGUF name.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Add python side architecture name

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Add python-side plumbing for setting FEATURE_LAYERS hparam

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Add c++ side tensor naming defines

NOTE: Usage of these hasn't been updated to include prefix yet

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat(mtmd): Convert vision_feature_layer to an ordered vector

We need to preserve the ordering of these feature index values so that they
can be mapped to the sub-tensors within the stacked projectors.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat(mtmd): Add architecture label plumbing

Branch: Granite4Vision
AI-usage: full (OpenCode + qwen3.5:122b)
Signed-off-by: Gabe Goodhart <redacted>
* feat(wip): Add partial conversion for mmproj

This handles stacking the projector tensors and setting the new harams

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Add gguf_writer and constant support for new hparams and deepstack layer arr

Branch: Granite4Vision
AI-usage: draft (OpenCode + qwen3.5:122b)
Signed-off-by: Gabe Goodhart <redacted>
* feat: Full conversion for mmproj w/ tensor mappings

Branch: Granite4Vision
AI-usage: full (OpenCode + qwen3.5:122b)
Signed-off-by: Gabe Goodhart <redacted>
* fix: Add lm_head skip for mmproj for 4.0

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: De-alias text_config architecture in convert_lora_to_gguf.py

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Add --trust-remote-code arg to convert_lora_to_gguf.py

This defaults to False, but allows a user to enable it programmaticly
instead of using the interactive prompt.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: De-alias model.language_model. -> model. for lora adapters

Branch: Granite4Vision
AI-usage: full (OpenCode + qwen3.5:122b)
Signed-off-by: Gabe Goodhart <redacted>
* fix: Extend language model tensor dealiasing in adapters

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Remove unnecessary registration for GraniteSpeech in language model

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Plumb through mm prefix formatting for qformer tensors

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* refactor: Refactor vision projector tensors to use predictor ID as the block

This is cleaner than stacking them. The modeling file hard-codes
single-layer qformers, so we can punt on the multiipule multi-layer
projectors problem.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Add spatial offests array hparam conversion

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Add stub plumbing for granite vision in mtmd

Branch: Granite4Vision
AI-usage: draft (OpenCode + qwen3.5:122b)
Signed-off-by: Gabe Goodhart <redacted>
* feat: Add new hparam and tensor naming in clip-impl.h

New hparams:
- KEY_PROJ_SAMPLE_QUERY_SIDE
- KEY_PROJ_SAMPLE_WINDOW_SIDE
- KEY_PROJ_SPATIAL_OFFSETS

New tensors:
- TN_MULTI_PROJ_IMG_POS
- TN_MULTI_PROJ_QUERY
- TN_MULTI_PROJ_LAYERNORM
- TN_MULTI_PROJ_LINEAR
- TN_MULTI_PROJ_NORM

Branch: Granite4Vision
AI-usage: none

Signed-off-by: Gabe Goodhart <redacted>
* fix: Move deepstack_layer_arr to llm hparam instead of mmproj

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Remove IS_DEEPSTACK_LAYERS

This appears to have been added during Qwen3 VL
(https://github.com/ggml-org/llama.cpp/pull/16780), but it was never
actually used.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* refactor: n_deepstack_layers -> deepstack_layer_arr

The old logic hard coded a correspondence between the first N layers of the
LLM and the 1->N entries in the input embeddings. Now, that relationship is
maintained at loading time if the GGUF value is single-valued. If it is
multi-valued, it loads directly allowing for deepstack layers to be spaced
out throughout the model.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Use try/catch for single/multi valued deepstack info

The alternative would be to use get_key_or_arr, but then the single value
would be populated through the entire array and we'd need to detect that
and update it with the right correspondence.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Add deepstack injection point for granite LLM

The use of ggml_add here assumes that the elements of inp_embd will be pre-
arranged to be the full embedding length with only the vision-mask'ed
portions non-zero from the projector. This matches how Qwen3VL does it.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: add missing vision attn layernorm eps

Branch: Granite4Vision
AI-usage: full (OpenCode + Qwen 3.6-35B)
Signed-off-by: Gabe Goodhart <redacted>
* refactor: Hoist qformer tensors into qf_block and hold a vector for multi-proj

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Fix missing prefix template for TN_QF_PROJ_LINEAR

It's not strictly necessary since vision uses the blockwise version, but it
makes the loading consistent.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Add embedding scale and image grid pinpoints hparams in conversion

Also remove dead parsing for self._deepstack_layer_arr

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Add mtmd KEY_ section for hparams shared with the LLM

In this case, we need the EMBEDDING_SCALE so we can unscale the image
embeddings to compensate for applying embedding scale to the input
embeddings

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Implement c++ hparam parsing

Branch: Granite4Vision
AI-usage: draft (Claude Code)
Co-authored-by: Eli Schwartz <redacted>
Signed-off-by: Gabe Goodhart <redacted>
* fix: Flatten pinpoints in conversion

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Add missing break

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: No reason to have modality prefix for img_pos

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Add tensor loading

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix(convert): Fix confusion between proj.norm and proj.qformer.layernorm

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Use the right portion of speech for tensor loading!

Also plumb through the layernorm -> post_norm naming change

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Add logging of deepstack_layers_arr if set

I also changed the print_f output type to int32_t to avoid printing
overflow values for -1. This could cause overflows on the other side, but
I can't imagine a value for any of the current array hparams that would
trigger that.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Make sure input embeddings are cont before f_embedding_scale

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Add init and mmproj_embd cases for g4v

The n_mmproj_embd is 1+ to make space for the text embedding and all 8
projectors

Branch: Granite4Vision
AI-usage: draft (Bob)
Signed-off-by: Gabe Goodhart <redacted>
* fix: Invert (h, w) -> (w, h) pinpoints

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Reorder projectors based on llm index and skip the first injection

The multi-projector stack has a strange asymmetry based on how it's
currently implemented for qwen3vl: on the mmproj side, it's all N
projectors, but the output of the "first" (by inp_embd index) projector is
automatically consumed as if it were a standard single-projector mmproj,
so the deepstack portion needs to only contain the 1-N entries.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
Co-authored-by: Eli Schwartz <redacted>
* fix: Fix mmproj hparams in conversion

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
Co-authored-by: Eli Schwartz <redacted>
* fix: Fix ordering/logic for deepstack injection in granite

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
Co-authored-by: Eli Schwartz <redacted>
* fix: Fix preprocessing config to match what the model needs

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
Co-authored-by: Eli Schwartz <redacted>
* wip: Partial port of Eli's implementation

This is still pretty broken, but it's getting closer. It now happily
generates tokens, but the values are quite incorrect still. I suspect it's
caused by the mapping of projectors from safetensors to their respective
orders here.

Also, this implementation breaks encapsulation pretty badly in mtmd_encode.
This will need a big refactor to put the G4V-specific encoding logic
somewhere more appropriate.

Branch: Granite4Vision
AI-usage: draft (Claude Code, Bob)
Signed-off-by: Gabe Goodhart <redacted>
Co-authored-by: Eli Schwartz <redacted>
* fix: Fix the pre-scaling on the input embeddings to correctly invert the scale

We've got tokens! They still don't line up quite right, so something's a
little off, but we're getting much closer now.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: invert embedding multiplier -> base_scale at load

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Fix setting image_resize_pad after new enum introduced

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Add G4V to mmproj mapping in conversion

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Re-add padding disable for non-hybrid hybrid models

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* refactor: Simplify G4V n_tokens computation

This is slightly more efficient and flexible for when we implement the
unpad cropping. IMO, it's also clearer that it is adding the number of
image_newline tokens (embeddings) to the grid, rather than recomputing the
entire count.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Add new clip APIs for post-tile-encoding assembly

Granite 4 Vision uses llava-next style pack-and-unpad which requires
injecting the learned newline after each row of the tile grid. A row here
is a single row of the grid which is composed of (grid_x * cols_per_tile) *
(grid_y * rows_per_tile), so the result is newlines injected in between
individual tile rows, thus not something that can be handled with the
standard llava-uhd block-wise endcoding.

Branch: Granite4Vision
AI-usage: draft (Claude Code + Opus 4.7)
Signed-off-by: Gabe Goodhart <redacted>
* feat: Add model interfaces for granite 4 vision assembler

I'm on the fence about the best organization of this. These free functions
allow the per-architecture logic in clip.cpp to access the model-specific
graph building, but they still require a fair bit of model-specific logic
in clip.cpp which is not ideal.

I think a better approach may be to replicate what is done with the
graph builders themselves (and possibly even make the assembler part of the
model's existing graph builder).

Branch: Granite4Vision
AI-usage: full (Claude Code + Opus 4.7)
Signed-off-by: Gabe Goodhart <redacted>
* refactor: Remove all g4v-specific branching from mtmd.cpp in favor of clip assembler

Branch: Granite4Vision
AI-usage: full (Claude Code + Opus 4.7)
Signed-off-by: Gabe Goodhart <redacted>
* refactor(mtmd): Consolidate assembler logic into clip_assembler class family

Just like `clip_graph` is the base class for building the model-specific
encoder graphs, `clip_assembler` will be the base class for building the
model-specific assembler graphs. This allows the assembly pattern to follow
how the encoder pattern is implemented where the model-specific logic lives
in a subclass co-located with the encoder graph builder that gets
constructed by a simple factory method.

Branch: Granite4Vision
AI-usage: full (Claude Code + Opus 4.7)
Signed-off-by: Gabe Goodhart <redacted>
* style: Comment improvement

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* refactor: granite_vision -> granite4_vision

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Remove dead codepath for Qwen3VL add_vision_is_deepstack

These pieces were never used on the c++ side (removed there in an earlier
commit), so this is just cleanup that I missed before.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Oops! I did not mean to commit one of my prompt files

But now it's too far back in history to effectively rebase out, even with
interactive and --rebase-merges :(

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Add missing <algorithm> include for std::find

It seems that this was already pulled in on some platforms, but not on
others

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Fix Flake8 warnings in granite conversion module

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* refactor: Remove clip_assembler in favor of clip_image_f32.append_token

Per conversation in the PR, the clip_assembler pattern was too invasive.
This is a compromise that limits model-specific blocks to add_media where
each preprocessed tile is annotated with an injection type, after which all
the token counting logic is generic and the newline injection itself is
handled in the graph based on the value for the given tile image.

Branch: Granite4Vision
AI-usage: draft (Bob, OpenCode + Qwen 3.6 35b)
Signed-off-by: Gabe Goodhart <redacted>
* refactor(convert): Split n_deepstack_layers and deepstack_layers (array)

Branch: Granite4Vision
AI-usage: full (Bob, OpenCode + Qwen3.6-35b)
Signed-off-by: Gabe Goodhart <redacted>
* refactor(src): Handle n_deepstack_layers and deepstack_layers GGUF keys

Branch: Granite4Vision
AI-usage: draft (Bob, OpenCode + Qwen3.6-35b)
Signed-off-by: Gabe Goodhart <redacted>
* fix: Fix GGUF key for deepstack_layers_arr

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* refactor: Remove pre-scaling embeddings and skip scaling for raw embd inputs

This follows how gemma3 and gemma4 handle embedding scaling by skipping the
multiplier for raw input embeddings.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* refactor: deepstack_layers(_arr) -> deepstack_mapping(_arr)

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* refactor: Fully revert changes to n_deepstack_layers and qwen3vl*

Since we're going to keep the GGUF KVs separate, it makes sense to just
keep the hparams separate too to limit the scope of this branch. The down
side is that n_deepstack_layers and deepstack_mapping_arr are potentially
conflicting.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Revert removal of "is_deepstack_layers" GGUF KV

This KV is not used at all on the c++ side, so it's fully dead, but there's
also no need to conflate this cleanup with the addition of G4V.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Remove unnecessary ggml_cont and build_forward_expand in cbx

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* style: Clean up comments

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Tighter and more flexible code for g4v_build_block

This could be refactored to look a lot more like granite-speech, but the
overall block constructs before/after the qformer are pretty different, so
for now I'm going to leave it as is and just tighten a bit.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Remove unnecessary `unordered_set` include

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Add architecture guard on deepstack_mapping_arr printout

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Remove unnecessary AI-gen comment

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Always initialize deepstack_mapping_arr with -1 values

This was causing `test-llama-archs` to fail, likely due to trying to save
the uninitialized values, then re-loading them. It's safer to always
initialize so that other models don't forget and end up with undefined
behavior.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* style: Remove TODO about block/vs non-block tensor mapping

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* refactor: Move is_vision_feature_layer logic into clip_hparams

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* refactor: Use a bool for append_token

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* style: Remove unnecessary comment

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Remove unused get_model api

yikes!

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* refactor: Rearrange helpers for g4v to be private members and use build_attn

Branch: Granite4Vision
AI-usage: full (Bob, OpenCode + Qwen3.6-35b)
Signed-off-by: Gabe Goodhart <redacted>
* fix: Fix off-by-one in vision layer index

This was inherited from the Claude Code implementation that pushed the
negative index inversion down into the model file.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Fix norm/post_norm mixup in conversion

face. palm. :(

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* style: More descriptive tensor names

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* fix: Apply PR cleanup for new conversion changes

AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
Co-authored-by: Sigbjørn Skjæret <redacted>
* fix(convert): Remove duplicate V_ENC_EMBD_IMGNL

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* refactor: append_token -> add_newline

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* style: Comment cleanup

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
* feat: Cleaner error handling/checking

NOTE: format_string is not available in granite.cpp (and including
clip-impl.h to get it doesn't compile, so I think it violates the intended
encapsulation), so std::stringstream is the simplest answer.

Branch: Granite4Vision
AI-usage: none
Signed-off-by: Gabe Goodhart <redacted>
---------

Signed-off-by: Gabe Goodhart <redacted>
3 months agoTP: round up granularity to 128 (#24180)
Johannes Gäßler [Fri, 5 Jun 2026 15:35:13 +0000 (17:35 +0200)]
TP: round up granularity to 128 (#24180)

* TP: round up granularity to 128

* remove assert

3 months agocli: fix model params not propagated (#23893)
therealkenc [Fri, 5 Jun 2026 15:29:41 +0000 (08:29 -0700)]
cli: fix model params not propagated (#23893)

Fixes #23847

3 months agomodel : fix llama_model::n_gpu_layers() (#24188)
Georgi Gerganov [Fri, 5 Jun 2026 14:11:42 +0000 (17:11 +0300)]
model : fix llama_model::n_gpu_layers() (#24188)

3 months agoui: run npm install when package-lock.json is newer than node_modules (#24171)
Pascal [Fri, 5 Jun 2026 12:57:32 +0000 (14:57 +0200)]
ui: run npm install when package-lock.json is newer than node_modules (#24171)

3 months agoFix link to available UI settings (#24169)
Mario [Fri, 5 Jun 2026 12:39:32 +0000 (13:39 +0100)]
Fix link to available UI settings (#24169)

The current link is to a non-existent file. I had a look at the repo, spotted the file containing the UI configuration key and updated the link

3 months agoui: add ignore-scripts=true to npmrc (#24149)
Xuan-Son Nguyen [Fri, 5 Jun 2026 12:31:03 +0000 (14:31 +0200)]
ui: add ignore-scripts=true to npmrc (#24149)

3 months agodocs: Update quantization readme (#24133)
Pedro Cuenca [Fri, 5 Jun 2026 10:21:26 +0000 (12:21 +0200)]
docs: Update quantization readme (#24133)

* Update quantization readme

* install requirements

* Apply suggestions from code review

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

---------

Co-authored-by: Sigbjørn Skjæret <redacted>
3 months agominor : fix lint issues (#24165)
Georgi Gerganov [Fri, 5 Jun 2026 08:17:54 +0000 (11:17 +0300)]
minor : fix lint issues (#24165)

3 months agohparams : refactor `hparams.n_layer` (#24060)
Georgi Gerganov [Fri, 5 Jun 2026 08:09:36 +0000 (11:09 +0300)]
hparams : refactor `hparams.n_layer` (#24060)

* hparams : refactor hparams.n_layer

* cont : remove `n_layer_kv()`, use n_layer_all instead

* cont : type consistency

* pi : update SYSTEM.md

* models : fix Step3.5 MTP

* cont : remove duplicate switch cases

* cont : explicitly set `false` to extra layers for `is_swa` and `is_recr`

* cont : fix nextn layer count handling

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

Co-authored-by: Sigbjørn Skjæret <redacted>
3 months agokleidiai : dynamic chunck-based scheduling for hybrid execution (#23819)
Charles Xu [Fri, 5 Jun 2026 07:11:47 +0000 (09:11 +0200)]
kleidiai : dynamic chunck-based scheduling for hybrid execution (#23819)

3 months agoCUDA: enroll mul_mat_vec_q_moe into pdl (#24087)
Oliver Simons [Fri, 5 Jun 2026 06:37:34 +0000 (08:37 +0200)]
CUDA: enroll mul_mat_vec_q_moe into pdl (#24087)

* Enroll mul_mat_vec_q_moe into PDL, boosting MTP performance on BW

Data collected on a B4500:

Before
```
(llama.cpp) ➜  llama.cpp git:(master) ✗ python mtp-bench.py
  code_python        pred= 192 draft= 150 acc= 116 rate=0.773 tok/s=202.8
  code_cpp           pred= 192 draft= 147 acc= 117 rate=0.796 tok/s=212.8
  explain_concept    pred= 192 draft= 161 acc= 110 rate=0.683 tok/s=196.4
  summarize          pred= 192 draft= 138 acc= 122 rate=0.884 tok/s=226.6
  qa_factual         pred= 192 draft= 138 acc= 121 rate=0.877 tok/s=225.1
  translation        pred= 192 draft= 158 acc= 112 rate=0.709 tok/s=201.5
  creative_short     pred= 192 draft= 160 acc= 110 rate=0.688 tok/s=197.2
  stepwise_math      pred= 192 draft= 150 acc= 115 rate=0.767 tok/s=209.2
  long_code_review   pred= 192 draft= 148 acc= 116 rate=0.784 tok/s=208.9
```
After
```
(llama.cpp) ➜  llama.cpp git:(master) ✗ python mtp-bench.py
  code_python        pred= 192 draft= 150 acc= 116 rate=0.773 tok/s=211.9
  code_cpp           pred= 192 draft= 147 acc= 117 rate=0.796 tok/s=224.6
  explain_concept    pred= 192 draft= 161 acc= 110 rate=0.683 tok/s=207.8
  summarize          pred= 192 draft= 138 acc= 122 rate=0.884 tok/s=240.2
  qa_factual         pred= 192 draft= 138 acc= 121 rate=0.877 tok/s=238.5
  translation        pred= 192 draft= 158 acc= 112 rate=0.709 tok/s=213.4
  creative_short     pred= 192 draft= 160 acc= 110 rate=0.688 tok/s=208.8
  stepwise_math      pred= 192 draft= 150 acc= 115 rate=0.767 tok/s=221.7
  long_code_review   pred= 192 draft= 148 acc= 116 rate=0.784 tok/s=220.7
```

Server launched with:
```
➜  llama.cpp git:(osimons/enroll_mul_mat_vec_q_moe_into_PDL) ✗ ./build-x64-linux-gcc-reldbg/bin/llama-server \
    -m /mnt/share/gguf/unsloth/Qwen3.6-35B-A3B-MTP-GGUF/Qwen3.6-35B-A3B-UD-Q4_K_M.gguf -dio \
    --spec-type draft-mtp \
    --spec-draft-n-max 2 \
    -ngl all \
    -fa on \
    --host 0.0.0.0 \
    --port 8080 -np 1 --chat-template-kwargs "{\"preserve_thinking\": true}"
```

* LC to overlap with following kernels

3 months agoci : build-msys job slimming [no ci] (#24157)
Daniel Bevenius [Fri, 5 Jun 2026 05:57:36 +0000 (07:57 +0200)]
ci : build-msys job slimming [no ci] (#24157)

This PR attempts to slim down the dependencies for build-msys jobs
making the same changes that we applied in whisper.cpp to reduce the
size of the github actions cache, and should also improve the run time
due to fewer dependencies that need to be installed.

I realize this is a scheduled job but I think it would still make sense
to apply these changes.

Refs: https://github.com/ggml-org/whisper.cpp/pull/3858

3 months agosycl : port multi-column MMVQ from CUDA backend (#21845)
Mason Milburn [Fri, 5 Jun 2026 05:10:31 +0000 (01:10 -0400)]
sycl : port multi-column MMVQ from CUDA backend (#21845)

mmvq:

Port the ncols_dst optimization from ggml-cuda/mmvq.cu to SYCL.
Read weights once per dispatch instead of once per column.
Covers all standard quant types + reorder paths for Q4_0, Q8_0,
Q3_K, Q4_K, Q5_K, Q6_K. IQ types (except IQ4_XS) excluded due to
incompatible vec_dot signatures.

ggml-sycl:

The weight reorder was only bootstrapped on single-token mat-vec
(ne[1] == 1). Speculative / MTP verify issues only multi-column mat-vec,
so it never triggered the reorder and ran on the slower non-reorder
kernel. Bootstrap it on small multi-column batches (ne[1] <= 8) too.

3 months agoserver : disable on-device spec checkpoints (#24108)
Georgi Gerganov [Thu, 4 Jun 2026 16:30:59 +0000 (19:30 +0300)]
server : disable on-device spec checkpoints (#24108)

3 months agoarg: fix double mtp downloads (#24128)
Xuan-Son Nguyen [Thu, 4 Jun 2026 16:23:48 +0000 (18:23 +0200)]
arg: fix double mtp downloads (#24128)

3 months agowebui: [a11y] fix keyboard navigation issues in chat interface and sidebar (#23132)
viggy [Thu, 4 Jun 2026 15:59:00 +0000 (08:59 -0700)]
webui: [a11y] fix keyboard navigation issues in chat interface and sidebar (#23132)

* use child snippets for landing and chat message elements

* make ... icon visible in conversation history menu

* conversation history forward tab fix

* add snippet fix for fork icon in conversation history

* focus/keyboard fix for attachment x icon and scroll left/right

* formatting

* fix scroll down issue

* simply Statistics and pointer events in scrolldown

* create storybook tests and move to folder

* improve tests to actually assert on element

3 months agoMove duplicated imatrix code into single common imatrix-loader.cpp (#22445)
Bartowski [Thu, 4 Jun 2026 15:45:40 +0000 (11:45 -0400)]
Move duplicated imatrix code into single common imatrix-loader.cpp (#22445)

* Deduplicate imatrix loading code

* Add back LLAMA_TRACE, early exit on quantize missing metadata

3 months agoui: Fixed packages (#24119)
Aleksander Grygier [Thu, 4 Jun 2026 14:23:08 +0000 (16:23 +0200)]
ui: Fixed packages (#24119)

* chore(ui): pin package versions to currently installed

- Update all dependencies and devDependencies to match exactly what's in package-lock.json
- This ensures reproducible builds by locking to specific versions rather than semver ranges

* chore: Update packages

* chore: Move remaining dependencies to devDependencies

* fix: Add missing `mermaid` package

* chore: Update `cookie` package to `v1.1.1`

* chore: Formatting

* test: Update test configs

3 months agoui: added single line reasoning preview (#23601)
MagicExists [Thu, 4 Jun 2026 14:09:43 +0000 (21:09 +0700)]
ui: added single line reasoning preview (#23601)

* webui: added single line reasoning preview.

* patch: reduce width slightly for the previewing section

* refactor: move formatter constants to the right file

* feat: reimplement reasoning preview with throttled dynamic per-line rendering

* chore: fix spacing

Co-authored-by: Aleksander Grygier <redacted>
* chore: refactor to requested changes

* refactor: grouped by capture pattern instead of block-level + inline

* ui: fax interrupt state only trigger for 1st reasoning message

* chore: make reasoning preview respects showThoughtInProgress setting

* chore; newline at EOF

Co-authored-by: Aleksander Grygier <redacted>
* fix: thread rawContent so collapsible content can handle compute preview

* patch: showThoughtInProgress accidentally blocks rawContent being passed

* chore: fix lint

* chore: change smoke test

---------

Co-authored-by: Aleksander Grygier <redacted>
3 months agoreturn filter to save memory (#24125)
forforever73 [Thu, 4 Jun 2026 13:56:33 +0000 (21:56 +0800)]
return filter to save memory (#24125)

Co-authored-by: lvyichen <redacted>
3 months agoconvert: Fix Gemma 4 Unified conversion (#24118)
Pedro Cuenca [Thu, 4 Jun 2026 13:21:38 +0000 (15:21 +0200)]
convert: Fix Gemma 4 Unified conversion (#24118)

* Fix Gemma 4 Unified conversion

* Set audio hidden size to audio_embed_dim

3 months agoggml: vectorize ggml_vec_dot_q4_1_q8_1 with WASM SIMD128 (#22209)
Kartik Sirohi [Thu, 4 Jun 2026 13:12:38 +0000 (18:42 +0530)]
ggml: vectorize ggml_vec_dot_q4_1_q8_1 with WASM SIMD128 (#22209)

* ggml: vectorize ggml_vec_dot_q4_1_q8_1 with WASM SIMD128

Optimize the inner loop of ggml_vec_dot_q4_1_q8_1_generic using
WASM SIMD128 intrinsics, gated behind #ifdef __wasm_simd128__ so
non-wasm builds are completely unaffected.

Approach:
- single wasm_v128_load covers all 32 packed 4-bit weights
- nibbles unpacked via AND/SHR into two u8x16 registers
- widened to i16 before multiply (WASM SIMD has no i8*i8 instruction)
- 4x wasm_i32x4_dot_i16x8 calls accumulate all 32 element pairs
- horizontal reduce via 4x wasm_i32x4_extract_lane

Benchmark (node v25, emcc -O3 -msimd128, 64 blocks x QK8_1=32,
200k iterations):

| impl   | ns/call | speedup |
|--------|---------|---------|
| scalar |   880.7 |   1.00x |
| simd   |   257.8 |   3.42x |

Correctness verified against scalar reference across 10 random seeds
with exact output match.

* ggml: move q4_1_q8_1 WASM SIMD implementation to wasm backend

Relocate the SIMD128 implementation of ggml_vec_dot_q4_1_q8_1 to ggml/src/ggml-cpu/arch/wasm/quants.c to follow architecture-specific layout. Restore the generic implementation in ggml/src/ggml-cpu/quants.c.
Move for loop in the else block.

* ggml: use generic q4_1_q8_1 fallback in wasm backend

3 months agoserver: avoid unnecessary checkpoint restore when new tokens are present (#24110)
Yongyue Sun [Thu, 4 Jun 2026 13:09:01 +0000 (21:09 +0800)]
server: avoid unnecessary checkpoint restore when new tokens are present (#24110)

* server: avoid unnecessary checkpoint restore when new tokens are present

The pos_min_thold calculation unconditionally subtracts 1 to ensure at
least one token is evaluated for logits when no new tokens exist.
However, when the request contains new tokens beyond the cached prefix,
this -1 is overly conservative and may trigger an unnecessary checkpoint
restore.

Conditionally apply the -1 only when n_past >= task.n_tokens() (no new
tokens), avoiding redundant KV state restoration when there is actual
work to do.

* cont : add ref

---------

Co-authored-by: Georgi Gerganov <redacted>
3 months agoagents: refactor, include more guidelines (#24111)
Xuan-Son Nguyen [Thu, 4 Jun 2026 11:40:23 +0000 (13:40 +0200)]
agents: refactor, include more guidelines (#24111)

* agents: refactor, include more guidelines

* better example

* rephrase a bit

* add more examples

* nits

3 months agowebui: fix tool selector toggle/counter, key tools by stable identity (#24065)
Pascal [Thu, 4 Jun 2026 11:09:49 +0000 (13:09 +0200)]
webui: fix tool selector toggle/counter, key tools by stable identity (#24065)

* webui: fix tool selector toggle/counter, key tools by stable identity

Key the disabled set, counts and toggles by a stable per-tool key
instead of bare function name, deduped from one canonical list. Per-tool
checkboxes become presentational (single row handler, no nested button),
category checkboxes drop the tristate (n/total carries partial). One
getEnabledToolsForLLM keeps normalized MCP schemas and dedupes by name.

* ui: use SvelteSet and SvelteMap for local tool collections to satisfy svelte/prefer-svelte-reactivity

3 months agobuild : use umbrella Headers directory for XCFramework module map (#23974)
Gerard Martinez [Thu, 4 Jun 2026 10:58:25 +0000 (03:58 -0700)]
build : use umbrella Headers directory for XCFramework module map (#23974)

The XCFramework generated by build-xcframework.sh creates a module map
that manually lists public headers.

That list can fall out of sync with the framework's Headers directory.
The module map is currently missing ggml-opt.h, which is present in the
framework headers. This can cause downstream Apple builds to fail with:

    Include of non-modular header inside framework module 'llama'

Use the framework's Headers directory itself as the module map umbrella
instead of maintaining a manual header list. This makes all public headers
under the generated framework's Headers directory part of the llama module.

3 months agoserver : add header to tools/server/server-http.h (#24089)
A B [Thu, 4 Jun 2026 10:14:46 +0000 (05:14 -0500)]
server : add header to tools/server/server-http.h (#24089)

3 months agocmake: skip cvector-generator and export-lora when CPU backend is disabled (#24053)
Andrea Richiardi [Thu, 4 Jun 2026 10:13:19 +0000 (04:13 -0600)]
cmake: skip cvector-generator and export-lora when CPU backend is disabled (#24053)

3 months agofix(mtmd): handle Gemma 4 audio projector embedding size (#24091)
Andrei [Thu, 4 Jun 2026 09:51:23 +0000 (02:51 -0700)]
fix(mtmd): handle Gemma 4 audio projector embedding size (#24091)

* mtmd: handle Gemma 4 audio projector embedding size

* rm projection_dim from clip_n_mmproj_embd

---------

Co-authored-by: Xuan Son Nguyen <redacted>
3 months agoreadme : add status badges (#24104)
Georgi Gerganov [Thu, 4 Jun 2026 07:58:13 +0000 (10:58 +0300)]
readme : add status badges (#24104)

3 months agotests : refactor test-save-load-state to accept token input (#24073)
Georgi Gerganov [Thu, 4 Jun 2026 05:06:36 +0000 (08:06 +0300)]
tests : refactor test-save-load-state to accept token input (#24073)

* tests : refactor test-save-load-state to accept token input

- Default prompt is now empty; when not provided, generate n_batch
  random tokens (useful for models without a tokenizer)
- Tokenization happens once upfront; pass token vector to test functions
- generate_tokens prints token IDs instead of decoded pieces
- Use llama_model_get_vocab / llama_vocab_n_tokens API
- Upgrade log level from LOG_TRC to LOG_INF for visibility

Assisted-by: llama.cpp:local pi
* cont : use llama_tokens alias