]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/log
pkg/ggml/sources/llama.cpp
8 weeks ago[SYCL] Flash Attention with XMX engine via oneDNN (#25222)
hmscider [Wed, 15 Jul 2026 07:26:53 +0000 (03:26 -0400)]
[SYCL] Flash Attention with XMX engine via oneDNN (#25222)

* [SYCL] F16 (default) Flash Attention with XMX engine via oneDNN graph API; Qwen3.6-27b-Q8_0 prefill speed up x1.21 at p=512 and x4.26 at p=80k

* [SYCL] Address review on FA oneDNN path. Result: llama-bench---pp512; 32% increase with fa1; llama-perplexity---0.11% difference; tested model: mradermacher/Meta-Llama-3.1-8B-Instruct-Q8_0.gguf

* PR-25222 revision v2: addressed audits

* [SYCL] flash-attn oneDNN SDPA KV F16 rev 3.0: add BMG gate + multi-device sync. Narrow the scrope of this PR to Battlemage only (bmg; Xe2). Other archs (e.g., alchemist) fall back to existing FA kernel. When device_count >1, apply stream -> wait_and_throw(), validated working path for multi-gpu sync fix by @maxious.

Co-authored-by: maxious <redacted>
* updated comment on bmg gate, noted the issue

---------

Co-authored-by: scientist3 <redacted>
Co-authored-by: hmscider <redacted>
Co-authored-by: maxious <redacted>
8 weeks agoopencl: do not use `clCreateBufferWithProperties` when targeting CL 2.x (#25673)
Hongqiang Wang [Wed, 15 Jul 2026 02:53:56 +0000 (19:53 -0700)]
opencl: do not use `clCreateBufferWithProperties` when targeting CL 2.x (#25673)

8 weeks agoopencl: handle OOB write in noshuffle GEMV kernels (odd ne01) (#25640)
Hongqiang Wang [Tue, 14 Jul 2026 20:46:54 +0000 (13:46 -0700)]
opencl: handle OOB write in noshuffle GEMV kernels (odd ne01) (#25640)

8 weeks agoopencl: avoid the vec path in GEMV for unaligned row stride (#25671)
Hongqiang Wang [Tue, 14 Jul 2026 19:27:56 +0000 (12:27 -0700)]
opencl: avoid the vec path in GEMV for unaligned row stride (#25671)

The f16 GEMV kernels take a vectorized path for ne00 >= 128 that casts the row
pointers to half4 or float4. When the row stride is not aligned, the wide load
becomes misaligned. On devices that require natural alignment for vector loads,
the kernel reads garbage. This is the case Intel GPUs and the kernels produce
incorrect results there. Adreno happpens to be byte addressable and the kernels
happen to work.

8 weeks agohexagon: fix hmx-queue signal enum-narrowing problem (#25677)
Chyan [Tue, 14 Jul 2026 19:27:09 +0000 (03:27 +0800)]
hexagon: fix hmx-queue signal enum-narrowing problem (#25677)

8 weeks agoserver : refactor prompt cache state ownership (#25649)
Georgi Gerganov [Tue, 14 Jul 2026 15:25:52 +0000 (18:25 +0300)]
server : refactor prompt cache state ownership (#25649)

* server : clear checkpoints upon prompt clear

* server : move the prompt state data to the server_prompt_cache

Assisted-by: pi:llama.cpp/Qwen3.6-27B
* server : handle batched slot being cleared

8 weeks agoserver: add --cors-* options (#25655)
Xuan-Son Nguyen [Tue, 14 Jul 2026 15:23:44 +0000 (17:23 +0200)]
server: add --cors-* options (#25655)

* server: add --cors-* options

* add special "localhost" value

* add tests

* fix test

* add link to PR

8 weeks agoui: Fix spacing in tool-call request (#25634)
Bill Sideris [Tue, 14 Jul 2026 15:23:11 +0000 (18:23 +0300)]
ui: Fix spacing in tool-call request (#25634)

8 weeks agowebui: parse effective-parameter sizes (E2B, E4B) as params (#25529)
Emanuil Rusev [Tue, 14 Jul 2026 15:12:22 +0000 (18:12 +0300)]
webui: parse effective-parameter sizes (E2B, E4B) as params (#25529)

8 weeks agoopencl: fix a dp4a bug for devices where cl_khr_integer_dot_product is unavailable...
Hongqiang Wang [Tue, 14 Jul 2026 15:08:13 +0000 (08:08 -0700)]
opencl: fix a dp4a bug for devices where cl_khr_integer_dot_product is unavailable (#25639)

* opencl: do not fail backend init on devices without cl_khr_integer_dot_product

* opencl: do not call dp4 kernels when dp is unavailable

---------

Co-authored-by: Li He <redacted>
8 weeks agoui: fix mcp panel for toggle + timeout + proxy + ON/OFF state (#25631)
Pascal [Tue, 14 Jul 2026 14:50:44 +0000 (16:50 +0200)]
ui: fix mcp panel for toggle + timeout + proxy + ON/OFF state (#25631)

* ui: fix MCP panel regressions after settings rework

Restore the llama-server proxy switch in the Add New Server dialog.
The dialog never passed useProxy/onUseProxyChange to McpServerForm,
which only renders the proxy switch when the handler is provided.
The flag is now wired, persisted on addServer, and reset on close.

Bound the MCP connection handshake with the configured timeout.
handshakeTimeoutMs was set in the server config but never consumed.
The SDK timeout only covers the initialize request, not
transport.start(), which can hang forever on an unreachable host.
The whole handshake now races against the timeout and closes the
transport on expiry so the underlying fetch or socket is aborted.

Keep disabled MCP servers visible in management and chat-add UIs.
Collapsing mcpDefaultServerOverrides into mcpServers[i].enabled turned
the visibleMcpServers enabled filter into a visibility trap: toggling
a server off outside a conversation hid it from every surface with no
way to re-enable it. The filter is dropped, tools derived from health
checks still skip disabled servers, and the settings page and server
card render the real card instead of a skeleton for disabled servers
that never receive a startup health check.

* ui: clarify MCP server list semantics and add regression test

Remove the visibleMcpServers getter, a filterless alias of getServers
whose name invites the next refactor to put a filter back. Call sites
read getServers directly, the duplicate list in the chat submenu is
merged, and the misleading local variable in the sheet is renamed.

A parser unit test pins the invariant: enabled is an on/off state,
never a visibility filter, so disabled servers stay listed and
toggleable.

* ui: apply the MCP request timeout setting live to all servers

The per-server requestTimeoutSeconds field was never editable in any
UI and froze the global setting at server creation time, so changing
the timeout in Settings was a no-op for existing servers. The field
is removed from the data model and parsers, the timeout is read live
from the global setting wherever a request config is built, and the
misleading "Can be overridden per server" help text is dropped. A
parser unit test guards against reintroducing the stored field.

* ui: move the MCP request timeout into the Agentic settings section

The MCP section held a single setting. The timeout is a global tool
execution parameter like the other Agentic entries, so it moves there
and the section is removed. Same settings key, no migration needed.

* ui: remove the dead tool preview lines setting

The agenticMaxToolPreviewLines setting was read into AgenticConfig
and consumed by nothing: the agentic loop only uses enabled and
maxTurns. Its help text described a previous architecture where only
truncated previews and the final response survived the loop; tool
results and intermediate turns now persist as full DB messages, so
the setting had no effect at any value. Stale keys in localStorage
or a server ui-config are ignored.

* ui: resolve absent MCP per-chat overrides to the server enabled flag

New conversations started with every MCP server off: the settings
rework stopped seeding a per-conversation override list, assuming
the enabled check would fall back to mcpServers[i].enabled, but it
fell back to false, and the send path passed the raw stored list
with no fallback at all. The per-conversation list is now sparse by
contract, holding only explicit toggles, and every access point
resolves a missing entry to the server's own enabled flag: the
toggle display, the resolved list handed to the agentic flow, and
the enabled check itself.

8 weeks agoDeepseekV4: fix seq_rm (#25588)
Aman Gupta [Tue, 14 Jul 2026 13:45:36 +0000 (21:45 +0800)]
DeepseekV4: fix seq_rm (#25588)

* DeepseekV4: fix seq_rm

* implement proper seq_cp

* create actual update context

8 weeks agovulkan/cpu: Support f16 as SET_ROWS src. (#25432)
Jeff Bolz [Tue, 14 Jul 2026 13:26:55 +0000 (08:26 -0500)]
vulkan/cpu: Support f16 as SET_ROWS src. (#25432)

* vulkan/cpu: Support f16 as SET_ROWS src.

This adds full support for f16 SET_ROWS (equivalent to f32) to vulkan and CPU
backends, and adds more backend tests.

* Set DenormPreserve 16 when supported, to try to fix failures on Intel

* tune error threshold

* update metal supports_op

8 weeks agotokenize : align usage by using common args (#25516)
Adrien Gallouët [Tue, 14 Jul 2026 13:20:53 +0000 (15:20 +0200)]
tokenize : align usage by using common args (#25516)

Migrate the tokenize tool to common_params_parse, replacing its
hand-rolled argv parsing, Windows UTF-8 handling and file reading
with the shared common helpers.

Expose the model-sourcing flags (-m, -mu, -dr, -hf, -hff, --offline,
HF_TOKEN) to LLAMA_EXAMPLE_TOKENIZE, and register --ids, --stdin,
--no-bos, --no-parse-special and --show-count as common args.
parse_special defaults to true for TOKENIZE to preserve the old
behavior. Errors now go through LOG_ERR instead of fprintf(stderr).

Signed-off-by: Adrien Gallouët <redacted>
8 weeks agoggml : add a set of functions for checking contiguity of inner tensor dimensions...
fairydreaming [Tue, 14 Jul 2026 12:37:52 +0000 (14:37 +0200)]
ggml : add a set of functions for checking contiguity of inner tensor dimensions (#25650)

Co-authored-by: Stanisław Szymczyk <redacted>
8 weeks agotests: export-graph-ops: exit gracefully when called w/o arguments (#25619)
Christian Kastner [Tue, 14 Jul 2026 10:15:41 +0000 (12:15 +0200)]
tests: export-graph-ops: exit gracefully when called w/o arguments (#25619)

Fixes a segfault when `test-export-graph-ops` is called without any
arguments.

8 weeks agoggml: uniformize im2col dst_type for all conv ops (#23660)
JusteLeo [Tue, 14 Jul 2026 10:13:13 +0000 (12:13 +0200)]
ggml: uniformize im2col dst_type for all conv ops (#23660)

* ggml: uniformize im2col dst_type for all conv ops

* Update ggml/src/ggml.c

Co-authored-by: Georgi Gerganov <redacted>
* ggml : uniformize im2col casting logic across all conv ops

* fix : allow im2col_f16 to accept any kernel type

---------

Co-authored-by: Georgi Gerganov <redacted>
8 weeks agokleidiai : add SME2 f32 kernel (#24414)
Charles Xu [Tue, 14 Jul 2026 10:12:18 +0000 (12:12 +0200)]
kleidiai : add SME2 f32 kernel (#24414)

* kleidiai : add SME2 f32 kernel

* enable dynamic scheduling for SME2 f32 kernel

8 weeks agoui: add reasoning effort control to mobile add sheet (#25539)
Pascal [Tue, 14 Jul 2026 10:05:40 +0000 (12:05 +0200)]
ui: add reasoning effort control to mobile add sheet (#25539)

The mobile "+" sheet was missing the reasoning effort section present
in the desktop dropdown, so thinking could not be toggled on touch.

Extract the shared derivation and selection logic into useReasoningMenu
and consume it from both the desktop submenu and the mobile sheet,
keeping a single source of truth and preserving each surface idiom.

8 weeks agoconvert_hf_to_gguf: support split MTP export for HY V3 (#25641)
Thiago Padilha [Tue, 14 Jul 2026 09:43:15 +0000 (06:43 -0300)]
convert_hf_to_gguf: support split MTP export for HY V3 (#25641)

- Add a supports_mtp_export capability to ModelBase so architectures can opt
  into --mtp and --no-mtp without extending a central class allowlist.
- Enable the capability for the existing Qwen3.5/3.6 and Step3.5/3.7
  implementations, and for HY V3, whose converter already supports
  filtering the appended MTP layers.

8 weeks agoarg: Flush log before exiting after usage() (#25504)
Christian Kastner [Tue, 14 Jul 2026 09:03:22 +0000 (11:03 +0200)]
arg: Flush log before exiting after usage() (#25504)

Under certain conditions, it's possible for messages emitted via LOG()
to get lost before exit, apparently because they are emitted by another
thread. common_params_print_usage() uses printf directly, and is not
affected.

Flushing the log before exit seems to resolve this.

8 weeks agosycl: set fattn_vec_nthreads to 256 for Battlemage (#25205)
Titaniumtown [Tue, 14 Jul 2026 09:00:00 +0000 (05:00 -0400)]
sycl: set fattn_vec_nthreads to 256 for Battlemage (#25205)

Currently detects lunarlake + battlemage / xe2 and
sets the value to 256.

Keeps default at 128, Intel's ARC Alchemist's prefered value.

8 weeks agometal : add Q2_0 support (#25419)
Pasha Khosravi [Tue, 14 Jul 2026 04:52:00 +0000 (21:52 -0700)]
metal : add Q2_0 support (#25419)

8 weeks agomodel: add Hy3 (hy_v3) support with MTP speculative decoding (#25395)
Satinder Grewal [Mon, 13 Jul 2026 22:31:04 +0000 (10:31 +1200)]
model: add Hy3 (hy_v3) support with MTP speculative decoding (#25395)

* model: add Hy3 (hy_v3) architecture support

Adds Tencent Hunyuan 3 (HF architecture HYV3ForCausalLM, GGUF arch
hy_v3): a MoE decoder stack with per-head Q/K RMSNorm, a sigmoid
router with expert selection bias, an always-active ungated shared
expert, and leading dense block(s) (first_k_dense_replace).

The base implementation is ported from charlie12345's fork
(https://github.com/charlie12345/ROCmFPX, src/models/hyv3.cpp),
adapted to current mainline APIs (hparams.n_layer(), build_qkv,
build_moe_ffn with fused gate_up + scale tensors, output_s).

Note: blk.N.exp_probs_b is stored without a .bias suffix for
compatibility with existing hy_v3 GGUFs produced by that fork.

Co-Authored-By: charlie12345 <redacted>
Co-authored-by: Piotr Wilkin <redacted>
Assisted-by: Claude Fable 5
8 weeks agoCUDA: refactor MMQ kernel configuration (#24127)
Johannes Gäßler [Mon, 13 Jul 2026 16:37:57 +0000 (18:37 +0200)]
CUDA: refactor MMQ kernel configuration (#24127)

* CUDA: refactor MMQ kernel configuration

* fix Blackwell config

* remove legacy code

8 weeks agovulkan: Use native e2m1 and e4m3 conversions for mxfp4/nvfp4 (#25338)
Jeff Bolz [Mon, 13 Jul 2026 13:44:17 +0000 (08:44 -0500)]
vulkan: Use native e2m1 and e4m3 conversions for mxfp4/nvfp4 (#25338)

This uses the new VK_EXT_shader_ocp_microscaling_types extension to do fp4 type
promotions, and also uses the float8 extension to do ue4m3 promotions for
nvfp4. It's reasonable to assume that an implementation that supports fp4 will
also support fp8, so we don't need to handle all possible combinations of
support.

8 weeks agospec: add Minimax2 eagle3 support
Adrian [Mon, 13 Jul 2026 13:22:37 +0000 (06:22 -0700)]
spec: add Minimax2 eagle3 support

* Fix nullptr in minimax2 EAGLE3

* minor : add newline

---------

Co-authored-by: Georgi Gerganov <redacted>
8 weeks agoreadme : add link to maintainer PRs (#25621)
Georgi Gerganov [Mon, 13 Jul 2026 13:07:58 +0000 (16:07 +0300)]
readme : add link to maintainer PRs (#25621)

8 weeks agotests: Harmonize header use (#25616)
Christian Kastner [Mon, 13 Jul 2026 12:36:51 +0000 (14:36 +0200)]
tests: Harmonize header use (#25616)

* tests: Harmonize the use of private ggml includes

* tests: In test-backend-ops, use quoted includes

As with all other tests. This is to ensure that the build uses shipped
headers over possibly system-installed ones.

8 weeks agogguf : add tensor shape accessor (#24405)
QuintinShaw [Mon, 13 Jul 2026 10:55:15 +0000 (18:55 +0800)]
gguf : add tensor shape accessor (#24405)

* gguf : add tensor shape accessors

* gguf : return tensor shape as const int64_t *

* gguf : remove n_dims accessor, keep only gguf_get_tensor_ne

8 weeks agochat : fix reasoning leak with force-opened bare <think> templates (#24674)
Frosty40 [Mon, 13 Jul 2026 07:45:10 +0000 (02:45 -0500)]
chat : fix reasoning leak with force-opened bare <think> templates (#24674)

* chat : fix reasoning leak with force-opened bare <think> templates

The reasoning start tag inferred from prior turns can carry trailing
whitespace (e.g. <think>\n) while a force-open template prefills a bare
<think>. Trim the tag used for the prefix split so the bare prefill is
matched instead of being swallowed into content.

* chat : fix Nemotron Nano v2 regression

---------

Co-authored-by: Alde Rojas <redacted>
8 weeks agosycl: add fused top-k MoE (#25217)
Frosty40 [Mon, 13 Jul 2026 06:56:41 +0000 (01:56 -0500)]
sycl: add fused top-k MoE (#25217)

* sycl: add fused top-k MoE

* sycl: address review: GGML_SYCL_ENABLE_FUSION env, move fusion dispatch to topk-moe

* sycl: print GGML_SYCL_ENABLE_FUSION at startup like other env vars

Co-Authored-By: Claude Fable 5 <redacted>
---------

Co-authored-by: Claude Fable 5 <redacted>
8 weeks agosycl: add Q2_K to DMMV reorder path (#25064)
Todd Malsbary [Mon, 13 Jul 2026 06:53:39 +0000 (23:53 -0700)]
sycl: add Q2_K to DMMV reorder path (#25064)

Signed-off-by: Todd Malsbary <redacted>
8 weeks agoui: Remove recommended MCP Servers + improve MCP Servers Settings UI/UX (#25535)
Aleksander Grygier [Mon, 13 Jul 2026 06:45:04 +0000 (08:45 +0200)]
ui: Remove recommended MCP Servers + improve MCP Servers Settings UI/UX (#25535)

* fix: drop MCP recommendations auto-popup and silent preloads

* feat: Add consent-driven MCP recommendations inside Add New Server dialog

* refactor: Drop mcpDefaultServerOverrides for mcpServers[i].enabled

* feat: Center the empty state on the MCP settings page

* fix: keep existing MCP cards intact when adding a new server

* fix: keep MCP cards stable when a new server is added

* refactor: keep MCP server list in config insertion order

* feat: shrink the recommended-MCP cards to two tools each and fit them in one row

* feat: make recommended MCP cards click-to-fill and tighten copy

* feat: highlight the selected MCP recommendation and stop auto-focus on dialog open

* feat: derive MCP recommendation selection from the form URL

* fix: make recommendation MCP cards fully non-focusable

* fix: redirect focus from first card to the URL input on consent

* chore: Formatting

* refactor: Remove Recommended MCP Servers completely

* fix: Preserve legacy mcpDefaultServerOverrides key after merge migration for downgrade compatibility

8 weeks agoserver: honour per-request reasoning_budget_tokens in chat completions (#23116)
Bernard Ladenthin [Sun, 12 Jul 2026 23:58:44 +0000 (01:58 +0200)]
server: honour per-request reasoning_budget_tokens in chat completions (#23116)

* server: honour per-request reasoning_budget_tokens in chat completions

The reasoning-budget block in oaicompat_chat_params_parse read only the
server-level default (opt.reasoning_budget, typically -1) and the
Anthropic-style alias thinking_budget_tokens, but never the canonical
reasoning_budget_tokens field from the request body.  Because the key
was then written into llama_params before the generic body-copy loop
ran, the copy loop found the key already present and silently skipped
the caller-supplied value.  Any per-request override (e.g. 0 to
suppress thinking entirely) was therefore discarded.

Fix: read reasoning_budget_tokens from the request body first, so the
value that reaches the sampling layer is the one the caller intended.

Add a unit test in test-chat.cpp that exercises this path via
oaicompat_chat_params_parse with a Qwen3 template (which the autoparser
detects as a thinking-capable model) and asserts the returned
llama_params carries reasoning_budget_tokens == 0.

* server: honour per-request reasoning_budget_message in chat completions

The reasoning-budget block in oaicompat_chat_params_parse wrote
reasoning_budget_message into llama_params straight from the server-level
default (opt.reasoning_budget_message) and never read the canonical
reasoning_budget_message field from the request body. Because the key
was written before the generic body-copy loop ran, that loop found the
key already present and silently skipped the caller-supplied value. Any
per-request override of the message injected before the end tag when the
budget is exhausted was therefore discarded, even though server-task.cpp
already reads reasoning_budget_message from that data.

This mirrors the reasoning_budget_tokens bug fixed in the previous commit.

Fix: read reasoning_budget_message from the request body first, falling
back to the server default, so the value that reaches the sampling layer
is the one the caller intended.

While here, collapse the adjacent reasoning_budget_tokens override to a
single json_value() call; json_value already falls back to the default on
a missing/null/wrong-type key, so the explicit body.contains() guard was
redundant. No behavioral change.

Add a unit test in test-chat.cpp that exercises this path via
oaicompat_chat_params_parse with a Qwen3 template (which the autoparser
detects as a thinking-capable model) and asserts the returned
llama_params carries the per-request reasoning_budget_message rather than
the server default.

* cleanup

---------

Co-authored-by: Xuan Son Nguyen <redacted>
8 weeks agovendor : update cpp-httplib to 0.50.1 (#25576)
Alessandro de Oliveira Faria (A.K.A.CABELO) [Sun, 12 Jul 2026 23:10:03 +0000 (20:10 -0300)]
vendor : update cpp-httplib to 0.50.1 (#25576)

8 weeks agoserver: Don't consider models with --no-mmproj-auto as multimodal (#25590)
Sebastian Dröge [Sun, 12 Jul 2026 22:48:13 +0000 (01:48 +0300)]
server: Don't consider models with --no-mmproj-auto as multimodal (#25590)

If mmproj is explicitly disabled via the model preset or command-line
parameters then the model won't be able to handle image/audio inputs and
this shouldn't be declared as supported input modality on the /v1/models
endpoint.

8 weeks agomtmd: fix silent prompt truncation on embedded NUL (#25548)
Pascal [Sun, 12 Jul 2026 22:47:25 +0000 (00:47 +0200)]
mtmd: fix silent prompt truncation on embedded NUL (#25548)

* mtmd: fix silent prompt truncation on embedded NUL

mtmd_input_text carried the prompt as a bare const char* with no
length, so a NUL byte in message content cut the prompt at the
tokenizer boundary and dropped every later message plus the assistant
marker, with no log. Add an explicit text_len and thread it through,
matching llama_tokenize and the text only path.

* cleanup

---------

Co-authored-by: Xuan Son Nguyen <redacted>
8 weeks agoserver : evict checkpoints within min-step of each other (#25472)
Aldehir Rojas [Sun, 12 Jul 2026 20:59:14 +0000 (15:59 -0500)]
server : evict checkpoints within min-step of each other (#25472)

8 weeks agoserver : fix image blocks in tool_result being dropped during Anthropic OpenAI conver...
quei [Sun, 12 Jul 2026 15:43:51 +0000 (23:43 +0800)]
server : fix image blocks in tool_result being dropped during Anthropic OpenAI conversion (#22536)

* server : fix image blocks in tool_result being dropped during Anthropic→OpenAI conversion

server_chat_convert_anthropic_to_oai() silently discarded image blocks

inside Anthropic tool_result content. This broke multimodal tool outputs

(e.g. a tool that returns an image) because the model never received the

image.

When tool_result contains image blocks, convert them to OpenAI

multimodal content parts (text + image_url array). Plain-text results

remain simple strings for backwards compatibility.

* server : add test for image blocks in Anthropic tool_result conversion

8 weeks agoFix conditional to display 'LLAMA_SPLIT_MODE_TENSOR not implemented for architecture...
kdkd [Sat, 11 Jul 2026 18:03:24 +0000 (13:03 -0500)]
Fix conditional to display 'LLAMA_SPLIT_MODE_TENSOR not implemented for architecture' message (#24926)

8 weeks agogguf : reject empty metadata keys (#24917)
Rohit Mahesh [Sat, 11 Jul 2026 18:02:44 +0000 (13:02 -0500)]
gguf : reject empty metadata keys (#24917)

8 weeks agocuda: Don't crash when querying memory on device with no free memory. (#25157)
cphlipot [Sat, 11 Jul 2026 17:13:43 +0000 (10:13 -0700)]
cuda: Don't crash when querying memory on device with no free memory. (#25157)

If a Cuda device has no or limited available memory, the actual call
to cudaMemGetInfo() itself can cause a fatal crash due to a cuda out
of memory error (there is not enough memory to actually query memory)

This causes an issue because we query memory for all devices at
startup even if the user isn't trying to use the device for inference.

Fix this by making the error non-fatal and assigning zero total/free
memory to the device. This will have the downstream effect of the fit
algorithm not trying to put any layers on it, which is desired outcome
vs hard crashing.

this also prevents crashes in cuda enabled builds when user explicitly
passes '-dev none'

8 weeks agoDeepseekV4: clear cache only for seq rather than full (#25521)
Aman Gupta [Sat, 11 Jul 2026 15:35:45 +0000 (23:35 +0800)]
DeepseekV4: clear cache only for seq rather than full (#25521)

8 weeks agoserver: allow stream for exec_shell_command (#25526)
Xuan-Son Nguyen [Sat, 11 Jul 2026 10:42:55 +0000 (12:42 +0200)]
server: allow stream for exec_shell_command (#25526)

* init stream

* add stream for shell tool

* add test

* nits

* update docs

8 weeks agoserver: refactor server_stream (#25541)
Xuan-Son Nguyen [Sat, 11 Jul 2026 10:41:47 +0000 (12:41 +0200)]
server: refactor server_stream (#25541)

* server: refactoring, remove spipe from server_http_res

* wip

* remove non-thread-safe rd.stop() call

* move server_res_spipe

* nits

* improve server_stream_create_spipe

* server-stream: update dev docs for the improved API

---------

Co-authored-by: Pascal <redacted>
8 weeks agoggml : add GGML_OP_LIGHTNING_INDEXER that implements DeepSeek V3.2/V4 lightning index...
fairydreaming [Sat, 11 Jul 2026 09:39:07 +0000 (11:39 +0200)]
ggml : add GGML_OP_LIGHTNING_INDEXER that implements DeepSeek V3.2/V4 lightning indexer (#24231)

* ggml : add GGML_OP_LIGHTNING_INDEXER that implements DeepSeek V3.2/V4 lightning indexer

* ggml : remove scale parameters from lightning indexer OP, add f16 mask parameter

* tests : add GGML_OP_LIGHTNING_INDEXER tests

* ggml : bump RPC version

* chore : check if lightning indexer input tensors are not transposed

* tests : count flops instead of bandwidth in lightning indexer test

* chore : add missing const

* chore : whitespace

* ggml : renamed variables in CPU lightning indexer implementation

* ggml : fix lightning indexer mask broadcasting

* tests : tests for lightning indexer mask broadcasting

* chore : whitespace

* llama : use GGML_OP_LIGHTNING_INDEXER in DeepSeek V3.2 and DeepSeek V4 models

---------

Co-authored-by: Stanisław Szymczyk <redacted>
8 weeks agoVulkan: route large matmuls to medium tile on Adreno (#24877)
Raman Shinde [Sat, 11 Jul 2026 08:28:29 +0000 (13:58 +0530)]
Vulkan: route large matmuls to medium tile on Adreno (#24877)

* [Vulkan] Fixes llama-cli breaking over longer promts sizes

The llama-cli was breaking for longer promts sizes for q4_0 quantized networks. Causing due to insufficient shared memory.

* Removed the un-used Adreno device

* Updated matmul for small pipeline.

8 weeks agoopencl: add int8 dp4 dense and MoE prefill optimization for Adreno GPUs (#25537)
Hongqiang Wang [Sat, 11 Jul 2026 06:05:58 +0000 (23:05 -0700)]
opencl: add int8 dp4 dense and MoE prefill optimization for Adreno GPUs (#25537)

* opencl: add int8 dp4 dense and moe GEMM

* opencl: refactor

---------

Co-authored-by: Li He <redacted>
8 weeks agoserver: accept null sampling params (#25538)
Pascal [Fri, 10 Jul 2026 20:07:29 +0000 (22:07 +0200)]
server: accept null sampling params (#25538)

* server: accept null sampling params

Extend the schema validation to treat a null value as absent, so
clients can send null on nullable params (temperature, top_p, ...)
to request the server default. This matches the OpenAI spec and the
json_value convention used elsewhere.

Add has_field() to skip null in the field eval guards.

* has_field -> has_value​

8 weeks agollama : make tensor-split regex patterns static (#24710)
eduardopessin [Fri, 10 Jul 2026 17:04:12 +0000 (18:04 +0100)]
llama : make tensor-split regex patterns static (#24710)

llama_meta_device_get_split_state() recompiled 29 std::regex on every call.
In -sm tensor mode the callback runs once per tensor per token, so this
dominated the decode thread in profiling. Mark them static const so they are
compiled once. Kept inside the function (local statics are thread-safe since
C++11). Patterns are literal and stateless, so behavior is unchanged.

2 months agohexagon: improve ARGSORT performance for small tensors (#25512)
Max Krasnyansky [Fri, 10 Jul 2026 16:06:06 +0000 (09:06 -0700)]
hexagon: improve ARGSORT performance for small tensors (#25512)

* hex-sort: add efficient bitomic sort in hvx regs up to 1024 elements

* hex-sort: fix inverted vrors

* hex-sort: specialize sort functions for the common cases

* hex-sort: add tracing and local context

2 months agoarg: prevent duplicate spec model downloads (#25527)
Xuan-Son Nguyen [Fri, 10 Jul 2026 14:53:26 +0000 (16:53 +0200)]
arg: prevent duplicate spec model downloads (#25527)

2 months agomtmd: deepseek-ocr v1 multi-tile (#24717)
Xuan-Son Nguyen [Fri, 10 Jul 2026 14:05:49 +0000 (16:05 +0200)]
mtmd: deepseek-ocr v1 multi-tile (#24717)

* mtmd: deepseek-ocr v1 multi-tile dynamic resolution + unified image-preprocessors for both versions (ds-ocr v1 and v2)

* remove hacky API

* fuse row into a long image

* almost working

* adapt to new preprocessor api

* rm debugging printf

* improve

* mtmd: dsocr-tiles fixes (#25481)

* ds-ocr img-preproc fuse_row tile-drop fix for multi rows and columns images

* mtmd drop the duplicate redundant img_end

* deepseekocr graph simplify CLS broadcast cleanup

* test-deepseek-ocr: relax v1 single-view tolerance; drop trailing prompt space; make DRY opt-in and n_predict model-specific (#25486)

---------

Co-authored-by: Saba Fallah <redacted>
Co-authored-by: Saba Fallah <redacted>
2 months agofeat: pre-select models in the webui using alias (#25492)
felix [Fri, 10 Jul 2026 13:04:00 +0000 (13:04 +0000)]
feat: pre-select models in the webui using alias (#25492)

Co-authored-by: example name <redacted>
2 months agoui: use server modalities in non-router mode (#24874)
Josh Leverette [Fri, 10 Jul 2026 13:03:52 +0000 (08:03 -0500)]
ui: use server modalities in non-router mode (#24874)

2 months agoserver: remove loading.html (#25500)
Xuan-Son Nguyen [Fri, 10 Jul 2026 12:42:17 +0000 (14:42 +0200)]
server: remove loading.html (#25500)

* server: remove loading.html

* apply ui changes

2 months agosync : ggml
Georgi Gerganov [Fri, 10 Jul 2026 10:10:49 +0000 (13:10 +0300)]
sync : ggml

2 months agoggml : use ggml_vqtbl1q_u8 for 32-bit compat (whisper/0)
Georgi Gerganov [Fri, 10 Jul 2026 08:06:42 +0000 (11:06 +0300)]
ggml : use ggml_vqtbl1q_u8 for 32-bit compat (whisper/0)

2 months agoserver: improve tools, remove apply_diff (#25498)
Xuan-Son Nguyen [Fri, 10 Jul 2026 09:52:59 +0000 (11:52 +0200)]
server: improve tools, remove apply_diff (#25498)

* server: improve tools, remove apply_diff

* improve edit tool

* add tools_io abstraction

* add tools_io_basic

* fix build

* move utils to class member

* add const

2 months agocli: fix crash on wrong server base url (#25497)
marcoStocchi [Fri, 10 Jul 2026 09:52:20 +0000 (11:52 +0200)]
cli: fix crash on wrong server base url (#25497)

* llama-cli: fix crash on wrong server base url by catching exceptions and graceful exit

* review: leaner catch group: json error and standard exception

2 months agoui: prevent tooltip from flickering open and closed on hover (#25503)
Pascal [Fri, 10 Jul 2026 09:49:52 +0000 (11:49 +0200)]
ui: prevent tooltip from flickering open and closed on hover (#25503)

2 months agosync : ggml (#25517)
Georgi Gerganov [Fri, 10 Jul 2026 07:28:39 +0000 (10:28 +0300)]
sync : ggml (#25517)

* ggml : bump version to 0.16.0 (ggml/1559)

* sync : ggml

2 months agoui: export full message tree instead of active path only (#25501)
Pascal [Fri, 10 Jul 2026 07:10:45 +0000 (09:10 +0200)]
ui: export full message tree instead of active path only (#25501)

downloadConversation serialized activeMessages, the root -> currNode
path, so exporting a conversation with edited or regenerated messages
dropped every alternate version and kept only the selected one.

Fetch the whole message tree via getConversationMessages so the export
carries all message versions, matching the multi-conversation export
path which already did this. Keep the active conversation as the header
source to preserve an up-to-date currNode.

Forks are separate conversations, each with its own convId, and are
exported on their own.

2 months agollama : make all KQ masks f16 if FA is used, remove zero attention bias, remove raw_k...
fairydreaming [Fri, 10 Jul 2026 07:06:58 +0000 (09:06 +0200)]
llama : make all KQ masks f16 if FA is used, remove zero attention bias, remove raw_k repeats in DeepSeek V4 (#25370)

* llama : make all KQ masks (except the lightning indexer one) f16 if FA is used and remove zero attention bias in DeepSeek V4

* llama : remove dead code that repeats unified raw_k cache for each stream in DeepSeek V4 - no longer needed as raw_k is always non-unified.

---------

Co-authored-by: Stanisław Szymczyk <redacted>
2 months agoggml-et: Initial ET backend (#24179)
Martin Chang [Fri, 10 Jul 2026 04:38:34 +0000 (12:38 +0800)]
ggml-et: Initial ET backend  (#24179)

* ggml-et: Add performance logging

* ggml-et: Quants helpers

* ggml-et: Add MUL_MAT kernel

* ggml-et: Add ROPE kernel

* ggml-et: Add RMS_NORM kernel

* ggml-et: Add GLU kernel

* ggml-et: Add SOFT_MAX kernel

* ggml-et: Add GET_ROWS kernel

* ggml-et: Add CONT kernel

* ggml-et: Add SET_ROWS kernel

* ggml-et: Add MUL_MAT_ID kernel

* ggml-et: Build et kernels as part of ggml

* ggml-et: Embed kernels with fs fallback

* ggml-et: Build fixes

* ggml-et: Add MUL_MAT F32xF32 op

* ggml_et: Add MUL_MAT_ID op

* ggml-et: Disable offloading for debug

* ggml-et: Refactor out block ops

* ggml-et: ggml backend API changes

* ggml-et: Add RESHAPE/TRANSPOSE to supported

* ggml-et: Add CONT_F16

* ggml-et: Add supported ops doc

* gglm-et: Initial doc

* ggml-et: Remove  runtime import hacks

We can now import the runtime by a simple find_package(), so we
can cleanup the CMakeLists.txt.

* ggml-et: Fix GET_ROWS kernel

Fix lost batch dimension.

Also clean vibe-comments.

* ggml-et: Fix SET_ROWS kernel

Remove incorrect broadcasting guard.

* ggml-et: Use custom instruction for fp32->fp16

* ggml-et: Vectorize set_rows fp32->fp16

* ggml-et: Fix ROPE kernel (yarn)

ggml-et: fix et_logf

WIP: Fix ramp

WIP: fix ROPE!

* ggml-et: Better sinf

* ggml-et: Fix SOFT_MAX

Add `max_bias` and `sink` support.

* ggml-et: Fix CONT

Reorder from contiguous write to read with atomic stores.

* ggml-et: Fix elmap kernel

Remainder handlin

* ggml-et: Fix MUL_MAT MUL_MAT_ID remainders

* ggml-et: Fix ET-SOC reference

* ggml-et: Fix embed kernels scripts for old python

This allows GGML-ET to build on pre-3.8 python.

* Add sysemu support with compile time flag `-DGGML_ET_SYSEMU=ON` (#6)

* Example using ET-Soc-1 emulator configuration

Example usage:
```bash
cmake -B build -DGGML_CUDA=OFF -DGGML_ET=ON -DLLAMA_CURL=OFF -DGGML_CCACHE=ON
cmake --build build --config Release -j $(nproc)

time ./build/bin/test-backend-ops

./build/bin/llama-server \
    --model Qwen3-0.6B-Q8_0.gguf \
    --alias Qwen3-0.6B-Q8_0 \
    -fa 0 \
    --ctx-size 1024 \
    --no-warmup \
    --host 127.0.0.1 \
    --port 8080
```

* build: proper dep tracking for kernels

* support host using MOLD linker

* initial multi core GET_ROW F32 implementation

* vectorized q8 dequant

* wip: cland warning clenaups and initial logging refactor

* wip: message default message cleanup

* chore: message cleanups

* cmake cleanup

* migrate to use platform provided functions

* cmake back into subdir

* support et_print() in kernels

* fix: repair kernel building

* perf: operations run async by default

* debug: proper kernel dep tracking and error detection on kenrel launch

* fix: kernel binary dep tracking and fixing get_rows_f32 erroring

* perf: back to doing async kernel runs by default

* perf: vectorize and parallel device memset

* merge matmul work

* misc: align allocation and enable all offload

* misc: delete deadcode and respect memory limits

* fix: repair tensor debug print

* fix: loosen RMS_NORM op percision

* feat: Q4_0 GET_ROWS

* perf: FP32 MUL_MAT using TensorFMA

* update limitations

* perf: redue L1 load in compute_block_dot_product_q8_0

* feat: save kernel mapping (name to id) when profiling is enabled

* chore: memops cleanup

* perf: parallelize softmax by rows

* perf: vectorize 2nd phase of softmax

* perf: ban GET_ROWS from offloaded

* perf: vectorize and non-atomic for eltwise ops and sub support

* perf: vectorize normal rope

* perf: glu runs in parallel

* merge: manually merge saqib's work on kernel fixes

* perf: more vectorized RoPE

* perf: parallelize mul_mat_id

* perf: parallelize set_rows_f32

* perf: vectorize softmax

* feat: support kernel fusion and fuse RMS_NORM + MUL

* fix: mostly resolve test-backend-ops failure in SOFT_MAX and ROPE

* fix: bump max rope dims for gemma

* feat: GeGLU and SCALE support to fully offload Gemma

* perf: faster device memset

* feat: get_rows supporting Q4_K and avoid cont cache coherent issues

* better F32 MM

* feat: NORM for ET backend

* feat: SQR for ET backend

* feat: UNARY on ET

* feat: el_map support broadcasting for ET

* feat: SUM_ROWS in ET backend

* feat: more ops in ET backend

* feat: WKV* operators in ET backend

* perf: parallelize operators across cacheline instead of row

* perf: parallelize get_rows on cacheline

* wip: baseline FlashAttention for ET backend

* wip: enough FA and CPY f32->f16 to run llama 3.1 fully offloaded with FA on

* feat: f16 x f16 -> f32 MM using matrix engine

* wip: f16 FlashAttention using matrix engine

* wip: clean up

* feat: barriers

* perf: optimize FA_F16 in ET

* perf: vectorize pack_k_for_transpose16

* perf: prefetch next loop matrix tile

* perf: FlashAttention 2nd MM uses TensorFMA and optimizations

* cleanup: flashattention reorg

* perf: optimizations and fixes

* feat: L2SCP API and make FlashAttention support DV = 256 for gemma

* perf: parallelize norms beyond single row

* feat: GATED_DELTA_NET support and relaxed L2_NORM requirment

* feat: loosen RMS_NORM, NORM, ROPE contingous req too

* feat: repeat supports brocasting on dim 0 and loosen cont check

* feat: FILL and DIAG operator

* feat: loosen UNARY support chcek

* feat: TRI support

* feat: SOLVE_TRI support

* feat: basic SET support

* feat: loosen CONT req

* perf: fp16_to_fp32 use ASM

* feat: IMROPE support

* feat: PAD support

* feat: global barrier

* fix: view must live on the same backend as backing tensor

* feat: relax CONCAT in ET backend

* feat: dead simple CUMSUM implementation

* feat: basic SSM_CONV support

* feat: loosen CONCAT req

* feat: relax GATED_DELTA_NET and add SET support proper

* cleanup: cleanup LCM math

* feat: SWIGLU single input

* feat: SSM_SCAN support

* feat: el_map supports non aligned tensors in best effort

* feat: basic GROUP_NORM support

* feat: loosen MUL_MAT capablities slightly

* feat: loosen MUL_MAT and GET_ROWS and add IM2COL

* feat: special case for softmax 1x1x1x1

* feat: loosen SOFT_MAX req in ET backend

* fix: el_map unaligned acse fixes

* perf: optimize zero_acc_vec in flash_attn_ext_f16_me

* perf: use hart 1 for packing in MM and FA for FP16

* feat: kernel semaphore

* perf: better instruction sequence in FlashAttention

* fix: gated_delta_net with proper masking

* perf: better parallelization for GATED_DELTA_NET

* perf: parallelize SSM_CONV over nr

* perf: vectorize SSM_CONV

* perf: optimize MUL_MAT for q8

* feat: support Gemma 4

* fix: support multi-device

* feat: broader GLU support

* feat: unary ops supports view

* fix: repair fp16 MM using matrix engine

* perf: handle large N GEMV better

* perf: better q8_0 MM

* perf: better set_rows

* add back deleted files

* fix: repair after merge

* feat: POC version of uberkernel

* feat: RMS_NORM in uberkernel

* feat: add more kernels into usage

* chore: clean up uberkernel compilation

* perf: faster flash attention

* perf: opt flash attention for large seq length

* feat: loosen op bounds. clamp and mean support

* perf: vectorize ssm_scan

* perf: slightly faster FA

* perf: FlashAttention parallel MM and load

* perf: fuse Q8 MM and ADD

* feat: basic conv kernel for ET

* softMAx_test

* set_rows_f32

* get_rows and cont

* testing

* set_rows_exp

* Junk addition

* Narrowing the issue

* Update flash_attn_ext_f16_me.c

Focusing FA_ext_f16_me

* test

* Eviction updated

* Detailed cache eviction debug

* mulmat

* removeal of `BUILD_FOR_UBERKERNEL` flag

* cleaning...

* fix: balance FCC0 count

* feat: implement mul_mat and mul_mat_id for Q4_0 type

* optimize uberkernel plan upload

* add mul_mat q4 into uberkernel

* enable gating flush to just uberkernel

* update docs for ET

* update op support for ET

* et-backend: optimize Q4_0 and Q8_0 mul_mat_id row accumulations

* et-backend: specialize mul_mat_id kernels for Q4_0 and Q8_0

* et-backend: fix RoPE YaRN corr_dim formula and handle degenerate inputs

* test-backend-ops: add DeepSeek-V2-Lite RoPE test coverage

* et-backend: add Q4_0 mul_mat matrix-engine kernel using TensorFMA32

* et-backend: vectorize Q4_0 matrix-engine dequantization

* et-backend: support hybrid matrix/vector engine execution for Q4_0 mul_mat tail

* et-backend: run partial-N tiles on matrix engine for Q4_0 mul_mat

* et-backend: route Q4_0 mul_mat N < 53 to vecdot for better prefill latency

* Update uberkernel.c

* Update unary_f32.c

* gemma 4

* bisect gemma4: enable scale_f32 only

* bisect gemma4: +rms_norm_f32

* bisect gemma4: +rms_norm_mul_f32

* bisect gemma4: disable rms_norm_mul_f32 -- BREAKS OUTPUT

* bisect gemma4: +rope_f32 (skip rms_norm_mul)

* bisect gemma4: +el_map_f32

* bisect gemma4: +softmax_f32

* bisect gemma4: +get_rows_f32

* bisect gemma4: +glu_f32

* bisect gemma4: +mul_mat_f32 +mul_mat_f32_matrix_engine

* bisect gemma4: +mul_mat_f16 +mul_mat_f16_matrix_engine

* bisect gemma4: +mul_mat_Q8_0 +mul_mat_Q4_0

* bisect gemma4: +flash_attn_ext_f32 +flash_attn_ext_f16_me

* bisect gemma4: +mul_mat_id_f32

* bisect gemma4: +sum_rows_f32

* bisect gemma4: +cont_f16

* bisect gemma4: +fill_f32

* bisect gemma4: +unary_f32 (all ops re-enabled except rms_norm_mul)

* Update rms_norm_mul_f32.c

* bisect2 gemma4 n64: +scale_f32 only

* bisect2 gemma4 n64: +rms_norm_f32 +rope_f32

* bisect2 gemma4 n64: +rms_norm_mul_f32 (with ET_UBERKERNEL eviction fix)

* bisect2 gemma4 n64: +el_map +get_rows +glu +softmax (skip rms_norm_mul)

* bisect2 gemma4 n64: all ops enabled except rms_norm_mul

* bisect2 n64: test unary+cont+fill+sum_rows (no mul_mat/flash_attn)

* bisect2 n64: +mul_mat_f32 +mul_mat_f32_matrix_engine

* bisect2 n64: +mul_mat_f16 +mul_mat_f16_matrix_engine

* bisect2 n64: +mul_mat_Q8_0 +mul_mat_Q4_0

* bisect2 n64: +mul_mat_Q8_0 only (disable Q4_0)

* bisect2 n64: +mul_mat_Q4_0 only (Q8_0 breaks)

* bisect2 n64: +mul_mat_id +flash_attn_ext (skip Q8_0)

* run-3: matmul + rms_norm_mul

* run-4

* Revert "run-4"

* run5

* changes after cleanup

* cleanup before upstream

* restrict changes into ET backend

* move kernel embedding from Python to CMake

* move uberkernel gen into CMake

* apply clang format

* update CMake style

* update to match C and C++ style

* use source ggml and quant headers instead of ET's

* MROPE support

* absorb view ops into same branch as none

* fix bad rebase

* add marty1885 to codeowners

* oops

* remove redundant newline

* fix CI editor warnings

---------

Co-authored-by: Vidas <redacted>
Co-authored-by: Gianluca Guida <redacted>
Co-authored-by: Gianluca Guida <redacted>
Co-authored-by: ubergarm <redacted>
Co-authored-by: SaqibAkram-10xE <redacted>
Co-authored-by: Rehan Qasim <redacted>
2 months agollama-batch: add unit test (#25471)
Aman Gupta [Fri, 10 Jul 2026 03:04:31 +0000 (11:04 +0800)]
llama-batch: add unit test (#25471)

* llama-batch: add unit test

* fix win32 builds

* add not implemented assertion in unused methods

* remove unreachable code

2 months agoopencl: cluster-parallel decode FA for Adreno (#25473)
Hongqiang Wang [Thu, 9 Jul 2026 18:13:48 +0000 (11:13 -0700)]
opencl: cluster-parallel decode FA for Adreno (#25473)

2 months agoggml : process data in smaller chunks in CUDA ggml_top_k() and ggml_argsort() to...
fairydreaming [Thu, 9 Jul 2026 18:07:12 +0000 (20:07 +0200)]
ggml : process data in smaller chunks in CUDA ggml_top_k() and ggml_argsort() to reduce temporary buffers memory usage (#24776)

* ggml : process data in smaller chunks in CUDA ggml_top_k() implementation to reduce temporary buffers memory usage

* ggml : allocate tmp_dst only only once before the loop

* chore : whitespaces

Co-authored-by: Georgi Gerganov <redacted>
* ggml : use chunked processing in both CUDA CUB top-k and argsort implementations

* chore : separate argsort_f32_i32_cuda_bitonic() call from return statement

Co-authored-by: Johannes Gäßler <redacted>
* chore : replace ternary operators with min/max

---------

Co-authored-by: Stanisław Szymczyk <redacted>
Co-authored-by: Georgi Gerganov <redacted>
Co-authored-by: Johannes Gäßler <redacted>
2 months agocli: add --output option (#25484)
Xuan-Son Nguyen [Thu, 9 Jul 2026 17:37:39 +0000 (19:37 +0200)]
cli: add --output option (#25484)

2 months agohexagon: tiling, tracing and optimizations for unary ops (#25474)
Aparna M P [Thu, 9 Jul 2026 17:15:47 +0000 (22:45 +0530)]
hexagon: tiling, tracing and optimizations for unary ops (#25474)

* hexagon: tile wide rows in pointwise unary ops to avoid VTCM overflow

* unary: reject permuted tensors for now (not used by models)

* hex-unary: replace divs with fastdiv

* hex-unary: add vtcm layout and host computed kernel params

* hex-unary: move fastdiv init into kernel params

* hex-unary: add specialized thread functions to improve generated code

* hex-unary: tracing instrumentation for unary ops

* hex-unary: factor out hvx kernels, streamline and remove more duplication

* ggml-hexagon: fix std::min collision with Windows min macro

* hex-cmake: make lto build happy

---------

Co-authored-by: Max Krasnyansky <redacted>
2 months agoserver : move chat-template thinking probe inside the init try/catch (#24093)
Jesse LaRose [Thu, 9 Jul 2026 16:37:39 +0000 (12:37 -0400)]
server : move chat-template thinking probe inside the init try/catch (#24093)

A model whose chat template parses at init but fails parser generation
at apply time (e.g. uses {% call %}) throws std::invalid_argument from
common_chat_templates_support_enable_thinking(), which ran outside the
try/catch guarding common_chat_templates_init(). The throw was uncaught
and llama-cli aborted (SIGABRT) instead of failing to load. Moved the
probe inside that try/catch so an apply-time error fails load the same
way an init parse error does.

Signed-off-by: Jesse LaRose <redacted>
2 months agoggml : fix conv 2d dw (#25490)
Georgi Gerganov [Thu, 9 Jul 2026 14:56:32 +0000 (17:56 +0300)]
ggml : fix conv 2d dw (#25490)

2 months agometa: add hard emphasis on agents not writing descriptions/comments (#25480)
Piotr Wilkin (ilintar) [Thu, 9 Jul 2026 13:18:07 +0000 (15:18 +0200)]
meta: add hard emphasis on agents not writing descriptions/comments (#25480)

* meta: add hard emphasis on agents not writing descriptions/comments

Add a block in AGENTS.md to emphasize that agents are forbidden, under any circumstances, to post comments or pull request descriptions on behalf of the user.

* Add example

* Move examples to examples

* White space

2 months agoRefactor: Consistently use smart pointers in `test-backend-ops` (#25440)
Oliver Simons [Thu, 9 Jul 2026 13:00:17 +0000 (15:00 +0200)]
Refactor: Consistently use smart pointers in `test-backend-ops` (#25440)

* Use smart pointers in test_case::eval

This makes it consistent with other methods of `test_case`.

* Use smart pointer in show_test_coverage also

* Also use smart pointers for backends

2 months agoOnly index by compile times + always multiply/add (#25445)
Oliver Simons [Thu, 9 Jul 2026 11:23:57 +0000 (13:23 +0200)]
Only index by compile times + always multiply/add (#25445)

The first one avoids relying on compile to optimize local memory away,
and the second is cheaper than issuing control flow statements

2 months agollama-bench : init params.offline (#25476)
Adrien Gallouët [Thu, 9 Jul 2026 09:56:56 +0000 (11:56 +0200)]
llama-bench : init params.offline (#25476)

Signed-off-by: Adrien Gallouët <redacted>
2 months agometal : add CONV_2D_DW (depthwise convolution) support (#21565)
Sou-ly [Thu, 9 Jul 2026 09:29:15 +0000 (18:29 +0900)]
metal : add CONV_2D_DW (depthwise convolution) support (#21565)

* metal : add CONV_2D_DW (depthwise 2D convolution) support

* test : add perf cases for CONV_2D_DW

* metal : use 3D dispatch for CONV_2D_DW kernel

* metal : add channel-tiled CONV_2D_DW kernel for non-contiguous layouts

* metal : simplify CONV_2D_DW dispatch and trim comments

* metal : merge duplicate CONV_2D_DW pipeline getters

* tests : add F16 CONV2D_DW tests

* cpu : fix F16 kernel support for CONV_2D_DW

* tests : remove commented-out CONV_2D_DW test block

---------

Co-authored-by: Georgi Gerganov <redacted>
2 months agoggml-hip: enable -funsafe-math-optimizations (#24668)
RapidMark [Thu, 9 Jul 2026 08:02:26 +0000 (01:02 -0700)]
ggml-hip: enable -funsafe-math-optimizations (#24668)

CUDA is compiled with fast math and AMD/HIP is not — this flag lets AMD use fast math too.

We can't use -ffast-math: it implies -ffinite-math-only, which won't compile (ggml uses INFINITY for masking) and produces NaNs. -funsafe-math-optimizations gives the speedup without the NaN problems.

Co-authored-by: Mark Caldwell <redacted>
2 months agocuda: align snake fusion matcher with the other backends (#25460)
Pascal [Thu, 9 Jul 2026 08:00:06 +0000 (10:00 +0200)]
cuda: align snake fusion matcher with the other backends (#25460)

* cuda: fix snake fusion type predicate, a and inv_b are F32

The matcher required a->type == x->type while launch_snake reads both
as const float *, matching the CPU and Metal contract where a and inv_b
stay F32. F16/BF16 chains never fused and fell back to the naive path,
and a hypothetical all F16 chain would have read F16 bits as float.
Aligns the predicate and the comment with ggml-cpu.c

* cuda: reject snake fusion on non-contiguous operands

The kernel reads x[idx] and a[c] / inv_b[c] linearly, so a
non-contiguous view passing the matcher would silently read wrong data.
Mirror the contiguity guard already present in the CPU, Vulkan and
Metal matchers.

2 months agoserver : respect min-step when splitting prompt batches (#25420)
Aldehir Rojas [Thu, 9 Jul 2026 06:23:30 +0000 (01:23 -0500)]
server : respect min-step when splitting prompt batches (#25420)

2 months agohexagon: add VISION RoPE support (#25216)
Aparna M P [Thu, 9 Jul 2026 04:55:00 +0000 (10:25 +0530)]
hexagon: add VISION RoPE support (#25216)

* hexagon: add VISION RoPE support

* hexagon: support RoPE on strided half-dim views for all modes

* hex-rope: decouple src0 DMA copy size from row stride

* hex-rope: support non-contiguous dst for RoPE

* hex-rope: fix dst spad pitch for non-contiguous dst

2 months agoggml-webgpu: tune subgroup split (d_split) in flash_attn_vec (#25418)
Masashi Yoshimura [Wed, 8 Jul 2026 23:34:19 +0000 (08:34 +0900)]
ggml-webgpu: tune subgroup split (d_split) in flash_attn_vec (#25418)

2 months agoopencl: Q6_K GEMM/GEMV fix for ne01 of weights that are not multiples of 128. ...
Hongqiang Wang [Wed, 8 Jul 2026 22:52:21 +0000 (15:52 -0700)]
opencl:  Q6_K GEMM/GEMV fix for ne01 of weights that are not multiples of 128.  (#25464)

* opencl: fix garbled output for Q6_K weights with ne01 % 128 != 0 on Adreno

Observed with granite-3.1-3b-a800m-instruct, whose vocab is an odd number.

Route Q6_K dense mul_mat with ne01 % 128 != 0 off the noshuffle path:
decode (ne1==1) uses the correct flat GEMV and the matching GEMM (ne1>1)
falls back to CPU (the flat convert has no verified small-batch GEMM kernel
for these shapes). All standard hidden/FFN/vocab dims are multiples of 128
and keep the noshuffle path.

* opencl: reserve alignment slack for the SOA subbuffer carve in alloc size

set_tensor carves quantized weights into per-component subbuffers (d/q,
ql/qh/s/d, ...) whose origins are each rounded up to the device base
address alignment. When a component's size is not a multiple of the
alignment, the carve extends past ggml_nbytes(tensor) and the last
subbuffer overlaps the next tensor in the pool -- e.g. q6_K [1536, 49155]:
size_s = 49155*96 ends 32 bytes past a 128-byte boundary, so the d
subbuffer ends 96 bytes past the tensor's allocation, and whichever of the
two neighboring tensors is uploaded last silently corrupts the other (here:
the last vocab rows' block scales). This affects any quant type whose
component sizes can be misaligned, on any shape with ne01 not a multiple of
the alignment granularity; standard power-of-two dims are unaffected.

Implement get_alloc_size for the OpenCL buffer type and reserve the
worst-case carve slack (4 aligned gaps; 5 components max, q5_K) for
quantized tensors. Costs at most 512 bytes per quantized tensor at the
observed 128-byte alignment.

* opencl: use lm based q6_k mm when ne1 is not multiple of 128

---------

Co-authored-by: Li He <redacted>
2 months agovulkan: disable FA mask_opt on GCN to improve performance (#24362)
Ruben Ortlam [Wed, 8 Jul 2026 17:01:25 +0000 (19:01 +0200)]
vulkan: disable FA mask_opt on GCN to improve performance (#24362)

* vulkan: disable FA mask_opt on GCN to improve performance

* reenable mask opt over attention head size 256

2 months agoopencl: ragged-tile MoE prefill FP16 GEMM optimization (skip padded expert tiles...
Hongqiang Wang [Wed, 8 Jul 2026 16:44:55 +0000 (09:44 -0700)]
opencl: ragged-tile MoE prefill FP16 GEMM optimization (skip padded expert tiles) (#25433)

* opencl: ragged-tile MoE prefill GEMM (skip padded expert tiles)

The MoE prefill GEMM groups tokens into TILESIZE_N=32 per-expert tiles; at low
tokens-per-expert most tiles are mostly padding. When a tile's upper 16 slots
are all padding (router index 0xFFFFFFFF), skip the second dotx16_reduce8 half.
Numerically identical (skipped lanes are padding). Applied to all eight *_f32_ns
MoE GEMMs; default on, opt out with GGML_OPENCL_MOE_RAGGED_FP16=0.

* opencl: quarter-granularity ragged MoE tile-skip (8-col skip-groups)

Replace the two half-tile dotx16_reduce8 calls in the 8 *_f32_ns MoE GEMMs with
four dotx8_reduce4 (8-column) calls, skipping each empty trailing skip-group
independently. Padding is always trailing, so the kernel rounds the valid count
up to the skip granularity and skips fully-padding groups. Byte-identical to the
non-skipped path. New env GGML_OPENCL_MOE_RAGGED_GRAN={8,16,32} (quarter/half/
off); default quarter.

* opencl: move ragged moe env var in cl_init

---------

Co-authored-by: Li He <redacted>
2 months agollama-batch: fix allowed decreasing pos in a seq (#25449)
Aman Gupta [Wed, 8 Jul 2026 16:24:34 +0000 (00:24 +0800)]
llama-batch: fix allowed decreasing pos in a seq (#25449)

2 months agovulkan: for small AMD GPUs, reduce submission threshold based on CU count (#25240)
Ruben Ortlam [Wed, 8 Jul 2026 16:15:18 +0000 (18:15 +0200)]
vulkan: for small AMD GPUs, reduce submission threshold based on CU count (#25240)

2 months agohexagon: new vtcm layouts and improved pipelines for MUL_MAT, MUL_MAT_ID and FLASH_AT...
Max Krasnyansky [Wed, 8 Jul 2026 14:38:27 +0000 (07:38 -0700)]
hexagon: new vtcm layouts and improved pipelines for MUL_MAT, MUL_MAT_ID and FLASH_ATTN_EXT (#25425)

* hex-fa: refactor kernel param compute to use common layout builder

* hmx: add explicit compiler barriers to make hmx funcs more robust

* hex-vtcm: more generic vtcm layout builder for mm and flash-attn kernels

* hex-hmx: unroll inner kernels

* hex-hmx: use inline asm instead of intrinsics to avoid compiler issues

* hex-hmx: define inline asm macros and simplify code

* hex-hmx: replace leftover intrinsics

* hmx-fa: minor cleanup for hmx asm

* hmx-mm: move per-task stucts out of the kernels header

* hmx-mm: simplify core_dot_chunk

* hmx-mm: simplify inner loops that call hmx instructions

* hmx-mm: proper instrumentation for activation prep work for dma pipelined version

* hmx-mm: update a-prep loop for better prefetch

* hex-vtcm: improved vtcm layout alloc for mm to support overlapping areas

* hmx-mm: reduce the number of act fetch tows to 4 for now, going larger doesnt help here

* hex-hmx: always use hmx-queue in all modes

* hmx-mm: update comments and minor formatting

* hmx-mm: further improve synchro fallback path to prefetch the weights earlier

* hex-fa: further pipeline improvements (earlier prefetch)

* hmx-mm: cleanup dma pipelines to use dst cached in the queue

* hmx-fa: minor cleanup and opts for fa dma pipelines

* hmx-fa: optimize q-prep stage with dma and unrolling

* hmx-fa: use o_tile size from layout instead of computing it

* hmx-mm: cleanup types and size handling

* hmx-mm: replace divs with fastdiv in qprep loops

* hmx-fa: minor update/formatting to q_tile handling

* hmx-fa: cleanup the layout to avoid overpadding

* hmx-fa: simplified and improved cost mode for hmx fa solver that uses vtcm layout funcs

* hmx-queue: add support queue wakeup and make suspend async to avoid hmx-lock latency

* hex-hmx: move queue wakeup / suspend to the op-batch level

* hex-threads: add hybrid polling to workpool

* hex-mm: fix trailing spaces

2 months agocli : move to HTTP-based implementation (#24948)
Xuan-Son Nguyen [Wed, 8 Jul 2026 12:52:43 +0000 (14:52 +0200)]
cli : move to HTTP-based implementation (#24948)

* cli: move to HTTP-based implementation

* wip

* working

* remote server ok

* cli support router mode

Co-authored-by: Piotr Wilkin <redacted>
* case: router with only one model

* Apply suggestions from code review

Co-authored-by: Piotr Wilkin (ilintar) <redacted>
* remove outdated comment

* use destructor instead

* add ftype

* cli-view --> cli-ui

* pimpl

* no more json in header

* nits fixes

* also show model aliases

---------

Co-authored-by: Piotr Wilkin <redacted>
Co-authored-by: Piotr Wilkin (ilintar) <redacted>
2 months agoMake hip quality check run on all changes (#25403)
Oliver Simons [Wed, 8 Jul 2026 12:38:51 +0000 (14:38 +0200)]
Make hip quality check run on all changes (#25403)

Improvement of the CI to run on all hip-related changes as a follow-up to
https://github.com/ggml-org/llama.cpp/pull/25373
so breakage is more likely to be caught in future

2 months agocuda : add support for f16->f16 GGML_OP_SET_ROWS (#25367)
fairydreaming [Wed, 8 Jul 2026 11:24:20 +0000 (13:24 +0200)]
cuda : add support for f16->f16 GGML_OP_SET_ROWS (#25367)

2 months agollama: refactor fused ops (#24646)
Aman Gupta [Wed, 8 Jul 2026 10:18:09 +0000 (18:18 +0800)]
llama: refactor fused ops (#24646)

2 months agoserver-stream: follow-up on SSE Replay Buffer (#23226) (#25047)
Pascal [Wed, 8 Jul 2026 09:02:50 +0000 (11:02 +0200)]
server-stream: follow-up on SSE Replay Buffer (#23226) (#25047)

* server-stream : pimpl

* server-stream: prefix free functions with server_stream_

address review from ggerganov: scope the public stream functions under the
server_stream_ prefix, matching server_stream_session_manager_start/stop.

* server-stream: guard session and manager state with the mutex

address review from ggerganov: make done, completed_ts and the GC running flag plain members under their
mutex and set the condvar predicates under the lock. keep cancelled atomic for
the lock-free should_stop poll.

* server-stream: trim comments to the non-obvious

address review from ggerganov: drop comments that restate the code, keep the
concurrency, lifetime and ordering rationale. de-stale a few comments left by the
pimpl: g_stream_sessions is now internal and the /v1/streams listing is gone.

* server-stream: update dev docs for the pimpl and prefix

reflect server_stream_session_manager_start/stop and the server_stream_ prefix,
note the manager is now a file-static singleton hidden in the .cpp

* server-stream: move stream traces to debug level

keep the bring-up traces for diagnostics but off the default log: skip
drain, draining, drain ended, DELETE evict, attach_pipe, and the router
stream resume proxy.

* server-stream: align router stream resume proxy trace with upstream

the child-side bring-up traces are already SRV_TRC on master, move the
router stream resume proxy trace to the same level.

* server-stream: move stream_read_status enum to the cpp

it is only used by the hidden session and consumer types, so it belongs
with them behind the pimpl boundary, not on the public header surface.

---------

Co-authored-by: Georgi Gerganov <redacted>
2 months agollama-batch: add n_keep_tail in split_equal for recurrent models (#25278)
Aman Gupta [Wed, 8 Jul 2026 07:55:19 +0000 (15:55 +0800)]
llama-batch: add n_keep_tail in split_equal for recurrent models (#25278)

2 months agocommon: auto-create prompts-log-dir at argument parsing, so all tools using the flag...
rankaiyx [Wed, 8 Jul 2026 07:45:28 +0000 (15:45 +0800)]
common: auto-create prompts-log-dir at argument parsing, so all tools using the flag benefit (#25322)

2 months agoui: Context usage gauge and panel (#25340)
Aleksander Grygier [Wed, 8 Jul 2026 07:22:35 +0000 (09:22 +0200)]
ui: Context usage gauge and panel (#25340)

* feat: WIP

* feat: Retire ChatScreenProcessingInfo component, context, and keepStatsVisible settings

* feat: Always-on gauge with active-model /props, conversation stats and live-reactive reading/output/avg

* feat: Add /tokenize endpoint, TokenizeService, FNV-1a and JSON Schema utilities

* feat: Surface enabled-tools token count in context hover card

* refactor(tools): make toolsStore the sole owner of the OpenAI wire format

Previously mcpStore.getToolDefinitionsForLLM() owned the MCP->OpenAI
shape conversion (plus normalizeSchemaProperties). That created two
sources of truth for what gets sent to the LLM, with the
duplication-prone risk of the deduplicated enabled list (which feeds
the token-count cache) drifting from the bytes actually shipped on
chat.

Now:
- mcpStore: pure protocol state + routing. Drop getToolDefinitionsForLLM
  and the inline OpenAIToolDefinition conversion + normalizeSchemaProperties.
  Doc comment adjusted to declare wire-format ownership as belonging
  to toolsStore. Connection lifecycle, health checks, executeTool,
  and the connections/toolsIndex remain.
- toolsStore: owns the wire shape (added earlier this series). mcpEntries()
  inlines the MCP tool conversion; uses normalizeJsonSchema (the JSON
  Schema util extracted in the prior commit) so missing 'type' fields
  are inferred from defaults. mcpTools getter iterates mcpEntries() so
  the Settings UI and the deduplicated enabled list see the same
  definitions. getEnabledToolsForLLM iterates mcpEntries() instead of
  calling mcpStore, so the JSON sent to the LLM is identical to what
  toolsStore.refreshEnabledToolsTokenCount tokenizes.
- agentic: the chat-completion tools field's type was annotated as
  ReturnType<typeof mcpStore.getToolDefinitionsForLLM>, claiming the
  shape was owned by mcpStore. Switch to ReturnType<typeof
  toolsStore.getEnabledToolsForLLM>, the actual source.

Assisted-by: Claude
* feat: UI WIP

* feat: UI WIP

* feat: UI WIP

* feat: Adjust reasoning submenu layout and spacing

* feat: Adjust context usage gauge thresholds and styling

* feat: Split context usage gauge stats into current and cumulative breakdowns

* chore: Format

* refactor: Cleanup

* refactor: Cleanup

* feat: improve token gauge accuracy and display

* refactor: remove MCP recommendation gating and simplify server visibility

* feat: add token audit logging to ChatStore for debugging

* refactor: Simplify context token reading to use server promptTokens directly

* feat: Replace last-known token tracking with live server-derived stats for accurate streaming gauges

* feat: UI Improvements

* feat: Move prompt processing stats to the preceding user message

* feat: Fix context token double-counting and refine gauge layout

* refactor: remove always-show-agentic-turns setting and simplify agentic turn display

* feat: track and display cache tokens in context gauge

* feat: add diagnostic logging for chat completion requests

* refactor: improve token audit console output with fresh/cached breakdown

* fix: invalidate enabled tools token count cache on tool changes

* test: add unit tests for tools store token count invalidation

* refactor: Remove tools token counting infrastructure

* refactor: Update ChatFormContextGauge to use simplified token tracking

* refactor: Update ChatStore to remove tools token counting

* chore: Formatting

* feat: Improve UI text

* feat: simplify context usage derivation and refine gauge labels

* refactor: cleanup logs

* cleaning

* fix: UI

* refactor: Enums

* refactor: Extract context gauge logic into hook and split UI into sub-components

* refactor: Cleanup comments

---------

Co-authored-by: Pascal <redacted>
2 months agollama-eval : fix crash when answer is None in HTML dump (#25435)
Georgi Gerganov [Wed, 8 Jul 2026 07:00:03 +0000 (10:00 +0300)]
llama-eval : fix crash when answer is None in HTML dump (#25435)

dict.get("key", default) returns None (not default) when the key
exists but its value is explicitly None. This caused an AttributeError
in _escape_html() when a task errored before grading and answer was
set to None.

Assisted-by: pi:llama.cpp/Qwen3.6-27B
2 months agometal : add set_rows with src0 f16 (#25434)
fairydreaming [Wed, 8 Jul 2026 06:49:07 +0000 (08:49 +0200)]
metal : add set_rows with src0 f16 (#25434)

Co-authored-by: Georgi Gerganov <redacted>
2 months agofix: OOB reads in UGM tokenizer (precompiled_charsmap handling) (#18750)
hourhl [Wed, 8 Jul 2026 05:02:09 +0000 (13:02 +0800)]
fix: OOB reads in UGM tokenizer (precompiled_charsmap handling) (#18750)

* fix: OOB reads in UGM tokenizer (precompiled_charsmap handling)

- Validate minimum size (4 bytes) before reading xcda_blob_size
- Use strnlen with bounds check instead of unsafe strlen

Both issues allow heap-buffer-overflow from malicious T5/UGM GGUF files.

* Replace unsafe strnlen() with a bounds-checked loop that scans for \0 within the remaining array size.

* move bounds checks to load

* typo merge fix

---------

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