]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/log
pkg/ggml/sources/llama.cpp
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>
2 months agoggml : fix A indexing in simd_gemm scalar tail-column path (#25390)
tyronecai [Wed, 8 Jul 2026 05:00:05 +0000 (13:00 +0800)]
ggml : fix A indexing in simd_gemm scalar tail-column path (#25390)

`simd_gemm()` has an incorrect A-matrix index in the scalar tail-column path for full row blocks.

2 months agoggml : add support for CPU f16->f16 GGML_OP_SET_ROWS (#25344)
fairydreaming [Wed, 8 Jul 2026 03:46:28 +0000 (05:46 +0200)]
ggml : add support for CPU f16->f16 GGML_OP_SET_ROWS (#25344)

* ggml : add support for CPU f16->f16 GGML_OP_SET_ROWS

* ggml : add missing type checks in f16 GGML_OP_SET_ROWS

* ggml : merge ggml_compute_forward_set_rows_f32() and ggml_compute_forward_set_rows_f16() into ggml_compute_forward_set_rows_impl()

* chore : replace assert() with GGML_ASSERT()

---------

Co-authored-by: Stanisław Szymczyk <redacted>
2 months agoopencl: fix potential crash in aos reconstruct (#25383)
lhez [Wed, 8 Jul 2026 03:34:29 +0000 (20:34 -0700)]
opencl: fix potential crash in aos reconstruct (#25383)

2 months agoAdd Q2_0 quantization: type definition and CPU backend (#24448)
Pasha Khosravi [Tue, 7 Jul 2026 19:05:47 +0000 (12:05 -0700)]
Add Q2_0 quantization: type definition and CPU backend (#24448)

2 months agospec : fix naming, spacing (#25410)
Georgi Gerganov [Tue, 7 Jul 2026 15:52:30 +0000 (18:52 +0300)]
spec : fix naming, spacing (#25410)

2 months agoCUDA: Fuse MMVQ post-scale for NVFP4 (#24481)
Oliver Simons [Tue, 7 Jul 2026 15:12:19 +0000 (17:12 +0200)]
CUDA: Fuse MMVQ post-scale for NVFP4 (#24481)

* CUDA: Fuse MMVQ for NVFP4 and BS 1

TODO:
1. Add tests to test-backend-ops (did verify correctness manually for
   one model)
2. Reorder bias/scale once PRs for NVFP4 are merged/landed

* Add dense MMVQ fusion as well

Perf numbers on B4500. Note qwen35 is FP8->Q8
+ ./scripts/compare-llama-bench.py -b master -c osimons/nvfp4_fuse_mmvq --tool llama-bench -i llama-bench.sqlite
| Model                    | Test         |   t/s master |   t/s osimons/nvfp4_fuse_mmvq |   Speedup |
|:-------------------------|:-------------|-------------:|------------------------------:|----------:|
| qwen35moe 35B.A3B NVFP4  | tg128@d32768 |       150.15 |                        156.29 |      1.04 |
| qwen35moe 35B.A3B Q4_K_M | tg128@d32768 |       157.91 |                        157.64 |      1.00 |

Perf numbers on DGX Spark
+ ./scripts/compare-llama-bench.py -b master -c osimons/nvfp4_fuse_mmvq --tool llama-bench -i llama-bench.sqlite
| Model                    | Test         |   t/s master |   t/s osimons/nvfp4_fuse_mmvq |   Speedup |
|:-------------------------|:-------------|-------------:|------------------------------:|----------:|
| qwen35moe 35B.A3B NVFP4  | tg128@d32768 |        58.31 |                         59.69 |      1.02 |
| qwen35moe 35B.A3B Q4_K_M | tg128@d32768 |        54.94 |                         54.79 |      1.00 |

* Add tests for the added fusion ops

* Cleanup test-backend-ops

* Cleanup ggml-cuda/mmvq

1. Unrestrict post-scale fusion
2. Rename names accordingly
3. Remove env variable to disable fusion

* Merge old mul_mat patterns into the lane-based approach

* Enable fusion for MoE in shared MMVQ

* Restrict scale_view_nodes, enroll MM + ADD into lane-matcher

* Refactor mmvq loads, still does not help non-nvfp4 kernels

* Restrict scale-fusion to NVFP4

This is necessary, as the prolog is quite heavy in GEMV for some
quants/model configs, leading to net perf regression.
We should really be looking to refactor this such that ratio of
prologue/hot-loop/epilogue is better on the hot-loop
front:

+ ./scripts/compare-llama-bench.py -b master -c c1b9381d327e063cc846b46b59708444b66dc4d8 --tool llama-bench -i llama-bench.sqlite
| CPU                         | Model                    | Test         |   t/s master |   t/s c1b9381d3 |   Speedup |
|:----------------------------|:-------------------------|:-------------|-------------:|----------------:|----------:|
| INTEL(R) XEON(R) GOLD 6542Y | gemma4 26B.A4B NVFP4     | tg128@d32768 |       151.70 |          154.32 |      1.02 |
| INTEL(R) XEON(R) GOLD 6542Y | gemma4 26B.A4B Q4_K_M    | tg128@d32768 |       187.95 |          185.73 |      0.99 |
| INTEL(R) XEON(R) GOLD 6542Y | gpt-oss 20B MXFP4 MoE    | tg128@d32768 |       304.62 |          300.69 |      0.99 |
| INTEL(R) XEON(R) GOLD 6542Y | qwen35moe 35B.A3B NVFP4  | tg128@d32768 |       193.72 |          211.99 |      1.09 |
| INTEL(R) XEON(R) GOLD 6542Y | qwen35moe 35B.A3B Q4_K_M | tg128@d32768 |       217.76 |          218.15 |      1.00

* Reorder scale & bias-add to adhere to #24331

* Restrict lane scale to NVFP4

Don't need to test unfused combinations

* Cleanup

* Merge single-lane mm-fusion helpers

* Refactor and clean-up host-side fusion logic

* Move gate_bias and scale into the same active-thread guard

Latest perf numbers:
B6000

build: 5b7d9f272 (9578)
+ ./scripts/compare-llama-bench.py -b master -c osimons/nvfp4_fuse_mmvq --tool llama-bench -i llama-bench.sqlite
| CPU                         | Model                    | Test         |   t/s master |   t/s osimons/nvfp4_fuse_mmvq |   Speedup |
|:----------------------------|:-------------------------|:-------------|-------------:|------------------------------:|----------:|
| INTEL(R) XEON(R) GOLD 6542Y | gemma4 26B.A4B NVFP4     | tg128@d32768 |       151.79 |                        154.10 |      1.02 |
| INTEL(R) XEON(R) GOLD 6542Y | gemma4 26B.A4B Q4_K_M    | tg128@d32768 |       187.90 |                        187.27 |      1.00 |
| INTEL(R) XEON(R) GOLD 6542Y | gpt-oss 20B MXFP4 MoE    | tg128@d32768 |       303.77 |                        306.56 |      1.01 |
| INTEL(R) XEON(R) GOLD 6542Y | qwen35moe 35B.A3B NVFP4  | tg128@d32768 |       193.41 |                        207.99 |      1.08 |
| INTEL(R) XEON(R) GOLD 6542Y | qwen35moe 35B.A3B Q4_K_M | tg128@d32768 |       217.60 |                        218.58 |      1.00 |

DGX Spark

build: 5b7d9f272 (9578)
+ ./scripts/compare-llama-bench.py -b master -c osimons/nvfp4_fuse_mmvq --tool llama-bench -i llama-bench.sqlite
| CPU   | Model                    | Test         |   t/s master |   t/s osimons/nvfp4_fuse_mmvq |   Speedup |
|:------|:-------------------------|:-------------|-------------:|------------------------------:|----------:|
| CPU   | gemma4 26B.A4B NVFP4     | tg128@d32768 |        34.61 |                         34.84 |      1.01 |
| CPU   | gemma4 26B.A4B Q4_K_M    | tg128@d32768 |        46.95 |                         46.90 |      1.00 |
| CPU   | gpt-oss 20B MXFP4 MoE    | tg128@d32768 |        64.84 |                         64.62 |      1.00 |
| CPU   | qwen35moe 35B.A3B NVFP4  | tg128@d32768 |        59.63 |                         60.72 |      1.02 |
| CPU   | qwen35moe 35B.A3B Q4_K_M | tg128@d32768 |        56.53 |                         56.55 |      1.00 |

PPL values for 5 chunks:
this PR

model                                                                                                       mode             ppl         uncertainty  log
/mnt/share/gguf/unsloth/Qwen3.6-35B-A3B-GGUF/Qwen3.6-35B-A3B-UD-Q4_K_M.gguf                                 fusion_enabled   5.2892      0.35389      ppl-value-checks/Qwen3.6-35B-A3B-UD-Q4_K_M.fusion_enabled.log
/mnt/share/gguf/unsloth/Qwen3.6-35B-A3B-GGUF/Qwen3.6-35B-A3B-UD-Q4_K_M.gguf                                 fusion_disabled  5.2742      0.35215      ppl-value-checks/Qwen3.6-35B-A3B-UD-Q4_K_M.fusion_disabled.log
/mnt/share/gguf/nvidia/Qwen3.6-35B-A3B-2.06GB-per-token-CT/Qwen3.6-35B-A3B-2.06GB-per-token-CT_fp8_q8.gguf  fusion_enabled   5.4487      0.36866      ppl-value-checks/Qwen3.6-35B-A3B-2.06GB-per-token-CT_fp8_q8.fusion_enabled.log
/mnt/share/gguf/nvidia/Qwen3.6-35B-A3B-2.06GB-per-token-CT/Qwen3.6-35B-A3B-2.06GB-per-token-CT_fp8_q8.gguf  fusion_disabled  5.4403      0.36782      ppl-value-checks/Qwen3.6-35B-A3B-2.06GB-per-token-CT_fp8_q8.fusion_disabled.log
/mnt/share/gguf/nvidia/Gemma-4-26B-A4B-NVFP4/Gemma-4-26B-A4B-NVFP4_fp8_q8.gguf                              fusion_enabled   17342.4348  3703.13932   ppl-value-checks/Gemma-4-26B-A4B-NVFP4_fp8_q8.fusion_enabled.log
/mnt/share/gguf/nvidia/Gemma-4-26B-A4B-NVFP4/Gemma-4-26B-A4B-NVFP4_fp8_q8.gguf                              fusion_disabled  18627.0624  3998.42475   ppl-value-checks/Gemma-4-26B-A4B-NVFP4_fp8_q8.fusion_disabled.log
/mnt/share/gguf/ggml-org/gpt-oss-20b-GGUF/gpt-oss-20b-mxfp4.gguf                                            fusion_enabled   363.8913    33.14007     ppl-value-checks/gpt-oss-20b-mxfp4.fusion_enabled.log
/mnt/share/gguf/ggml-org/gpt-oss-20b-GGUF/gpt-oss-20b-mxfp4.gguf                                            fusion_disabled  363.8913    33.14007     ppl-value-checks/gpt-oss-20b-mxfp4.fusion_disabled.log
/mnt/share/gguf/unsloth/gemma-4-26B-A4B-it-GGUF/gemma-4-26B-A4B-it-UD-Q4_K_XL.gguf                          fusion_enabled   17330.3926  3716.70472   ppl-value-checks/gemma-4-26B-A4B-it-UD-Q4_K_XL.fusion_enabled.log
/mnt/share/gguf/unsloth/gemma-4-26B-A4B-it-GGUF/gemma-4-26B-A4B-it-UD-Q4_K_XL.gguf                          fusion_disabled  17933.9524  3883.17066   ppl-value-checks/gemma-4-26B-A4B-it-UD-Q4_K_XL.fusion_disabled.log

master:
summary: ppl-value-checks/summary.tsv
model                                                                                                       mode             ppl         uncertainty  log
/mnt/share/gguf/unsloth/Qwen3.6-35B-A3B-GGUF/Qwen3.6-35B-A3B-UD-Q4_K_M.gguf                                 fusion_enabled   5.2892      0.35389      ppl-value-checks/Qwen3.6-35B-A3B-UD-Q4_K_M.fusion_enabled.log
/mnt/share/gguf/unsloth/Qwen3.6-35B-A3B-GGUF/Qwen3.6-35B-A3B-UD-Q4_K_M.gguf                                 fusion_disabled  5.2742      0.35215      ppl-value-checks/Qwen3.6-35B-A3B-UD-Q4_K_M.fusion_disabled.log
/mnt/share/gguf/nvidia/Qwen3.6-35B-A3B-2.06GB-per-token-CT/Qwen3.6-35B-A3B-2.06GB-per-token-CT_fp8_q8.gguf  fusion_enabled   5.4487      0.36866      ppl-value-checks/Qwen3.6-35B-A3B-2.06GB-per-token-CT_fp8_q8.fusion_enabled.log
/mnt/share/gguf/nvidia/Qwen3.6-35B-A3B-2.06GB-per-token-CT/Qwen3.6-35B-A3B-2.06GB-per-token-CT_fp8_q8.gguf  fusion_disabled  5.4403      0.36782      ppl-value-checks/Qwen3.6-35B-A3B-2.06GB-per-token-CT_fp8_q8.fusion_disabled.log
/mnt/share/gguf/nvidia/Gemma-4-26B-A4B-NVFP4/Gemma-4-26B-A4B-NVFP4_fp8_q8.gguf                              fusion_enabled   17342.4348  3703.13932   ppl-value-checks/Gemma-4-26B-A4B-NVFP4_fp8_q8.fusion_enabled.log
/mnt/share/gguf/nvidia/Gemma-4-26B-A4B-NVFP4/Gemma-4-26B-A4B-NVFP4_fp8_q8.gguf                              fusion_disabled  18627.0624  3998.42475   ppl-value-checks/Gemma-4-26B-A4B-NVFP4_fp8_q8.fusion_disabled.log
/mnt/share/gguf/ggml-org/gpt-oss-20b-GGUF/gpt-oss-20b-mxfp4.gguf                                            fusion_enabled   363.8913    33.14007     ppl-value-checks/gpt-oss-20b-mxfp4.fusion_enabled.log
/mnt/share/gguf/ggml-org/gpt-oss-20b-GGUF/gpt-oss-20b-mxfp4.gguf                                            fusion_disabled  363.8913    33.14007     ppl-value-checks/gpt-oss-20b-mxfp4.fusion_disabled.log
/mnt/share/gguf/unsloth/gemma-4-26B-A4B-it-GGUF/gemma-4-26B-A4B-it-UD-Q4_K_XL.gguf                          fusion_enabled   17330.3926  3716.70472   ppl-value-checks/gemma-4-26B-A4B-it-UD-Q4_K_XL.fusion_enabled.log
/mnt/share/gguf/unsloth/gemma-4-26B-A4B-it-GGUF/gemma-4-26B-A4B-it-UD-Q4_K_XL.gguf                          fusion_disabled  17933.9524  3883.17066   ppl-value-checks/gemma-4-26B-A4B-it-UD-Q4_K_XL.fusion_disabled.log

* Allow views to weights in ggml_can_fuse_subgraph

* Remove gate_first from test_mul_mat_vec_fusion

* Ditch lane-parsing approach in favor of hard-coded patterns

* Apply suggestions from code review

Co-authored-by: Georgi Gerganov <redacted>
* Rename ggml_is_constant_view_src to ggml_is_constant

* Finish renaming of 0905129e9d12e2bc6f16d6d3cc4e6b40606fc893

* Readd descriptive prints for fusion debugging

* Add weight-buffer pre-allocation to `test_case`

This is required so we correctly test fusion of NVFP4.

* Update ggml/src/ggml.c

Co-authored-by: Johannes Gäßler <redacted>
* Add 2nd context for weights as suggested by @JohannesGaessler

This reflects more natural use of ggml compared to artifically
pre-allocating weights into the same context

* Exclude fused tests from gradient mode

I'm unsure of the current state, but naively every fusion pattern
should require its own backpropagation implementation. I don't see these
implemented for the CUDA backend, so we can disable tests to avoid
triggering GGML_ASSERT for

    ggml_tensor * build_graph(ggml_context * ctx) override {
        GGML_ASSERT(!use_weight_context());
        return build_graph(ctx, nullptr);
    }

* Apply suggestions from code review

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

Co-authored-by: Georgi Gerganov <redacted>
Co-authored-by: Johannes Gäßler <redacted>
2 months agoserver : fix draft model fit vs load inconsistency (#25056)
Alex [Tue, 7 Jul 2026 14:20:42 +0000 (10:20 -0400)]
server : fix draft model fit vs load inconsistency (#25056)

* fix: draft model fit vs load inconsistency

* refactor(server): unify draft/mtp parameter initialization, model, and context load
- moves speculative init to speculative.cpp
- changes server_context_impl model_dft and ctx_dft to use raw pointers

- fix: don't throttle progress callback when loading draft model
- refactor: rename draft model/ctx load method

* fix: valign

2 months agoserver : add timings and progress to /responses API stream (#25348)
Thomas LECONTE [Tue, 7 Jul 2026 14:13:03 +0000 (16:13 +0200)]
server : add timings and progress to /responses API stream (#25348)

2 months agoserver: enforce prompt cache RAM limit (#25070)
Thiago Padilha [Tue, 7 Jul 2026 13:24:35 +0000 (10:24 -0300)]
server: enforce prompt cache RAM limit (#25070)

Before this commit, --cache-ram was not a hard limit:

- The cache always kept at least one entry, even if that entry exceeded the
  RAM/token limits.
- Old entries were only evicted for the RAM/token limits after saving the new
  one, which could cause the cache to temporarily exceed the RAM/token limits
  even if individual entries were below the limit.

Now, ensure that the RAM limit is strict with these changes:

- Skip saving state to cache if by itself it exceeds the RAM limit.
- Evict old entries as necessary to make the new entry fit.

Additionally, token-limit cleanup may now evict the last remaining cache entry
instead of always preserving one.

2 months agocommon : add missing <fstream> include in common.h (#25220)
zhangrunda [Tue, 7 Jul 2026 13:23:53 +0000 (21:23 +0800)]
common : add missing <fstream> include in common.h (#25220)

Signed-off-by: zhangrunda <redacted>
2 months agoggml-hip : add -fno-finite-math-only alongside -ffast-math (#25373)
asf0 [Tue, 7 Jul 2026 11:27:50 +0000 (05:27 -0600)]
ggml-hip : add -fno-finite-math-only alongside -ffast-math (#25373)

-ffast-math implies -ffinite-math-only under ROCm/clang 22, which
disables INFINITY/NaN and triggers -Wnan-infinity-disabled (errors
under -Werror in CI). Re-enable infinity handling without dropping
the rest of fast-math.

Fixes #25361

2 months agollama: fix quantized kv-cache for dsv4 (#25202)
Aman Gupta [Tue, 7 Jul 2026 09:46:57 +0000 (17:46 +0800)]
llama: fix quantized kv-cache for dsv4 (#25202)

2 months ago[SYCL] fix unsupported UT cases of CONT & CPY (#25231)
Neo Zhang [Tue, 7 Jul 2026 09:20:52 +0000 (17:20 +0800)]
[SYCL] fix unsupported UT cases of CONT & CPY (#25231)

* fix unsupported UT cases of CONT & CPY

* update ops.md

* rm unused head file

2 months ago[SYCL] support op col2im_1d (#25264)
Neo Zhang [Tue, 7 Jul 2026 08:07:46 +0000 (16:07 +0800)]
[SYCL] support op col2im_1d (#25264)

* support op col2im_1d

* update ops.md

* rm unused words

* update for bf16

* optimize 1%-11% as the review comments

* fix the format issue

* update as the review comments

2 months ago[SYCL] support OP cross_entropy_loss, cross_entropy_loss_back (#25236)
Neo Zhang [Tue, 7 Jul 2026 07:48:50 +0000 (15:48 +0800)]
[SYCL] support OP cross_entropy_loss, cross_entropy_loss_back (#25236)

* support OP cross_entropy_loss, cross_entropy_loss_back

* correct format issue

2 months agosycl : set K_QUANTS_PER_ITERATION to 1 on DMMV path (#25063)
Todd Malsbary [Tue, 7 Jul 2026 07:43:41 +0000 (00:43 -0700)]
sycl : set K_QUANTS_PER_ITERATION to 1 on DMMV path (#25063)

* sycl: add supported types to ggml_sycl_supports_reorder_dmmv

The reordered feature is implemented in ggml_sycl_op_dequantize_mul_mat_vec,
but gated by ggml_sycl_supports_reorder_dmmv. This commit fixes the gate.

Signed-off-by: Todd Malsbary <redacted>
* sycl: set K_QUANTS_PER_ITERATION=1 to improve utilization

When combined with opening the reorder gate, this improves GPU
utilization on B70, giving a significant boost to tg t/s.

Signed-off-by: Todd Malsbary <redacted>
* sycl: replace QK_WARP_SIZE with WARP_SIZE for QK_5

Signed-off-by: Todd Malsbary <redacted>
* sycl: add missing types to ggml_backend_sycl_buffer_init_tensor

Without this, the extra field is not allocated and the reorder path
will not take effect.

Signed-off-by: Todd Malsbary <redacted>
---------

Signed-off-by: Todd Malsbary <redacted>
2 months ago[SYCL] fix unsupport ACC UT cases for noncontiguous (#25124)
Neo Zhang [Tue, 7 Jul 2026 07:40:38 +0000 (15:40 +0800)]
[SYCL] fix unsupport ACC UT cases for noncontiguous (#25124)

* fix unsupport ACC UT cases for noncontiguous

* update ops.md

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