]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/log
pkg/ggml/sources/llama.cpp
2 months agosycl : enhance argsort to support all UT cases (#25125)
Neo Zhang [Tue, 7 Jul 2026 07:39:29 +0000 (15:39 +0800)]
sycl : enhance argsort to support all UT cases (#25125)

2 months agosycl : use sycl func to fix AOT double type issue (#25081)
Neo Zhang [Tue, 7 Jul 2026 07:38:33 +0000 (15:38 +0800)]
sycl : use sycl func to fix AOT double type issue (#25081)

2 months agosycl : rename the env vars from "disable" to "enable" (#25042)
Neo Zhang [Tue, 7 Jul 2026 07:33:51 +0000 (15:33 +0800)]
sycl : rename the env vars from "disable" to "enable" (#25042)

2 months agoggml : make ggml_time_init idempotent (#24422)
An Long [Tue, 7 Jul 2026 07:29:17 +0000 (16:29 +0900)]
ggml : make ggml_time_init idempotent (#24422)

2 months agospeculative : fix out-of-bounds read in ngram-map on prompt shrink (#23936)
o7si [Tue, 7 Jul 2026 07:25:04 +0000 (15:25 +0800)]
speculative : fix out-of-bounds read in ngram-map on prompt shrink (#23936)

* speculative : fix out-of-bounds read in ngram-map on prompt shrink

* speculative : fix ngram-map cleanup cutoff after prompt shrink

2 months agovulkan : check src0 type in GGML_OP_SET_ROWS to avoid failures due to unimplemented...
fairydreaming [Tue, 7 Jul 2026 04:56:02 +0000 (06:56 +0200)]
vulkan : check src0 type in GGML_OP_SET_ROWS to avoid failures due to unimplemented f16 support (#25351)

* vulkan : check src0 type in GGML_OP_SET_ROWS to avoid failures due to unimplemented f16 support

* chore : get rid of else

---------

Co-authored-by: Stanisław Szymczyk <redacted>
2 months agoopencl: general flash attention decode performance optimizations (#25366)
Hongqiang Wang [Tue, 7 Jul 2026 02:57:52 +0000 (19:57 -0700)]
opencl: general flash attention decode performance optimizations (#25366)

* opencl: vec flash-attention decode kernels for f16/q8_0/q4_0 KV

* opencl: improve non FA KQ mv kernels

* opencl: tweaks for multiquery FA

* opencl: some tweaks for FA q1 kernels

* opencl: FA with DK=DV=512 for gemma-4

* opencl: various fixes

* opencl: cleanup

* opencl: fix FA decode crash for DK=512 (gemma-4)

The DK=512 decode-only program does not create the f32_f16 prefill
kernel, so the compiled check in ensure_fa_variant never hit and
supports_op gave inconsistent answers for the same op. block_n is also
unset for DK=512 decode; guard it to avoid an out-of-range read at
dispatch.

* opencl: run DK=512 FA decode on CPU

DK=512 decode is bandwidth-bound and faster on the CPU than the GPU,
increasingly so with depth. Decline it in supports_op; prefill stays on the GPU.

* opencl: compile MQ_GQA=8 FA kernels in a minimal program

The full program compiled with -D MQ_GQA=8 runs the Adreno compiler out
of memory at DK>=256. Only the vec_mq kernels are used from this
program, so compile it with FA_MQ_ONLY, which excludes everything else.
Also include the program name in the compile error log.

* opencl: remove stray token in flash_attn_f32_f16.cl

A stray "." broke the f32_f16 program build.

* opencl: split f16-KV FA decode finer (FD_KV_PER_SPLIT_F16)

The 2048 default under-fills the GPU on single-query f16-KV decode;
use 512 for f16 KV to get more splits. Quantized KV keeps 2048.

---------

Co-authored-by: Li He <redacted>
2 months agocommon: Set optimal default thread count for ppc ( linux as well as AIX) (#25237)
shalinib-ibm [Mon, 6 Jul 2026 21:35:20 +0000 (03:05 +0530)]
common: Set optimal default thread count for ppc ( linux as well as AIX) (#25237)

2 months agometal: add col2im_1d op (f32/f16/bf16) (#25176)
Pascal [Mon, 6 Jul 2026 18:47:36 +0000 (20:47 +0200)]
metal: add col2im_1d op (f32/f16/bf16) (#25176)

* metal: add col2im_1d op (f32/f16/bf16)

Gather kernel mirroring the CPU/CUDA path: each output (t_out, oc)
reads its ceil(K/s0) source columns with an F32 accumulator, a single
write and no atomics. One thread per output element, 256 per
threadgroup.

* metal: check dst contiguity and type match in supports_op for COL2IM_1D

Align the GGML_OP_COL2IM_1D predicate with the CPU, CUDA, and Vulkan
backends: the kernel writes dst with linear indexing and assumes the
same type as src0, so supports_op must also require a contiguous dst
and op->type == op->src[0]->type.

* Update ggml/src/ggml-metal/ggml-metal.metal

Co-authored-by: YiChen Lv <redacted>
---------

Co-authored-by: YiChen Lv <redacted>
2 months agoCUDA: remove -sm row, refactor cuBLAS (#24216)
Johannes Gäßler [Mon, 6 Jul 2026 18:04:53 +0000 (20:04 +0200)]
CUDA: remove -sm row, refactor cuBLAS (#24216)

* CUDA: remove -sm row, refactor cuBLAS

* fix CDNA + BF16 logic

* fix bad return

* fix src0 strides, contiguous requirements

* fix GGML_CUDA_FORCE_CUBLAS

* fix casts to BF16

2 months agoserver: fix deadlock in load_models() when erasing a finished download (#25358)
Pascal [Mon, 6 Jul 2026 17:26:06 +0000 (19:26 +0200)]
server: fix deadlock in load_models() when erasing a finished download (#25358)

* server: fix deadlock in load_models() when erasing a finished download

The download monitoring thread acquires the models mutex on its way out,
but load_models() joined it from the erase loop while holding that mutex.
Join it outside the lock via threads_to_join like the other monitoring
threads.

* server: add default timeout to test requests

A hung server now fails the test after 10 minutes instead of stalling
the CI job for hours. Explicit timeouts are unchanged.

2 months agoCUDA: extend K-type validation to V-types for flash attention (#24403)
Alexey Kopytko [Mon, 6 Jul 2026 14:26:50 +0000 (23:26 +0900)]
CUDA: extend K-type validation to V-types for flash attention (#24403)

* CUDA: extend K-type validation to V-types for flash attention

* reorder

2 months agoserver: temporary skip model downloading API test (#25355)
Xuan-Son Nguyen [Mon, 6 Jul 2026 14:10:04 +0000 (16:10 +0200)]
server: temporary skip model downloading API test (#25355)

2 months agoggml-cpu: use UE4M3 LUT in ARM NVFP4 dot product (#25331)
ragz4125 [Mon, 6 Jul 2026 11:06:40 +0000 (16:36 +0530)]
ggml-cpu: use UE4M3 LUT in ARM NVFP4 dot product (#25331)

2 months agoggml-cpu: Enable tiled matmul on AIX (#25199)
shalinib-ibm [Mon, 6 Jul 2026 10:18:17 +0000 (15:48 +0530)]
ggml-cpu: Enable tiled matmul on AIX (#25199)

The matmul_tiled path uses large local stack buffers for A_pack and B_pack. On AIX this can trigger a segmentation fault, so reduce the buffer footprint there to keep the tiled path usable.

 Performance Impact:
    ~ 2x gains in PP_Speed for FP32, Q4_0 and Q8_0 models tested with llama-bench, llama-batched-bench and llama-cli.
    Models used: Llama3.2 3b Instruct F32, qwen 2.5 3b Q4_0 and Q8_0

2 months agovulkan: fix 32-bit integer overflow in CEIL_DIV (#25245)
hokanosekai [Mon, 6 Jul 2026 08:35:57 +0000 (10:35 +0200)]
vulkan: fix 32-bit integer overflow in CEIL_DIV (#25245)

2 months agoui: restore Ctrl+B sidebar toggle shortcut (#25307)
Pascal [Mon, 6 Jul 2026 08:30:07 +0000 (10:30 +0200)]
ui: restore Ctrl+B sidebar toggle shortcut (#25307)

2 months agoscripts : use HF_TOKEN when downloading UI assets (#25280)
Adrien Gallouët [Mon, 6 Jul 2026 07:53:35 +0000 (09:53 +0200)]
scripts : use HF_TOKEN when downloading UI assets (#25280)

Signed-off-by: Adrien Gallouët <redacted>
2 months agoggml-hip: enable -ffast-math for HIP builds (#23862)
a-huk [Mon, 6 Jul 2026 07:02:26 +0000 (09:02 +0200)]
ggml-hip: enable -ffast-math for HIP builds (#23862)

2 months agoui: fake 200 for proxy DELETE req (#25298)
Xuan-Son Nguyen [Mon, 6 Jul 2026 06:41:39 +0000 (08:41 +0200)]
ui: fake 200 for proxy DELETE req (#25298)

2 months agoggml-cuda: optimize conv_transpose_1d indexing (#25310)
adavyas [Mon, 6 Jul 2026 03:49:06 +0000 (20:49 -0700)]
ggml-cuda: optimize conv_transpose_1d indexing (#25310)

2 months agoFix stale tensor-split params for draft models (#24814)
Al G [Sun, 5 Jul 2026 18:39:36 +0000 (19:39 +0100)]
Fix stale tensor-split params for draft models (#24814)

* meta: fix tensor split metadata for GQA attention

* Tidied the code a bit to match existing style

* Revert "Tidied the code a bit to match existing style"

This reverts commit b90c6c6300091fe09e2350a3d4edcfcf15db8d2e.

* Reverted the ggml-backend-meta asset hack.

2 months agoabort if we see a multi buffer (#25276)
Eve [Sun, 5 Jul 2026 18:38:47 +0000 (18:38 +0000)]
abort if we see a multi buffer (#25276)

2 months agoggml : fix tensor-parallel + -ncmoe crash on MoE models (#25028)
liminfei-amd [Sun, 5 Jul 2026 17:56:11 +0000 (01:56 +0800)]
ggml : fix tensor-parallel + -ncmoe crash on MoE models (#25028)

Tensor parallelism (-sm tensor) combined with -ncmoe (CPU-offloaded MoE
experts) aborts during warm-up on MoE models with
GGML_ASSERT(ggml_is_contiguous(tensor)) in ggml-backend-meta.cpp.

The failing tensor is the MoE router output (ffn_moe_topk): it is mirrored
(GGML_BACKEND_SPLIT_AXIS_MIRRORED, replicated across backends since routing
must be identical) and happens to be a non-contiguous view.
ggml_backend_meta_buffer_{get,set}_tensor asserted contiguity before
consulting the split state, so a mirrored non-contiguous tensor tripped the
assert even though the GGML_BACKEND_SPLIT_AXIS_MIRRORED case right below
already handles it.

Move the split-state lookup above the assert and allow the mirrored case in
both get_tensor and set_tensor.

Diagnosis credit to the reporter (@nathanmp).

Fixes #24886

Signed-off-by: liminfei-amd <redacted>
2 months agoggml: Update VMM Pool allocation ggml-cuda.cu - Turing P2P access fix (fixes #24489...
Vexxie [Sun, 5 Jul 2026 17:10:09 +0000 (18:10 +0100)]
ggml: Update VMM Pool allocation ggml-cuda.cu - Turing P2P access fix (fixes #24489) (#24491)

* Update ggml-cuda.cu - Turing P2P access fix.

* Add original code as fallback behaviour when NCCL or P2P is not set/true.

* Update ggml/src/ggml-cuda/ggml-cuda.cu to add comment as per suggestion

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

Co-authored-by: Johannes Gäßler <redacted>
2 months agocuda : concat implementation for quantized types (#25303)
fairydreaming [Sun, 5 Jul 2026 15:26:24 +0000 (17:26 +0200)]
cuda : concat implementation for quantized types (#25303)

* cuda : concat implementation for quantized types

* chore : apply am17an clever suggestion to shorten the code

---------

Co-authored-by: Stanisław Szymczyk <redacted>
2 months agollama : add guard for K/V rotation input when buffer is unallocated (#25215)
liminfei-amd [Sat, 4 Jul 2026 20:37:38 +0000 (04:37 +0800)]
llama : add guard for K/V rotation input when buffer is unallocated (#25215)

llm_graph_input_attn_kv::set_input and llm_graph_input_attn_kv_iswa::set_input
call set_input_k_rot / set_input_v_rot whenever the rotation tensor pointer is
non-null, but the tensor's buffer can be unallocated (NULL) when a graph only
stores K/V without attending -- e.g. DFlash speculative decoding's KV-injection
pass. set_input_k_rot then calls ggml_backend_buffer_is_host() on a NULL buffer
and aborts with GGML_ASSERT(buffer).

Guard the four k_rot/v_rot inputs with the same "&& ->buffer" check that the
adjacent kq_mask inputs already use in these two functions. When the buffer is
unallocated there is no data to upload, so skipping is correct.

Fixes #25191

Signed-off-by: liminfei-amd <redacted>
2 months agoui: add sync blocks so display/behavior settings can be set via --ui-config-file...
Pascal [Sat, 4 Jul 2026 14:12:27 +0000 (16:12 +0200)]
ui: add sync blocks so display/behavior settings can be set via --ui-config-file (#25132)

* ui: add sync blocks so display/behavior settings can be set via --ui-config-file

* ui: remove enable thinking setting

2 months agoggml : fix broken CPU concat implementation for quantized types (#25247)
fairydreaming [Sat, 4 Jul 2026 11:37:37 +0000 (13:37 +0200)]
ggml : fix broken CPU concat implementation for quantized types (#25247)

* ggml : fix broken CPU concat implementation for quantized types

* tests : concat tests for quantized types

---------

Co-authored-by: Stanisław Szymczyk <redacted>
2 months agochat: trim messages sent to StepFun parser (fixes long reasoning loops) (#25238)
Piotr Wilkin (ilintar) [Fri, 3 Jul 2026 21:12:11 +0000 (23:12 +0200)]
chat: trim messages sent to StepFun parser (fixes long reasoning loops) (#25238)

* chat: trim messages sent to StepFun parser (fixes long reasoning loops)

* add regression test; remove duplicate template

* chat: trim StepFun content parts before rendering

The StepFun trim workaround ran on the already-rendered messages, where
typed content parts have been concatenated into a single string, so the
per-part whitespace could no longer be reached. Move the trim ahead of
rendering and apply it to content_parts text as well as the string
content and reasoning_content. Adds a content-parts regression test.

Co-Authored-By: Piotr Wilkin <redacted>
Assisted-By: Claude Fable 5 <redacted>
---------

Co-authored-by: tarruda <redacted>
2 months agoui: Improve performance when streaming (#25225)
Nick Towle [Fri, 3 Jul 2026 17:03:51 +0000 (10:03 -0700)]
ui: Improve performance when streaming (#25225)

* ui: Improve performance when streaming

* ui: build sibling info map in branching utils

Moves the node map and sibling map construction from the
.by block into buildSiblingInfoMap() in branching.ts.

The map is built once per structural change and only read
afterwards, so it does not need SvelteMap reactivity. Keeping
the construction in plain TypeScript fixes the
svelte/prefer-svelte-reactivity lint error and groups the
branching logic where it already lives.

---------

Co-authored-by: Pascal <redacted>
2 months agoui: strip path and weight extension from model id in single model mode (#25137)
Pascal [Fri, 3 Jul 2026 15:32:48 +0000 (17:32 +0200)]
ui: strip path and weight extension from model id in single model mode (#25137)

2 months agospec: support spec-draft-p-min in DFlash (#25246)
Ruixiang Wang [Fri, 3 Jul 2026 13:40:06 +0000 (15:40 +0200)]
spec: support spec-draft-p-min in DFlash (#25246)

* spec: support spec-draft-p-min in DFlash

* dflash: add n_min guard

* dflash: guard both n_min and n_max

2 months agocuda: enable topk-moe fusion for 288 experts (#25267)
Piotr Wilkin (ilintar) [Fri, 3 Jul 2026 13:36:55 +0000 (15:36 +0200)]
cuda: enable topk-moe fusion for 288 experts (#25267)

* cuda: enable topk-moe fusion for 288 experts

The topk-moe fusion only accepted power-of-2 expert counts (or the
special-cased 576), so models with 288 experts (e.g. Step-3.7-Flash)
fell back to the unfused per-layer routing chain: softmax/sigmoid,
argsort, get_rows, sum_rows, div, clamp, scale. At batch size 1 that
is ~330 extra tiny graph nodes per token.

288 is a multiple of the warp size, so the existing kernel already
handles it; this adds the missing template instantiation and accepts
288 in the eligibility check.

Measured on gfx1151 with Step-3.7-Flash IQ4_XS (llama-bench,
-b 4096 -ub 4096 -fa 1 -dio 1 -ctk q8_0 -ctv q8_0; machine idle,
before/after paired so pp4096 stays matched as a load control):

  test            | before         | after
  ----------------+----------------+----------------
  pp4096          | 460.99 ± 0.45  | 462.47 ± 0.34   (unchanged)
  tg128           |  19.10 ± 0.04  |  19.56 ± 0.03   (+2.4%)
  tg128 @ d30000  |  12.68 ± 0.04  |  12.69 ± 0.03   (unchanged)

Prompt processing is unaffected (the fusion only touches decode
routing). The decode gain is ~+2.4% at shallow context and fades with
depth: by 30k tokens each step is attention-bound over the KV cache,
so removing the fixed routing overhead is no longer visible.

Assisted-By: Claude Fable 5 <redacted>
* Update tests/test-backend-ops.cpp

Co-authored-by: Oliver Simons <redacted>
* Add comment for case 288 in topk-moe.cu

---------

Co-authored-by: Oliver Simons <redacted>
2 months agoui: align persisted config with strict server schema and enable thinking by default...
Pascal [Fri, 3 Jul 2026 11:14:52 +0000 (13:14 +0200)]
ui: align persisted config with strict server schema and enable thinking by default (#25242)

* ui: migrate legacy string-encoded booleans in persisted config

* ui: enable thinking by default

Fresh users and legacy conversations without a persisted thinking
preference now default to enabled. The per-conversation toggle and
the persisted localStorage choice keep taking precedence.

Picks up the enable_thinking default from #24876.

2 months agoserver + ui: ping silent SSE streams every 1s and kick only after 3s so slow prefill...
Pascal [Fri, 3 Jul 2026 10:47:04 +0000 (12:47 +0200)]
server + ui: ping silent SSE streams every 1s and kick only after 3s so slow prefill never drops healthy connections (#25241)

* server + ui: ping silent SSE streams every 1s and kick only after 3s so slow prefill never drops healthy connections

* server + ui: sse_ping_interval becomes a per-request body field

Address review from ngxson: the global default returns to 30 so API
clients see no behavior change, and the WebUI sends sse_ping_interval: 1
in the request body since it owns the 3s visibility-kick contract and
declares the cadence it needs. Positive values keep the existing > 0
gate, -1 keeps its disabled semantics.

* server: move sse_ping_interval into the request schema

Address review from ngxson: the field is now a typed field_num with
hard limits (-1, INT32_MAX) bound to task_params, seeded from the CLI
default alongside the other inherited parameters. The raw json_value
read and its redundant comment are gone, and schema evaluation brings
type and range validation for free.

2 months agoui: Add MCP Servers Opt-In for first time visitors (#25239)
Aleksander Grygier [Fri, 3 Jul 2026 10:16:29 +0000 (12:16 +0200)]
ui: Add MCP Servers Opt-In for first time visitors (#25239)

* feat: ui: Add predefined recommended MCP servers to settings

* feat: ui: Add MCP server recommendation dialog with custom server support

* feat: Auto-focus input fields on mount and dynamic addition

* feat: Add header validation to MCP server add and edit forms

* feat: Persist recommended MCP server opt-in selections

* test: Cover MCP configuration with tests

* chore: Format & cleanup

* feat: Centralize MCP server overrides to settings config and improve recommendation UI

* fix: Capture index before mutation to prevent focus drift

* refactor: Extract MCP_CARD_VISIBLE_TOOL_LIMIT to shared constants

* refactor: Support arbitrary authorization header schemes

* refactor: Consolidate MCP recommendations dismissal into existing storage key

* fix: Use case-insensitive comparison for MCP server ID prefix check

* refactor: Centralize MCP server visibility logic and extract recommendations hook

* refactor: Cleanup

2 months agoRemove redundant CUDA copies after gated_delta_net. (#23940)
Gaurav Garg [Fri, 3 Jul 2026 09:06:29 +0000 (14:36 +0530)]
Remove redundant CUDA copies after gated_delta_net. (#23940)

* Remove redundant CUDA copies after gated_delta_net.

Currently, GDN writes recurrent state snapshots into its output tail, then the graph immediately copies those snapshots into ssm_states_all. With MTP draft length 3, target decode uses K=4, so that becomes 4 extra ggml_cuda_cpy calls.

The change detects that gated_delta_net -> view -> cpy pattern and makes the CUDA GDN kernel write the state snapshot(s) directly into the recurrent cache, skipping the intermediate tail writes and copy kernels when safe.

* Address review comments

2 months agovendor : update cpp-httplib to 0.49.0 (#25218)
Alessandro de Oliveira Faria (A.K.A.CABELO) [Fri, 3 Jul 2026 08:26:54 +0000 (05:26 -0300)]
vendor : update cpp-httplib to 0.49.0 (#25218)

2 months agollama : add llama_model_ftype_name() (#25134)
Adrien Gallouët [Thu, 2 Jul 2026 15:26:47 +0000 (17:26 +0200)]
llama : add llama_model_ftype_name() (#25134)

* llama : add llama_model_ftype_name()

Expose the model file type (quantization) name, e.g. "Q8_0" or
"Q4_K - Medium", through a new public C API. The returned pointer is
valid for the lifetime of the model and nullptr when the model is
invalid or the file type is unknown.

Signed-off-by: Adrien Gallouët <redacted>
* Export enum

Signed-off-by: Adrien Gallouët <redacted>
* s/llama_model_ftype_name/llama_ftype_name/

Signed-off-by: Adrien Gallouët <redacted>
* Move "(guessed)" to the front in llama_ftype_name

Prepend the "(guessed)" label instead of appending it. This allows removing
the non-thread-safe static std::string, making the function allocation-free.

Signed-off-by: Adrien Gallouët <redacted>
* Add LLAMA_FTYPE_PREFIX

Signed-off-by: Adrien Gallouët <redacted>
* Dont check for model

Signed-off-by: Adrien Gallouët <redacted>
---------

Signed-off-by: Adrien Gallouët <redacted>
2 months agoopencl: allow loading precompiled binary kernels from library (#23042)
lhez [Wed, 1 Jul 2026 17:29:22 +0000 (10:29 -0700)]
opencl: allow loading precompiled binary kernels from library (#23042)

* opencl: allow loading binary kernel

* opencl: add libdl.h

* ggml-backend-dl is in ggml, which depends backend libs, thus
  ggml-opencl cannot depend on ggml-backend-dl
* add libdl.h to break cyclic dep

* opencl: allow loading bin kernel lib

* opencl: load `gemm_moe_mxfp4_f32_ns` from kernel lib if available

* opencl: load q8_0 gemm from kernel lib

* opencl: load q4_0 moe gemm from kernel lib

* opencl: load q4_1 moe gemm from kernel lib

* opencl: load q4_k moe gemm from kernel lib

* opencl: always declare `get_adreno_bin_kernel_func_t`

* opencl: rephrase message

* opencl: fix for rebase

* opencl: update doc

2 months agocommon : use hf primary split as model path (#25194)
Adrien Gallouët [Wed, 1 Jul 2026 16:33:00 +0000 (18:33 +0200)]
common : use hf primary split as model path (#25194)

Fixes #25181

2 months agohexagon: flash attention rework (optimizations, accuracy improvements, etc) (#25085)
Max Krasnyansky [Wed, 1 Jul 2026 13:59:19 +0000 (06:59 -0700)]
hexagon: flash attention rework (optimizations, accuracy improvements, etc) (#25085)

* hex-mm: fold mm quant tasks into the main matmul threads

* hex-mm: minor formatting fixes

* hex-mm: cleanup is_quant checks in dma dispatch

* hex-mm: fix dst-spad alignment

* hex-mm: move fp kernels in the hvx-mm-kernels header

* hex-mm: fuse with ADD

* hex-fa: factor out ukernels into separate headers and unify the rest

* hex-fa: move kernel-params compute into the host

* hex-fa: refactor vtcm alloc for consistency

* hex-fa: add support for FA_SELECT

* hex-fa: update tracing insrumentation to cover all functions

* hex-fa: update hvx fallback thresholds to recover t/g regressions

* hex-fa: update tracing instrumentation

* hex-fa: improved tracing with additional events

* hex-fa: optimize mask processing (fastdiv, etc)

* hex-fa: improve mask dma caching

* hmx-fa: change loop order to maximize mask cache hits

* hex-fa: remove over instrumentation

* hex-fa: breakdown QKV prep trace events

* hmx-fa: further mask proc optimizations

* hex-fa: mask broadcast is the common case, optimize for that

* hex-fa: use aligned loads where possible

* hex-fa: update loops to use uint32_t indices

* hmx-fa: fold vtcm init into q prep task

* hex-fa: update rest of the hmx funcs to use uint32_t

* hmx-fa: fold build_d into the main softmax loop

* hmx-fa: start kv dmas earlier

* hmx-fa: start mask dma a bit earlier

* hex-fa: precompute rows per task to avoid divs

* hmx-fa: specialize fa_o_store for f16 and f32

* hmx-fa: prelim support for Sinks

* hmx-fa: keep softmax accumulators in fp32

* hex-fa: add tanh_f16 and exp2_f16 and use that in FA

* hex-fa: use fp16 math in the hvx kernel

* hex-fa: avoid expensive float -> __fp16 cast for slopes and softcap

* hex-fa: replace most vec_exp_f32 with vec_exp2_f16

* hmx-fa: vectorize sinks update

* hex-fa: minor formatting

* hmx-fa: fold softcap loop into the tile load

* hmx-fa: use vectoralias to populate sinks

* hex-fa: remove redudant check

* hex-fa: fix vtcm size compute to use fp32 for accumulators

* hex-mm: fix trailing spaces

* hmx-fa: dont use -inf to init mask to avoid conversion overflows

* hex-fa: no need to explicitly guard -inf in the f16->f32 converter now

* hmx-fa: cleanup fa sinks handling

* hex-mm: fixed src2 stride handling when mm is fused with add

* hex-fa: make lto happy

2 months agoCUDA: consistent use of __restrict__ + PDL for FA (#25185)
Johannes Gäßler [Wed, 1 Jul 2026 08:55:14 +0000 (10:55 +0200)]
CUDA: consistent use of __restrict__ + PDL for FA (#25185)

2 months agoggml-cpu: add AVX2 optimization for nvfp4 dot product and use UE4M3 LUT (#23961)
ragz4125 [Wed, 1 Jul 2026 07:31:20 +0000 (13:01 +0530)]
ggml-cpu: add AVX2 optimization for nvfp4 dot product and use UE4M3 LUT (#23961)

2 months agoui Prevent tool messages from incorrectly appending to other conversations (#25177)
Aleksander Grygier [Wed, 1 Jul 2026 07:25:18 +0000 (09:25 +0200)]
ui Prevent tool messages from incorrectly appending to other conversations (#25177)

* fix: Prevent tool messages from incorrectly appending to other conversations

* ui: prevent agentic loop from poisoning another conv's currNode

* ui: make editedContent a  so background recompute does not wipe in-progress edits

---------

Co-authored-by: Pascal <redacted>
2 months agoui: Remove PWA navigate fallback to prevent caching API endpoint requests (#25174)
Aleksander Grygier [Wed, 1 Jul 2026 05:32:55 +0000 (07:32 +0200)]
ui: Remove PWA navigate fallback to prevent caching API endpoint requests (#25174)

2 months agoopencl: initial q1_0 support (#25160)
lhez [Wed, 1 Jul 2026 04:43:20 +0000 (21:43 -0700)]
opencl: initial q1_0 support (#25160)

* opencl: general q1_0 support

* opencl: add Adreno GEMM/GEMV for q1_0

2 months agocuda : prevent integer truncation and overflow errors when using KQ mask strides...
fairydreaming [Tue, 30 Jun 2026 18:47:05 +0000 (20:47 +0200)]
cuda : prevent integer truncation and overflow errors when using KQ mask strides in flash_attn_mask_to_KV_max kernel (#24945)

Co-authored-by: Stanisław Szymczyk <redacted>
2 months agomodel : register t_layer_inp for qwen3next (#25141)
Jürgen Schmied [Tue, 30 Jun 2026 15:57:14 +0000 (17:57 +0200)]
model : register t_layer_inp for qwen3next (#25141)

* Fix input assignment in layer processing loop

Fix DFLASH for qwen-coder-next

* add line break

Added tensor for attention normalization in Qwen3 model.

2 months agocommon,server: handle bracketed IPv6 literals in URL authority (#25140)
Pascal [Tue, 30 Jun 2026 14:16:44 +0000 (16:16 +0200)]
common,server: handle bracketed IPv6 literals in URL authority (#25140)

* common,server: handle bracketed IPv6 literals in URL authority

Parse the [host]:port form (RFC 3986) and bracket IPv6 hosts when
formatting a URL authority: listening log, proxy Host header, proxy
log, client rebuild. The per-request remote_addr stays bare.

* common: restore unsupported scheme throw in url parser

Address @ngxson review: keep the explicit reject in port resolution so
the block stays self-contained. Non-http(s) schemes still throw (also
gated at the top of common_http_parse_url).

2 months agoCUDA: fix get_rows_back for tables with more than 65535 rows (grid-y clamp + stride...
Matt Jallo [Tue, 30 Jun 2026 12:16:24 +0000 (05:16 -0700)]
CUDA: fix get_rows_back for tables with more than 65535 rows (grid-y clamp + stride) (#25103)

2 months agoCUDA: fix Gemma E4B MTP FlashAttention (#25148)
Johannes Gäßler [Tue, 30 Jun 2026 12:06:54 +0000 (14:06 +0200)]
CUDA: fix Gemma E4B MTP FlashAttention (#25148)

* CUDA: fix Gemma E4B MTP FlashAttention

* remove unused template declaration

2 months agovulkan: roll bk loop in matmul for asahi linux (#24663)
Kevin Liu [Tue, 30 Jun 2026 10:27:38 +0000 (06:27 -0400)]
vulkan: roll bk loop in matmul for asahi linux (#24663)

* vulkan: roll bk loop in matmul for asahi linux

* vulkan: fix inline comment

* vulkan: revert BK-loop unroll change

* vulkan: edit spirv directly for asahi roll bk loop

* vulkan: remove trailing whitespace at the end of comments

2 months agoHIP: use hipBLAS for dense prefill on gfx900, keep MMQ for MoE (#24588)
zduford [Tue, 30 Jun 2026 09:51:38 +0000 (05:51 -0400)]
HIP: use hipBLAS for dense prefill on gfx900, keep MMQ for MoE (#24588)

* HIP: keep MMQ for gfx900 MoE and Q8_0, use hipBLAS for dense K-quants

Assisted-by: GitHub Copilot CLI
* HIP: tighten conditional block to be explicitly for gfx900

* HIP: Further simplified gfx900 conditional block

* removed unnecessary comment

2 months agoggml-webgpu: add support for NVFP4 (#25143)
Masashi Yoshimura [Tue, 30 Jun 2026 08:20:04 +0000 (17:20 +0900)]
ggml-webgpu: add support for NVFP4 (#25143)

2 months agoRevert "sched : reintroduce less synchronizations during split compute (#20793)"...
Oliver Simons [Tue, 30 Jun 2026 00:41:45 +0000 (02:41 +0200)]
Revert "sched : reintroduce less synchronizations during split compute (#20793)" (#25138)

2 months agocommon : dedup preset and cached model entries in /v1/models (#25131)
Adrien Gallouët [Mon, 29 Jun 2026 15:37:23 +0000 (17:37 +0200)]
common : dedup preset and cached model entries in /v1/models (#25131)

Signed-off-by: Adrien Gallouët <redacted>
2 months agovulkan: use flops instead of weight tensor size for submission heuristic (#25005)
Ruben Ortlam [Mon, 29 Jun 2026 13:24:44 +0000 (15:24 +0200)]
vulkan: use flops instead of weight tensor size for submission heuristic (#25005)

* vulkan: extract flops calculation into function

* use flops instead of matmul src0 tensor size for submission threshold

* use unsigned ints

2 months agoDeepSeek V4 (#24162)
Aman Gupta [Mon, 29 Jun 2026 08:58:51 +0000 (16:58 +0800)]
DeepSeek V4  (#24162)

* convert: add dsv4 conversion

* add basic setup

* add llm_graph_input_dsv4

* add save-load state

* add sinkhorn eps - correction by @fairydreaming

* add rope fix

* cleanup dead code

* fix bugs

* support pro model: added by @fairydreaming

* remove redundant V cache

* Chat template

* remove debugging leftovers

* Add mechanism for inlining templates based on architecture

* s/deepseek-v4-flash/deepseek4/g

* s/deepseek-v4-flash/deepseek4/g continued

* enable graph reuse

* enable FA

* fix test llama archs

* rename

* compatibility with antirez ds4 GGUFs

* simplified set_gguf_parameters() by calling super class method, replaced moe.score_func with expert_gating_func.

* reserve worst-case kv-cache

* revert max split inputs

* address review comments

* add padding to enable FA

* pad only the final value of plan.n_kv to 256

* remove built-in cpp chat template

* cont: remove cpp built-in template

* rm outdated test

* replace ggml_view_3d() with ggml_reshape_3d()

Co-authored-by: Georgi Gerganov <redacted>
* only support n_seq=1 for now

* remove unused var

* cont: remove unused var

* use scale bias

* use correct ptr for can_reuse

* remove gen-chat-inline-templates.py

* simplify graph reuse

* cont: cleanup

* remove unused inputs

* enable partial checkpointing

* add correct shape for kq_mask + set llama_model_n_swa to 0 for dsv4

* precompute source_idx + add comment about dummy write

* support multi-seq

* remove restored_trim_pos

* use split_equal when possible

* fix indent

* address review comments

* use LLM_KV

* fix ci

---------

Co-authored-by: Piotr Wilkin <redacted>
Co-authored-by: Stanisław Szymczyk <redacted>
Co-authored-by: Xuan Son Nguyen <redacted>
Co-authored-by: fairydreaming <redacted>
Co-authored-by: Georgi Gerganov <redacted>
2 months agotools/ui: restore Tailwind scanning in ignored worktrees (#24879)
seryogakovalyov [Mon, 29 Jun 2026 08:55:52 +0000 (11:55 +0300)]
tools/ui: restore Tailwind scanning in ignored worktrees (#24879)

2 months agocommon : remove unused regex-partial (#25118)
o7si [Mon, 29 Jun 2026 06:48:39 +0000 (14:48 +0800)]
common : remove unused regex-partial (#25118)

2 months agojinja, chat: add --reasoning-preserve flag (#25105)
Xuan-Son Nguyen [Sun, 28 Jun 2026 21:33:51 +0000 (23:33 +0200)]
jinja, chat: add --reasoning-preserve flag (#25105)

* jinja, chat: add --reasoning-preserve flag

* correct help message

2 months agoRevert "ui: fix accessibility for hover-gated interactive elements assisted by claude...
Aleksander Grygier [Sun, 28 Jun 2026 19:30:03 +0000 (21:30 +0200)]
Revert "ui: fix accessibility for hover-gated interactive elements assisted by claude(in debugging and tests) (#24727)" (#25098)

2 months agoui: fix stop and reasoning skip in single-model mode (#25084)
Pascal [Sun, 28 Jun 2026 19:06:43 +0000 (21:06 +0200)]
ui: fix stop and reasoning skip in single-model mode (#25084)

2 months agodflash: refactor draft model conversion (#25110)
Ruixiang Wang [Sun, 28 Jun 2026 18:31:48 +0000 (20:31 +0200)]
dflash: refactor draft model conversion (#25110)

* dflash: refactor draft model conversion

* apply fix for eagle3 convert

2 months agochat : implement minicpm5 parser (#24889)
Aldehir Rojas [Sun, 28 Jun 2026 14:53:32 +0000 (09:53 -0500)]
chat : implement minicpm5 parser (#24889)

* Add minicpm5 tool call parser

* Refactor MiniCPM5 PEG parser per review feedback

* Fix jinja min/max API to match Jinja2

* modify by review

* MiniCPM5: use autoparser for XML tool calls and fix grammar preserved-token triggers

* MiniCPM5: fix streaming tool-arg placeholder and remove alt XML markers

* skip min/max attribute tests in -py mode

* test-jinja: use real expected output for min/max attribute tests

* MiniCPM5: revert shared mapper and history fallbacks per review

Drop streaming tool-arg placeholder workarounds from the generic PEG
mapper and restore strict tool-call argument JSON parsing so MiniCPM5
support stays limited to autoparser/diff-analyzer changes.

* chat : refactor minicpm5 back to dedicated parser

* cont : simplify grammar

* cont : refactor

* cont : fixes

* cont : rename template to openbmb-MiniCPM5-1B.jinja

* cont : add message delimiters

* cont : fix tests

---------

Co-authored-by: zhangtao <redacted>
Co-authored-by: 张涛 <>
2 months agojinja: add --dump-prog for debugging (#25086)
Xuan-Son Nguyen [Sun, 28 Jun 2026 13:50:31 +0000 (15:50 +0200)]
jinja: add --dump-prog for debugging (#25086)

* jinja: add --dump-prog for debugging

* Update common/jinja/runtime.cpp

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

Co-authored-by: Sigbjørn Skjæret <redacted>
2 months agospec : add DFlash support (#22105)
Ruixiang Wang [Sun, 28 Jun 2026 13:01:34 +0000 (15:01 +0200)]
spec : add DFlash support (#22105)

* spec: add DFlash v2 support

* dflash: support sliding window attention per layer_types

* docs: add dflash section

---------

Co-authored-by: Kashif Rasul <redacted>
2 months agocommon : allow --offline in llama download (#25091)
Adrien Gallouët [Sun, 28 Jun 2026 10:34:11 +0000 (12:34 +0200)]
common : allow --offline in llama download (#25091)

Expose the existing --offline flag to `llama download` so a script can
run it to check whether a model is already cached and ready to be served
without touching the network.

Also fix a latent use-after-free in the URL-task on_done callback:
first_path is block-scoped and was captured by reference, but invoked
after the block ends.

Signed-off-by: Adrien Gallouët <redacted>
2 months agologs : reduce v2 (#25078)
Georgi Gerganov [Sun, 28 Jun 2026 05:52:15 +0000 (08:52 +0300)]
logs : reduce v2 (#25078)

* server : reduce logs

* cont : common

* cont : spec

* cont : CMN_ -> COM_

2 months agoopencl: flash attention improvement (#25069)
Hongqiang Wang [Sat, 27 Jun 2026 22:36:06 +0000 (15:36 -0700)]
opencl: flash attention improvement (#25069)

* opencl: rework FA kernel for f16 and f32

* opencl: flash-attention prefill prepass kernels

- flash_attn_kv_pad_f16    pads the tail KV tile to a BLOCK_N multiple
- flash_attn_mask_pad_f16  pads the matching mask tile
- flash_attn_blk_f16       classifies each KV tile per query block as
                           fully masked / mixed / fully unmasked, so
                           the main kernel can skip fully-masked tiles
                           and the mask lookup for fully-unmasked ones

* opencl: FA kernels for q4_0 and q8_0

* opencl: `set_rows` for f32 to q8_0/q4_0

* opencl: dequant kernels for q4_0 and q8_0

* opencl: add FA tile tuning table with override

* opencl: wire host side for FA

* opencl: q4_0 MoE tensors are also SOA'ed

* opencl: cosmetic fix

* opencl: refactor, also clarify some code paths in comments

* opencl: fix inifity for `-cl-finite-math-only`

---------

Co-authored-by: Li He <redacted>
2 months ago[CUDA] Added a cudaMemcpy2DAsync fast path to ggml_cuda_cpy (#25057)
Gaurav Garg [Sat, 27 Jun 2026 12:16:21 +0000 (17:46 +0530)]
[CUDA] Added a cudaMemcpy2DAsync fast path to ggml_cuda_cpy (#25057)

* [CUDA] Added a cudaMemcpy2DAsync fast path to ggml_cuda_cpy

Add a CUDA ggml_cpy fast path for same-type, same-shape strided copies that are just 2D pitched block copies.
When tensors are not fully contiguous but each row is contiguous, it now uses cudaMemcpy2DAsync instead of the slow element-wise scalar copy kernel.

This fixes the GDN recurrent snapshot update with -np 4, where rollback slots are separated by cache stride gaps.

* Add new tests that execute the new optimized strided copy path

* Return unsupported for strided copy in OpenVINO, as new tests are failing

2 months agosycl : fix failed ut cases of norm (#25044)
Neo Zhang [Sat, 27 Jun 2026 09:13:43 +0000 (17:13 +0800)]
sycl : fix failed ut cases of norm (#25044)

2 months agovulkan: fix step operator for 0 input (#25036)
Ruben Ortlam [Sat, 27 Jun 2026 08:57:31 +0000 (10:57 +0200)]
vulkan: fix step operator for 0 input (#25036)

2 months agobinaries : Improve rpc-server and export-graph-ops names. (#25045)
Christian Kastner [Sat, 27 Jun 2026 07:31:29 +0000 (09:31 +0200)]
binaries : Improve rpc-server and export-graph-ops names. (#25045)

Tests are generally prefixed with -test, so rename export-graph-ops
accordingly.

rpc-server is probably too generic a name for /usr/bin. Because it
should work with any ggml application, it is renamed to ggml-rpc-server.

2 months agoci : add windows-openvino to check-release (#25022)
Sigbjørn Skjæret [Sat, 27 Jun 2026 07:30:56 +0000 (09:30 +0200)]
ci : add windows-openvino to check-release (#25022)

2 months agotests : fix test-chat-template --no-common option (#25075)
Sigbjørn Skjæret [Sat, 27 Jun 2026 07:30:19 +0000 (09:30 +0200)]
tests : fix test-chat-template --no-common option (#25075)

2 months agoapp : allow --version, --licenses & --help (#25054)
Adrien Gallouët [Fri, 26 Jun 2026 21:18:11 +0000 (23:18 +0200)]
app : allow --version, --licenses & --help (#25054)

Signed-off-by: Adrien Gallouët <redacted>
2 months agosched : reintroduce less synchronizations during split compute (#20793)
Andreas Kieslinger [Fri, 26 Jun 2026 14:18:30 +0000 (16:18 +0200)]
sched : reintroduce less synchronizations during split compute (#20793)

* CUDA:  Improve performance via less synchronizations between token (#17795)

* Adds CPU-to-CUDA copy capability to
ggml_backend_cuda_cpy_tensor_async()

* Adds function to relax sync requirements between input copies on
supported backends (CUDA for now)

* Exchanges synchronous copy with async copy function.

* Adds macro guards to allow compilation in non-CUDA builds

* Reworked backend detection in ggml-backend.cpp to avoid linking
conflicts

* Relax requirement of checks in async CUDA copies from backend and buffer type to just buffer type, to avoid linking issues

* Minor cleanup

* Makes opt-in to relax use of explicit syncs more general. Backends like
vulkan which require a synchronization between HtoD copies and graph
execution could also adopt this change now.

* Reintroduces stricter check for CPU->CUDA backend async copy via
GGML_DEVICE_TYPE_CPU.

* Corrects initialization of ggml_backend_sync_mode in
ggml_backend_sched_split initialization

* Simplifies synchronizations to adhere to `saaasg` pattern.

* Apply suggestion from @ggerganov (src->buffer to buf_src)

Co-authored-by: Georgi Gerganov <redacted>
* Apply suggestion from @ggerganov (src->buffer to buf_src) v2

Co-authored-by: Georgi Gerganov <redacted>
---------

Co-authored-by: Georgi Gerganov <redacted>
* Apply suggestions from @johannesgaessler code review

Co-authored-by: Johannes Gäßler <redacted>
* Adds single-GPU synchronizations to multi-GPU settings to fix hip backend pipeline parallel bugs.

* Scheduler Hardening: Exclude hip/MUSA from copy_from_host CPU split ->
GPU split optimization

* Scheduler Hardening: Re-adding original additional synchronizations for
non-async backends

* Adds disclaimer to hip/musa exclusion of copy_from_host. Highlights that it is out of
precaution, but that no perf-impact is visible, and that it can be
revisited separately anytime.

---------

Co-authored-by: Georgi Gerganov <redacted>
Co-authored-by: Johannes Gäßler <redacted>
2 months agodevops : add llama in all docker images (#25035)
Adrien Gallouët [Fri, 26 Jun 2026 13:15:48 +0000 (15:15 +0200)]
devops : add llama in all docker images (#25035)

Signed-off-by: Adrien Gallouët <redacted>
2 months agoarg: fix handling --spec-draft-hf and --hf-repo-v (#25043)
Xuan-Son Nguyen [Fri, 26 Jun 2026 12:36:03 +0000 (14:36 +0200)]
arg: fix handling --spec-draft-hf and --hf-repo-v (#25043)

* arg: fix handling --spec-draft-hf and --hf-repo-v

* fix missing mparams.hf_file

2 months agoopenvino: Update to OV 2026.2.1, self-contained release packages, operator improvemen...
Ravi Panchumarthy [Fri, 26 Jun 2026 12:07:19 +0000 (05:07 -0700)]
openvino: Update to OV 2026.2.1, self-contained release packages, operator improvements (#24974)

* Update to OV 2026.2.1, Make OV release packages self-contained

* Update to OV 2026.2.1, Make OV release packages self-contained

* OpenVINO Backend: Remove compute_op_type hardcoded sets (#222)

* OpenVINO Backend: Remove compute_op_type hardcoded sets

* revert get_op_type removal

* OpenVINO backend: enable softmax with sink input

* OpenVINO backend: opt mul_mat_id convert process for large size

* OpenVINO backend: Modify add_id to support 2D/4D

* OpenVINO Backend: Add glu_swiglu_oai

* PR review: fix paths

* PR review: fix path consistency

---------

Co-authored-by: Mostafa <redacted>
Co-authored-by: Xuejun <redacted>
2 months agosync : ggml
Georgi Gerganov [Fri, 26 Jun 2026 12:04:05 +0000 (15:04 +0300)]
sync : ggml

2 months agoggml : bump version to 0.15.3 (ggml/1550)
Georgi Gerganov [Fri, 26 Jun 2026 11:37:43 +0000 (14:37 +0300)]
ggml : bump version to 0.15.3 (ggml/1550)

2 months agovulkan: opt mul_mat_vecq for mi50 (#22933)
nullname [Fri, 26 Jun 2026 11:49:24 +0000 (19:49 +0800)]
vulkan: opt mul_mat_vecq for mi50 (#22933)

2 months agovulkan: add INTEL_XE1 arch enum and enable coopmat1 on Intel Xe-LPG Plus (#24404)
Jiang, Fish [Fri, 26 Jun 2026 11:26:22 +0000 (11:26 +0000)]
vulkan: add INTEL_XE1 arch enum and enable coopmat1 on Intel Xe-LPG Plus (#24404)

* vulkan: add INTEL_PRE_XE2 arch enum and enable coopmat1 on Intel Xe-LPG Plus (1/3, Xe1-ARLH)

Co-authored-by: Xia, Jie <redacted>
Co-authored-by: Liu, Russell <redacted>
* Address comments of bf16 and trailing whitespace

* Rename INTEL_PRE_XE2 to INTEL_XE1 and remove driver workaround

* Add Windows driver check

---------

Co-authored-by: Xia, Jie <redacted>
Co-authored-by: Liu, Russell <redacted>
2 months agoui: fix accessibility for hover-gated interactive elements assisted by claude(in...
Sanjay Ahari [Fri, 26 Jun 2026 10:55:38 +0000 (16:25 +0530)]
ui: fix accessibility for hover-gated interactive elements assisted by claude(in debugging and tests) (#24727)

2 months agovulkan: Workaround compiler bug in conv2d coopmat2 path (#24924)
Jeff Bolz [Fri, 26 Jun 2026 09:53:32 +0000 (04:53 -0500)]
vulkan: Workaround compiler bug in conv2d coopmat2 path (#24924)

* vulkan: Workaround compiler bug in conv2d coopmat2 path

* apply same workaround to CONV_3D

* Apply suggestion from @jeffbolznv

2 months agoCUDA: add cublasSgemmBatched mapping for HIP/MUSA vendor headers (#25033)
leonardHONG [Fri, 26 Jun 2026 09:42:56 +0000 (17:42 +0800)]
CUDA: add cublasSgemmBatched mapping for HIP/MUSA vendor headers (#25033)

2 months agoggml-cpu: fix SVE leftover path in ggml_vec_dot_f32 (#24699)
Tarek Dakhran [Fri, 26 Jun 2026 07:41:56 +0000 (09:41 +0200)]
ggml-cpu: fix SVE leftover path in ggml_vec_dot_f32 (#24699)

* ggml-cpu: fix SVE leftover path in ggml_vec_dot_f32

2D convolutions with kernel size 9 produced different results on SVE
enabled ARM devices. After debugging it turned out that ggml_vec_dot_f32
was using data from inactive lanes.

Use svmla_f32_m(pg, sum1, ax1, ay1) so inactive lanes retain sum1.

* cont : clean-up

---------

Co-authored-by: Georgi Gerganov <redacted>
2 months agoserver + ui: SSE Replay Buffer (#23226)
Pascal [Fri, 26 Jun 2026 07:31:29 +0000 (09:31 +0200)]
server + ui: SSE Replay Buffer (#23226)

* server: SSE replay buffer, survives client disconnect

Opt in on POST /v1/chat/completions when the client sends
X-Stream-Resume: 1 and a non empty X-Conversation-Id. The conv id is
the session identity end to end, no extra opaque token. The drain
runs detached server side and buffers SSE bytes, the generation
survives HTTP disconnect, F5, or lets users switch from iOS Safari
to another app without losing the actively generated response.

Routes:
  GET    /v1/stream/<conv_id>?from=N       replay
  GET    /v1/streams[?conversation_id=X]   list, drives sidebar spinners
  DELETE /v1/stream/<conv_id>              Stop, idempotent

Router parent fans out to children for list and delete, probes on GET
to route to the owner, fans out DELETE on POST so "one session per
conv" holds across model swaps.

WebUI: the layout snapshots /v1/streams at mount and on
visibilitychange, the sidebar reflects live inferences across all
convs. The chat page reattaches on mount, append vs fresh is detected
from existing content so continue mid stream keeps its prefix.

update_slots: on llama_memory_seq_rm refusal at a deep position, full
clear of the seq and reprefill from zero instead of GGML_ABORT.

OAI strict path unchanged when the opt in headers are absent.

* server: create stream session only after post_tasks succeeds

* server, ui: drop X-Stream-Resume, X-Conversation-Id alone enables the replay buffer

* server: drop magic 17, derive the X-Conversation-Id header length from sizeof at build time

* refactor: address review feedback from ngxson

* server-context: cleaning

* server-stream: fix use-after-free on rd

Guard stop_producer with a shared alive flag, flipped by on_stream_end
before rd dies. Prevents a late cancel (session eviction by a later
POST on the same conv_id, or a DELETE arriving after the producer
ended) from touching a destroyed rd.

* ui: fix cross-conversation contamination

Scope streaming flags per conv so one finishing does not unflag the
others, guard discoverActiveStream against concurrent runs to avoid
duplicate attaches, and stop racing syncRemoteRunningStreams for the
sidebar set.

* server-http: keep request alive in detached SSE drain

The response next() lambda may reach into *request via &req long
after on_complete reset the request shared_ptr. Capture request in
the detached thread so it outlives the drain.

* ui: address review feedback from coder543

Forward Authorization to /v1/stream and /v1/streams fetches, the resumable routes
must obey --api-key like the rest of the API.

Wrap reader.read() in a try/catch, the underlying connection drop rejects with
TypeError instead of resolving done=true, treat it as a premature end of stream
so the existing resume loop kicks in.

Freeze the model at session start in chatStreamingStates.model and thread it
through cancel and resume, the dropdown selection may have changed since the
POST and the server side identity is fixed at that time.

* format

* ui: remove unused selectedModelName

* server-stream: poll session->is_cancelled() in stream_aware_should_stop

Address review feedback from coder543. The cancel propagation through
rd.stop() relies on the slot eventually processing the cancel task and
posting a result that notifies the recv condvar, remove_waiting_task_ids
does not notify directly. Add a defensive poll on session->is_cancelled()
so the producer-side next() loop exits on its next iteration after
cancel() without waiting for the cancel task to round trip through a slot.

* server-stream, ui: replace GET /v1/streams with POST /v1/streams/lookup

Address review feedback from coder543. Listing live sessions leaks the
conversation_id of every concurrent user, which defeats the random UUID
unguessability. The new route takes {conversation_ids: [...]} in the
body and returns matches only for the ids the caller already owns, so
foreign UUIDs stay private. The router fans out the same POST to every
child and aggregates, the WebUI passes the convs visible in its sidebar.

* ui: read conv ids from IndexedDB in syncRemoteRunningStreams

The conversations store is not hydrated yet at +layout onMount, so the
sidebar spinners stayed off for background convs until the user clicked
on them. Read straight from the DB to dodge the init race.

* server-models: deduplicate stream lookup timeouts behind one constant

* ui: extract visibility kick grace into a stream constant, bump to 1000 ms

* make it safer & more simple

* server-stream: survive client disconnect via stream_pipe::finish_producer

After the RAII rewrite the generation stopped the moment the client
disconnected. httplib bails its content provider on the is_peer_alive
check at the top of write_content_chunked, so returning true from the
provider never keeps it producing: the response resets, rd is destroyed
and its task gets cancelled.

Reinstate the disconnect survival inside the pipe. stream_pipe gains
finish_producer, which pumps the response next() into the ring buffer
until the generation ends, and mark_producer_done for the clean wire
end. server-http only triggers them: mark before sink.done on a clean
close, finish in on_complete when the peer left early. No detach, no
stream logic in server-http beyond the trigger, and the strict OAI path
is untouched when no pipe is attached.

Known limitation: finish_producer pumps synchronously on the http
worker, so a disconnected stream keeps its worker busy until the
generation ends. A follow-up will move the drain off the http worker so
no worker is held.

* server-stream: drain disconnected streams on a manager owned thread

The previous commit pumped the post disconnect drain synchronously in
on_complete, on the http worker, so a disconnected stream kept its
worker busy until the generation ended. Under a wave of reloads or tab
closes that pins workers from the pool.

Move the drain off the http worker. on_complete now hands the response
to stream_session_manager::adopt_orphan, which pumps it to completion on
a manager owned thread and releases the worker at once. One thread per
disconnected stream still generating, stored in a list, joined and
reaped on the next adopt, by the GC, and at shutdown. No detach, the
thread lifecycle is fully owned by the manager. needs_drain gates the
handoff so a cleanly finished stream never spawns a thread, and the
strict OAI path stays untouched when no pipe is attached.

stop_gc now cancels sessions before finalizing them, so an in flight
drain sees is_cancelled and exits instead of blocking the shutdown join
until the generation ends naturally.

* ui: add missing JSDoc

* server-stream: drain on the http worker, drop the manager thread

Address @ngxson review: httplib runs a large dynamic pool and a worker
blocked in next() sits on a condvar instead of burning cpu, so draining
the rest of the generation on that worker is fine and much simpler than
a dedicated thread.

on_complete calls finish_producer directly again. Removes adopt_orphan,
the orphan thread list and its reaping, the stop_gc session cancel that
only existed to unblock those threads, and the now dead drain_shutdown
flag.

* server-stream: split stream_pipe into producer and consumer classes

Address @ngxson review: one class covering both ends was messy. stream_pipe
is now a base holding the session and is_cancelled, with stream_pipe_producer
(write, mark_producer_done, finish_producer, cleanup, finalizes on destruct)
and stream_pipe_consumer (read only, no finalize) deriving from it.

Drops the is_producer_ discriminator and its runtime guards, the type now
encodes the role. res.spipe is retyped to shared_ptr<stream_pipe_producer>
since it is only ever a producer. No behavior change.

* server-stream: rename producer methods to unix pipe semantics

Address @ngxson review: mark_producer_done becomes done(), finish_producer
becomes close(), matching a unix pipe write end. The producer_done_ member
follows as done_. write() is unchanged. No behavior change.

* server, ui: route resumable streams via a conv map, persist resume identity

Address ngxson review: drop the polling probe, proxy_post records a conv_id ->
model map and the stream routes resolve the owning child with one lookup. The
map is the single source of truth, the ::model suffix stays for child session
uniqueness but the router never parses it.

UI: the server keys a session by the POST time identity (conv::model), but reload
probed with the bare conv id and missed model tagged sessions, so F5 stopped the
stream and sidebar spinners stayed off. Persist the model and rebuild the exact
identity on resume, single conv and bulk sidebar both send it.

Add unit coverage for the identity round trip.

* ui: resolve continue target by id to stop cross-conversation flash on switch

* ui: skip stream resume when the abort is intentional

* server: move the conv id to model map into a self contained tracker

Address review from ngxson: server_models held two mutexes side by side, the
global one and a bare conv_model_mu guarding a loose map, which made the locking
hard to follow. Wrap the map and its lock in a small conv_model_tracker struct
that owns its mutex, one mutex per struct. The remember, lookup and forget
methods move inline into the tracker, server_models exposes a single conv_models
member and the routes call models.conv_models.lookup and friends. No behavior
change, the map stays the single source of truth for routing resumable streams
to a child.

* ui: replace stream magic values with enums and shared constants

Address review from allozaur: lift the inline literals around the resumable
stream code into named symbols so the intent is explicit and reusable.

* ui: fold the stream resume and discovery helpers into ChatService

Address review from allozaur: drop the two standalone stream-*.service files.
They were used only by the chat service and store, carried no shared state, and
did not follow the static class pattern the other services use, so a separate
abstraction was not warranted. Move the helpers onto ChatService as static
methods. No behavior change, tests now exercise them through ChatService.

* docs: document the SSE replay buffer in server README-dev

Add the resumable streaming section, list stream_session_manager in the
backend component inventory, and link PR 23226 in the related PRs.

* ui: align attachServerStream call with onCompletionId param in handleStreamResponse

* server-http: rename del_ to del to match get and post

* ui: address review feedback from allozaur

* ui: drop duplicate SSE constants, keep sse.ts canonical

* ui: use svelte:document for the visibilitychange listener

address review from allozaur: replace the manual document.addEventListener
in onMount with a declarative <svelte:document onvisibilitychange>. svelte
handles attach, detach and SSR, so the typeof document guard and the onMount
cleanup go away. onMount keeps only the first load snapshot.

* server: trim redundant stream drain comments

Address review from ngxson

* server: balance and clean up stream comments

remove redundant comments and tighten the verbose ones across the resumable
stream code, keeping the concurrency and lifetime rationale that is not obvious
from the code. also fix two stale comments in server.cpp and server-models.h
that still described the old ::model suffix probe and fan out routing, now
replaced by the conv_id -> model map

Address review from ngxson

* ui: balance and clean up stream comments

dedup repeated rationale (frozen conv::model identity, the lookup privacy note,
the abort patterns) down to one canonical spot, tighten the verbose blocks, and
keep the concurrency and resume-offset reasoning. fix stale comments in
stream-identity.ts and chat.service.ts that still described the old loopback
probe and fan out routing, now the conv_id -> model map.

---------

Co-authored-by: Xuan Son Nguyen <redacted>
2 months agosycl : clamp softmax input to avoid underflow (#24941)
Jassieluo [Fri, 26 Jun 2026 07:02:42 +0000 (15:02 +0800)]
sycl : clamp softmax input to avoid underflow (#24941)

2 months agomtmd: add more validations (#25013)
Xuan-Son Nguyen [Fri, 26 Jun 2026 06:43:29 +0000 (08:43 +0200)]
mtmd: add more validations (#25013)

* mtmd: add more validations

* fix

* refactor a bit

* type check for get_arr_int

2 months agoCUDA: batch out_prod broadcast (dps2>1) path with cublasSgemmBatched (#24426)
leonardHONG [Fri, 26 Jun 2026 05:51:25 +0000 (13:51 +0800)]
CUDA: batch out_prod broadcast (dps2>1) path with cublasSgemmBatched (#24426)

2 months agomamba2: remove hardcoded 2x expansion factor and invalid d_inner % d_state check...
Arsen Arutunan [Fri, 26 Jun 2026 05:50:54 +0000 (08:50 +0300)]
mamba2: remove hardcoded 2x expansion factor and invalid d_inner % d_state check (#23082)

* mamba2: remove hardcoded 2x expansion factor, support any expand value

* mamba2: remove invalid d_inner %% d_state check (unrelated parameters)

* Update convert_hf_to_gguf.py: make expand optional with default 2

Co-authored-by: Sigbjørn Skjæret <redacted>
* mamba2: apply expand fix to refactored conversion/mamba.py

* also check for mamba_expand

---------

Co-authored-by: Sigbjørn Skjæret <redacted>
Co-authored-by: Sigbjørn Skjæret <redacted>
2 months agoopencl: flush profiling batch at shutdown for incomplete batches (#25016)
shaofeiqi [Fri, 26 Jun 2026 01:48:24 +0000 (18:48 -0700)]
opencl: flush profiling batch at shutdown for incomplete batches (#25016)

2 months agoxcframework : disable mtmd video on i/tv/visionos (#25018)
Sigbjørn Skjæret [Thu, 25 Jun 2026 22:13:59 +0000 (00:13 +0200)]
xcframework : disable mtmd video on i/tv/visionos (#25018)

2 months agomodel : Add label for LFM2.5-230M (#25008)
Tarek Dakhran [Thu, 25 Jun 2026 16:58:52 +0000 (18:58 +0200)]
model : Add label for LFM2.5-230M (#25008)

2 months agoCUDA: Various fixes to `cpy.cu` (#25000)
Oliver Simons [Thu, 25 Jun 2026 15:29:23 +0000 (17:29 +0200)]
CUDA: Various fixes to `cpy.cu` (#25000)

* Add failing test-case to test-backend-ops

Extracted from https://github.com/ggml-org/llama.cpp/issues/24072

* Minimize repro with help of AI

N = 8 * (65535 - 1) + 1 = 524273

* Port and adjust workaround from https://github.com/LostRuins/koboldcpp/commit/0ba798341e0c70517cb226cb63c966b086a3b5b3

Fall-back should share code, also relax y-z constraint to be inclusive

* Add test-case + fallback also for y dim

* Fix x-guards which is 2^{31}-1, so inlusive of INT_MAX

* Fix overflow problems for transposed copy kernel