Skip to content

Adding sliding window attention - #4734

Merged
jagrit06 merged 4 commits into
mainfrom
digani/sliding
Oct 23, 2026
Merged

jagrit06 merged 4 commits into
mainfrom
digani/sliding

Conversation

@jagrit06

Copy link
Copy Markdown
Member
  • Add sliding window attention in fast::sdpa
  • Add metal kernels for vector (1 and 2 pass) and matrix (nax and pre-nax)
  • Add tests and fallbacks

Benchmarks to follow

@jagrit06

Copy link
Copy Markdown
Member Author

I have also updated the metal kernels so that you can pass an array mask (boolean or additive) and also enable the kernel to be causal / sliding windowed at the same time
I haven't plumbed that all the way up to the operation / API since I'm hoping for comments on how people would prefer to do that on the API side.
My suggestion is to just allow mask arrays as inputs alongside a string that says "causal" if you wish to have the causal pattern run and also read a mask array

@jagrit06
jagrit06 requested review from nastya236 and zcbenz October 20, 2026 14:21
@jagrit06

Copy link
Copy Markdown
Member Author

Adding some comparisons between using the new window_size parameter vs passing a dense boolean mask
The most notable savings are in matrix and single vector set-ups - looks like small number of query tokens will need another optimization pass in the future

Apple M5

==================================
  B,   qsl,   ksl, hdim, n_qh, n_kvh, tp,   dtype, causal,    ws, t_unfs,  t_fus, speed_up
  1,     1,  2048,  128,   32,     8,  1, float16,      0,  1024,  0.020,  0.016,    1.227
  1,     1,  4096,  128,   32,     8,  1, float16,      0,  2048,  0.032,  0.023,    1.389
  1,     4,  2048,  128,   32,     8,  1, float16,      0,  1024,  0.044,  0.036,    1.208
  1,     4,  4096,  128,   32,     8,  1, float16,      0,  2048,  0.067,  0.051,    1.305
  1,  2048,  2048,  128,   32,     8,  1, float16,      0,  1024,  1.379,  0.925,    1.491
  1,  4096,  4096,  128,   32,     8,  1, float16,      0,  2048,  5.433,  3.672,    1.480

==================================
  B,   qsl,   ksl, hdim, n_qh, n_kvh, tp,   dtype, causal,    ws, t_unfs,  t_fus, speed_up
  1,     1,  2048,  128,   32,     8,  1, float16,      1,  1024,  0.020,  0.017,    1.200
  1,     1,  4096,  128,   32,     8,  1, float16,      1,  2048,  0.033,  0.023,    1.420
  1,     4,  2048,  128,   32,     8,  1, float16,      1,  1024,  0.044,  0.036,    1.226
  1,     4,  4096,  128,   32,     8,  1, float16,      1,  2048,  0.066,  0.060,    1.098
  1,  2048,  2048,  128,   32,     8,  1, float16,      1,  1024,  1.381,  0.504,    2.739
  1,  4096,  4096,  128,   32,     8,  1, float16,      1,  2048,  5.547,  1.964,    2.824
Apple M3 Max

==================================
  B,   qsl,   ksl, hdim, n_qh, n_kvh, tp,   dtype, causal,    ws, t_unfs,  t_fus, speed_up
  1,     1,  2048,  128,   32,     8,  1, float16,      0,  1024,  0.026,  0.021,    1.220
  1,     1,  4096,  128,   32,     8,  1, float16,      0,  2048,  0.025,  0.014,    1.861
  1,     4,  2048,  128,   32,     8,  1, float16,      0,  1024,  0.033,  0.030,    1.088
  1,     4,  4096,  128,   32,     8,  1, float16,      0,  2048,  0.034,  0.029,    1.177
  1,  2048,  2048,  128,   32,     8,  1, float16,      0,  1024,  2.062,  1.455,    1.417
  1,  4096,  4096,  128,   32,     8,  1, float16,      0,  2048,  8.127,  5.767,    1.409

==================================
  B,   qsl,   ksl, hdim, n_qh, n_kvh, tp,   dtype, causal,    ws, t_unfs,  t_fus, speed_up
  1,     1,  2048,  128,   32,     8,  1, float16,      1,  1024,  0.017,  0.014,    1.289
  1,     1,  4096,  128,   32,     8,  1, float16,      1,  2048,  0.026,  0.015,    1.723
  1,     4,  2048,  128,   32,     8,  1, float16,      1,  1024,  0.027,  0.026,    1.028
  1,     4,  4096,  128,   32,     8,  1, float16,      1,  2048,  0.034,  0.031,    1.099
  1,  2048,  2048,  128,   32,     8,  1, float16,      1,  1024,  2.103,  0.799,    2.631
  1,  4096,  4096,  128,   32,     8,  1, float16,      1,  2048,  8.280,  3.035,    2.728

@zcbenz zcbenz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work!

@jagrit06
jagrit06 merged commit 360078a into main Oct 23, 2026
30 checks passed
@jagrit06
jagrit06 deleted the digani/sliding branch October 23, 2026 19:38
dhiltgen added a commit to ollama/ollama that referenced this pull request Oct 26, 2026
…9291)

* MLX, MLX-C: version bump

The MLX-C pin now provides its own bindings for gather_qmm global_scale
and fast::gated_delta_update, so those two carried patches drop out.
Carry 0001-mlx-c-sdpa-window-size instead: sliding-window attention
added a window_size argument to fast::scaled_dot_product_attention
(ml-explore/mlx#4734) that MLX-C has not bound yet, to be regenerated
from MLX-C once the upstream binding PR merges. The SDPA wrappers gain
a window size argument; all call sites default to the full context.

* mlxrunner: dispatch sliding-window prefills to the native SDPA window

Sliding layers no longer materialize a causal∩sliding mask for prefill
chunks past the window: resolve() dispatches {causal, window} natively
when the rotating cache's L>1 concat has linearized the ring and the
mask is otherwise pure causal, via a new MaskApplier.NativeWindow hint.
Vision relaxations, padding, model arrays, and decode keep the
materialized path. No model changes; sinks compose natively.
inureyes added a commit to lablup/mlxcel that referenced this pull request Oct 26, 2026
## Summary

- `mlxcel_core::window_sdpa` routes a causal multi-query prefill whose keys outgrow the sliding window either through upstream MLX's native `window_size` with `mask_mode = "causal"` (ml-explore/mlx#4734) or through the explicit full-width windowed mask of before (kept byte for byte). Softcap, sinks, extra mask arrays, `q_len <= 8`, queries longer than keys, empty batches, head dims outside the full-kernel set and every non-Metal backend keep the legacy route by construction.
- `MLXCEL_NATIVE_WINDOW_SDPA` (`0`, `1`, `auto`, default `auto`) selects the route; `auto` takes the native entry only where MLX's own `ScaledDotProductAttention::use_fallback` reports a fused kernel. That verdict comes from a shape probe that is memoized per thread (bounded at 64 entries, keyed on shape, dtypes and arm), returns false for degenerate shapes, and catches MLX exceptions so it can never abort across the cxx boundary. An unknown env value warns once and runs `auto`. `MLXCEL_LOG_WINDOW_SDPA` prints per-dispatch route evidence (shapes, dtypes, window; no prompt data). Both variables are in `docs/environment-variables.md`.
- `RotatingKVCache::attend` carries the ring's window for an unmasked over-window multi-token step (it ran unmasked, non-causal attention before; only Gemma 3 can reach it, and before this PR every Gemma 3 path built the mask so the branch was unreachable). Gemma 3, its stage model and VLM backbone, and Gemma 4's text-only prefill skip building the sliding mask when the plan is native, so production prefill reaches the route.
- The model-level plan uses the K/V dtype the sliding caches actually return (`RotatingKVCache::fetched_kv_dtype`: f16 for `fp16+turbo4`, the input dtype otherwise) and goes native only when every sliding cache agrees (`--turbo-boundary-v` mixes modes per layer). The plan and each layer's decision therefore match, so TurboQuant modes keep one mask build per forward instead of rebuilding it per layer.
- On the pinned MLX at pre-M5 Metal, head dim 256 (every cached sliding-window checkpoint) is fused only for a fresh f16/bf16 prefill of 2048 rows or more, so with `DEFAULT_PREFILL_CHUNK = 2048` the route engages on a prompt's first chunk and continuation chunks stay legacy; head dim 128 is fused at any width.

## Measurements (M1 Ultra, `docs/benchmark_results/native-window-sdpa-m1ultra-2026-10-26.md`)

- Enablement criterion, fixed before timing: (a) correctness suite at stated tolerances, (b) 0 logit-trace disagreements on decided positions, (c) a repeatable full-model prefill gain of at least 3% with non-overlapping ranges on at least one eligible shape and no eligible shape slower than its noise band. All three hold; (c) rests on one shape (Gemma 4 E4B, 2327 to 2257 ms median, 3.0%), which the report states.
- Kernel level: on the shapes `auto` selects, 0.50x to 0.11x of the legacy time at W=512 and 0.89x to 0.20x at W=1024, call peak memory 94 MiB to 26 MiB (Gemma 3 1B, 2048 rows) and 5376 MiB to 640 MiB (31B geometry, 8192 rows); graph-fallback shapes neutral to 4% slower, which `auto` keeps legacy; head dim 128 0.43x to 0.06x.
- Full model: Gemma 4 E4B prefill -3.0% at 2105 tokens (n = 6, non-overlapping ranges), 31B -5.8% to -13.7% at 4129 and 8187 tokens (n = 2, large legacy-arm variance, direction only), Gemma 3 1B inside its 2% to 3% noise band; decode and process RSS unchanged; `auto` dispatch counts 22/35/50 per prompt, all fused.
- Logit trace (`--decided 2`, widths 2048 and 4096, route lines confirm `native_fused=true`): 0 disagreements on decided positions for Gemma 3 1B (f16, 24/8192 near-tie flips, all rank 2) and Gemma 4 E4B (bf16, 0 of 3150 decided); the reverted arm against itself is byte-identical; width 512 (graph fallback on both arms) identical in effect.
- Behavior change: greedy text on bf16 Gemma 4 differs from the previous release at near-tie positions (MLX's graph fallback rounds scores and probabilities to the activation dtype; the fused kernel keeps f32). Gemma 3 1B is byte-identical across arms. `MLXCEL_NATIVE_WINDOW_SDPA=0` restores the previous route.
- Not run: M5/NAX hosts (the pinned dispatch fuses head dim 256 at every width there, so `auto` would engage on more shapes and needs its own measurement), CUDA and ROCm (unchanged by construction), any head-dim 128 sliding-window checkpoint at the model level, and TurboQuant cache modes timed in either arm.

## Changes during review

- Model-level plan now accounts for the cache's K/V dtype and requires agreement across sliding caches; before, `fp16+turbo4` on a bf16 model planned native and then declined in every sliding layer, rebuilding the mask per layer.
- Fused probe memoized and made exception-safe; eligibility rejects empty batches and zero query heads.

## Test plan

- [x] `cargo test --workspace --profile test-fast --features metal,accelerate --no-fail-fast` on cc18090: 13896 passed, 0 failed over 176 binaries
- [x] `cargo clippy --workspace --all-targets -- -D warnings` and `cargo fmt --check` clean
- [x] `window_sdpa_tests::` (19): native vs legacy vs f64 host reference over 8 shapes at f32/f16/bf16, MHA/GQA, W=1, continuation, rotating-cache wrap, trim and decode; invisible keys bitwise inert; eligibility exclusions; cache-mode plan dtype; probe memo bounds and degenerate shapes
- [x] `attend_tests::batched_paged_one_row_is_one_pooled_launch` failed once in an earlier full run (process-global paged launch counter, code this PR does not touch) and passed on every rerun, including both later full gates
- [x] Real-model runs on `gemma-3-1b-it-4bit`, `gemma-4-e4b-it-4bit`, `gemma-4-31b-it-4bit` with route evidence from `MLXCEL_LOG_WINDOW_SDPA`

Closes #2621
rick-github added a commit to rick-github/ollama that referenced this pull request Nov 8, 2026
* server: extract GGUF metadata and unify capabilities (#17858)

Loading GGUF metadata is an expensive operation. Two caches had evolved to
mitigate this, and the two capability implementations produced inconsistent
results for some models.

This PR now extracts the metadata once per blob into a file at
<OLLAMA_MODELS>/metadata/sha256-<hex>.json. Only arrays over 4096 elements and
non-finite floats are left out.

Direct Capabilities() discovery now costs us instead of ms.  /api/tags can
build directly from manifests and the extracted metadata.

* mlxrunner: capture whole-state at close for nodes split out of an edge

KV snapshots must cover a node's edge exactly. Recurrent and
sliding-window state is only useful at a node's end, and a node may
have none: a request resuming there lands on the previous checkpoint
and begin schedules a capture at the match.

The header claimed every node carries its snapshots from creation,
which a node split out of an existing edge at close cannot. That hid a
gap: when a response is a prefix of a stored one, close lands on the
split-off head with the caches resting at its end, and pageOut skipped
the capture because the node already had a KV snapshot.

Restate the header as the rules that hold, and make pageOut capture
whatever layers a node is missing. The scheduling comment also said
eviction preserves user nodes; it only resists compaction.

* mlxrunner: keep cache boundaries out of non-causal media items

The tokens of a non-causal media item attend to each other in both
directions, so the item has to be evaluated in one forward. Prefill
honors that when it picks chunk boundaries, but the prefix cache did
not: a snapshot could be taken partway through an item, and a request
that resumed there would evaluate the rest of the item alone and
compute different attention for it.

Snapshots scheduled inside a non-causal item now land at its end, and
a match that ends inside one resumes at its start.

* mlxrunner: keep the reused head of a cached edge safe from eviction

When a request resumes partway through a cached edge, the node holding
that edge was dropped from the active path, because the path has to end
at the live offset for close and the prefill captures to extend the trie
from its last node. Off the path, the node was an ordinary leaf with a
stale last-used time, so eviction removed it first.

The captures taken during that request start at the resume offset, but
attach rebuilds the missing node from the path's last node, so the new
node's edge begins earlier than its KV snapshot. A later request
resuming there was refused by the KV cache and re-prefilled from
scratch. If eviction first merged the node into its parent, the two
snapshots were concatenated as if adjacent, and the restore reported a
hit while the buffer held tokens from other positions.

Split the node at the live offset instead. The head stays on the path
and gets the last-used update. Only the unused tail can be evicted, and
losing it costs nothing. The split only happens when every layer can
rewind into the edge, so it never involves a recurrent layer, and the
head gets the same KV-only snapshots a close-time split already
produces. When the request follows the edge, compaction merges the
halves back.

* mlxrunner: evict the active conversation's own checkpoints under the budget

Eviction skipped every node on the active path, so a conversation's own
turn checkpoints were never reclaimed no matter how far over budget the
trie was. On models with sliding-window or recurrent layers each turn's
checkpoint is a full copy of that state, 800 MiB per turn on
gemma4:31b-mlx, and a long chat grows without bound. The scheduler then
counts that memory as in use and evicts the model to load anything
else.

Only the frontier and branch points are protected now. Any other node,
active or not, is evicted least recently used first. On the active path
that merges a turn into the next one: the merged node keeps the newer
whole-state, and the KV snapshots there are lazy views of the live
buffer, so nothing is copied. Rewinding to an evicted turn resumes at
the newest surviving checkpoint before it.

qwen3.8:27b-mlx on an M5 Max, the same short question every turn with
24 tokens generated per reply, 8 GiB budget, 17.2 GiB of weights:

  turn | before: paged out  nodes  reported | after: paged out  nodes  reported
    11 |          4.61 GiB     33  21.6 GiB |         4.61 GiB     33  21.6 GiB
    21 |          7.91 GiB     56  24.9 GiB |         7.92 GiB     56  24.9 GiB
    31 |          8.46 GiB     60  25.5 GiB |         7.94 GiB     56  25.0 GiB
    41 |          9.90 GiB     70  26.9 GiB |         7.96 GiB     56  25.0 GiB
    50 |         11.19 GiB     79  28.2 GiB |         7.98 GiB     56  25.0 GiB

Fixes #17783

* mlxrunner: bound MLX loads by system free memory while other models are loaded

On Apple silicon the scheduler's free-memory figure for the GPU is the
Metal working set minus what Ollama's own runners report. It does not see
memory held by other applications, so a second MLX model can pass the fit
check on a machine that is already short of memory, and the load pushes
the system into swap and compression.

While other models are loaded, the MLX fit check now also bounds the
available memory by the system's free memory on shared-memory GPUs, the
same rule llama-server loads already apply. A miss evicts an idle model
and retries instead of starting the load. First loads are unchanged: with
nothing else loaded, the model loads against the working-set figure alone,
as both engines do today. The check also does not cover memory that grows
after load, such as KV caches and prefix-cache snapshots.

* mlxrunner: wait for a killed runner to exit before the scheduler loads the next model

The scheduler starts the next load as soon as Close returns. The MLX client
sent SIGINT, gave the process five seconds, then sent SIGKILL and returned
without waiting, so a runner that could not take the signal was still
exiting, with its memory still held, when the next load began. The runner
has no signal handler, so SIGINT was already a kill.

Load also started the process and recorded it without the client's mutex,
so a Close racing with a load at server shutdown could find nothing to stop
and leave the runner it missed running.

Close now kills the process and waits for it to be reaped, as the
llama-server client does. Load starts and records the process under the
mutex and refuses to start once Close has run.

* llm: raise token repeat limit to 100 and return error instead of silently closing (#18374)

* mlx: scope array lifetimes instead of pinning and sweeping

The bindings freed arrays by sweeping everything not pinned, so freeing
anything required knowing what every other caller still held, and code
that never swept accumulated until memory ran out. The prefix cache's
eviction of a long stored path did exactly that: each merge copied the
KV snapshots and nothing freed the consumed copies until the request
ended, which drove a second long request past physical memory.

Every array now belongs to a scope. A function scope, entered with Scoped
or one of the ScopedEval forms, frees what was created in it when the
function returns; results leave only by being returned. A held scope is
closed by its holder and frees what was attached to it. A graph is
built in a function scope and evaluated after it, so the eval frees each
intermediate as it consumes it. Pin, Unpin, Sweep, and the array list's
mutex are gone.

On an M5 Max with qwen3.8:27b-mlx, the second 84k-token request after a
stored one peaks at 35 GB instead of 57 GB; the cold path is unchanged.
The copies themselves are untouched, so restoring an owned path can still
exceed memory.

* mlx: drop the empty-handle checks outside the bindings

Models and layers checked optional weights for nil and also for a handle
that no longer refers to an array, and evaluation and weight collection
skipped such handles. No path produces one: a missing tensor is nil, and a
handle only loses its array when its scope frees it, after which using it
is a bug. The nil checks stay; the validity check is internal to the
bindings now.

* mlxrunner: release the buffers weight loading leaves in the MLX pool

Loading a model can transform tensors after reading them: qwen3.5 models
pack their linear-attention projections into one layout, and MoE models
fuse the gate and up expert stacks. The buffers those transforms consume
go back to MLX's allocator pool rather than to the system, and nothing
releases the pool until the first request finishes. On qwen3.8:27b-mlx
that is 2.15 GiB held idle on top of 16.9 GiB of weights, counted in the
runner's reported memory the whole time.

Clear the pool once the weights are evaluated. Models whose tensors load
unchanged, such as gemma4, leave nothing in the pool and are unaffected.

* cmd: remove built-in agent (#18393)

* llm: keep gemma3n projector off the CPU (#18376)

Gemma3n's MobileNetV5 projector silently produces corrupted image
embeddings on the CPU backend - no error, the model just describes the
wrong image (reproduced on llama.cpp b10760; gemma4's encoder is fine on
CPU). Without this guard the existing partial-offload, limited-VRAM, and
OOM-retry fallbacks would pick the CPU projector on exactly the small
GPUs where gemma3n lands.

* app: refresh Apps layout and command copy feedback (#18372)

* MLX: version bump (#18235)

* MLX: version bump

* mlx: support ModelOpt global scales in MoE models

* address comments

* address comments

* docs: add ChatGPT Desktop integration (#18377)

* mlx: add mlx patch to docker build context (#18440)

* create: add server-side MLX imports and drop GGUF conversion (#14969)

* create: add server-side MLX imports and drop GGUF conversion

Support safetensors imports through the MLX create pipeline both locally and on the server, including remote upload/staging, draft layer handling, cancellation propagation, transfer limits, and shared manifest/blob writing.

Limit GGUF create to wrapping existing GGUF inputs into Ollama manifests. Remove the in-tree safetensors-to-GGUF converter, server quantization path, and converter-only dependencies so GGUF conversion and quantization stay in llama.cpp tooling.

Keep the MLX path focused on supported safetensors model creation with validation before MLX work, and expose that flow without the --experimental CLI gate.

* address comments

* add client side gguf create fast path

* address comments

* rebase adjustments

* MLX, MLX-C: version bump (#18449)

Includes quantized matmul corruption fix, which impacts nvfp4 multimodal models (gemma4 vision towers). Deferring wiring up the new MLX-C thread-local stream/sync APIs for now.

* API: Deprecate typical_p (#18448)

Drop support for creating new models with typical_p parameters, while
retaining support for existing GGUF models with the setting.

* docs: refresh getting started guides (#18450)

* llama.cpp: version bump b10969 (#18446)

llama.cpp build changes resulted in duplicate symbols between libllama and libmtmd.  This moves the compat patch into libllama with exported symbols.

* cmd: launch the MLX runner without the engine dispatcher

The runner package used to pick an engine from the first argument of the
runner subcommand. Only the MLX engine is left, so the dispatcher has a
single arm, its README still describes the removed Go runner's flags and
endpoints, and the standalone cmd/runner binary exists only to invoke it.

We call mlxrunner.Execute directly from the hidden runner subcommand and
drop the --mlx-engine argument from the command line the MLX client
spawns. Both sides ship in the same binary, so nothing has to accept both
forms. The runner package and cmd/runner are removed.

The subcommand's help hook hands the runner a bare --help. cobra calls the
hook with no arguments for `ollama help runner`, which used to index past
the end of the slice.

* tokenizer, ml: remove dead code

Several pieces outlived the code that used them. The root tokenizer
package implemented the GGUF-side vocabularies for the Go engine and the
safetensors-to-GGUF converter; nothing has imported it since the
converter went. ml/backend.go held the Go engine's Backend, Context and
Tensor interfaces, with fs.Config existing only to be returned from them,
and a single CUDA template instance under ml/backend/ggml survived the
engine removal along with the gitattributes entries for that tree and the
CI change-filter globs for it and for the long-gone llama/llama.cpp. From
the image generation engine, an integration test group that no test
registers, its build tag, and the StepBar progress widget remained.
DeviceInfo.IsBetter has no caller at all.

All of it goes. Tidying the module file drops the regexp2 dependency and
leaves protobuf as an indirect requirement. The llama3.2 tokenizer
fixtures stay: the MLX runner's tokenizer uses them for its GGML parity
test.

* mlx, mlxrunner: move the MLX engine out of x/

The MLX runner is the only Go inference runner left and is no longer
experimental, so its packages leave x/. The bindings become a top-level
mlx package beside the carried patches in mlx/compat, mirroring how
llama/ holds the llama.cpp integration, and the runner becomes mlxrunner
with the architectures nested under the package they implement.
Subpackages move with their parent unless listed.

  x/mlxrunner/mlx            mlx
  x/internal/mlxthread       mlx/mlxthread
  x/internal/mlxthreadtest   mlx/mlxthread/mlxthreadtest
  x/internal/mlxtest         mlx/mlxtest
  x/quant                    mlx/quant
  mlx/compat/*.patch         mlx/compat/mlx-c   (MLX patches go in mlx/compat/mlx)
  x/mlxrunner                mlxrunner
  x/models/nn                mlxrunner/nn
  x/models/<arch>            mlxrunner/model/<arch>
  x/mlxrunner/imports.go     mlxrunner/model/architectures   (new package)
  x/create                   create
  x/safetensors              fs/safetensors
  x/tokenizer                mlxrunner/tokenizer

Every package keeps its name, so the Go changes are the import path
rewrites the moves force, and the CMake, Dockerfile, CI cache keys, drift
check and Darwin payload script follow the new paths. Four edits are not
paths: the runner's blank architecture imports become the package
mlxrunner/model/architectures, so the list to extend for a new model sits
beside the architecture directories; a depguard rule keeps the two test
harnesses out of non-test code, as the x/internal placement used to; the
CI change filter's two entries for the long-deleted x/imagegen/mlx now
name the bindings' CMake project and the carried patches, so a change to
either builds the payload; and the tokenizer parity test reads its
fixtures from its own testdata instead of walking out of x/.

x/server and x/imagegen/manifest stay for the next two commits.

* mlxrunner, cmd, server: fold three small packages into their users

model/base held the Model interface and the architecture registry while
model held weight loading and quant parameters, and every architecture
imported both. create/client was the CLI side of safetensors imports,
with the create command as its only caller, a duplicate of the command's
adapter error, and a name that read like a second API client. The
safetensors show helpers had their own package under x/ although it
already declared package server.

base merges into model, so base.Model and base.Register become
model.Model and model.Register; nothing in the two overlapped. The create
client's two files and their tests join package cmd, and the five names
the command called are no longer exported. The show helpers join the
server package, and the three entry points routes.go calls become
unexported like the helpers around them.

* mlxrunner: read model manifests through the manifest package

The runner and its weight loader read a model's manifest through
x/imagegen/manifest, the last piece of the removed image generation
engine. It was a hand-rolled copy of the manifest package: its own model
name parser with the default registry and namespace spelled out, its own
blob path builder, and re-spelled media types, plus a model_index.json
reader and other helpers that nothing has called since the engine went.

The manifest package gains the three lookups the runner needs, a config
layer by path, its contents, and the tensor layers, and ReadConfigJSON is
built on the second of them. The weight loader resolves the model name
with the shared parser, which fills in the same defaults the copy did, and
locates blobs with BlobsPath. The architectures' calls to read their
config.json compile unchanged. x/imagegen is gone.

* mlxrunner: lay out nn one layer kind per file

nn.go held every layer type in the package apart from attention,
recurrence and rope: the Linear and Embedding interfaces with their dense
and quantized types, Conv1d, RMSNorm, LayerNorm and MultiLinear, with one
test file to match. Finding a layer meant scanning the file named after
the package.

Each layer kind gets its own file: linear.go and embedding.go hold the
interface and the dense and quantized types, conv.go, norm.go and
multilinear.go take the rest, and nn_test.go splits the same way. The
Layer and MultiLinearLayer interfaces go; nothing implemented or accepted
them. No code changes otherwise.

* mlxrunner: lay out model by contract, checkpoint and construction

model is one package with three jobs: the contract between the runner
and the architectures, the opened checkpoint, and building nn layers
from checkpoint tensors. Its files did not say which was which. base.go
carried the folded package's name over the interfaces and the registry,
root.go held the safetensors header scan next to Root, and quant.go
mixed the nvfp4 global-scale helpers with quant parameter resolution.

base.go becomes model.go, named for what it holds. root.go keeps Root
and Open; TensorQuantInfo and the header scan join quant.go, so
everything the checkpoint says about quantization is read and resolved
in one file. The global-scale helpers move to globalscale.go with their
tests. Root.Close, a no-op with one caller, goes. No code changes
otherwise.

* docs: fix cloud retirements settings link (#18496)

* app: clarify Claude connection dialog (#18498)

* app: add Apps deep link (#18497)

* mlxrunner: Release freed KV buffers during speculative decode

The decode loop releases MLX's pool of freed buffers every 256 generated
tokens, which is also how often the KV cache grows and drops its previous,
smaller buffers. The check fires only when the token count lands exactly on
a multiple of 256. Speculative decoding emits several tokens per round, so
most rounds step over the boundary and the pool is never released. Each
growth at a long context leaves several GB of buffers that no later
allocation can reuse, so the runner's footprint keeps climbing over a long
generation until the system runs out of memory.

We now release the pool whenever a round crosses a multiple of 256 tokens,
which is what a single-token round already did. With qwen3.8:27b-mlx at a
98k-token context on a 128 GB machine, a long speculative generation
previously grew the runner past 90 GB and panicked the kernel; it now stays
flat at 30 GB.

* cli: add first-run onboarding shared with the desktop app (#18495)

* docs: clarify integrations overview and add assistant icons (#18511)

* x/transfer, server: tighten redirect handling for registry requests (#18512)

Redirects for registry and blob transfers now validate the target scheme
and resolved addresses before following, re-check DNS on each redirect,
and do not follow redirects that switch an https session to plain http.
The --insecure option continues to relax address checks for private
registries but not scheme checks.

* ci: harden release artifact uploads (#18516)

Serialize final release jobs and delete old assets before retagging to
avoid overlapping updates and mixed-version payloads.

Keep uploads parallel and retry failures twice with 15s/30s delays.
Retry cleanup using a fresh asset list and upload the checksum manifest
only after all payloads succeed.

* nemotron_h: add MLX vision support (#17714)

* nemotron_h: add MLX vision support

Implement the RADIO vision encoder and projector on the shared MLX media pipeline, including dynamic-resolution preprocessing, deterministic placeholder expansion, chunked feature scattering, and MTP offsets.

Expose source-advertised Nemotron vision while continuing to suppress unsupported audio, and preserve both modality towers at source precision during create.

Harden Nemotron streaming parser termination and add focused coverage for vision configuration, media placement, capability reporting, and tool-call parsing.

* review comments

* address comments

* tests: fix metadata deletion test flake (#18493)

Test both publication/deletion orderings directly instead of polling for a short-lived temporary file with a machine-dependent timeout.

* app: keep closed macOS windows from reopening on activation (#18518)

* api: expose model thinking levels and defaults (#18473)

* server: allow registry cross-host redirects among allowlisted hosts (#18533)

* server: fix getExistingName canonicalizing model name parts independently (#18438)

getExistingName canonicalizes the case of each model name part (host,
namespace, model, tag) by searching all manifests for a case-insensitive
match. The original implementation matched each part independently —
the tag from any manifest whose tag case-insensitively matched the
requested tag would overwrite the tag, regardless of whether the host,
namespace, or model matched.

A 'set' variable was intended to track which parts had already been
canonicalized and prevent overwrites, but it was never written to, so
it was always zero-valued and every match overwrote the corresponding
part unconditionally.

With 3000+ manifests, if another model had a tag that case-insensitively
matched (e.g. 'Q4_K_M' for a different model), the requested model's tag
could be canonicalized to that other model's tag casing. Go's map
iteration order is randomized, so the last match wins — producing
intermittent 'model not found' errors that succeed on retry.

Fix: when all four parts of an entry case-insensitively match the input,
return that entry's canonical name directly. Otherwise canonicalize each
part independently, with the 'set' variable now properly updated after
each part is set so it is only written once. This handles both exact
matches and new tags on existing models.

* parsers: report the strings that end a response's thinking

A format on a thinking model has to leave the thinking free and constrain
only the content after it, so whatever enforces the format needs to know
where the thinking ends. Today the server guesses whether a parser's
response starts inside thinking from the think value alone, which is wrong
for parsers whose default differs, and it has no way to learn the closing
string at all.

Each parser now answers ThinkingClose after Init: the strings any of which
ends the thinking its response begins with, or none when the response
starts in content because thinking is off, an assistant prefill continues
content, or the parser suppresses thinking for tools. Parsers whose models
open a new message before content end the thinking at that message's
header. Nothing consumes the answer yet.

* mlxrunner: constrain a format after the thinking in one generation

The MLX runner applies a format's grammar from the first sampled token,
so a thinking model asked for a format cannot think first, and the server
has to run two generations to get both the thinking and the formatted
content.

A completion request now carries the strings that end the thinking its
response begins with, and the MLX client builds from them a structural
tag: free text that cannot contain any of them, then one of them, then
the schema. The tail is optional so a response may still end inside its
thinking, as an unconstrained one can. Without a closing string the tag
is the plain schema, as before. The server does not send the strings yet.

* llm: apply a format after the thinking in one llama-server request

llama-server applies a schema from the first sampled token, so a thinking
model asked for a format cannot think first, and the server has to run two
generations to get both the thinking and the formatted content.

The client now sends one request whose grammar leaves the text before a
closing string unconstrained and requires the format after it.
llama-server converts the schema for us: an empty completion evaluates and
generates nothing but reports the GBNF it derived, which we wrap in rules
that recognize the closing strings and cache per schema for the life of
the process. On qwen3 0.6b at temperature 0 the thinking is byte-identical
with and without a format and the JSON follows the schema.

A response that ends before a closing string is delivered unchanged. The
conversion request briefly takes a llama-server slot on a cache miss. The
server does not send the strings yet.

* server: apply structured outputs in a single pass on thinking models

A format on a thinking model ran two generations: an unconstrained one,
cancelled once the parser reported content, then a re-rendered prompt with
the parsed thinking under the grammar. The restart cost a second prefill,
dropped the chunk that crossed the boundary, needed a harmony prompt hack,
stitched metrics across the two requests, and on MLX could leak a stray
first token into the JSON. The generate endpoint never deferred at all, so
its JSON was forced inside the thinking.

Both handlers now make one completion request that names the strings
ending the response's thinking, from the builtin parser or the generic
thinking parser, and the runner constrains only the content after them in
a single generation. The prompt is evaluated once and metrics pass straight
through. A raw generate prompt names no strings, since nothing says where
its response starts, and its format applies from the first token as
before. A format now applies to whatever follows the thinking, so a tool
call can no longer take the place of formatted content, which was already
the case with thinking off; harmony is the exception, since its tool calls
precede the final message.

The per-token metrics flag both runners carried for the cancelled first
pass has no caller left and goes with the two-pass code and its tests.

Fixes #18441
Fixes #17544
Fixes #14196
Fixes #10929

* app: avoid System Events for ChatGPT/Codex detection (#18601)

* llama.cpp: version update (#18577)

Refine memory allocation failure log substrings for upstream changes.

Remove the no longer needed Laguna metal patch - fixed upstream.

* MLX: version bump (#18576)

Plumbs fast::gated_delta_update through a temporary MLX-C patch for now.

* mlx: select Gemma 4 image resolution dynamically (#18603)

Replace the fixed checkpoint image budget with per-image selection across
the supported 70, 140, 280, 560, and 1120 budgets. Choose the publisher resize
grid closest to the input resolution, accounting for aspect ratio.

This preserves more detail in high-resolution documents while allowing
smaller images to use fewer tokens, without adding an API parameter.

Cover budget boundaries, extreme dimensions, position limits, and media
expansion for both vision architectures.

* mlx: speed up Qwen 3.8 prompt processing (#18550)

* mlx: speed up Qwen 3.8 prompt processing

Use MLX's gated-delta kernel for long scans and fold dense MLP global scales into SwiGLU.

* address comments

* docs: document thinking control discovery (#18501)

* xgrammar: add standalone CMake project for native library (#18611)

Move the ollama_xgrammar target into mlxrunner/xgrammar/native so it
can be configured on its own against an installed xgrammar. cmake/mlx
now adds it as a subdirectory and still uses the pinned xgrammar.

* launch: default Claude Code to client-side auto checks (#18596)

* mlxrunner: Update XGrammar to 0.2.7 for structured outputs

We pick up schema fixes for typed dictionary values and short arrays.

* app: sync macOS update menu and icon at startup (#18622)

* app: defer Settings model discovery (#18598)

* app: isolate cloud-setting tests from Windows user config (#18626)

Set USERPROFILE alongside HOME in both cloud-setting handler tests.
On Windows, os.UserHomeDir uses USERPROFILE, so the tests could write
to the developer's real server.json and leave cloud disabled.

* api: deprecate typical_p (#18627)

Switch from rejecting API requests to logging a warning.  Model creation still rejects the deprecated param.

Follow up from #18448 to remove the hard API failure.

* llama-server: prepare to remove compatibility patch

Add manifest-list storage so runner-specific manifests can coexist under one tag while preserving existing v1 tags as best-effort downgrade anchors. Show/list/copy/remove/pull/push now understand runner and digest selection and transfer referenced child manifests and layers.

Add lazy local compatibility migration for legacy Ollama GGUFs into llama.cpp-compatible children, covering the patched model families and preserving parser/renderer, templates, projectors, media metadata, split GGUFs, and MTP/draft tensors where applicable.

Extend create/import/conversion paths for the same compatibility rules, harden manifest-list combine validation, and add focused manifest, migration, transfer, and integration coverage for first-load conversion plus chat/tools/vision/audio/embedding behavior.

* bench: use HumanEval patch prompts (#17480)

* bench: use code prompts for prompt-token runs

Replace the synthetic word-list prompt with packed HumanEval Python prompts so speculative draft models see code-like continuations.

Keep the benchmark on the chat path, and calibrate -prompt-tokens with untimed chat probes that read PromptEvalCount instead of relying on a separate token-count API.

Each request still gets a nonce prefix to avoid prefix-cache hits while timed epochs measure the chat-rendered workload.

* review comments

* use different windows for each epoch

* add OpenAI API support

* address comments

* feat: add System One scoring API (#18606)

* mlx: bound pull stall retries and let the watchdog interrupt them (#18625)

* transfer: bound stall retries and let the watchdog interrupt them

A download that stalls could never recover. copy derived its own
cancellable context, but the request was built from the parent, so
cancelling on a stall never reached the in-flight body and the read
stayed parked. The stall watchdog could detect a stall it had no way
to stop.

Stall retries were also unbounded: they never incremented attempt, so
the retry loop had no limit, and because backoff was gated on
attempt > 0 they retried with no delay at all.

The request now owns the cancellable context and passes its cancel
down to copy, so a stall aborts the read. Stalls get their own retry
budget before counting against the limit, and backoff is keyed to
every retry rather than only the counted ones.

* move out of x/

* feat: allow ten web searches per response (#18602)

* MLX: version bump (#18651)

* llama.cpp: version bump b11232 (#18652)

* create: support explicit model capabilities (#18708)

Add CAPABILITY declarations to Modelfiles and an additive capabilities
field to create requests. Preserve declarations across GGUF and safetensors
creation, inheritance, and Modelfile export.

Require decision capability before scheduling System One requests instead
of matching Qwen architecture/renderer metadata. Retain main's GGUF-only
scoring restriction until the separate MLX runtime work lands.

Extracted from the capability foundation in 36d46a0c3 on system_one_mlx;
MLX scoring and manifest-list changes are intentionally separate.

* docs: document System One API (#18702)

* openai: keep tool message content parts in one message

FromChatRequest splits array content into one api.Message per part. That
is intended for user content, but a tool message is a single result: the
split also dropped its tool_call_id and tool name, since those were only
copied when the message had tool_calls. Renderers that resolve tool
results by ID then see extra, unnamed results; for example, Kimi K3 fails
with "tool message 2 has no resolvable tool name" on a tool result with
two text parts, which the OpenAI spec allows.

Merge the parts of a tool message into one message with the text joined,
the images kept, and ToolCallID and ToolName set, matching how
function_call_output items are converted for /v1/responses.

* openai: keep empty tool results sent as an empty content array

A tool message with "content": [] produced no message at all, so the
tool call it answers had no result in the rendered prompt. Emit an empty
tool message that keeps its ToolCallID and ToolName, and skip it only
when it has no parts, call id, or name.

* server: report only decision capability for decision models (#18737)

Show and list now return just "decision" for models declaring it, so clients don't offer them for general chat, tools, or thinking. The show response also omits the thinking field for these models. Scheduling and serving still check the full capability set.

* README: add oxi to community integrations

* models: add clef support (#18741)

* ci: fix missing build context (#18742)

* openai: keep image positions when merging tool result parts

Merging a tool result's parts collected its images separately from the
text, so renderers placed them all before the text: "Before: <A> After:
<B>" rendered as "<A><B>Before: After:". Write an [img] placeholder at
each image's position so renderContentWithImageTags and chatPrompt put
each image back where it was.

* docs: link to available decision models (#18758)

* docs: document image input for decision models (#18757)

* openai: split tool results with images instead of adding [img] markers

The [img] placeholders mixed internal markers into tool text: the native
llama-server path sends them as literal text, so an image-only result
gained a text part, and tool output containing [img] or [img-N] moved or
dropped image tags. api.Message cannot carry image positions without
in-band markers, so stop merging tool results that include images.

Text-only tool results, the only array form the Chat Completions spec
allows for tool messages, are still merged into one message (now with a
strings.Builder). Results with images keep the per-part split in order,
which preserves image positions, with the tool call id and name set on
every part.

* mlx: System one support (#18701)

* mlxrunner: restore System One scoring

Carry the MLX implementation and its tests from the original System One
commit. The API/compiler and llama-server implementation already exist on
the release branch, so retain those versions. Adapt the optional model test
to the renamed decision package and its explicit rendering/context setup.

(cherry picked from commit 26e546ddb3897b4564f03d3bdbdbefce9281edf8)

* Enable MLX System One and add regression coverage

* mlxrunner: add Laya support for System One

Import Laya checkpoints and implement bidirectional decision scoring.

* mlxrunner: release cached buffers after System One scoring

* decision: match Tev1 and Nimble publisher prompt formats

Select Tev1 prompts using renderer metadata and fix JSON formatting, with regression coverage for GGUF and MLX.

* mlx: support Clef and Clef Flash decision models

Add model import, quantization safeguards, and text/image scoring with the Clef joint decision head.

* support vision capabilities for decision models

* Make Clef scoring cancellable between prefill chunks

Preserve joint-head inputs and test cancellation, cleanup, and recovery.

* mlx: separate decision preparation and readout from forward

Let serial and batched scoring share model-owned preparation and readout
without duplicating architecture-specific logic in the runner.

* mlx: add Strands Decider support

* implement caching

---------

Co-authored-by: ParthSareen <[email protected]>

* mlx: Decision model improvements (#18776)

* reject instead of truncate on overflow

* tune route logic for faster warm runner lookup

* mlx: match publisher tokenizer semantics (#18779)

* mlx: match publisher tokenizer semantics

Honor pretokenizer stage order, split behavior, Unicode boundaries,
added-token normalization, and ranked BPE merges. Handle empty added
tokens and empty Metaspace input consistently.

Add shared Go/Python reference cases using published tokenizers, pulling
missing models directly and failing on errors, plus focused regressions
for configuration precedence, byte fallback, and parallel encoding.

* address comments

* pull: allow RCs to pull matching min_version (#18790)

Strip off pre-release from the version string so RCs can pull
models for the same release.

* test: split create integration tests out (#18470)

The create tests upload blobs which can cause problems when run in parallel on multiple systems.  This change splits them out with an explicit tag to make it easier to control when they are run.

* mlx: mitigate high latency after GPU idle (#18807)

Carry the MLX residency-refresh patch and enable it every second in the
runner, preserving explicit environment overrides.

Fixes #18744.

* Reduce model lookup and MLX decision request overhead (#18806)

* Reduce model lookup and MLX decision request overhead

Avoid decoding unrelated manifests when resolving existing model names.
Reuse small Metal scratch buffers between decision requests, releasing
larger working sets and clearing scratch after scoring errors.

* address comments

* llama.cpp: version update (#18761)

* MLX: version bump (#18720)

* MLX: version bump

* add scopes for unit tests to reduce memory usage

* mlx: fix patch for recent mlx update (#18812)

* docs: fix 6 dead links in README community integrations list

* model: add multimodal embeddings (#18820)

Implements the EmbeddingGemma2Model architecture on the MLX runner: 24-layer
bidirectional text encoder with PLE, shared gemma4 vision/audio towers,
mean-pool + L2 output. /api/embed accepts per-item media via input dicts.

* routes: fix embed 413 vs 400 routing (#18822)

* documentation re-structuring

* reorganizing the docs folder, adding error handling to the sample project, changing wording

* server: proxy cloud usage and balance APIs (#18829)

Forward GET /api/usage and GET /api/balance through the local server
using the signed-in account.

Add API documentation and tests for proxying, signing, and
disabled cloud access.

* llama: fix clef head reads past 2GiB on windows (#18777)

The Clef head read its weights with std::ifstream::seekg. The Windows
llama-server ships with libc++ 18.1.8, where that seek truncates the
offset to 32 bits. clef-flash stores the clef.* tensors at about 9.5GB,
so the head loaded backbone bytes as its weights and every
/v1/systemone request failed with "Clef: non-finite logit". clef:27b
keeps the head and output.weight below 2GB and was unaffected.

Read with ggml_fopen and an explicit 64-bit seek instead, as read_at
in llama/compat already does.

Fixes #18769

* keeping old urls, updating model retirement page

* cmd: remove account step from CLI onboarding (#18826)

* changing wording

* removing repetition, fixing a typo

* re-ordering top nav, splitting out sample project into new PR

* manifest: avoid symlinks on Windows (#18852)

Store named manifests as regular files on Windows, where symlinks can
be created successfully but fail when opened.

Repair existing symlinks lazily on read using the verified blob and
existing copy path. Keep locking consistent across platforms and avoid
reacquiring the store lock during pruning.

Fixes #18847

* mlx: drop carried metal residency patch now that it is upstream (#18854)

* Set CLAUDE_CODE_MAX_CONTEXT_TOKENS to whatever the models context window is

* server: hide duplicate and downgrade guards from list (#18874)

When a legacy GGUF which requires our llama.cpp patch set is loaded, we do a
lazy conversion on disk to make it llama.cpp compatible.  To support
downgrades, we temporarily hold both the new and old GGUFs and create a shadow
v1 manifest tag to prevent the downgraded server from deleting the new blobs.
Showing these in the list output is confusing to users and API consumers.  The
legacy copies will be removed in a future release to recover the disk space.

* respect CLAUDE_CODE_AUTO_COMPACT_WINDOW user setting

* launch: avoid inherited service-tier warnings in Codex (#18879)

* standardizing language referring to cloud services

* launch: suppress Claude Code connector warning for Ollama (#18878)

Co-authored-by: Parth Sareen <[email protected]>

* server: skip local model compatibility migration (#18908)

* decision: align request validation and option descriptions

* llama: update to b11521 and use native decision support

* llm: support multimodal embeddings through llama-server

* mlx: clip long laya states instead of rejecting them

* mlx: read candidate logits in float32 for quantized heads

* server: reuse verified manifests and loaded models in inference routes (#18947)

* server: reuse verified manifests and loaded models in inference routes

Resolve named manifests and runner selection in one verified cold lookup.
When a runner is loaded, reuse its model after checking that the v2 tag
still points to the same digest. Fully verify regular-file manifests,
including Windows copies.

Share the lookup across generate, chat, embed, and System One. Keep parser
selection request-local so reusing a model does not mutate its config.

Cover tag changes, runner selection, concurrent unloads, and existing
missing-model responses with regression tests and a lookup benchmark.

* address comments

* mlx: compact restored recurrent state after speculative rollback (#18955)

* mlx: compact restored recurrent state after speculative rollback

Per-token recurrent captures can leave a restored state pointing into a larger buffer. If a request ends before another model step, the live cache retains that buffer even though it accounts for only the selected state.

Track when a restored state may share that backing buffer. At request close, compact marked states in one batch before retaining them in the prefix cache. Clear the marker when a normal model step replaces the state, and cover restoration and buffer detachment in tests.

* address comments

* launch: populate Codex model picker with installed Ollama models (#18887)

* MLX, MLX-C: version bump (#18956)

* typo in docs

* docs: update README to include cloud and privacy language

* Revert "docs: restructuring" (#18960)

* docs: update SECURITY.md

- Directs users to Github advisories instead of hello email address

* Introduce clef and clef flash on cloud

* server: fix multimodal embedding load with small num_ctx (#18973)

* Add Kev decision scoring to MLX (#18976)

* Add Kev decision scoring to MLX

Load Kev models with their FP32 decision head and release metadata.
Support System One scoring with shared-state caching and Kev-specific limits.

* address comments

* mlx: preserve generation panics during cleanup (#18886)

A failure during decoding can trigger deferred drain and cache close, which may panic again and hide the original error. Skip stateful cleanup while a panic is unwinding so the runner reports the initial failure.

Add regression tests for the masked panic paths and normal cache saving.

* ci: harden download steps with retries (#18883)

Try a little harder instead of giving up on the first failure.

* gemma4: use MLX SDPA for CUDA prefill with wide head dims (#18809)

MLX's SDPA already handles head dims > 128 on CUDA, and is faster than our formerly required hand-rolled one.

* docs: changing model recs to Models page link, updating references to Ollamas cloud

* Add decision model integration tests and benchmarks (#18746)

* Add decision model integration tests and benchmarks

Support external JSONL corpora, quality scoring, concurrent requests, vision, and System One timing metrics.

* Refine decision tests and benchmarks with cache checks, external endpoints, and consistent response validation and timing

* cli: add decision model support to `ollama run` (#18962)

* decision: fix JSON state prompts for MLX decision models (#18974)

* renderers: add Python json.dumps serializer

* decision: render JSON states like the publishers' json.dumps

* Update README for improved privacy wording

* app: clarify cloud payment errors

* launch: allow usage credits without upgrading (#18985)

* mlx: port the Metal custom kernels to CUDA (#18657)

* mlx: port the Metal custom kernels to CUDA

mamba2_scan, depthwise_conv_silu and gated_delta (plus their _states/_bias
variants) had a Metal source only, so on CUDA each fell back to graph ops.

Deviations from the Metal sources:

- The scan returns early past D: Metal dispatches an exact thread count,
  CUDA rounds the grid up to whole blocks.
- T is dereferenced; CUDA passes inputs by address, Metal scalarizes
  zero-dimensional ones.
- simd_sum becomes a shfl butterfly, and the threadgroup q/k caches become
  per-warp registers: each warp normalizes the row its own lanes consume,
  costing a redundant norm but no shared memory and no barriers.
- The gates and SiLU call MLX's Sigmoid/LogAddExp/Exp instead of restating
  their formulas. Metal cannot: its custom-kernel preamble is metal::utils()
  alone, while CUDA embeds the op headers for nvrtc.

The parity tests now run on Metal and CUDA hosts.  The fused gated-delta
comparison takes a tolerance: the kernel and the graph path reduce in a
different order, so the bf16 output can land one ULP away.

* address comments

* openai: accept custom tool calls in Responses history (#18911)

Co-authored-by: Jeffrey Morgan <[email protected]>

* MLX: version bump (#18993)

* revert docs changes for now

* use cloudPassthroughMiddleware

* server: stop HTML-escaping cloud proxy request bodies (#19008)

* proxy: pass through ChatGPT upstream access errors (#19007)

* openai: clarify Responses authentication errors (#19004)

* New model... (#19030)

* ci: shorten Windows Vulkan build path

Keep the nested shader-generator compiler probes below Windows path limits in checkouts with longer repository names.

* mlx: fix Nemotron bugs and support global scales

Accept published Nemotron layer names while retaining legacy aliases, and
fix layer-count inference and detached MTP quantization. Stabilize Mamba
softplus, preserve FP32 vision normalization, and compile Mamba gate and
norm scaling.

Support per-expert F32 global scales and preserve activation-scale
companions in ModelOpt and compressed-tensors NVFP4 imports. Normalize
reciprocal globals and reject invalid scales. Keep activation scales
separate from weight-only inference.

* mlx: add Nemotron 3.5 Super

* minor adjustments

* llama.cpp: version bump b11669 (#19032)

* win: prevent orphaned runners (#18500)

* win: prevent orphaned runners

Assign runner processes to a singleton Windows Job Object configured with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE. This lets Windows terminate owned llama-server and MLX subprocesses when Ollama exits, including forced termination where graceful cleanup cannot run.

* address comments

* clef cloud launch

* be more precise with wording

* gguf: add the q2_0 tensor and file types (#18967)

* cleanup

* use identifiers for --ask mode question keys

* test

* transfer: support proxies on registry redirect targets (#19065)

Behind a proxy, defer redirect-target DNS to the proxy; without one, keep the resolve-and-pin path. Trust default-registry/CDN hostnames with no local DNS. Fix a nil CancelFunc crash in blobDownload.release.

* docs: add model grouping to cloud usage (#19069)

* docs: add model grouping to cloud usage

Document group_by=model in the cloud usage guide and OpenAPI schema.
Explain group selection and remainder, and show responses with multiple
models across time buckets.

* Update docs/api/cloud-usage.mdx

Co-authored-by: Bruce MacDonald <[email protected]>

---------

Co-authored-by: Bruce MacDonald <[email protected]>

* openai: allow Responses effort on non-thinking models (#19010)

* llama-server: let llama-server infer the draft speculative type (#19064)

llama-server can auto-detect most drafting models, so only pass the --spec-type
for drafting models it can't autodetect today: MTP sidecars detected by
Ollama's existing markers, and Eagle3.

* mlx: add PPLX Decider v1.2 support (#19072)

Implement the Qwen3.5-backed decision scorer with noncausal attention,
the publisher readout, image handling, and System One prompt encoding.

* api: populate show renderer/parser fields and add template_source (#19095)

ShowResponse's renderer and parser fields existed but the server never
set them; they now carry the effective values (renderer resolves the
gemma4 legacy alias by model size). A new template_source names what
actually renders chat prompts: the configured renderer/parser (leaving
any packaged template inert), a Go template layer, the GGUF's embedded
jinja, harmony, or none.

The CLI prints renderer/parser/template source rows only when set, so
ollama show output is unchanged for models without rendering config.

* openai: accept foreign compaction in Responses history (#19003)

* server: cancel remote inference when clients disconnect (#19144)

* avoid scary claude warning about auto compact window being too big

* openai: finish reasoning before client tool calls (#19146)

* llama.cpp: version bump b11738 (#19143)

* server: read loaded runner models without refMu (#19070)

* server: read loaded runner models without refMu

Concurrent lookups of a warm model failed TryLock against each other and
fell back to a manifest reload, defeating the cache and making
TestLoadedModelLookupConcurrent flaky. Make runnerRef.model an
atomic.Pointer so lookups never take refMu.

* address comments

* mlx: deduplicate CUDA runtime payloads (#17956)

* Deduplicate MLX CUDA runtime payloads

Move CUDA libraries shared by the GGML and MLX backends into the sibling CUDA payload, and teach in-process and subprocess MLX loading to resolve that packaged dependency directory.

Keep MLX-private libraries and JIT headers in the MLX overlay, include the full OpenBLAS Fortran runtime closure, and verify those dependencies in release packaging.

* address comments

* mlx: add Flint model support (#19181)

Preserve source tool JSON alongside decoded API values so Flint can retain
numeric types and schema order in prompts. Existing API marshaling is unchanged.

Assemble ModelOpt expert banks during safetensors import, and reject direct
Flint NVFP4 creation before conversion. Other models retain their existing
import and quantization paths.

Add optional learned sinks and device causal masks to shared MLX attention.
Existing callers retain the no-sink and host-mask paths; Flint opts into the
new behavior.

* ci: switch to released WoA CTK (#19185)

We were still using a pre-release, and the download site is flaky, so lets
get current on the latest CUDA Toolkit for WoA support.

* llama.cpp update (#19194)

* anthropic: surface errors after streaming starts (#19188)

* mlx: add d3 decision model support (#19196)

* mlx: add d3 decision model support

* bench: report loaded VRAM for decision runs

* build: update Go toolchain and dependencies (#19200)

* launch: use cloud model context in Claude Code (#19119)

* build: update jsonparser to v1.1.2 (#19220)

* mlxrunner: add Phonon text-to-speech support (#19166)

* mlxrunner: add Phonon text-to-speech support

Add Phonon text-to-speech through the existing MLX runner, with an
OpenAI-compatible speech endpoint and CLI playback.

Include model loading, text preprocessing, streaming audio, and
regression tests.

* docs: add speech models

* fix min version

---------

Co-authored-by: Daniel Hiltgen <[email protected]>

* flint: fix replies with thinking disabled (#19216)

* flint: fix replies with thinking disabled

Close the thinking section when think:false so Flint answers directly. Default and think:true prompts are unchanged.

* update template

* anthropic: reuse resolved thinking for web search (#19098)

* openai: preserve failures in Responses streams (#19225)

* Make sure all launchers know about cloud model metadata (#19223)

* Support GA Gradium Phonon checkpoints (#19227)

Replace the prerelease checkpoint path with Gradium's GA format, including default-voice import and speech conditioning. Set the 0.40.9 minimum, update the speech docs, and test import, inference setup, and rejection of the old checkpoint.

* Update gemma renderers (#19241)

* renderers: add gemma4-nemotron renderer

Add a Gemma 4 renderer variant that renders assistant content before
its tool calls rather than after the tool responses. Models opt in with
RENDERER gemma4-nemotron; gemma4 auto-detection is unchanged.

Adds the corresponding chat template as a test fixture for Jinja parity
checks.

* mlx: support Gemma 4 targets with DFlash drafts

Load a draft-owned output head when its config requires one, while preserving the target-head path used by existing DFlash models.

Expose Gemma 4 hidden-state taps and raw logits for speculative decoding. Report safetensors target precision independently of quantized draft weights.

* qwen3coder: preserve literal function closing tags in parameters (#19228)

* launch: use allocated context for OpenCode (#19193)

* decision: allow empty state for vllm-d3 (#19173)

* decision: allow empty state for vllm-d3

* server: reuse decoded state in System One tests

---------

Co-authored-by: Patrick Devine <[email protected]>

* llama.cpp: version bump b11845 (#19250)

* mlxrunner: spell out symbols, numbers and links for Phonon (#19234)

* mlxrunner: spell out symbols, numbers and links for Phonon

* docs: describe speech text normalization

* mlxrunner: fix Phonon misreadings inherited from xn-ptts

* mlxrunner: fix remaining Phonon misreadings

* mlxrunner: fold Phonon letters from the vocab, read #, _ and lists

* mlxrunner: add xn-ptts license notice for Phonon

* mlxrunner: move the xn-ptts license notice into normalize.go

* mlxrunner: fix remaining Phonon readings and port elongations

* docs: speech reads times and numeric dates

* mlxrunner: fix Phonon readings found in a listening pass

* docs: speech reads times and dates as written

* voice: add voice catalog for Phonon (#19242)

* mlxrunner: import and list Phonon catalog voices

* docs: document Phonon voices

* mlx: preserve small-image detail for compact Gemma 4 vision towers (#19247)

Dynamic sizing can floor the smallest image grid below its intended 70-token budget, losing detail in small images. Round that grid up for the compact tower, capped at the next supported budget.

Keep explicit budgets and the existing sizing for larger and unified towers. Update geometry and media-expansion tests.

* MLX, MLX-C: version bump - prompt speed up for gemma/flint/laguna (#19291)

* MLX, MLX-C: version bump

The MLX-C pin now provides its own bindings for gather_qmm global_scale
and fast::gated_delta_update, so those two carried patches drop out.
Carry 0001-mlx-c-sdpa-window-size instead: sliding-window attention
added a window_size argument to fast::scaled_dot_product_attention
(ml-explore/mlx#4734) that MLX-C has not bound yet, to be regenerated
from MLX-C once the upstream binding PR merges. The SDPA wrappers gain
a window size argument; all call sites default to the full context.

* mlxrunner: dispatch sliding-window prefills to the native SDPA window

Sliding layers no longer materialize a causal∩sliding mask for prefill
chunks past the window: resolve() dispatches {causal, window} natively
when the rotating cache's L>1 concat has linearized the ring and the
mask is otherwise pure causal, via a new MaskApplier.NativeWindow hint.
Vision relaxations, padding, model arrays, and decode keep the
materialized path. No model changes; sinks compose natively.

* dflash: add the DFlash2 draft model (#19149)

DFlash2 adds block-local dynamic convolutions and a candidate selector
to DFlash. The selector proposes each token conditioned on its
predecessor and returns each position's candidate distribution, which
verification uses to keep the output exact. Like the reference, the
draft samples with the request's temperature only.

A DFlash2 session drafts seven tokens every round on the existing
snapshot verify path instead of following the depth controller, whose
shallower picks lose more accepted tokens than they save in verify time.

qwen3.5-family targets now expose the layer taps, token embeddings and
raw logits a DFlash draft needs.

* llama.cpp: version bump b11901 (#19311)

* Fix kimi cli tool-only assistant turns (#19312)

* Fix kimi cli

* just interpret [] same as empty string actually

* dont gate on role

* cmd/launch: fix OpenCode v2 launch and config parsing (#19310)

Co-authored-by: 0d00ciallo0721 <[email protected]>

* mlx: add LFM3 and d1 models (#19333)

* llm: LFM3 GGUF fixes and llama-server speech (#19344)

Fixes for running LFM3 GGUFs on the llama-server runner, plus GGUF
text-to-speech that turns on once llama.cpp is bumped past b11901.

- BOS: honor an explicit tokenizer.ggml.add_bos_token. LFM3 GGUFs (and
  lfm2:24b) set it to false and expect the template's BOS, which the
  lfm2 default was stripping. The lfm2 default still applies when the
  key is absent. On lfm2:24b, WikiText PPL goes from 81.3 to 72.0.
- repeat_last_n -1 now maps to the context size; llama-server rejects
  negative values.
- Audio-only projectors (LFM3-Audio) no longer advertise vision, so
  clients don't send images the model can't take.
- /v1/audio/speech on GGUF models calls llama-server /tts chunk by
  chunk. Renderers opt in through a new SpeechPrompter (voices,
  voice parsing, chunking), so other speech models can add their own.
  The LFM3 voice and chunking helpers move from the MLX runner into
  model/renderers and are shared by both runners.

* llama.cpp: version bump b11963 (#19360)

* cmd: show help when running ollama without arguments (#19248)

* llama.cpp: workaround Metal unary crash (#19372)

This temporary patch works around a regression on older versions of MacOS
ggml_metal_library_compile_all: failed to build 'unary' library

* ci: pin buildx to workaround deadlock (#19373)

Recent buildx updates are causing frequent deadlocks in our CI builds.
Until this is resolved upstream, pin to an older version.

* openai: preserve readable Responses input content (#19192)

* mlx: sort long top-k rows in chunks (#19392)

MLX's argpartition sorts the whole row, and a row longer than one block
of the GPU sort takes a multi-pass merge sort. TopKIndices sorts each
2048-value chunk in a single block, then only the chunks' top k, and
returns the same indices in the same order.

The sampler's top_k and top_logprobs and the DFlash2 candidate selector
use it in place of a full-vocabulary argpartition.

* app: make ChatGPT disconnect failures retryable (#19336)

* feat(launch): use model output limits for Claude Code (#19410)

* openai: don't override model sampler defaults (#19432)

The OpenAI-compatible endpoints filled in sampler options the client
left out: temperature and top_p fell back to 1.0, and /v1/completions
always sent frequency_penalty and presence_penalty as 0. Request
options are applied last, so these values replaced the model's packaged
defaults. /api/chat honored those defaults; /v1 did not.

Omitted options are now left unset on /v1/chat/completions,
/v1/completions and /v1/responses, so the model's parameters apply, the
same as on /api/chat. Values the client sends still win, including an
explicit 0. On /v1/completions, top_p and the penalties are now
pointers so "omitted" and "0" can be told apart.

Clients that send no sampler options now get the model's defaults
instead of 1.0/1.0. A model with no sampler parameters gets Ollama's
defaults (temperature 0.8, top_p 0.9), as on /api/chat.

Fixes #17744
Fixes #18690

* launch: check ChatGPT routing before configuring (#19470)

* server: decode cloud web search responses (#19476)

* mlx: load bundled CUDA libraries in-process on Linux (#19433)

NVIDIA's libcusolver looks for its dependencies only in its own
directory, so libcublas and libnvJitLink resolved to the host's copies
and MLX failed to load when those didn't match the bundled ones. Preload
the bundled copies by full path before loading MLX.

* model: add MiMo V2.6 renderer for Qwen3.5 (#19400)

* launch: populate Pi models automatically (#19460)

* Add AutoTrust decision model to MLX (#19399)

* Add AutoTrust decision scoring to MLX

* address comments

* Support AutoTrust 35B decision models in MLX

* Resolve AutoTrust choice limits during config loading

Apply publisher-specific defaults and validate requests against the resolved limit.

* mlx: reject unsupported CUDA devices (#19521)

* mlx: bump for CUDA architecture metadata

* mlx: reject unsupported CUDA devices

* address comments

* mlx: support YaRN scaling in Qwen3 and Qwen3.5 (#19231)

* llama.cpp: version bump b12111 (#19530)

Drop 002-metal-unary-cast-constexpr.patch: superseded by upstream fix

* llama-server: allow parallel requests for recurrent and vision models (#19545)

These architectures were forced to num_parallel=1 because the older Go
engine's recurrent caches held one sequence. llama-server supports
multiple slots for all of them so we can allow parallelism now.

* cmd/launch: show gateway model names in Claude Desktop's model picker (#19533)

* cmd: restore the no-argument launcher (#19478)

Co-authored-by: Jeffrey Morgan <[email protected]>

* mlxrunner: close generation cache on shutdown (#19550)

* cmd/launch: add Kimi Code CLI support (#19506)

* openai: forward truncation option in responses requests (#19501)

Co-authored-by: Eva Ho <[email protected]>

* openai: return an empty array for /v1/models when no models are installed (#19539)

* llama.cpp: version bump b12177 (#19576)

* README: add Quock to Mobile community integrations (#19361)

* windows: add CUDA 13.5 and SM 103 for ARM64 (#19580)

Install the separate ARM64 cross package in CI and retain SM 121
support. Other platforms are unchanged.

* MLX: make Qwen3.8 Flash Next memory efficient (#18078)

* MLX: reduce Qwen3.8 Flash Next memory use

For NVFP4 creation, retain source precision for sensitive QSA projections
and non-expert MTP weights. Keep routed experts and PLE at NVFP4, and
promote other eligible weights to MXFP8.

Keep NVFP4 PLE tables host-backed, transferring only selected packed rows
and their scales to MLX. Honor scalar and per-expert NVFP4 global scales
in MoE, and per-shard global scales in host-backed PLE.

Use compressed QSA block selections in fused indexed Metal attention for
long prefill batches, retaining the graph fallback. Co-locate component
loading and forward methods, with explicit quantization and cache ownership.

* mlx: skip materializing host-backed tensors

Let models exclude tensors already owned by host storage from MLX loading.
Avoid allocating and discarding the full Qwen PLE tables at startup while
preserving the resident fallback.

* address comments

* launch: fix Claude Code routing and retired model errors (#19587)

* Add ripple preview support to the MLX runner (#19592)

Add the Ripple model, renderer, parser and import registration.
Support per-layer NoPE in DFlash drafts.
Fuse MLP activation, value blending and attention gating.
Add reference fixtures and model/runner regression tests.

* integrate: merge 24 topic branches into main

  - docker: add missing libraries and configs for Nvidia MLX/Vulkan, add new build targets.
  - "PARAMETER env" for setting environment variables from the Modelfile.
  - RunnerOptions: surface string runner fields for inheritance
  - per-model flash attention and KV cache type via Modelfile PARAMETER
  - server: allow dynamic token generation limit with num_predict==-2
  - server: emit load and total durations for a load
  - env: add runner default env vars and per-model num_parallel
  - Add OLLAMA_API_KEY for inbound request authentication
  - Add per-request UUID tracking behind OLLAMA_TRACK_REQUESTS env var
  - Log auth token in gin request completion line behind OLLAMA_LOG_AUTH
  - server: add keepalive heartbeats for streaming responses
  - args: pass-through runner args via Modelfile/API/OpenAI endpoints
  - bench: add perplexity and approximate KLD measurements
  - health: add /health endpoint with per-runner status
  - expiring-runner: per-runner expiring flag to prevent sessionDuration reset during eviction
  - drain: server drain mode and model unloading for graceful request management
  - move think into Runner options for Modelfile PARAMETER support
  - add think_level Modelfile parameter for custom thinking validation
  - modelfile: add JINJA statement for custom Jinja2 chat templates
  - prompt: preserve last user message during context truncation
  - metrics: prometheus endpoint with cloud usage, balance, runner params
  - app: log swallowed ollama server Run error
  - progress: suppress cursor hide/show ANSI sequences when stderr is not a tty
  - parser: support single quotes and ex…
rick-github added a commit to rick-github/ollama that referenced this pull request Nov 8, 2026
* llama.cpp: version bump b10864 (#18317)

* server: extract GGUF metadata and unify capabilities (#17858)

Loading GGUF metadata is an expensive operation. Two caches had evolved to
mitigate this, and the two capability implementations produced inconsistent
results for some models.

This PR now extracts the metadata once per blob into a file at
<OLLAMA_MODELS>/metadata/sha256-<hex>.json. Only arrays over 4096 elements and
non-finite floats are left out.

Direct Capabilities() discovery now costs us instead of ms.  /api/tags can
build directly from manifests and the extracted metadata.

* mlxrunner: capture whole-state at close for nodes split out of an edge

KV snapshots must cover a node's edge exactly. Recurrent and
sliding-window state is only useful at a node's end, and a node may
have none: a request resuming there lands on the previous checkpoint
and begin schedules a capture at the match.

The header claimed every node carries its snapshots from creation,
which a node split out of an existing edge at close cannot. That hid a
gap: when a response is a prefix of a stored one, close lands on the
split-off head with the caches resting at its end, and pageOut skipped
the capture because the node already had a KV snapshot.

Restate the header as the rules that hold, and make pageOut capture
whatever layers a node is missing. The scheduling comment also said
eviction preserves user nodes; it only resists compaction.

* mlxrunner: keep cache boundaries out of non-causal media items

The tokens of a non-causal media item attend to each other in both
directions, so the item has to be evaluated in one forward. Prefill
honors that when it picks chunk boundaries, but the prefix cache did
not: a snapshot could be taken partway through an item, and a request
that resumed there would evaluate the rest of the item alone and
compute different attention for it.

Snapshots scheduled inside a non-causal item now land at its end, and
a match that ends inside one resumes at its start.

* mlxrunner: keep the reused head of a cached edge safe from eviction

When a request resumes partway through a cached edge, the node holding
that edge was dropped from the active path, because the path has to end
at the live offset for close and the prefill captures to extend the trie
from its last node. Off the path, the node was an ordinary leaf with a
stale last-used time, so eviction removed it first.

The captures taken during that request start at the resume offset, but
attach rebuilds the missing node from the path's last node, so the new
node's edge begins earlier than its KV snapshot. A later request
resuming there was refused by the KV cache and re-prefilled from
scratch. If eviction first merged the node into its parent, the two
snapshots were concatenated as if adjacent, and the restore reported a
hit while the buffer held tokens from other positions.

Split the node at the live offset instead. The head stays on the path
and gets the last-used update. Only the unused tail can be evicted, and
losing it costs nothing. The split only happens when every layer can
rewind into the edge, so it never involves a recurrent layer, and the
head gets the same KV-only snapshots a close-time split already
produces. When the request follows the edge, compaction merges the
halves back.

* mlxrunner: evict the active conversation's own checkpoints under the budget

Eviction skipped every node on the active path, so a conversation's own
turn checkpoints were never reclaimed no matter how far over budget the
trie was. On models with sliding-window or recurrent layers each turn's
checkpoint is a full copy of that state, 800 MiB per turn on
gemma4:31b-mlx, and a long chat grows without bound. The scheduler then
counts that memory as in use and evicts the model to load anything
else.

Only the frontier and branch points are protected now. Any other node,
active or not, is evicted least recently used first. On the active path
that merges a turn into the next one: the merged node keeps the newer
whole-state, and the KV snapshots there are lazy views of the live
buffer, so nothing is copied. Rewinding to an evicted turn resumes at
the newest surviving checkpoint before it.

qwen3.8:27b-mlx on an M5 Max, the same short question every turn with
24 tokens generated per reply, 8 GiB budget, 17.2 GiB of weights:

  turn | before: paged out  nodes  reported | after: paged out  nodes  reported
    11 |          4.61 GiB     33  21.6 GiB |         4.61 GiB     33  21.6 GiB
    21 |          7.91 GiB     56  24.9 GiB |         7.92 GiB     56  24.9 GiB
    31 |          8.46 GiB     60  25.5 GiB |         7.94 GiB     56  25.0 GiB
    41 |          9.90 GiB     70  26.9 GiB |         7.96 GiB     56  25.0 GiB
    50 |         11.19 GiB     79  28.2 GiB |         7.98 GiB     56  25.0 GiB

Fixes #17783

* mlxrunner: bound MLX loads by system free memory while other models are loaded

On Apple silicon the scheduler's free-memory figure for the GPU is the
Metal working set minus what Ollama's own runners report. It does not see
memory held by other applications, so a second MLX model can pass the fit
check on a machine that is already short of memory, and the load pushes
the system into swap and compression.

While other models are loaded, the MLX fit check now also bounds the
available memory by the system's free memory on shared-memory GPUs, the
same rule llama-server loads already apply. A miss evicts an idle model
and retries instead of starting the load. First loads are unchanged: with
nothing else loaded, the model loads against the working-set figure alone,
as both engines do today. The check also does not cover memory that grows
after load, such as KV caches and prefix-cache snapshots.

* mlxrunner: wait for a killed runner to exit before the scheduler loads the next model

The scheduler starts the next load as soon as Close returns. The MLX client
sent SIGINT, gave the process five seconds, then sent SIGKILL and returned
without waiting, so a runner that could not take the signal was still
exiting, with its memory still held, when the next load began. The runner
has no signal handler, so SIGINT was already a kill.

Load also started the process and recorded it without the client's mutex,
so a Close racing with a load at server shutdown could find nothing to stop
and leave the runner it missed running.

Close now kills the process and waits for it to be reaped, as the
llama-server client does. Load starts and records the process under the
mutex and refuses to start once Close has run.

* llm: raise token repeat limit to 100 and return error instead of silently closing (#18374)

* mlx: scope array lifetimes instead of pinning and sweeping

The bindings freed arrays by sweeping everything not pinned, so freeing
anything required knowing what every other caller still held, and code
that never swept accumulated until memory ran out. The prefix cache's
eviction of a long stored path did exactly that: each merge copied the
KV snapshots and nothing freed the consumed copies until the request
ended, which drove a second long request past physical memory.

Every array now belongs to a scope. A function scope, entered with Scoped
or one of the ScopedEval forms, frees what was created in it when the
function returns; results leave only by being returned. A held scope is
closed by its holder and frees what was attached to it. A graph is
built in a function scope and evaluated after it, so the eval frees each
intermediate as it consumes it. Pin, Unpin, Sweep, and the array list's
mutex are gone.

On an M5 Max with qwen3.8:27b-mlx, the second 84k-token request after a
stored one peaks at 35 GB instead of 57 GB; the cold path is unchanged.
The copies themselves are untouched, so restoring an owned path can still
exceed memory.

* mlx: drop the empty-handle checks outside the bindings

Models and layers checked optional weights for nil and also for a handle
that no longer refers to an array, and evaluation and weight collection
skipped such handles. No path produces one: a missing tensor is nil, and a
handle only loses its array when its scope frees it, after which using it
is a bug. The nil checks stay; the validity check is internal to the
bindings now.

* mlxrunner: release the buffers weight loading leaves in the MLX pool

Loading a model can transform tensors after reading them: qwen3.5 models
pack their linear-attention projections into one layout, and MoE models
fuse the gate and up expert stacks. The buffers those transforms consume
go back to MLX's allocator pool rather than to the system, and nothing
releases the pool until the first request finishes. On qwen3.8:27b-mlx
that is 2.15 GiB held idle on top of 16.9 GiB of weights, counted in the
runner's reported memory the whole time.

Clear the pool once the weights are evaluated. Models whose tensors load
unchanged, such as gemma4, leave nothing in the pool and are unaffected.

* cmd: remove built-in agent (#18393)

* llm: keep gemma3n projector off the CPU (#18376)

Gemma3n's MobileNetV5 projector silently produces corrupted image
embeddings on the CPU backend - no error, the model just describes the
wrong image (reproduced on llama.cpp b10760; gemma4's encoder is fine on
CPU). Without this guard the existing partial-offload, limited-VRAM, and
OOM-retry fallbacks would pick the CPU projector on exactly the small
GPUs where gemma3n lands.

* app: refresh Apps layout and command copy feedback (#18372)

* MLX: version bump (#18235)

* MLX: version bump

* mlx: support ModelOpt global scales in MoE models

* address comments

* address comments

* docs: add ChatGPT Desktop integration (#18377)

* mlx: add mlx patch to docker build context (#18440)

* create: add server-side MLX imports and drop GGUF conversion (#14969)

* create: add server-side MLX imports and drop GGUF conversion

Support safetensors imports through the MLX create pipeline both locally and on the server, including remote upload/staging, draft layer handling, cancellation propagation, transfer limits, and shared manifest/blob writing.

Limit GGUF create to wrapping existing GGUF inputs into Ollama manifests. Remove the in-tree safetensors-to-GGUF converter, server quantization path, and converter-only dependencies so GGUF conversion and quantization stay in llama.cpp tooling.

Keep the MLX path focused on supported safetensors model creation with validation before MLX work, and expose that flow without the --experimental CLI gate.

* address comments

* add client side gguf create fast path

* address comments

* rebase adjustments

* MLX, MLX-C: version bump (#18449)

Includes quantized matmul corruption fix, which impacts nvfp4 multimodal models (gemma4 vision towers). Deferring wiring up the new MLX-C thread-local stream/sync APIs for now.

* API: Deprecate typical_p (#18448)

Drop support for creating new models with typical_p parameters, while
retaining support for existing GGUF models with the setting.

* docs: refresh getting started guides (#18450)

* llama.cpp: version bump b10969 (#18446)

llama.cpp build changes resulted in duplicate symbols between libllama and libmtmd.  This moves the compat patch into libllama with exported symbols.

* cmd: launch the MLX runner without the engine dispatcher

The runner package used to pick an engine from the first argument of the
runner subcommand. Only the MLX engine is left, so the dispatcher has a
single arm, its README still describes the removed Go runner's flags and
endpoints, and the standalone cmd/runner binary exists only to invoke it.

We call mlxrunner.Execute directly from the hidden runner subcommand and
drop the --mlx-engine argument from the command line the MLX client
spawns. Both sides ship in the same binary, so nothing has to accept both
forms. The runner package and cmd/runner are removed.

The subcommand's help hook hands the runner a bare --help. cobra calls the
hook with no arguments for `ollama help runner`, which used to index past
the end of the slice.

* tokenizer, ml: remove dead code

Several pieces outlived the code that used them. The root tokenizer
package implemented the GGUF-side vocabularies for the Go engine and the
safetensors-to-GGUF converter; nothing has imported it since the
converter went. ml/backend.go held the Go engine's Backend, Context and
Tensor interfaces, with fs.Config existing only to be returned from them,
and a single CUDA template instance under ml/backend/ggml survived the
engine removal along with the gitattributes entries for that tree and the
CI change-filter globs for it and for the long-gone llama/llama.cpp. From
the image generation engine, an integration test group that no test
registers, its build tag, and the StepBar progress widget remained.
DeviceInfo.IsBetter has no caller at all.

All of it goes. Tidying the module file drops the regexp2 dependency and
leaves protobuf as an indirect requirement. The llama3.2 tokenizer
fixtures stay: the MLX runner's tokenizer uses them for its GGML parity
test.

* mlx, mlxrunner: move the MLX engine out of x/

The MLX runner is the only Go inference runner left and is no longer
experimental, so its packages leave x/. The bindings become a top-level
mlx package beside the carried patches in mlx/compat, mirroring how
llama/ holds the llama.cpp integration, and the runner becomes mlxrunner
with the architectures nested under the package they implement.
Subpackages move with their parent unless listed.

  x/mlxrunner/mlx            mlx
  x/internal/mlxthread       mlx/mlxthread
  x/internal/mlxthreadtest   mlx/mlxthread/mlxthreadtest
  x/internal/mlxtest         mlx/mlxtest
  x/quant                    mlx/quant
  mlx/compat/*.patch         mlx/compat/mlx-c   (MLX patches go in mlx/compat/mlx)
  x/mlxrunner                mlxrunner
  x/models/nn                mlxrunner/nn
  x/models/<arch>            mlxrunner/model/<arch>
  x/mlxrunner/imports.go     mlxrunner/model/architectures   (new package)
  x/create                   create
  x/safetensors              fs/safetensors
  x/tokenizer                mlxrunner/tokenizer

Every package keeps its name, so the Go changes are the import path
rewrites the moves force, and the CMake, Dockerfile, CI cache keys, drift
check and Darwin payload script follow the new paths. Four edits are not
paths: the runner's blank architecture imports become the package
mlxrunner/model/architectures, so the list to extend for a new model sits
beside the architecture directories; a depguard rule keeps the two test
harnesses out of non-test code, as the x/internal placement used to; the
CI change filter's two entries for the long-deleted x/imagegen/mlx now
name the bindings' CMake project and the carried patches, so a change to
either builds the payload; and the tokenizer parity test reads its
fixtures from its own testdata instead of walking out of x/.

x/server and x/imagegen/manifest stay for the next two commits.

* mlxrunner, cmd, server: fold three small packages into their users

model/base held the Model interface and the architecture registry while
model held weight loading and quant parameters, and every architecture
imported both. create/client was the CLI side of safetensors imports,
with the create command as its only caller, a duplicate of the command's
adapter error, and a name that read like a second API client. The
safetensors show helpers had their own package under x/ although it
already declared package server.

base merges into model, so base.Model and base.Register become
model.Model and model.Register; nothing in the two overlapped. The create
client's two files and their tests join package cmd, and the five names
the command called are no longer exported. The show helpers join the
server package, and the three entry points routes.go calls become
unexported like the helpers around them.

* mlxrunner: read model manifests through the manifest package

The runner and its weight loader read a model's manifest through
x/imagegen/manifest, the last piece of the removed image generation
engine. It was a hand-rolled copy of the manifest package: its own model
name parser with the default registry and namespace spelled out, its own
blob path builder, and re-spelled media types, plus a model_index.json
reader and other helpers that nothing has called since the engine went.

The manifest package gains the three lookups the runner needs, a config
layer by path, its contents, and the tensor layers, and ReadConfigJSON is
built on the second of them. The weight loader resolves the model name
with the shared parser, which fills in the same defaults the copy did, and
locates blobs with BlobsPath. The architectures' calls to read their
config.json compile unchanged. x/imagegen is gone.

* mlxrunner: lay out nn one layer kind per file

nn.go held every layer type in the package apart from attention,
recurrence and rope: the Linear and Embedding interfaces with their dense
and quantized types, Conv1d, RMSNorm, LayerNorm and MultiLinear, with one
test file to match. Finding a layer meant scanning the file named after
the package.

Each layer kind gets its own file: linear.go and embedding.go hold the
interface and the dense and quantized types, conv.go, norm.go and
multilinear.go take the rest, and nn_test.go splits the same way. The
Layer and MultiLinearLayer interfaces go; nothing implemented or accepted
them. No code changes otherwise.

* mlxrunner: lay out model by contract, checkpoint and construction

model is one package with three jobs: the contract between the runner
and the architectures, the opened checkpoint, and building nn layers
from checkpoint tensors. Its files did not say which was which. base.go
carried the folded package's name over the interfaces and the registry,
root.go held the safetensors header scan next to Root, and quant.go
mixed the nvfp4 global-scale helpers with quant parameter resolution.

base.go becomes model.go, named for what it holds. root.go keeps Root
and Open; TensorQuantInfo and the header scan join quant.go, so
everything the checkpoint says about quantization is read and resolved
in one file. The global-scale helpers move to globalscale.go with their
tests. Root.Close, a no-op with one caller, goes. No code changes
otherwise.

* docs: fix cloud retirements settings link (#18496)

* app: clarify Claude connection dialog (#18498)

* app: add Apps deep link (#18497)

* mlxrunner: Release freed KV buffers during speculative decode

The decode loop releases MLX's pool of freed buffers every 256 generated
tokens, which is also how often the KV cache grows and drops its previous,
smaller buffers. The check fires only when the token count lands exactly on
a multiple of 256. Speculative decoding emits several tokens per round, so
most rounds step over the boundary and the pool is never released. Each
growth at a long context leaves several GB of buffers that no later
allocation can reuse, so the runner's footprint keeps climbing over a long
generation until the system runs out of memory.

We now release the pool whenever a round crosses a multiple of 256 tokens,
which is what a single-token round already did. With qwen3.8:27b-mlx at a
98k-token context on a 128 GB machine, a long speculative generation
previously grew the runner past 90 GB and panicked the kernel; it now stays
flat at 30 GB.

* cli: add first-run onboarding shared with the desktop app (#18495)

* docs: clarify integrations overview and add assistant icons (#18511)

* x/transfer, server: tighten redirect handling for registry requests (#18512)

Redirects for registry and blob transfers now validate the target scheme
and resolved addresses before following, re-check DNS on each redirect,
and do not follow redirects that switch an https session to plain http.
The --insecure option continues to relax address checks for private
registries but not scheme checks.

* ci: harden release artifact uploads (#18516)

Serialize final release jobs and delete old assets before retagging to
avoid overlapping updates and mixed-version payloads.

Keep uploads parallel and retry failures twice with 15s/30s delays.
Retry cleanup using a fresh asset list and upload the checksum manifest
only after all payloads succeed.

* nemotron_h: add MLX vision support (#17714)

* nemotron_h: add MLX vision support

Implement the RADIO vision encoder and projector on the shared MLX media pipeline, including dynamic-resolution preprocessing, deterministic placeholder expansion, chunked feature scattering, and MTP offsets.

Expose source-advertised Nemotron vision while continuing to suppress unsupported audio, and preserve both modality towers at source precision during create.

Harden Nemotron streaming parser termination and add focused coverage for vision configuration, media placement, capability reporting, and tool-call parsing.

* review comments

* address comments

* tests: fix metadata deletion test flake (#18493)

Test both publication/deletion orderings directly instead of polling for a short-lived temporary file with a machine-dependent timeout.

* app: keep closed macOS windows from reopening on activation (#18518)

* api: expose model thinking levels and defaults (#18473)

* server: allow registry cross-host redirects among allowlisted hosts (#18533)

* server: fix getExistingName canonicalizing model name parts independently (#18438)

getExistingName canonicalizes the case of each model name part (host,
namespace, model, tag) by searching all manifests for a case-insensitive
match. The original implementation matched each part independently —
the tag from any manifest whose tag case-insensitively matched the
requested tag would overwrite the tag, regardless of whether the host,
namespace, or model matched.

A 'set' variable was intended to track which parts had already been
canonicalized and prevent overwrites, but it was never written to, so
it was always zero-valued and every match overwrote the corresponding
part unconditionally.

With 3000+ manifests, if another model had a tag that case-insensitively
matched (e.g. 'Q4_K_M' for a different model), the requested model's tag
could be canonicalized to that other model's tag casing. Go's map
iteration order is randomized, so the last match wins — producing
intermittent 'model not found' errors that succeed on retry.

Fix: when all four parts of an entry case-insensitively match the input,
return that entry's canonical name directly. Otherwise canonicalize each
part independently, with the 'set' variable now properly updated after
each part is set so it is only written once. This handles both exact
matches and new tags on existing models.

* parsers: report the strings that end a response's thinking

A format on a thinking model has to leave the thinking free and constrain
only the content after it, so whatever enforces the format needs to know
where the thinking ends. Today the server guesses whether a parser's
response starts inside thinking from the think value alone, which is wrong
for parsers whose default differs, and it has no way to learn the closing
string at all.

Each parser now answers ThinkingClose after Init: the strings any of which
ends the thinking its response begins with, or none when the response
starts in content because thinking is off, an assistant prefill continues
content, or the parser suppresses thinking for tools. Parsers whose models
open a new message before content end the thinking at that message's
header. Nothing consumes the answer yet.

* mlxrunner: constrain a format after the thinking in one generation

The MLX runner applies a format's grammar from the first sampled token,
so a thinking model asked for a format cannot think first, and the server
has to run two generations to get both the thinking and the formatted
content.

A completion request now carries the strings that end the thinking its
response begins with, and the MLX client builds from them a structural
tag: free text that cannot contain any of them, then one of them, then
the schema. The tail is optional so a response may still end inside its
thinking, as an unconstrained one can. Without a closing string the tag
is the plain schema, as before. The server does not send the strings yet.

* llm: apply a format after the thinking in one llama-server request

llama-server applies a schema from the first sampled token, so a thinking
model asked for a format cannot think first, and the server has to run two
generations to get both the thinking and the formatted content.

The client now sends one request whose grammar leaves the text before a
closing string unconstrained and requires the format after it.
llama-server converts the schema for us: an empty completion evaluates and
generates nothing but reports the GBNF it derived, which we wrap in rules
that recognize the closing strings and cache per schema for the life of
the process. On qwen3 0.6b at temperature 0 the thinking is byte-identical
with and without a format and the JSON follows the schema.

A response that ends before a closing string is delivered unchanged. The
conversion request briefly takes a llama-server slot on a cache miss. The
server does not send the strings yet.

* server: apply structured outputs in a single pass on thinking models

A format on a thinking model ran two generations: an unconstrained one,
cancelled once the parser reported content, then a re-rendered prompt with
the parsed thinking under the grammar. The restart cost a second prefill,
dropped the chunk that crossed the boundary, needed a harmony prompt hack,
stitched metrics across the two requests, and on MLX could leak a stray
first token into the JSON. The generate endpoint never deferred at all, so
its JSON was forced inside the thinking.

Both handlers now make one completion request that names the strings
ending the response's thinking, from the builtin parser or the generic
thinking parser, and the runner constrains only the content after them in
a single generation. The prompt is evaluated once and metrics pass straight
through. A raw generate prompt names no strings, since nothing says where
its response starts, and its format applies from the first token as
before. A format now applies to whatever follows the thinking, so a tool
call can no longer take the place of formatted content, which was already
the case with thinking off; harmony is the exception, since its tool calls
precede the final message.

The per-token metrics flag both runners carried for the cancelled first
pass has no caller left and goes with the two-pass code and its tests.

Fixes #18441
Fixes #17544
Fixes #14196
Fixes #10929

* app: avoid System Events for ChatGPT/Codex detection (#18601)

* llama.cpp: version update (#18577)

Refine memory allocation failure log substrings for upstream changes.

Remove the no longer needed Laguna metal patch - fixed upstream.

* MLX: version bump (#18576)

Plumbs fast::gated_delta_update through a temporary MLX-C patch for now.

* mlx: select Gemma 4 image resolution dynamically (#18603)

Replace the fixed checkpoint image budget with per-image selection across
the supported 70, 140, 280, 560, and 1120 budgets. Choose the publisher resize
grid closest to the input resolution, accounting for aspect ratio.

This preserves more detail in high-resolution documents while allowing
smaller images to use fewer tokens, without adding an API parameter.

Cover budget boundaries, extreme dimensions, position limits, and media
expansion for both vision architectures.

* mlx: speed up Qwen 3.8 prompt processing (#18550)

* mlx: speed up Qwen 3.8 prompt processing

Use MLX's gated-delta kernel for long scans and fold dense MLP global scales into SwiGLU.

* address comments

* docs: document thinking control discovery (#18501)

* xgrammar: add standalone CMake project for native library (#18611)

Move the ollama_xgrammar target into mlxrunner/xgrammar/native so it
can be configured on its own against an installed xgrammar. cmake/mlx
now adds it as a subdirectory and still uses the pinned xgrammar.

* launch: default Claude Code to client-side auto checks (#18596)

* mlxrunner: Update XGrammar to 0.2.7 for structured outputs

We pick up schema fixes for typed dictionary values and short arrays.

* app: sync macOS update menu and icon at startup (#18622)

* app: defer Settings model discovery (#18598)

* app: isolate cloud-setting tests from Windows user config (#18626)

Set USERPROFILE alongside HOME in both cloud-setting handler tests.
On Windows, os.UserHomeDir uses USERPROFILE, so the tests could write
to the developer's real server.json and leave cloud disabled.

* api: deprecate typical_p (#18627)

Switch from rejecting API requests to logging a warning.  Model creation still rejects the deprecated param.

Follow up from #18448 to remove the hard API failure.

* llama-server: prepare to remove compatibility patch

Add manifest-list storage so runner-specific manifests can coexist under one tag while preserving existing v1 tags as best-effort downgrade anchors. Show/list/copy/remove/pull/push now understand runner and digest selection and transfer referenced child manifests and layers.

Add lazy local compatibility migration for legacy Ollama GGUFs into llama.cpp-compatible children, covering the patched model families and preserving parser/renderer, templates, projectors, media metadata, split GGUFs, and MTP/draft tensors where applicable.

Extend create/import/conversion paths for the same compatibility rules, harden manifest-list combine validation, and add focused manifest, migration, transfer, and integration coverage for first-load conversion plus chat/tools/vision/audio/embedding behavior.

* bench: use HumanEval patch prompts (#17480)

* bench: use code prompts for prompt-token runs

Replace the synthetic word-list prompt with packed HumanEval Python prompts so speculative draft models see code-like continuations.

Keep the benchmark on the chat path, and calibrate -prompt-tokens with untimed chat probes that read PromptEvalCount instead of relying on a separate token-count API.

Each request still gets a nonce prefix to avoid prefix-cache hits while timed epochs measure the chat-rendered workload.

* review comments

* use different windows for each epoch

* add OpenAI API support

* address comments

* feat: add System One scoring API (#18606)

* mlx: bound pull stall retries and let the watchdog interrupt them (#18625)

* transfer: bound stall retries and let the watchdog interrupt them

A download that stalls could never recover. copy derived its own
cancellable context, but the request was built from the parent, so
cancelling on a stall never reached the in-flight body and the read
stayed parked. The stall watchdog could detect a stall it had no way
to stop.

Stall retries were also unbounded: they never incremented attempt, so
the retry loop had no limit, and because backoff was gated on
attempt > 0 they retried with no delay at all.

The request now owns the cancellable context and passes its cancel
down to copy, so a stall aborts the read. Stalls get their own retry
budget before counting against the limit, and backoff is keyed to
every retry rather than only the counted ones.

* move out of x/

* feat: allow ten web searches per response (#18602)

* MLX: version bump (#18651)

* llama.cpp: version bump b11232 (#18652)

* create: support explicit model capabilities (#18708)

Add CAPABILITY declarations to Modelfiles and an additive capabilities
field to create requests. Preserve declarations across GGUF and safetensors
creation, inheritance, and Modelfile export.

Require decision capability before scheduling System One requests instead
of matching Qwen architecture/renderer metadata. Retain main's GGUF-only
scoring restriction until the separate MLX runtime work lands.

Extracted from the capability foundation in 36d46a0c3 on system_one_mlx;
MLX scoring and manifest-list changes are intentionally separate.

* docs: document System One API (#18702)

* openai: keep tool message content parts in one message

FromChatRequest splits array content into one api.Message per part. That
is intended for user content, but a tool message is a single result: the
split also dropped its tool_call_id and tool name, since those were only
copied when the message had tool_calls. Renderers that resolve tool
results by ID then see extra, unnamed results; for example, Kimi K3 fails
with "tool message 2 has no resolvable tool name" on a tool result with
two text parts, which the OpenAI spec allows.

Merge the parts of a tool message into one message with the text joined,
the images kept, and ToolCallID and ToolName set, matching how
function_call_output items are converted for /v1/responses.

* openai: keep empty tool results sent as an empty content array

A tool message with "content": [] produced no message at all, so the
tool call it answers had no result in the rendered prompt. Emit an empty
tool message that keeps its ToolCallID and ToolName, and skip it only
when it has no parts, call id, or name.

* server: report only decision capability for decision models (#18737)

Show and list now return just "decision" for models declaring it, so clients don't offer them for general chat, tools, or thinking. The show response also omits the thinking field for these models. Scheduling and serving still check the full capability set.

* README: add oxi to community integrations

* models: add clef support (#18741)

* ci: fix missing build context (#18742)

* openai: keep image positions when merging tool result parts

Merging a tool result's parts collected its images separately from the
text, so renderers placed them all before the text: "Before: <A> After:
<B>" rendered as "<A><B>Before: After:". Write an [img] placeholder at
each image's position so renderContentWithImageTags and chatPrompt put
each image back where it was.

* docs: link to available decision models (#18758)

* docs: document image input for decision models (#18757)

* openai: split tool results with images instead of adding [img] markers

The [img] placeholders mixed internal markers into tool text: the native
llama-server path sends them as literal text, so an image-only result
gained a text part, and tool output containing [img] or [img-N] moved or
dropped image tags. api.Message cannot carry image positions without
in-band markers, so stop merging tool results that include images.

Text-only tool results, the only array form the Chat Completions spec
allows for tool messages, are still merged into one message (now with a
strings.Builder). Results with images keep the per-part split in order,
which preserves image positions, with the tool call id and name set on
every part.

* mlx: System one support (#18701)

* mlxrunner: restore System One scoring

Carry the MLX implementation and its tests from the original System One
commit. The API/compiler and llama-server implementation already exist on
the release branch, so retain those versions. Adapt the optional model test
to the renamed decision package and its explicit rendering/context setup.

(cherry picked from commit 26e546ddb3897b4564f03d3bdbdbefce9281edf8)

* Enable MLX System One and add regression coverage

* mlxrunner: add Laya support for System One

Import Laya checkpoints and implement bidirectional decision scoring.

* mlxrunner: release cached buffers after System One scoring

* decision: match Tev1 and Nimble publisher prompt formats

Select Tev1 prompts using renderer metadata and fix JSON formatting, with regression coverage for GGUF and MLX.

* mlx: support Clef and Clef Flash decision models

Add model import, quantization safeguards, and text/image scoring with the Clef joint decision head.

* support vision capabilities for decision models

* Make Clef scoring cancellable between prefill chunks

Preserve joint-head inputs and test cancellation, cleanup, and recovery.

* mlx: separate decision preparation and readout from forward

Let serial and batched scoring share model-owned preparation and readout
without duplicating architecture-specific logic in the runner.

* mlx: add Strands Decider support

* implement caching

---------

Co-authored-by: ParthSareen <[email protected]>

* mlx: Decision model improvements (#18776)

* reject instead of truncate on overflow

* tune route logic for faster warm runner lookup

* mlx: match publisher tokenizer semantics (#18779)

* mlx: match publisher tokenizer semantics

Honor pretokenizer stage order, split behavior, Unicode boundaries,
added-token normalization, and ranked BPE merges. Handle empty added
tokens and empty Metaspace input consistently.

Add shared Go/Python reference cases using published tokenizers, pulling
missing models directly and failing on errors, plus focused regressions
for configuration precedence, byte fallback, and parallel encoding.

* address comments

* pull: allow RCs to pull matching min_version (#18790)

Strip off pre-release from the version string so RCs can pull
models for the same release.

* test: split create integration tests out (#18470)

The create tests upload blobs which can cause problems when run in parallel on multiple systems.  This change splits them out with an explicit tag to make it easier to control when they are run.

* mlx: mitigate high latency after GPU idle (#18807)

Carry the MLX residency-refresh patch and enable it every second in the
runner, preserving explicit environment overrides.

Fixes #18744.

* Reduce model lookup and MLX decision request overhead (#18806)

* Reduce model lookup and MLX decision request overhead

Avoid decoding unrelated manifests when resolving existing model names.
Reuse small Metal scratch buffers between decision requests, releasing
larger working sets and clearing scratch after scoring errors.

* address comments

* llama.cpp: version update (#18761)

* MLX: version bump (#18720)

* MLX: version bump

* add scopes for unit tests to reduce memory usage

* mlx: fix patch for recent mlx update (#18812)

* docs: fix 6 dead links in README community integrations list

* model: add multimodal embeddings (#18820)

Implements the EmbeddingGemma2Model architecture on the MLX runner: 24-layer
bidirectional text encoder with PLE, shared gemma4 vision/audio towers,
mean-pool + L2 output. /api/embed accepts per-item media via input dicts.

* routes: fix embed 413 vs 400 routing (#18822)

* documentation re-structuring

* reorganizing the docs folder, adding error handling to the sample project, changing wording

* server: proxy cloud usage and balance APIs (#18829)

Forward GET /api/usage and GET /api/balance through the local server
using the signed-in account.

Add API documentation and tests for proxying, signing, and
disabled cloud access.

* llama: fix clef head reads past 2GiB on windows (#18777)

The Clef head read its weights with std::ifstream::seekg. The Windows
llama-server ships with libc++ 18.1.8, where that seek truncates the
offset to 32 bits. clef-flash stores the clef.* tensors at about 9.5GB,
so the head loaded backbone bytes as its weights and every
/v1/systemone request failed with "Clef: non-finite logit". clef:27b
keeps the head and output.weight below 2GB and was unaffected.

Read with ggml_fopen and an explicit 64-bit seek instead, as read_at
in llama/compat already does.

Fixes #18769

* keeping old urls, updating model retirement page

* cmd: remove account step from CLI onboarding (#18826)

* changing wording

* removing repetition, fixing a typo

* re-ordering top nav, splitting out sample project into new PR

* manifest: avoid symlinks on Windows (#18852)

Store named manifests as regular files on Windows, where symlinks can
be created successfully but fail when opened.

Repair existing symlinks lazily on read using the verified blob and
existing copy path. Keep locking consistent across platforms and avoid
reacquiring the store lock during pruning.

Fixes #18847

* mlx: drop carried metal residency patch now that it is upstream (#18854)

* Set CLAUDE_CODE_MAX_CONTEXT_TOKENS to whatever the models context window is

* server: hide duplicate and downgrade guards from list (#18874)

When a legacy GGUF which requires our llama.cpp patch set is loaded, we do a
lazy conversion on disk to make it llama.cpp compatible.  To support
downgrades, we temporarily hold both the new and old GGUFs and create a shadow
v1 manifest tag to prevent the downgraded server from deleting the new blobs.
Showing these in the list output is confusing to users and API consumers.  The
legacy copies will be removed in a future release to recover the disk space.

* respect CLAUDE_CODE_AUTO_COMPACT_WINDOW user setting

* launch: avoid inherited service-tier warnings in Codex (#18879)

* standardizing language referring to cloud services

* launch: suppress Claude Code connector warning for Ollama (#18878)

Co-authored-by: Parth Sareen <[email protected]>

* server: skip local model compatibility migration (#18908)

* decision: align request validation and option descriptions

* llama: update to b11521 and use native decision support

* llm: support multimodal embeddings through llama-server

* mlx: clip long laya states instead of rejecting them

* mlx: read candidate logits in float32 for quantized heads

* server: reuse verified manifests and loaded models in inference routes (#18947)

* server: reuse verified manifests and loaded models in inference routes

Resolve named manifests and runner selection in one verified cold lookup.
When a runner is loaded, reuse its model after checking that the v2 tag
still points to the same digest. Fully verify regular-file manifests,
including Windows copies.

Share the lookup across generate, chat, embed, and System One. Keep parser
selection request-local so reusing a model does not mutate its config.

Cover tag changes, runner selection, concurrent unloads, and existing
missing-model responses with regression tests and a lookup benchmark.

* address comments

* mlx: compact restored recurrent state after speculative rollback (#18955)

* mlx: compact restored recurrent state after speculative rollback

Per-token recurrent captures can leave a restored state pointing into a larger buffer. If a request ends before another model step, the live cache retains that buffer even though it accounts for only the selected state.

Track when a restored state may share that backing buffer. At request close, compact marked states in one batch before retaining them in the prefix cache. Clear the marker when a normal model step replaces the state, and cover restoration and buffer detachment in tests.

* address comments

* launch: populate Codex model picker with installed Ollama models (#18887)

* MLX, MLX-C: version bump (#18956)

* typo in docs

* docs: update README to include cloud and privacy language

* Revert "docs: restructuring" (#18960)

* docs: update SECURITY.md

- Directs users to Github advisories instead of hello email address

* Introduce clef and clef flash on cloud

* server: fix multimodal embedding load with small num_ctx (#18973)

* Add Kev decision scoring to MLX (#18976)

* Add Kev decision scoring to MLX

Load Kev models with their FP32 decision head and release metadata.
Support System One scoring with shared-state caching and Kev-specific limits.

* address comments

* mlx: preserve generation panics during cleanup (#18886)

A failure during decoding can trigger deferred drain and cache close, which may panic again and hide the original error. Skip stateful cleanup while a panic is unwinding so the runner reports the initial failure.

Add regression tests for the masked panic paths and normal cache saving.

* ci: harden download steps with retries (#18883)

Try a little harder instead of giving up on the first failure.

* gemma4: use MLX SDPA for CUDA prefill with wide head dims (#18809)

MLX's SDPA already handles head dims > 128 on CUDA, and is faster than our formerly required hand-rolled one.

* docs: changing model recs to Models page link, updating references to Ollamas cloud

* Add decision model integration tests and benchmarks (#18746)

* Add decision model integration tests and benchmarks

Support external JSONL corpora, quality scoring, concurrent requests, vision, and System One timing metrics.

* Refine decision tests and benchmarks with cache checks, external endpoints, and consistent response validation and timing

* cli: add decision model support to `ollama run` (#18962)

* decision: fix JSON state prompts for MLX decision models (#18974)

* renderers: add Python json.dumps serializer

* decision: render JSON states like the publishers' json.dumps

* Update README for improved privacy wording

* app: clarify cloud payment errors

* launch: allow usage credits without upgrading (#18985)

* mlx: port the Metal custom kernels to CUDA (#18657)

* mlx: port the Metal custom kernels to CUDA

mamba2_scan, depthwise_conv_silu and gated_delta (plus their _states/_bias
variants) had a Metal source only, so on CUDA each fell back to graph ops.

Deviations from the Metal sources:

- The scan returns early past D: Metal dispatches an exact thread count,
  CUDA rounds the grid up to whole blocks.
- T is dereferenced; CUDA passes inputs by address, Metal scalarizes
  zero-dimensional ones.
- simd_sum becomes a shfl butterfly, and the threadgroup q/k caches become
  per-warp registers: each warp normalizes the row its own lanes consume,
  costing a redundant norm but no shared memory and no barriers.
- The gates and SiLU call MLX's Sigmoid/LogAddExp/Exp instead of restating
  their formulas. Metal cannot: its custom-kernel preamble is metal::utils()
  alone, while CUDA embeds the op headers for nvrtc.

The parity tests now run on Metal and CUDA hosts.  The fused gated-delta
comparison takes a tolerance: the kernel and the graph path reduce in a
different order, so the bf16 output can land one ULP away.

* address comments

* openai: accept custom tool calls in Responses history (#18911)

Co-authored-by: Jeffrey Morgan <[email protected]>

* MLX: version bump (#18993)

* revert docs changes for now

* use cloudPassthroughMiddleware

* server: stop HTML-escaping cloud proxy request bodies (#19008)

* proxy: pass through ChatGPT upstream access errors (#19007)

* openai: clarify Responses authentication errors (#19004)

* New model... (#19030)

* ci: shorten Windows Vulkan build path

Keep the nested shader-generator compiler probes below Windows path limits in checkouts with longer repository names.

* mlx: fix Nemotron bugs and support global scales

Accept published Nemotron layer names while retaining legacy aliases, and
fix layer-count inference and detached MTP quantization. Stabilize Mamba
softplus, preserve FP32 vision normalization, and compile Mamba gate and
norm scaling.

Support per-expert F32 global scales and preserve activation-scale
companions in ModelOpt and compressed-tensors NVFP4 imports. Normalize
reciprocal globals and reject invalid scales. Keep activation scales
separate from weight-only inference.

* mlx: add Nemotron 3.5 Super

* minor adjustments

* llama.cpp: version bump b11669 (#19032)

* win: prevent orphaned runners (#18500)

* win: prevent orphaned runners

Assign runner processes to a singleton Windows Job Object configured with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE. This lets Windows terminate owned llama-server and MLX subprocesses when Ollama exits, including forced termination where graceful cleanup cannot run.

* address comments

* clef cloud launch

* be more precise with wording

* gguf: add the q2_0 tensor and file types (#18967)

* cleanup

* use identifiers for --ask mode question keys

* test

* transfer: support proxies on registry redirect targets (#19065)

Behind a proxy, defer redirect-target DNS to the proxy; without one, keep the resolve-and-pin path. Trust default-registry/CDN hostnames with no local DNS. Fix a nil CancelFunc crash in blobDownload.release.

* docs: add model grouping to cloud usage (#19069)

* docs: add model grouping to cloud usage

Document group_by=model in the cloud usage guide and OpenAPI schema.
Explain group selection and remainder, and show responses with multiple
models across time buckets.

* Update docs/api/cloud-usage.mdx

Co-authored-by: Bruce MacDonald <[email protected]>

---------

Co-authored-by: Bruce MacDonald <[email protected]>

* openai: allow Responses effort on non-thinking models (#19010)

* llama-server: let llama-server infer the draft speculative type (#19064)

llama-server can auto-detect most drafting models, so only pass the --spec-type
for drafting models it can't autodetect today: MTP sidecars detected by
Ollama's existing markers, and Eagle3.

* mlx: add PPLX Decider v1.2 support (#19072)

Implement the Qwen3.5-backed decision scorer with noncausal attention,
the publisher readout, image handling, and System One prompt encoding.

* api: populate show renderer/parser fields and add template_source (#19095)

ShowResponse's renderer and parser fields existed but the server never
set them; they now carry the effective values (renderer resolves the
gemma4 legacy alias by model size). A new template_source names what
actually renders chat prompts: the configured renderer/parser (leaving
any packaged template inert), a Go template layer, the GGUF's embedded
jinja, harmony, or none.

The CLI prints renderer/parser/template source rows only when set, so
ollama show output is unchanged for models without rendering config.

* openai: accept foreign compaction in Responses history (#19003)

* server: cancel remote inference when clients disconnect (#19144)

* avoid scary claude warning about auto compact window being too big

* openai: finish reasoning before client tool calls (#19146)

* llama.cpp: version bump b11738 (#19143)

* server: read loaded runner models without refMu (#19070)

* server: read loaded runner models without refMu

Concurrent lookups of a warm model failed TryLock against each other and
fell back to a manifest reload, defeating the cache and making
TestLoadedModelLookupConcurrent flaky. Make runnerRef.model an
atomic.Pointer so lookups never take refMu.

* address comments

* mlx: deduplicate CUDA runtime payloads (#17956)

* Deduplicate MLX CUDA runtime payloads

Move CUDA libraries shared by the GGML and MLX backends into the sibling CUDA payload, and teach in-process and subprocess MLX loading to resolve that packaged dependency directory.

Keep MLX-private libraries and JIT headers in the MLX overlay, include the full OpenBLAS Fortran runtime closure, and verify those dependencies in release packaging.

* address comments

* mlx: add Flint model support (#19181)

Preserve source tool JSON alongside decoded API values so Flint can retain
numeric types and schema order in prompts. Existing API marshaling is unchanged.

Assemble ModelOpt expert banks during safetensors import, and reject direct
Flint NVFP4 creation before conversion. Other models retain their existing
import and quantization paths.

Add optional learned sinks and device causal masks to shared MLX attention.
Existing callers retain the no-sink and host-mask paths; Flint opts into the
new behavior.

* ci: switch to released WoA CTK (#19185)

We were still using a pre-release, and the download site is flaky, so lets
get current on the latest CUDA Toolkit for WoA support.

* llama.cpp update (#19194)

* anthropic: surface errors after streaming starts (#19188)

* mlx: add d3 decision model support (#19196)

* mlx: add d3 decision model support

* bench: report loaded VRAM for decision runs

* build: update Go toolchain and dependencies (#19200)

* launch: use cloud model context in Claude Code (#19119)

* build: update jsonparser to v1.1.2 (#19220)

* mlxrunner: add Phonon text-to-speech support (#19166)

* mlxrunner: add Phonon text-to-speech support

Add Phonon text-to-speech through the existing MLX runner, with an
OpenAI-compatible speech endpoint and CLI playback.

Include model loading, text preprocessing, streaming audio, and
regression tests.

* docs: add speech models

* fix min version

---------

Co-authored-by: Daniel Hiltgen <[email protected]>

* flint: fix replies with thinking disabled (#19216)

* flint: fix replies with thinking disabled

Close the thinking section when think:false so Flint answers directly. Default and think:true prompts are unchanged.

* update template

* anthropic: reuse resolved thinking for web search (#19098)

* openai: preserve failures in Responses streams (#19225)

* Make sure all launchers know about cloud model metadata (#19223)

* Support GA Gradium Phonon checkpoints (#19227)

Replace the prerelease checkpoint path with Gradium's GA format, including default-voice import and speech conditioning. Set the 0.40.9 minimum, update the speech docs, and test import, inference setup, and rejection of the old checkpoint.

* Update gemma renderers (#19241)

* renderers: add gemma4-nemotron renderer

Add a Gemma 4 renderer variant that renders assistant content before
its tool calls rather than after the tool responses. Models opt in with
RENDERER gemma4-nemotron; gemma4 auto-detection is unchanged.

Adds the corresponding chat template as a test fixture for Jinja parity
checks.

* mlx: support Gemma 4 targets with DFlash drafts

Load a draft-owned output head when its config requires one, while preserving the target-head path used by existing DFlash models.

Expose Gemma 4 hidden-state taps and raw logits for speculative decoding. Report safetensors target precision independently of quantized draft weights.

* qwen3coder: preserve literal function closing tags in parameters (#19228)

* launch: use allocated context for OpenCode (#19193)

* decision: allow empty state for vllm-d3 (#19173)

* decision: allow empty state for vllm-d3

* server: reuse decoded state in System One tests

---------

Co-authored-by: Patrick Devine <[email protected]>

* llama.cpp: version bump b11845 (#19250)

* mlxrunner: spell out symbols, numbers and links for Phonon (#19234)

* mlxrunner: spell out symbols, numbers and links for Phonon

* docs: describe speech text normalization

* mlxrunner: fix Phonon misreadings inherited from xn-ptts

* mlxrunner: fix remaining Phonon misreadings

* mlxrunner: fold Phonon letters from the vocab, read #, _ and lists

* mlxrunner: add xn-ptts license notice for Phonon

* mlxrunner: move the xn-ptts license notice into normalize.go

* mlxrunner: fix remaining Phonon readings and port elongations

* docs: speech reads times and numeric dates

* mlxrunner: fix Phonon readings found in a listening pass

* docs: speech reads times and dates as written

* voice: add voice catalog for Phonon (#19242)

* mlxrunner: import and list Phonon catalog voices

* docs: document Phonon voices

* mlx: preserve small-image detail for compact Gemma 4 vision towers (#19247)

Dynamic sizing can floor the smallest image grid below its intended 70-token budget, losing detail in small images. Round that grid up for the compact tower, capped at the next supported budget.

Keep explicit budgets and the existing sizing for larger and unified towers. Update geometry and media-expansion tests.

* MLX, MLX-C: version bump - prompt speed up for gemma/flint/laguna (#19291)

* MLX, MLX-C: version bump

The MLX-C pin now provides its own bindings for gather_qmm global_scale
and fast::gated_delta_update, so those two carried patches drop out.
Carry 0001-mlx-c-sdpa-window-size instead: sliding-window attention
added a window_size argument to fast::scaled_dot_product_attention
(ml-explore/mlx#4734) that MLX-C has not bound yet, to be regenerated
from MLX-C once the upstream binding PR merges. The SDPA wrappers gain
a window size argument; all call sites default to the full context.

* mlxrunner: dispatch sliding-window prefills to the native SDPA window

Sliding layers no longer materialize a causal∩sliding mask for prefill
chunks past the window: resolve() dispatches {causal, window} natively
when the rotating cache's L>1 concat has linearized the ring and the
mask is otherwise pure causal, via a new MaskApplier.NativeWindow hint.
Vision relaxations, padding, model arrays, and decode keep the
materialized path. No model changes; sinks compose natively.

* dflash: add the DFlash2 draft model (#19149)

DFlash2 adds block-local dynamic convolutions and a candidate selector
to DFlash. The selector proposes each token conditioned on its
predecessor and returns each position's candidate distribution, which
verification uses to keep the output exact. Like the reference, the
draft samples with the request's temperature only.

A DFlash2 session drafts seven tokens every round on the existing
snapshot verify path instead of following the depth controller, whose
shallower picks lose more accepted tokens than they save in verify time.

qwen3.5-family targets now expose the layer taps, token embeddings and
raw logits a DFlash draft needs.

* llama.cpp: version bump b11901 (#19311)

* Fix kimi cli tool-only assistant turns (#19312)

* Fix kimi cli

* just interpret [] same as empty string actually

* dont gate on role

* cmd/launch: fix OpenCode v2 launch and config parsing (#19310)

Co-authored-by: 0d00ciallo0721 <[email protected]>

* mlx: add LFM3 and d1 models (#19333)

* llm: LFM3 GGUF fixes and llama-server speech (#19344)

Fixes for running LFM3 GGUFs on the llama-server runner, plus GGUF
text-to-speech that turns on once llama.cpp is bumped past b11901.

- BOS: honor an explicit tokenizer.ggml.add_bos_token. LFM3 GGUFs (and
  lfm2:24b) set it to false and expect the template's BOS, which the
  lfm2 default was stripping. The lfm2 default still applies when the
  key is absent. On lfm2:24b, WikiText PPL goes from 81.3 to 72.0.
- repeat_last_n -1 now maps to the context size; llama-server rejects
  negative values.
- Audio-only projectors (LFM3-Audio) no longer advertise vision, so
  clients don't send images the model can't take.
- /v1/audio/speech on GGUF models calls llama-server /tts chunk by
  chunk. Renderers opt in through a new SpeechPrompter (voices,
  voice parsing, chunking), so other speech models can add their own.
  The LFM3 voice and chunking helpers move from the MLX runner into
  model/renderers and are shared by both runners.

* llama.cpp: version bump b11963 (#19360)

* cmd: show help when running ollama without arguments (#19248)

* llama.cpp: workaround Metal unary crash (#19372)

This temporary patch works around a regression on older versions of MacOS
ggml_metal_library_compile_all: failed to build 'unary' library

* ci: pin buildx to workaround deadlock (#19373)

Recent buildx updates are causing frequent deadlocks in our CI builds.
Until this is resolved upstream, pin to an older version.

* openai: preserve readable Responses input content (#19192)

* mlx: sort long top-k rows in chunks (#19392)

MLX's argpartition sorts the whole row, and a row longer than one block
of the GPU sort takes a multi-pass merge sort. TopKIndices sorts each
2048-value chunk in a single block, then only the chunks' top k, and
returns the same indices in the same order.

The sampler's top_k and top_logprobs and the DFlash2 candidate selector
use it in place of a full-vocabulary argpartition.

* app: make ChatGPT disconnect failures retryable (#19336)

* feat(launch): use model output limits for Claude Code (#19410)

* openai: don't override model sampler defaults (#19432)

The OpenAI-compatible endpoints filled in sampler options the client
left out: temperature and top_p fell back to 1.0, and /v1/completions
always sent frequency_penalty and presence_penalty as 0. Request
options are applied last, so these values replaced the model's packaged
defaults. /api/chat honored those defaults; /v1 did not.

Omitted options are now left unset on /v1/chat/completions,
/v1/completions and /v1/responses, so the model's parameters apply, the
same as on /api/chat. Values the client sends still win, including an
explicit 0. On /v1/completions, top_p and the penalties are now
pointers so "omitted" and "0" can be told apart.

Clients that send no sampler options now get the model's defaults
instead of 1.0/1.0. A model with no sampler parameters gets Ollama's
defaults (temperature 0.8, top_p 0.9), as on /api/chat.

Fixes #17744
Fixes #18690

* launch: check ChatGPT routing before configuring (#19470)

* server: decode cloud web search responses (#19476)

* mlx: load bundled CUDA libraries in-process on Linux (#19433)

NVIDIA's libcusolver looks for its dependencies only in its own
directory, so libcublas and libnvJitLink resolved to the host's copies
and MLX failed to load when those didn't match the bundled ones. Preload
the bundled copies by full path before loading MLX.

* model: add MiMo V2.6 renderer for Qwen3.5 (#19400)

* launch: populate Pi models automatically (#19460)

* Add AutoTrust decision model to MLX (#19399)

* Add AutoTrust decision scoring to MLX

* address comments

* Support AutoTrust 35B decision models in MLX

* Resolve AutoTrust choice limits during config loading

Apply publisher-specific defaults and validate requests against the resolved limit.

* mlx: reject unsupported CUDA devices (#19521)

* mlx: bump for CUDA architecture metadata

* mlx: reject unsupported CUDA devices

* address comments

* mlx: support YaRN scaling in Qwen3 and Qwen3.5 (#19231)

* llama.cpp: version bump b12111 (#19530)

Drop 002-metal-unary-cast-constexpr.patch: superseded by upstream fix

* llama-server: allow parallel requests for recurrent and vision models (#19545)

These architectures were forced to num_parallel=1 because the older Go
engine's recurrent caches held one sequence. llama-server supports
multiple slots for all of them so we can allow parallelism now.

* cmd/launch: show gateway model names in Claude Desktop's model picker (#19533)

* cmd: restore the no-argument launcher (#19478)

Co-authored-by: Jeffrey Morgan <[email protected]>

* mlxrunner: close generation cache on shutdown (#19550)

* cmd/launch: add Kimi Code CLI support (#19506)

* openai: forward truncation option in responses requests (#19501)

Co-authored-by: Eva Ho <[email protected]>

* openai: return an empty array for /v1/models when no models are installed (#19539)

* llama.cpp: version bump b12177 (#19576)

* README: add Quock to Mobile community integrations (#19361)

* windows: add CUDA 13.5 and SM 103 for ARM64 (#19580)

Install the separate ARM64 cross package in CI and retain SM 121
support. Other platforms are unchanged.

* MLX: make Qwen3.8 Flash Next memory efficient (#18078)

* MLX: reduce Qwen3.8 Flash Next memory use

For NVFP4 creation, retain source precision for sensitive QSA projections
and non-expert MTP weights. Keep routed experts and PLE at NVFP4, and
promote other eligible weights to MXFP8.

Keep NVFP4 PLE tables host-backed, transferring only selected packed rows
and their scales to MLX. Honor scalar and per-expert NVFP4 global scales
in MoE, and per-shard global scales in host-backed PLE.

Use compressed QSA block selections in fused indexed Metal attention for
long prefill batches, retaining the graph fallback. Co-locate component
loading and forward methods, with explicit quantization and cache ownership.

* mlx: skip materializing host-backed tensors

Let models exclude tensors already owned by host storage from MLX loading.
Avoid allocating and discarding the full Qwen PLE tables at startup while
preserving the resident fallback.

* address comments

* launch: fix Claude Code routing and retired model errors (#19587)

* Add ripple preview support to the MLX runner (#19592)

Add the Ripple model, renderer, parser and import registration.
Support per-layer NoPE in DFlash drafts.
Fuse MLP activation, value blending and attention gating.
Add reference fixtures and model/runner regression tests.

---------

Co-authored-by: Daniel Hiltgen <[email protected]>
Co-authored-by: Jesse Gross <[email protected]>
Co-authored-by: Parth Sareen <[email protected]>
Co-authored-by: Eva H <[email protected]>
Co-authored-by: Patrick Devine <[email protected]>
Co-authored-by: Devon Rifkin <[email protected]>
Co-authored-by: Daniel Hiltgen <[email protected]>
Co-authored-by: Dong Chen <[email protected]>
Co-authored-by: manu <[email protected]>
Co-authored-by: Jeffrey Morgan <[email protected]>
Co-authored-by: Dongluo Chen <[email protected]>
Co-authored-by: Aniket Kumar <[email protected]>
Co-authored-by: Anna Rahn <[email protected]>
Co-authored-by: Gigrise <[email protected]>
Co-authored-by: Anna Rahn <[email protected]>
Co-authored-by: Jonathan Berg <[email protected]>
Co-authored-by: J Berg <[email protected]>
Co-authored-by: Anna Rahn <[email protected]>
Co-authored-by: Willie Tran <[email protected]>
Co-authored-by: Bruce MacDonald <[email protected]>
Co-authored-by: SynapShift <[email protected]>
Co-authored-by: 0d00ciallo0721 <[email protected]>
Co-authored-by: Marlon Ferreira <[email protected]>
Co-authored-by: Eva Ho <[email protected]>
Co-authored-by: liangliang205 <[email protected]>
Co-authored-by: Matteo Celani <[email protected]>
rick-github added a commit to rick-github/ollama that referenced this pull request Nov 8, 2026
* anthropic: reuse resolved thinking for web search (ollama#19098)

* openai: preserve failures in Responses streams (ollama#19225)

* Make sure all launchers know about cloud model metadata (ollama#19223)

* Support GA Gradium Phonon checkpoints (ollama#19227)

Replace the prerelease checkpoint path with Gradium's GA format, including default-voice import and speech conditioning. Set the 0.40.9 minimum, update the speech docs, and test import, inference setup, and rejection of the old checkpoint.

* Update gemma renderers (ollama#19241)

* renderers: add gemma4-nemotron renderer

Add a Gemma 4 renderer variant that renders assistant content before
its tool calls rather than after the tool responses. Models opt in with
RENDERER gemma4-nemotron; gemma4 auto-detection is unchanged.

Adds the corresponding chat template as a test fixture for Jinja parity
checks.

* mlx: support Gemma 4 targets with DFlash drafts

Load a draft-owned output head when its config requires one, while preserving the target-head path used by existing DFlash models.

Expose Gemma 4 hidden-state taps and raw logits for speculative decoding. Report safetensors target precision independently of quantized draft weights.

* qwen3coder: preserve literal function closing tags in parameters (ollama#19228)

* launch: use allocated context for OpenCode (ollama#19193)

* decision: allow empty state for vllm-d3 (ollama#19173)

* decision: allow empty state for vllm-d3

* server: reuse decoded state in System One tests

---------

Co-authored-by: Patrick Devine <[email protected]>

* llama.cpp: version bump b11845 (ollama#19250)

* mlxrunner: spell out symbols, numbers and links for Phonon (ollama#19234)

* mlxrunner: spell out symbols, numbers and links for Phonon

* docs: describe speech text normalization

* mlxrunner: fix Phonon misreadings inherited from xn-ptts

* mlxrunner: fix remaining Phonon misreadings

* mlxrunner: fold Phonon letters from the vocab, read #, _ and lists

* mlxrunner: add xn-ptts license notice for Phonon

* mlxrunner: move the xn-ptts license notice into normalize.go

* mlxrunner: fix remaining Phonon readings and port elongations

* docs: speech reads times and numeric dates

* mlxrunner: fix Phonon readings found in a listening pass

* docs: speech reads times and dates as written

* voice: add voice catalog for Phonon (ollama#19242)

* mlxrunner: import and list Phonon catalog voices

* docs: document Phonon voices

* mlx: preserve small-image detail for compact Gemma 4 vision towers (ollama#19247)

Dynamic sizing can floor the smallest image grid below its intended 70-token budget, losing detail in small images. Round that grid up for the compact tower, capped at the next supported budget.

Keep explicit budgets and the existing sizing for larger and unified towers. Update geometry and media-expansion tests.

* MLX, MLX-C: version bump - prompt speed up for gemma/flint/laguna (ollama#19291)

* MLX, MLX-C: version bump

The MLX-C pin now provides its own bindings for gather_qmm global_scale
and fast::gated_delta_update, so those two carried patches drop out.
Carry 0001-mlx-c-sdpa-window-size instead: sliding-window attention
added a window_size argument to fast::scaled_dot_product_attention
(ml-explore/mlx#4734) that MLX-C has not bound yet, to be regenerated
from MLX-C once the upstream binding PR merges. The SDPA wrappers gain
a window size argument; all call sites default to the full context.

* mlxrunner: dispatch sliding-window prefills to the native SDPA window

Sliding layers no longer materialize a causal∩sliding mask for prefill
chunks past the window: resolve() dispatches {causal, window} natively
when the rotating cache's L>1 concat has linearized the ring and the
mask is otherwise pure causal, via a new MaskApplier.NativeWindow hint.
Vision relaxations, padding, model arrays, and decode keep the
materialized path. No model changes; sinks compose natively.

* dflash: add the DFlash2 draft model (ollama#19149)

DFlash2 adds block-local dynamic convolutions and a candidate selector
to DFlash. The selector proposes each token conditioned on its
predecessor and returns each position's candidate distribution, which
verification uses to keep the output exact. Like the reference, the
draft samples with the request's temperature only.

A DFlash2 session drafts seven tokens every round on the existing
snapshot verify path instead of following the depth controller, whose
shallower picks lose more accepted tokens than they save in verify time.

qwen3.5-family targets now expose the layer taps, token embeddings and
raw logits a DFlash draft needs.

* llama.cpp: version bump b11901 (ollama#19311)

* Fix kimi cli tool-only assistant turns (ollama#19312)

* Fix kimi cli

* just interpret [] same as empty string actually

* dont gate on role

* cmd/launch: fix OpenCode v2 launch and config parsing (ollama#19310)

Co-authored-by: 0d00ciallo0721 <[email protected]>

* mlx: add LFM3 and d1 models (ollama#19333)

* llm: LFM3 GGUF fixes and llama-server speech (ollama#19344)

Fixes for running LFM3 GGUFs on the llama-server runner, plus GGUF
text-to-speech that turns on once llama.cpp is bumped past b11901.

- BOS: honor an explicit tokenizer.ggml.add_bos_token. LFM3 GGUFs (and
  lfm2:24b) set it to false and expect the template's BOS, which the
  lfm2 default was stripping. The lfm2 default still applies when the
  key is absent. On lfm2:24b, WikiText PPL goes from 81.3 to 72.0.
- repeat_last_n -1 now maps to the context size; llama-server rejects
  negative values.
- Audio-only projectors (LFM3-Audio) no longer advertise vision, so
  clients don't send images the model can't take.
- /v1/audio/speech on GGUF models calls llama-server /tts chunk by
  chunk. Renderers opt in through a new SpeechPrompter (voices,
  voice parsing, chunking), so other speech models can add their own.
  The LFM3 voice and chunking helpers move from the MLX runner into
  model/renderers and are shared by both runners.

* llama.cpp: version bump b11963 (ollama#19360)

* cmd: show help when running ollama without arguments (ollama#19248)

* llama.cpp: workaround Metal unary crash (ollama#19372)

This temporary patch works around a regression on older versions of MacOS
ggml_metal_library_compile_all: failed to build 'unary' library

* ci: pin buildx to workaround deadlock (ollama#19373)

Recent buildx updates are causing frequent deadlocks in our CI builds.
Until this is resolved upstream, pin to an older version.

* openai: preserve readable Responses input content (ollama#19192)

* mlx: sort long top-k rows in chunks (ollama#19392)

MLX's argpartition sorts the whole row, and a row longer than one block
of the GPU sort takes a multi-pass merge sort. TopKIndices sorts each
2048-value chunk in a single block, then only the chunks' top k, and
returns the same indices in the same order.

The sampler's top_k and top_logprobs and the DFlash2 candidate selector
use it in place of a full-vocabulary argpartition.

* app: make ChatGPT disconnect failures retryable (ollama#19336)

* feat(launch): use model output limits for Claude Code (ollama#19410)

* openai: don't override model sampler defaults (ollama#19432)

The OpenAI-compatible endpoints filled in sampler options the client
left out: temperature and top_p fell back to 1.0, and /v1/completions
always sent frequency_penalty and presence_penalty as 0. Request
options are applied last, so these values replaced the model's packaged
defaults. /api/chat honored those defaults; /v1 did not.

Omitted options are now left unset on /v1/chat/completions,
/v1/completions and /v1/responses, so the model's parameters apply, the
same as on /api/chat. Values the client sends still win, including an
explicit 0. On /v1/completions, top_p and the penalties are now
pointers so "omitted" and "0" can be told apart.

Clients that send no sampler options now get the model's defaults
instead of 1.0/1.0. A model with no sampler parameters gets Ollama's
defaults (temperature 0.8, top_p 0.9), as on /api/chat.

Fixes ollama#17744
Fixes ollama#18690

* launch: check ChatGPT routing before configuring (ollama#19470)

* server: decode cloud web search responses (ollama#19476)

* mlx: load bundled CUDA libraries in-process on Linux (ollama#19433)

NVIDIA's libcusolver looks for its dependencies only in its own
directory, so libcublas and libnvJitLink resolved to the host's copies
and MLX failed to load when those didn't match the bundled ones. Preload
the bundled copies by full path before loading MLX.

* model: add MiMo V2.6 renderer for Qwen3.5 (ollama#19400)

* launch: populate Pi models automatically (ollama#19460)

* Add AutoTrust decision model to MLX (ollama#19399)

* Add AutoTrust decision scoring to MLX

* address comments

* Support AutoTrust 35B decision models in MLX

* Resolve AutoTrust choice limits during config loading

Apply publisher-specific defaults and validate requests against the resolved limit.

* mlx: reject unsupported CUDA devices (ollama#19521)

* mlx: bump for CUDA architecture metadata

* mlx: reject unsupported CUDA devices

* address comments

* mlx: support YaRN scaling in Qwen3 and Qwen3.5 (ollama#19231)

* llama.cpp: version bump b12111 (ollama#19530)

Drop 002-metal-unary-cast-constexpr.patch: superseded by upstream fix

* llama-server: allow parallel requests for recurrent and vision models (ollama#19545)

These architectures were forced to num_parallel=1 because the older Go
engine's recurrent caches held one sequence. llama-server supports
multiple slots for all of them so we can allow parallelism now.

* cmd/launch: show gateway model names in Claude Desktop's model picker (ollama#19533)

* cmd: restore the no-argument launcher (ollama#19478)

Co-authored-by: Jeffrey Morgan <[email protected]>

* mlxrunner: close generation cache on shutdown (ollama#19550)

* cmd/launch: add Kimi Code CLI support (ollama#19506)

* openai: forward truncation option in responses requests (ollama#19501)

Co-authored-by: Eva Ho <[email protected]>

* openai: return an empty array for /v1/models when no models are installed (ollama#19539)

* llama.cpp: version bump b12177 (ollama#19576)

* README: add Quock to Mobile community integrations (ollama#19361)

* windows: add CUDA 13.5 and SM 103 for ARM64 (ollama#19580)

Install the separate ARM64 cross package in CI and retain SM 121
support. Other platforms are unchanged.

* MLX: make Qwen3.8 Flash Next memory efficient (ollama#18078)

* MLX: reduce Qwen3.8 Flash Next memory use

For NVFP4 creation, retain source precision for sensitive QSA projections
and non-expert MTP weights. Keep routed experts and PLE at NVFP4, and
promote other eligible weights to MXFP8.

Keep NVFP4 PLE tables host-backed, transferring only selected packed rows
and their scales to MLX. Honor scalar and per-expert NVFP4 global scales
in MoE, and per-shard global scales in host-backed PLE.

Use compressed QSA block selections in fused indexed Metal attention for
long prefill batches, retaining the graph fallback. Co-locate component
loading and forward methods, with explicit quantization and cache ownership.

* mlx: skip materializing host-backed tensors

Let models exclude tensors already owned by host storage from MLX loading.
Avoid allocating and discarding the full Qwen PLE tables at startup while
preserving the resident fallback.

* address comments

* launch: fix Claude Code routing and retired model errors (ollama#19587)

* Add ripple preview support to the MLX runner (ollama#19592)

Add the Ripple model, renderer, parser and import registration.
Support per-layer NoPE in DFlash drafts.
Fuse MLP activation, value blending and attention gating.
Add reference fixtures and model/runner regression tests.

---------

Co-authored-by: Eva H <[email protected]>
Co-authored-by: J Berg <[email protected]>
Co-authored-by: Daniel Hiltgen <[email protected]>
Co-authored-by: SynapShift <[email protected]>
Co-authored-by: Patrick Devine <[email protected]>
Co-authored-by: Jeffrey Morgan <[email protected]>
Co-authored-by: 0d00ciallo0721 <[email protected]>
Co-authored-by: Parth Sareen <[email protected]>
Co-authored-by: Marlon Ferreira <[email protected]>
Co-authored-by: Eva Ho <[email protected]>
Co-authored-by: liangliang205 <[email protected]>
Co-authored-by: Matteo Celani <[email protected]>
rick-github added a commit to rick-github/ollama that referenced this pull request Nov 8, 2026
* anthropic: reuse resolved thinking for web search (ollama#19098)

* openai: preserve failures in Responses streams (ollama#19225)

* Make sure all launchers know about cloud model metadata (ollama#19223)

* Support GA Gradium Phonon checkpoints (ollama#19227)

Replace the prerelease checkpoint path with Gradium's GA format, including default-voice import and speech conditioning. Set the 0.40.9 minimum, update the speech docs, and test import, inference setup, and rejection of the old checkpoint.

* Update gemma renderers (ollama#19241)

* renderers: add gemma4-nemotron renderer

Add a Gemma 4 renderer variant that renders assistant content before
its tool calls rather than after the tool responses. Models opt in with
RENDERER gemma4-nemotron; gemma4 auto-detection is unchanged.

Adds the corresponding chat template as a test fixture for Jinja parity
checks.

* mlx: support Gemma 4 targets with DFlash drafts

Load a draft-owned output head when its config requires one, while preserving the target-head path used by existing DFlash models.

Expose Gemma 4 hidden-state taps and raw logits for speculative decoding. Report safetensors target precision independently of quantized draft weights.

* qwen3coder: preserve literal function closing tags in parameters (ollama#19228)

* launch: use allocated context for OpenCode (ollama#19193)

* decision: allow empty state for vllm-d3 (ollama#19173)

* decision: allow empty state for vllm-d3

* server: reuse decoded state in System One tests

---------

Co-authored-by: Patrick Devine <[email protected]>

* llama.cpp: version bump b11845 (ollama#19250)

* mlxrunner: spell out symbols, numbers and links for Phonon (ollama#19234)

* mlxrunner: spell out symbols, numbers and links for Phonon

* docs: describe speech text normalization

* mlxrunner: fix Phonon misreadings inherited from xn-ptts

* mlxrunner: fix remaining Phonon misreadings

* mlxrunner: fold Phonon letters from the vocab, read #, _ and lists

* mlxrunner: add xn-ptts license notice for Phonon

* mlxrunner: move the xn-ptts license notice into normalize.go

* mlxrunner: fix remaining Phonon readings and port elongations

* docs: speech reads times and numeric dates

* mlxrunner: fix Phonon readings found in a listening pass

* docs: speech reads times and dates as written

* voice: add voice catalog for Phonon (ollama#19242)

* mlxrunner: import and list Phonon catalog voices

* docs: document Phonon voices

* mlx: preserve small-image detail for compact Gemma 4 vision towers (ollama#19247)

Dynamic sizing can floor the smallest image grid below its intended 70-token budget, losing detail in small images. Round that grid up for the compact tower, capped at the next supported budget.

Keep explicit budgets and the existing sizing for larger and unified towers. Update geometry and media-expansion tests.

* MLX, MLX-C: version bump - prompt speed up for gemma/flint/laguna (ollama#19291)

* MLX, MLX-C: version bump

The MLX-C pin now provides its own bindings for gather_qmm global_scale
and fast::gated_delta_update, so those two carried patches drop out.
Carry 0001-mlx-c-sdpa-window-size instead: sliding-window attention
added a window_size argument to fast::scaled_dot_product_attention
(ml-explore/mlx#4734) that MLX-C has not bound yet, to be regenerated
from MLX-C once the upstream binding PR merges. The SDPA wrappers gain
a window size argument; all call sites default to the full context.

* mlxrunner: dispatch sliding-window prefills to the native SDPA window

Sliding layers no longer materialize a causal∩sliding mask for prefill
chunks past the window: resolve() dispatches {causal, window} natively
when the rotating cache's L>1 concat has linearized the ring and the
mask is otherwise pure causal, via a new MaskApplier.NativeWindow hint.
Vision relaxations, padding, model arrays, and decode keep the
materialized path. No model changes; sinks compose natively.

* dflash: add the DFlash2 draft model (ollama#19149)

DFlash2 adds block-local dynamic convolutions and a candidate selector
to DFlash. The selector proposes each token conditioned on its
predecessor and returns each position's candidate distribution, which
verification uses to keep the output exact. Like the reference, the
draft samples with the request's temperature only.

A DFlash2 session drafts seven tokens every round on the existing
snapshot verify path instead of following the depth controller, whose
shallower picks lose more accepted tokens than they save in verify time.

qwen3.5-family targets now expose the layer taps, token embeddings and
raw logits a DFlash draft needs.

* llama.cpp: version bump b11901 (ollama#19311)

* Fix kimi cli tool-only assistant turns (ollama#19312)

* Fix kimi cli

* just interpret [] same as empty string actually

* dont gate on role

* cmd/launch: fix OpenCode v2 launch and config parsing (ollama#19310)

Co-authored-by: 0d00ciallo0721 <[email protected]>

* mlx: add LFM3 and d1 models (ollama#19333)

* llm: LFM3 GGUF fixes and llama-server speech (ollama#19344)

Fixes for running LFM3 GGUFs on the llama-server runner, plus GGUF
text-to-speech that turns on once llama.cpp is bumped past b11901.

- BOS: honor an explicit tokenizer.ggml.add_bos_token. LFM3 GGUFs (and
  lfm2:24b) set it to false and expect the template's BOS, which the
  lfm2 default was stripping. The lfm2 default still applies when the
  key is absent. On lfm2:24b, WikiText PPL goes from 81.3 to 72.0.
- repeat_last_n -1 now maps to the context size; llama-server rejects
  negative values.
- Audio-only projectors (LFM3-Audio) no longer advertise vision, so
  clients don't send images the model can't take.
- /v1/audio/speech on GGUF models calls llama-server /tts chunk by
  chunk. Renderers opt in through a new SpeechPrompter (voices,
  voice parsing, chunking), so other speech models can add their own.
  The LFM3 voice and chunking helpers move from the MLX runner into
  model/renderers and are shared by both runners.

* llama.cpp: version bump b11963 (ollama#19360)

* cmd: show help when running ollama without arguments (ollama#19248)

* llama.cpp: workaround Metal unary crash (ollama#19372)

This temporary patch works around a regression on older versions of MacOS
ggml_metal_library_compile_all: failed to build 'unary' library

* ci: pin buildx to workaround deadlock (ollama#19373)

Recent buildx updates are causing frequent deadlocks in our CI builds.
Until this is resolved upstream, pin to an older version.

* openai: preserve readable Responses input content (ollama#19192)

* mlx: sort long top-k rows in chunks (ollama#19392)

MLX's argpartition sorts the whole row, and a row longer than one block
of the GPU sort takes a multi-pass merge sort. TopKIndices sorts each
2048-value chunk in a single block, then only the chunks' top k, and
returns the same indices in the same order.

The sampler's top_k and top_logprobs and the DFlash2 candidate selector
use it in place of a full-vocabulary argpartition.

* app: make ChatGPT disconnect failures retryable (ollama#19336)

* feat(launch): use model output limits for Claude Code (ollama#19410)

* openai: don't override model sampler defaults (ollama#19432)

The OpenAI-compatible endpoints filled in sampler options the client
left out: temperature and top_p fell back to 1.0, and /v1/completions
always sent frequency_penalty and presence_penalty as 0. Request
options are applied last, so these values replaced the model's packaged
defaults. /api/chat honored those defaults; /v1 did not.

Omitted options are now left unset on /v1/chat/completions,
/v1/completions and /v1/responses, so the model's parameters apply, the
same as on /api/chat. Values the client sends still win, including an
explicit 0. On /v1/completions, top_p and the penalties are now
pointers so "omitted" and "0" can be told apart.

Clients that send no sampler options now get the model's defaults
instead of 1.0/1.0. A model with no sampler parameters gets Ollama's
defaults (temperature 0.8, top_p 0.9), as on /api/chat.

Fixes ollama#17744
Fixes ollama#18690

* launch: check ChatGPT routing before configuring (ollama#19470)

* server: decode cloud web search responses (ollama#19476)

* mlx: load bundled CUDA libraries in-process on Linux (ollama#19433)

NVIDIA's libcusolver looks for its dependencies only in its own
directory, so libcublas and libnvJitLink resolved to the host's copies
and MLX failed to load when those didn't match the bundled ones. Preload
the bundled copies by full path before loading MLX.

* model: add MiMo V2.6 renderer for Qwen3.5 (ollama#19400)

* launch: populate Pi models automatically (ollama#19460)

* Add AutoTrust decision model to MLX (ollama#19399)

* Add AutoTrust decision scoring to MLX

* address comments

* Support AutoTrust 35B decision models in MLX

* Resolve AutoTrust choice limits during config loading

Apply publisher-specific defaults and validate requests against the resolved limit.

* mlx: reject unsupported CUDA devices (ollama#19521)

* mlx: bump for CUDA architecture metadata

* mlx: reject unsupported CUDA devices

* address comments

* mlx: support YaRN scaling in Qwen3 and Qwen3.5 (ollama#19231)

* llama.cpp: version bump b12111 (ollama#19530)

Drop 002-metal-unary-cast-constexpr.patch: superseded by upstream fix

* llama-server: allow parallel requests for recurrent and vision models (ollama#19545)

These architectures were forced to num_parallel=1 because the older Go
engine's recurrent caches held one sequence. llama-server supports
multiple slots for all of them so we can allow parallelism now.

* cmd/launch: show gateway model names in Claude Desktop's model picker (ollama#19533)

* cmd: restore the no-argument launcher (ollama#19478)

Co-authored-by: Jeffrey Morgan <[email protected]>

* mlxrunner: close generation cache on shutdown (ollama#19550)

* cmd/launch: add Kimi Code CLI support (ollama#19506)

* openai: forward truncation option in responses requests (ollama#19501)

Co-authored-by: Eva Ho <[email protected]>

* openai: return an empty array for /v1/models when no models are installed (ollama#19539)

* llama.cpp: version bump b12177 (ollama#19576)

* README: add Quock to Mobile community integrations (ollama#19361)

* windows: add CUDA 13.5 and SM 103 for ARM64 (ollama#19580)

Install the separate ARM64 cross package in CI and retain SM 121
support. Other platforms are unchanged.

* MLX: make Qwen3.8 Flash Next memory efficient (ollama#18078)

* MLX: reduce Qwen3.8 Flash Next memory use

For NVFP4 creation, retain source precision for sensitive QSA projections
and non-expert MTP weights. Keep routed experts and PLE at NVFP4, and
promote other eligible weights to MXFP8.

Keep NVFP4 PLE tables host-backed, transferring only selected packed rows
and their scales to MLX. Honor scalar and per-expert NVFP4 global scales
in MoE, and per-shard global scales in host-backed PLE.

Use compressed QSA block selections in fused indexed Metal attention for
long prefill batches, retaining the graph fallback. Co-locate component
loading and forward methods, with explicit quantization and cache ownership.

* mlx: skip materializing host-backed tensors

Let models exclude tensors already owned by host storage from MLX loading.
Avoid allocating and discarding the full Qwen PLE tables at startup while
preserving the resident fallback.

* address comments

* launch: fix Claude Code routing and retired model errors (ollama#19587)

* Add ripple preview support to the MLX runner (ollama#19592)

Add the Ripple model, renderer, parser and import registration.
Support per-layer NoPE in DFlash drafts.
Fuse MLP activation, value blending and attention gating.
Add reference fixtures and model/runner regression tests.

---------

Co-authored-by: Eva H <[email protected]>
Co-authored-by: J Berg <[email protected]>
Co-authored-by: Daniel Hiltgen <[email protected]>
Co-authored-by: SynapShift <[email protected]>
Co-authored-by: Patrick Devine <[email protected]>
Co-authored-by: Jeffrey Morgan <[email protected]>
Co-authored-by: 0d00ciallo0721 <[email protected]>
Co-authored-by: Parth Sareen <[email protected]>
Co-authored-by: Marlon Ferreira <[email protected]>
Co-authored-by: Eva Ho <[email protected]>
Co-authored-by: liangliang205 <[email protected]>
Co-authored-by: Matteo Celani <[email protected]>
rick-github added a commit to rick-github/ollama that referenced this pull request Nov 8, 2026
* anthropic: reuse resolved thinking for web search (ollama#19098)

* openai: preserve failures in Responses streams (ollama#19225)

* Make sure all launchers know about cloud model metadata (ollama#19223)

* Support GA Gradium Phonon checkpoints (ollama#19227)

Replace the prerelease checkpoint path with Gradium's GA format, including default-voice import and speech conditioning. Set the 0.40.9 minimum, update the speech docs, and test import, inference setup, and rejection of the old checkpoint.

* Update gemma renderers (ollama#19241)

* renderers: add gemma4-nemotron renderer

Add a Gemma 4 renderer variant that renders assistant content before
its tool calls rather than after the tool responses. Models opt in with
RENDERER gemma4-nemotron; gemma4 auto-detection is unchanged.

Adds the corresponding chat template as a test fixture for Jinja parity
checks.

* mlx: support Gemma 4 targets with DFlash drafts

Load a draft-owned output head when its config requires one, while preserving the target-head path used by existing DFlash models.

Expose Gemma 4 hidden-state taps and raw logits for speculative decoding. Report safetensors target precision independently of quantized draft weights.

* qwen3coder: preserve literal function closing tags in parameters (ollama#19228)

* launch: use allocated context for OpenCode (ollama#19193)

* decision: allow empty state for vllm-d3 (ollama#19173)

* decision: allow empty state for vllm-d3

* server: reuse decoded state in System One tests

---------

Co-authored-by: Patrick Devine <[email protected]>

* llama.cpp: version bump b11845 (ollama#19250)

* mlxrunner: spell out symbols, numbers and links for Phonon (ollama#19234)

* mlxrunner: spell out symbols, numbers and links for Phonon

* docs: describe speech text normalization

* mlxrunner: fix Phonon misreadings inherited from xn-ptts

* mlxrunner: fix remaining Phonon misreadings

* mlxrunner: fold Phonon letters from the vocab, read #, _ and lists

* mlxrunner: add xn-ptts license notice for Phonon

* mlxrunner: move the xn-ptts license notice into normalize.go

* mlxrunner: fix remaining Phonon readings and port elongations

* docs: speech reads times and numeric dates

* mlxrunner: fix Phonon readings found in a listening pass

* docs: speech reads times and dates as written

* voice: add voice catalog for Phonon (ollama#19242)

* mlxrunner: import and list Phonon catalog voices

* docs: document Phonon voices

* mlx: preserve small-image detail for compact Gemma 4 vision towers (ollama#19247)

Dynamic sizing can floor the smallest image grid below its intended 70-token budget, losing detail in small images. Round that grid up for the compact tower, capped at the next supported budget.

Keep explicit budgets and the existing sizing for larger and unified towers. Update geometry and media-expansion tests.

* MLX, MLX-C: version bump - prompt speed up for gemma/flint/laguna (ollama#19291)

* MLX, MLX-C: version bump

The MLX-C pin now provides its own bindings for gather_qmm global_scale
and fast::gated_delta_update, so those two carried patches drop out.
Carry 0001-mlx-c-sdpa-window-size instead: sliding-window attention
added a window_size argument to fast::scaled_dot_product_attention
(ml-explore/mlx#4734) that MLX-C has not bound yet, to be regenerated
from MLX-C once the upstream binding PR merges. The SDPA wrappers gain
a window size argument; all call sites default to the full context.

* mlxrunner: dispatch sliding-window prefills to the native SDPA window

Sliding layers no longer materialize a causal∩sliding mask for prefill
chunks past the window: resolve() dispatches {causal, window} natively
when the rotating cache's L>1 concat has linearized the ring and the
mask is otherwise pure causal, via a new MaskApplier.NativeWindow hint.
Vision relaxations, padding, model arrays, and decode keep the
materialized path. No model changes; sinks compose natively.

* dflash: add the DFlash2 draft model (ollama#19149)

DFlash2 adds block-local dynamic convolutions and a candidate selector
to DFlash. The selector proposes each token conditioned on its
predecessor and returns each position's candidate distribution, which
verification uses to keep the output exact. Like the reference, the
draft samples with the request's temperature only.

A DFlash2 session drafts seven tokens every round on the existing
snapshot verify path instead of following the depth controller, whose
shallower picks lose more accepted tokens than they save in verify time.

qwen3.5-family targets now expose the layer taps, token embeddings and
raw logits a DFlash draft needs.

* llama.cpp: version bump b11901 (ollama#19311)

* Fix kimi cli tool-only assistant turns (ollama#19312)

* Fix kimi cli

* just interpret [] same as empty string actually

* dont gate on role

* cmd/launch: fix OpenCode v2 launch and config parsing (ollama#19310)

Co-authored-by: 0d00ciallo0721 <[email protected]>

* mlx: add LFM3 and d1 models (ollama#19333)

* llm: LFM3 GGUF fixes and llama-server speech (ollama#19344)

Fixes for running LFM3 GGUFs on the llama-server runner, plus GGUF
text-to-speech that turns on once llama.cpp is bumped past b11901.

- BOS: honor an explicit tokenizer.ggml.add_bos_token. LFM3 GGUFs (and
  lfm2:24b) set it to false and expect the template's BOS, which the
  lfm2 default was stripping. The lfm2 default still applies when the
  key is absent. On lfm2:24b, WikiText PPL goes from 81.3 to 72.0.
- repeat_last_n -1 now maps to the context size; llama-server rejects
  negative values.
- Audio-only projectors (LFM3-Audio) no longer advertise vision, so
  clients don't send images the model can't take.
- /v1/audio/speech on GGUF models calls llama-server /tts chunk by
  chunk. Renderers opt in through a new SpeechPrompter (voices,
  voice parsing, chunking), so other speech models can add their own.
  The LFM3 voice and chunking helpers move from the MLX runner into
  model/renderers and are shared by both runners.

* llama.cpp: version bump b11963 (ollama#19360)

* cmd: show help when running ollama without arguments (ollama#19248)

* llama.cpp: workaround Metal unary crash (ollama#19372)

This temporary patch works around a regression on older versions of MacOS
ggml_metal_library_compile_all: failed to build 'unary' library

* ci: pin buildx to workaround deadlock (ollama#19373)

Recent buildx updates are causing frequent deadlocks in our CI builds.
Until this is resolved upstream, pin to an older version.

* openai: preserve readable Responses input content (ollama#19192)

* mlx: sort long top-k rows in chunks (ollama#19392)

MLX's argpartition sorts the whole row, and a row longer than one block
of the GPU sort takes a multi-pass merge sort. TopKIndices sorts each
2048-value chunk in a single block, then only the chunks' top k, and
returns the same indices in the same order.

The sampler's top_k and top_logprobs and the DFlash2 candidate selector
use it in place of a full-vocabulary argpartition.

* app: make ChatGPT disconnect failures retryable (ollama#19336)

* feat(launch): use model output limits for Claude Code (ollama#19410)

* openai: don't override model sampler defaults (ollama#19432)

The OpenAI-compatible endpoints filled in sampler options the client
left out: temperature and top_p fell back to 1.0, and /v1/completions
always sent frequency_penalty and presence_penalty as 0. Request
options are applied last, so these values replaced the model's packaged
defaults. /api/chat honored those defaults; /v1 did not.

Omitted options are now left unset on /v1/chat/completions,
/v1/completions and /v1/responses, so the model's parameters apply, the
same as on /api/chat. Values the client sends still win, including an
explicit 0. On /v1/completions, top_p and the penalties are now
pointers so "omitted" and "0" can be told apart.

Clients that send no sampler options now get the model's defaults
instead of 1.0/1.0. A model with no sampler parameters gets Ollama's
defaults (temperature 0.8, top_p 0.9), as on /api/chat.

Fixes ollama#17744
Fixes ollama#18690

* launch: check ChatGPT routing before configuring (ollama#19470)

* server: decode cloud web search responses (ollama#19476)

* mlx: load bundled CUDA libraries in-process on Linux (ollama#19433)

NVIDIA's libcusolver looks for its dependencies only in its own
directory, so libcublas and libnvJitLink resolved to the host's copies
and MLX failed to load when those didn't match the bundled ones. Preload
the bundled copies by full path before loading MLX.

* model: add MiMo V2.6 renderer for Qwen3.5 (ollama#19400)

* launch: populate Pi models automatically (ollama#19460)

* Add AutoTrust decision model to MLX (ollama#19399)

* Add AutoTrust decision scoring to MLX

* address comments

* Support AutoTrust 35B decision models in MLX

* Resolve AutoTrust choice limits during config loading

Apply publisher-specific defaults and validate requests against the resolved limit.

* mlx: reject unsupported CUDA devices (ollama#19521)

* mlx: bump for CUDA architecture metadata

* mlx: reject unsupported CUDA devices

* address comments

* mlx: support YaRN scaling in Qwen3 and Qwen3.5 (ollama#19231)

* llama.cpp: version bump b12111 (ollama#19530)

Drop 002-metal-unary-cast-constexpr.patch: superseded by upstream fix

* llama-server: allow parallel requests for recurrent and vision models (ollama#19545)

These architectures were forced to num_parallel=1 because the older Go
engine's recurrent caches held one sequence. llama-server supports
multiple slots for all of them so we can allow parallelism now.

* cmd/launch: show gateway model names in Claude Desktop's model picker (ollama#19533)

* cmd: restore the no-argument launcher (ollama#19478)

Co-authored-by: Jeffrey Morgan <[email protected]>

* mlxrunner: close generation cache on shutdown (ollama#19550)

* cmd/launch: add Kimi Code CLI support (ollama#19506)

* openai: forward truncation option in responses requests (ollama#19501)

Co-authored-by: Eva Ho <[email protected]>

* openai: return an empty array for /v1/models when no models are installed (ollama#19539)

* llama.cpp: version bump b12177 (ollama#19576)

* README: add Quock to Mobile community integrations (ollama#19361)

* windows: add CUDA 13.5 and SM 103 for ARM64 (ollama#19580)

Install the separate ARM64 cross package in CI and retain SM 121
support. Other platforms are unchanged.

* MLX: make Qwen3.8 Flash Next memory efficient (ollama#18078)

* MLX: reduce Qwen3.8 Flash Next memory use

For NVFP4 creation, retain source precision for sensitive QSA projections
and non-expert MTP weights. Keep routed experts and PLE at NVFP4, and
promote other eligible weights to MXFP8.

Keep NVFP4 PLE tables host-backed, transferring only selected packed rows
and their scales to MLX. Honor scalar and per-expert NVFP4 global scales
in MoE, and per-shard global scales in host-backed PLE.

Use compressed QSA block selections in fused indexed Metal attention for
long prefill batches, retaining the graph fallback. Co-locate component
loading and forward methods, with explicit quantization and cache ownership.

* mlx: skip materializing host-backed tensors

Let models exclude tensors already owned by host storage from MLX loading.
Avoid allocating and discarding the full Qwen PLE tables at startup while
preserving the resident fallback.

* address comments

* launch: fix Claude Code routing and retired model errors (ollama#19587)

* Add ripple preview support to the MLX runner (ollama#19592)

Add the Ripple model, renderer, parser and import registration.
Support per-layer NoPE in DFlash drafts.
Fuse MLP activation, value blending and attention gating.
Add reference fixtures and model/runner regression tests.

---------

Co-authored-by: Eva H <[email protected]>
Co-authored-by: J Berg <[email protected]>
Co-authored-by: Daniel Hiltgen <[email protected]>
Co-authored-by: SynapShift <[email protected]>
Co-authored-by: Patrick Devine <[email protected]>
Co-authored-by: Jeffrey Morgan <[email protected]>
Co-authored-by: 0d00ciallo0721 <[email protected]>
Co-authored-by: Parth Sareen <[email protected]>
Co-authored-by: Marlon Ferreira <[email protected]>
Co-authored-by: Eva Ho <[email protected]>
Co-authored-by: liangliang205 <[email protected]>
Co-authored-by: Matteo Celani <[email protected]>
rick-github added a commit to rick-github/ollama that referenced this pull request Nov 8, 2026
* anthropic: reuse resolved thinking for web search (ollama#19098)

* openai: preserve failures in Responses streams (ollama#19225)

* Make sure all launchers know about cloud model metadata (ollama#19223)

* Support GA Gradium Phonon checkpoints (ollama#19227)

Replace the prerelease checkpoint path with Gradium's GA format, including default-voice import and speech conditioning. Set the 0.40.9 minimum, update the speech docs, and test import, inference setup, and rejection of the old checkpoint.

* Update gemma renderers (ollama#19241)

* renderers: add gemma4-nemotron renderer

Add a Gemma 4 renderer variant that renders assistant content before
its tool calls rather than after the tool responses. Models opt in with
RENDERER gemma4-nemotron; gemma4 auto-detection is unchanged.

Adds the corresponding chat template as a test fixture for Jinja parity
checks.

* mlx: support Gemma 4 targets with DFlash drafts

Load a draft-owned output head when its config requires one, while preserving the target-head path used by existing DFlash models.

Expose Gemma 4 hidden-state taps and raw logits for speculative decoding. Report safetensors target precision independently of quantized draft weights.

* qwen3coder: preserve literal function closing tags in parameters (ollama#19228)

* launch: use allocated context for OpenCode (ollama#19193)

* decision: allow empty state for vllm-d3 (ollama#19173)

* decision: allow empty state for vllm-d3

* server: reuse decoded state in System One tests

---------

Co-authored-by: Patrick Devine <[email protected]>

* llama.cpp: version bump b11845 (ollama#19250)

* mlxrunner: spell out symbols, numbers and links for Phonon (ollama#19234)

* mlxrunner: spell out symbols, numbers and links for Phonon

* docs: describe speech text normalization

* mlxrunner: fix Phonon misreadings inherited from xn-ptts

* mlxrunner: fix remaining Phonon misreadings

* mlxrunner: fold Phonon letters from the vocab, read #, _ and lists

* mlxrunner: add xn-ptts license notice for Phonon

* mlxrunner: move the xn-ptts license notice into normalize.go

* mlxrunner: fix remaining Phonon readings and port elongations

* docs: speech reads times and numeric dates

* mlxrunner: fix Phonon readings found in a listening pass

* docs: speech reads times and dates as written

* voice: add voice catalog for Phonon (ollama#19242)

* mlxrunner: import and list Phonon catalog voices

* docs: document Phonon voices

* mlx: preserve small-image detail for compact Gemma 4 vision towers (ollama#19247)

Dynamic sizing can floor the smallest image grid below its intended 70-token budget, losing detail in small images. Round that grid up for the compact tower, capped at the next supported budget.

Keep explicit budgets and the existing sizing for larger and unified towers. Update geometry and media-expansion tests.

* MLX, MLX-C: version bump - prompt speed up for gemma/flint/laguna (ollama#19291)

* MLX, MLX-C: version bump

The MLX-C pin now provides its own bindings for gather_qmm global_scale
and fast::gated_delta_update, so those two carried patches drop out.
Carry 0001-mlx-c-sdpa-window-size instead: sliding-window attention
added a window_size argument to fast::scaled_dot_product_attention
(ml-explore/mlx#4734) that MLX-C has not bound yet, to be regenerated
from MLX-C once the upstream binding PR merges. The SDPA wrappers gain
a window size argument; all call sites default to the full context.

* mlxrunner: dispatch sliding-window prefills to the native SDPA window

Sliding layers no longer materialize a causal∩sliding mask for prefill
chunks past the window: resolve() dispatches {causal, window} natively
when the rotating cache's L>1 concat has linearized the ring and the
mask is otherwise pure causal, via a new MaskApplier.NativeWindow hint.
Vision relaxations, padding, model arrays, and decode keep the
materialized path. No model changes; sinks compose natively.

* dflash: add the DFlash2 draft model (ollama#19149)

DFlash2 adds block-local dynamic convolutions and a candidate selector
to DFlash. The selector proposes each token conditioned on its
predecessor and returns each position's candidate distribution, which
verification uses to keep the output exact. Like the reference, the
draft samples with the request's temperature only.

A DFlash2 session drafts seven tokens every round on the existing
snapshot verify path instead of following the depth controller, whose
shallower picks lose more accepted tokens than they save in verify time.

qwen3.5-family targets now expose the layer taps, token embeddings and
raw logits a DFlash draft needs.

* llama.cpp: version bump b11901 (ollama#19311)

* Fix kimi cli tool-only assistant turns (ollama#19312)

* Fix kimi cli

* just interpret [] same as empty string actually

* dont gate on role

* cmd/launch: fix OpenCode v2 launch and config parsing (ollama#19310)

Co-authored-by: 0d00ciallo0721 <[email protected]>

* mlx: add LFM3 and d1 models (ollama#19333)

* llm: LFM3 GGUF fixes and llama-server speech (ollama#19344)

Fixes for running LFM3 GGUFs on the llama-server runner, plus GGUF
text-to-speech that turns on once llama.cpp is bumped past b11901.

- BOS: honor an explicit tokenizer.ggml.add_bos_token. LFM3 GGUFs (and
  lfm2:24b) set it to false and expect the template's BOS, which the
  lfm2 default was stripping. The lfm2 default still applies when the
  key is absent. On lfm2:24b, WikiText PPL goes from 81.3 to 72.0.
- repeat_last_n -1 now maps to the context size; llama-server rejects
  negative values.
- Audio-only projectors (LFM3-Audio) no longer advertise vision, so
  clients don't send images the model can't take.
- /v1/audio/speech on GGUF models calls llama-server /tts chunk by
  chunk. Renderers opt in through a new SpeechPrompter (voices,
  voice parsing, chunking), so other speech models can add their own.
  The LFM3 voice and chunking helpers move from the MLX runner into
  model/renderers and are shared by both runners.

* llama.cpp: version bump b11963 (ollama#19360)

* cmd: show help when running ollama without arguments (ollama#19248)

* llama.cpp: workaround Metal unary crash (ollama#19372)

This temporary patch works around a regression on older versions of MacOS
ggml_metal_library_compile_all: failed to build 'unary' library

* ci: pin buildx to workaround deadlock (ollama#19373)

Recent buildx updates are causing frequent deadlocks in our CI builds.
Until this is resolved upstream, pin to an older version.

* openai: preserve readable Responses input content (ollama#19192)

* mlx: sort long top-k rows in chunks (ollama#19392)

MLX's argpartition sorts the whole row, and a row longer than one block
of the GPU sort takes a multi-pass merge sort. TopKIndices sorts each
2048-value chunk in a single block, then only the chunks' top k, and
returns the same indices in the same order.

The sampler's top_k and top_logprobs and the DFlash2 candidate selector
use it in place of a full-vocabulary argpartition.

* app: make ChatGPT disconnect failures retryable (ollama#19336)

* feat(launch): use model output limits for Claude Code (ollama#19410)

* openai: don't override model sampler defaults (ollama#19432)

The OpenAI-compatible endpoints filled in sampler options the client
left out: temperature and top_p fell back to 1.0, and /v1/completions
always sent frequency_penalty and presence_penalty as 0. Request
options are applied last, so these values replaced the model's packaged
defaults. /api/chat honored those defaults; /v1 did not.

Omitted options are now left unset on /v1/chat/completions,
/v1/completions and /v1/responses, so the model's parameters apply, the
same as on /api/chat. Values the client sends still win, including an
explicit 0. On /v1/completions, top_p and the penalties are now
pointers so "omitted" and "0" can be told apart.

Clients that send no sampler options now get the model's defaults
instead of 1.0/1.0. A model with no sampler parameters gets Ollama's
defaults (temperature 0.8, top_p 0.9), as on /api/chat.

Fixes ollama#17744
Fixes ollama#18690

* launch: check ChatGPT routing before configuring (ollama#19470)

* server: decode cloud web search responses (ollama#19476)

* mlx: load bundled CUDA libraries in-process on Linux (ollama#19433)

NVIDIA's libcusolver looks for its dependencies only in its own
directory, so libcublas and libnvJitLink resolved to the host's copies
and MLX failed to load when those didn't match the bundled ones. Preload
the bundled copies by full path before loading MLX.

* model: add MiMo V2.6 renderer for Qwen3.5 (ollama#19400)

* launch: populate Pi models automatically (ollama#19460)

* Add AutoTrust decision model to MLX (ollama#19399)

* Add AutoTrust decision scoring to MLX

* address comments

* Support AutoTrust 35B decision models in MLX

* Resolve AutoTrust choice limits during config loading

Apply publisher-specific defaults and validate requests against the resolved limit.

* mlx: reject unsupported CUDA devices (ollama#19521)

* mlx: bump for CUDA architecture metadata

* mlx: reject unsupported CUDA devices

* address comments

* mlx: support YaRN scaling in Qwen3 and Qwen3.5 (ollama#19231)

* llama.cpp: version bump b12111 (ollama#19530)

Drop 002-metal-unary-cast-constexpr.patch: superseded by upstream fix

* llama-server: allow parallel requests for recurrent and vision models (ollama#19545)

These architectures were forced to num_parallel=1 because the older Go
engine's recurrent caches held one sequence. llama-server supports
multiple slots for all of them so we can allow parallelism now.

* cmd/launch: show gateway model names in Claude Desktop's model picker (ollama#19533)

* cmd: restore the no-argument launcher (ollama#19478)

Co-authored-by: Jeffrey Morgan <[email protected]>

* mlxrunner: close generation cache on shutdown (ollama#19550)

* cmd/launch: add Kimi Code CLI support (ollama#19506)

* openai: forward truncation option in responses requests (ollama#19501)

Co-authored-by: Eva Ho <[email protected]>

* openai: return an empty array for /v1/models when no models are installed (ollama#19539)

* llama.cpp: version bump b12177 (ollama#19576)

* README: add Quock to Mobile community integrations (ollama#19361)

* windows: add CUDA 13.5 and SM 103 for ARM64 (ollama#19580)

Install the separate ARM64 cross package in CI and retain SM 121
support. Other platforms are unchanged.

* MLX: make Qwen3.8 Flash Next memory efficient (ollama#18078)

* MLX: reduce Qwen3.8 Flash Next memory use

For NVFP4 creation, retain source precision for sensitive QSA projections
and non-expert MTP weights. Keep routed experts and PLE at NVFP4, and
promote other eligible weights to MXFP8.

Keep NVFP4 PLE tables host-backed, transferring only selected packed rows
and their scales to MLX. Honor scalar and per-expert NVFP4 global scales
in MoE, and per-shard global scales in host-backed PLE.

Use compressed QSA block selections in fused indexed Metal attention for
long prefill batches, retaining the graph fallback. Co-locate component
loading and forward methods, with explicit quantization and cache ownership.

* mlx: skip materializing host-backed tensors

Let models exclude tensors already owned by host storage from MLX loading.
Avoid allocating and discarding the full Qwen PLE tables at startup while
preserving the resident fallback.

* address comments

* launch: fix Claude Code routing and retired model errors (ollama#19587)

* Add ripple preview support to the MLX runner (ollama#19592)

Add the Ripple model, renderer, parser and import registration.
Support per-layer NoPE in DFlash drafts.
Fuse MLP activation, value blending and attention gating.
Add reference fixtures and model/runner regression tests.

---------

Co-authored-by: Eva H <[email protected]>
Co-authored-by: J Berg <[email protected]>
Co-authored-by: Daniel Hiltgen <[email protected]>
Co-authored-by: SynapShift <[email protected]>
Co-authored-by: Patrick Devine <[email protected]>
Co-authored-by: Jeffrey Morgan <[email protected]>
Co-authored-by: 0d00ciallo0721 <[email protected]>
Co-authored-by: Parth Sareen <[email protected]>
Co-authored-by: Marlon Ferreira <[email protected]>
Co-authored-by: Eva Ho <[email protected]>
Co-authored-by: liangliang205 <[email protected]>
Co-authored-by: Matteo Celani <[email protected]>
rick-github added a commit to rick-github/ollama that referenced this pull request Nov 8, 2026
* llama.cpp: version bump b10864 (#18317)

* server: extract GGUF metadata and unify capabilities (#17858)

Loading GGUF metadata is an expensive operation. Two caches had evolved to
mitigate this, and the two capability implementations produced inconsistent
results for some models.

This PR now extracts the metadata once per blob into a file at
<OLLAMA_MODELS>/metadata/sha256-<hex>.json. Only arrays over 4096 elements and
non-finite floats are left out.

Direct Capabilities() discovery now costs us instead of ms.  /api/tags can
build directly from manifests and the extracted metadata.

* mlxrunner: capture whole-state at close for nodes split out of an edge

KV snapshots must cover a node's edge exactly. Recurrent and
sliding-window state is only useful at a node's end, and a node may
have none: a request resuming there lands on the previous checkpoint
and begin schedules a capture at the match.

The header claimed every node carries its snapshots from creation,
which a node split out of an existing edge at close cannot. That hid a
gap: when a response is a prefix of a stored one, close lands on the
split-off head with the caches resting at its end, and pageOut skipped
the capture because the node already had a KV snapshot.

Restate the header as the rules that hold, and make pageOut capture
whatever layers a node is missing. The scheduling comment also said
eviction preserves user nodes; it only resists compaction.

* mlxrunner: keep cache boundaries out of non-causal media items

The tokens of a non-causal media item attend to each other in both
directions, so the item has to be evaluated in one forward. Prefill
honors that when it picks chunk boundaries, but the prefix cache did
not: a snapshot could be taken partway through an item, and a request
that resumed there would evaluate the rest of the item alone and
compute different attention for it.

Snapshots scheduled inside a non-causal item now land at its end, and
a match that ends inside one resumes at its start.

* mlxrunner: keep the reused head of a cached edge safe from eviction

When a request resumes partway through a cached edge, the node holding
that edge was dropped from the active path, because the path has to end
at the live offset for close and the prefill captures to extend the trie
from its last node. Off the path, the node was an ordinary leaf with a
stale last-used time, so eviction removed it first.

The captures taken during that request start at the resume offset, but
attach rebuilds the missing node from the path's last node, so the new
node's edge begins earlier than its KV snapshot. A later request
resuming there was refused by the KV cache and re-prefilled from
scratch. If eviction first merged the node into its parent, the two
snapshots were concatenated as if adjacent, and the restore reported a
hit while the buffer held tokens from other positions.

Split the node at the live offset instead. The head stays on the path
and gets the last-used update. Only the unused tail can be evicted, and
losing it costs nothing. The split only happens when every layer can
rewind into the edge, so it never involves a recurrent layer, and the
head gets the same KV-only snapshots a close-time split already
produces. When the request follows the edge, compaction merges the
halves back.

* mlxrunner: evict the active conversation's own checkpoints under the budget

Eviction skipped every node on the active path, so a conversation's own
turn checkpoints were never reclaimed no matter how far over budget the
trie was. On models with sliding-window or recurrent layers each turn's
checkpoint is a full copy of that state, 800 MiB per turn on
gemma4:31b-mlx, and a long chat grows without bound. The scheduler then
counts that memory as in use and evicts the model to load anything
else.

Only the frontier and branch points are protected now. Any other node,
active or not, is evicted least recently used first. On the active path
that merges a turn into the next one: the merged node keeps the newer
whole-state, and the KV snapshots there are lazy views of the live
buffer, so nothing is copied. Rewinding to an evicted turn resumes at
the newest surviving checkpoint before it.

qwen3.8:27b-mlx on an M5 Max, the same short question every turn with
24 tokens generated per reply, 8 GiB budget, 17.2 GiB of weights:

  turn | before: paged out  nodes  reported | after: paged out  nodes  reported
    11 |          4.61 GiB     33  21.6 GiB |         4.61 GiB     33  21.6 GiB
    21 |          7.91 GiB     56  24.9 GiB |         7.92 GiB     56  24.9 GiB
    31 |          8.46 GiB     60  25.5 GiB |         7.94 GiB     56  25.0 GiB
    41 |          9.90 GiB     70  26.9 GiB |         7.96 GiB     56  25.0 GiB
    50 |         11.19 GiB     79  28.2 GiB |         7.98 GiB     56  25.0 GiB

Fixes #17783

* mlxrunner: bound MLX loads by system free memory while other models are loaded

On Apple silicon the scheduler's free-memory figure for the GPU is the
Metal working set minus what Ollama's own runners report. It does not see
memory held by other applications, so a second MLX model can pass the fit
check on a machine that is already short of memory, and the load pushes
the system into swap and compression.

While other models are loaded, the MLX fit check now also bounds the
available memory by the system's free memory on shared-memory GPUs, the
same rule llama-server loads already apply. A miss evicts an idle model
and retries instead of starting the load. First loads are unchanged: with
nothing else loaded, the model loads against the working-set figure alone,
as both engines do today. The check also does not cover memory that grows
after load, such as KV caches and prefix-cache snapshots.

* mlxrunner: wait for a killed runner to exit before the scheduler loads the next model

The scheduler starts the next load as soon as Close returns. The MLX client
sent SIGINT, gave the process five seconds, then sent SIGKILL and returned
without waiting, so a runner that could not take the signal was still
exiting, with its memory still held, when the next load began. The runner
has no signal handler, so SIGINT was already a kill.

Load also started the process and recorded it without the client's mutex,
so a Close racing with a load at server shutdown could find nothing to stop
and leave the runner it missed running.

Close now kills the process and waits for it to be reaped, as the
llama-server client does. Load starts and records the process under the
mutex and refuses to start once Close has run.

* llm: raise token repeat limit to 100 and return error instead of silently closing (#18374)

* mlx: scope array lifetimes instead of pinning and sweeping

The bindings freed arrays by sweeping everything not pinned, so freeing
anything required knowing what every other caller still held, and code
that never swept accumulated until memory ran out. The prefix cache's
eviction of a long stored path did exactly that: each merge copied the
KV snapshots and nothing freed the consumed copies until the request
ended, which drove a second long request past physical memory.

Every array now belongs to a scope. A function scope, entered with Scoped
or one of the ScopedEval forms, frees what was created in it when the
function returns; results leave only by being returned. A held scope is
closed by its holder and frees what was attached to it. A graph is
built in a function scope and evaluated after it, so the eval frees each
intermediate as it consumes it. Pin, Unpin, Sweep, and the array list's
mutex are gone.

On an M5 Max with qwen3.8:27b-mlx, the second 84k-token request after a
stored one peaks at 35 GB instead of 57 GB; the cold path is unchanged.
The copies themselves are untouched, so restoring an owned path can still
exceed memory.

* mlx: drop the empty-handle checks outside the bindings

Models and layers checked optional weights for nil and also for a handle
that no longer refers to an array, and evaluation and weight collection
skipped such handles. No path produces one: a missing tensor is nil, and a
handle only loses its array when its scope frees it, after which using it
is a bug. The nil checks stay; the validity check is internal to the
bindings now.

* mlxrunner: release the buffers weight loading leaves in the MLX pool

Loading a model can transform tensors after reading them: qwen3.5 models
pack their linear-attention projections into one layout, and MoE models
fuse the gate and up expert stacks. The buffers those transforms consume
go back to MLX's allocator pool rather than to the system, and nothing
releases the pool until the first request finishes. On qwen3.8:27b-mlx
that is 2.15 GiB held idle on top of 16.9 GiB of weights, counted in the
runner's reported memory the whole time.

Clear the pool once the weights are evaluated. Models whose tensors load
unchanged, such as gemma4, leave nothing in the pool and are unaffected.

* cmd: remove built-in agent (#18393)

* llm: keep gemma3n projector off the CPU (#18376)

Gemma3n's MobileNetV5 projector silently produces corrupted image
embeddings on the CPU backend - no error, the model just describes the
wrong image (reproduced on llama.cpp b10760; gemma4's encoder is fine on
CPU). Without this guard the existing partial-offload, limited-VRAM, and
OOM-retry fallbacks would pick the CPU projector on exactly the small
GPUs where gemma3n lands.

* app: refresh Apps layout and command copy feedback (#18372)

* MLX: version bump (#18235)

* MLX: version bump

* mlx: support ModelOpt global scales in MoE models

* address comments

* address comments

* docs: add ChatGPT Desktop integration (#18377)

* mlx: add mlx patch to docker build context (#18440)

* create: add server-side MLX imports and drop GGUF conversion (#14969)

* create: add server-side MLX imports and drop GGUF conversion

Support safetensors imports through the MLX create pipeline both locally and on the server, including remote upload/staging, draft layer handling, cancellation propagation, transfer limits, and shared manifest/blob writing.

Limit GGUF create to wrapping existing GGUF inputs into Ollama manifests. Remove the in-tree safetensors-to-GGUF converter, server quantization path, and converter-only dependencies so GGUF conversion and quantization stay in llama.cpp tooling.

Keep the MLX path focused on supported safetensors model creation with validation before MLX work, and expose that flow without the --experimental CLI gate.

* address comments

* add client side gguf create fast path

* address comments

* rebase adjustments

* MLX, MLX-C: version bump (#18449)

Includes quantized matmul corruption fix, which impacts nvfp4 multimodal models (gemma4 vision towers). Deferring wiring up the new MLX-C thread-local stream/sync APIs for now.

* API: Deprecate typical_p (#18448)

Drop support for creating new models with typical_p parameters, while
retaining support for existing GGUF models with the setting.

* docs: refresh getting started guides (#18450)

* llama.cpp: version bump b10969 (#18446)

llama.cpp build changes resulted in duplicate symbols between libllama and libmtmd.  This moves the compat patch into libllama with exported symbols.

* cmd: launch the MLX runner without the engine dispatcher

The runner package used to pick an engine from the first argument of the
runner subcommand. Only the MLX engine is left, so the dispatcher has a
single arm, its README still describes the removed Go runner's flags and
endpoints, and the standalone cmd/runner binary exists only to invoke it.

We call mlxrunner.Execute directly from the hidden runner subcommand and
drop the --mlx-engine argument from the command line the MLX client
spawns. Both sides ship in the same binary, so nothing has to accept both
forms. The runner package and cmd/runner are removed.

The subcommand's help hook hands the runner a bare --help. cobra calls the
hook with no arguments for `ollama help runner`, which used to index past
the end of the slice.

* tokenizer, ml: remove dead code

Several pieces outlived the code that used them. The root tokenizer
package implemented the GGUF-side vocabularies for the Go engine and the
safetensors-to-GGUF converter; nothing has imported it since the
converter went. ml/backend.go held the Go engine's Backend, Context and
Tensor interfaces, with fs.Config existing only to be returned from them,
and a single CUDA template instance under ml/backend/ggml survived the
engine removal along with the gitattributes entries for that tree and the
CI change-filter globs for it and for the long-gone llama/llama.cpp. From
the image generation engine, an integration test group that no test
registers, its build tag, and the StepBar progress widget remained.
DeviceInfo.IsBetter has no caller at all.

All of it goes. Tidying the module file drops the regexp2 dependency and
leaves protobuf as an indirect requirement. The llama3.2 tokenizer
fixtures stay: the MLX runner's tokenizer uses them for its GGML parity
test.

* mlx, mlxrunner: move the MLX engine out of x/

The MLX runner is the only Go inference runner left and is no longer
experimental, so its packages leave x/. The bindings become a top-level
mlx package beside the carried patches in mlx/compat, mirroring how
llama/ holds the llama.cpp integration, and the runner becomes mlxrunner
with the architectures nested under the package they implement.
Subpackages move with their parent unless listed.

  x/mlxrunner/mlx            mlx
  x/internal/mlxthread       mlx/mlxthread
  x/internal/mlxthreadtest   mlx/mlxthread/mlxthreadtest
  x/internal/mlxtest         mlx/mlxtest
  x/quant                    mlx/quant
  mlx/compat/*.patch         mlx/compat/mlx-c   (MLX patches go in mlx/compat/mlx)
  x/mlxrunner                mlxrunner
  x/models/nn                mlxrunner/nn
  x/models/<arch>            mlxrunner/model/<arch>
  x/mlxrunner/imports.go     mlxrunner/model/architectures   (new package)
  x/create                   create
  x/safetensors              fs/safetensors
  x/tokenizer                mlxrunner/tokenizer

Every package keeps its name, so the Go changes are the import path
rewrites the moves force, and the CMake, Dockerfile, CI cache keys, drift
check and Darwin payload script follow the new paths. Four edits are not
paths: the runner's blank architecture imports become the package
mlxrunner/model/architectures, so the list to extend for a new model sits
beside the architecture directories; a depguard rule keeps the two test
harnesses out of non-test code, as the x/internal placement used to; the
CI change filter's two entries for the long-deleted x/imagegen/mlx now
name the bindings' CMake project and the carried patches, so a change to
either builds the payload; and the tokenizer parity test reads its
fixtures from its own testdata instead of walking out of x/.

x/server and x/imagegen/manifest stay for the next two commits.

* mlxrunner, cmd, server: fold three small packages into their users

model/base held the Model interface and the architecture registry while
model held weight loading and quant parameters, and every architecture
imported both. create/client was the CLI side of safetensors imports,
with the create command as its only caller, a duplicate of the command's
adapter error, and a name that read like a second API client. The
safetensors show helpers had their own package under x/ although it
already declared package server.

base merges into model, so base.Model and base.Register become
model.Model and model.Register; nothing in the two overlapped. The create
client's two files and their tests join package cmd, and the five names
the command called are no longer exported. The show helpers join the
server package, and the three entry points routes.go calls become
unexported like the helpers around them.

* mlxrunner: read model manifests through the manifest package

The runner and its weight loader read a model's manifest through
x/imagegen/manifest, the last piece of the removed image generation
engine. It was a hand-rolled copy of the manifest package: its own model
name parser with the default registry and namespace spelled out, its own
blob path builder, and re-spelled media types, plus a model_index.json
reader and other helpers that nothing has called since the engine went.

The manifest package gains the three lookups the runner needs, a config
layer by path, its contents, and the tensor layers, and ReadConfigJSON is
built on the second of them. The weight loader resolves the model name
with the shared parser, which fills in the same defaults the copy did, and
locates blobs with BlobsPath. The architectures' calls to read their
config.json compile unchanged. x/imagegen is gone.

* mlxrunner: lay out nn one layer kind per file

nn.go held every layer type in the package apart from attention,
recurrence and rope: the Linear and Embedding interfaces with their dense
and quantized types, Conv1d, RMSNorm, LayerNorm and MultiLinear, with one
test file to match. Finding a layer meant scanning the file named after
the package.

Each layer kind gets its own file: linear.go and embedding.go hold the
interface and the dense and quantized types, conv.go, norm.go and
multilinear.go take the rest, and nn_test.go splits the same way. The
Layer and MultiLinearLayer interfaces go; nothing implemented or accepted
them. No code changes otherwise.

* mlxrunner: lay out model by contract, checkpoint and construction

model is one package with three jobs: the contract between the runner
and the architectures, the opened checkpoint, and building nn layers
from checkpoint tensors. Its files did not say which was which. base.go
carried the folded package's name over the interfaces and the registry,
root.go held the safetensors header scan next to Root, and quant.go
mixed the nvfp4 global-scale helpers with quant parameter resolution.

base.go becomes model.go, named for what it holds. root.go keeps Root
and Open; TensorQuantInfo and the header scan join quant.go, so
everything the checkpoint says about quantization is read and resolved
in one file. The global-scale helpers move to globalscale.go with their
tests. Root.Close, a no-op with one caller, goes. No code changes
otherwise.

* docs: fix cloud retirements settings link (#18496)

* app: clarify Claude connection dialog (#18498)

* app: add Apps deep link (#18497)

* mlxrunner: Release freed KV buffers during speculative decode

The decode loop releases MLX's pool of freed buffers every 256 generated
tokens, which is also how often the KV cache grows and drops its previous,
smaller buffers. The check fires only when the token count lands exactly on
a multiple of 256. Speculative decoding emits several tokens per round, so
most rounds step over the boundary and the pool is never released. Each
growth at a long context leaves several GB of buffers that no later
allocation can reuse, so the runner's footprint keeps climbing over a long
generation until the system runs out of memory.

We now release the pool whenever a round crosses a multiple of 256 tokens,
which is what a single-token round already did. With qwen3.8:27b-mlx at a
98k-token context on a 128 GB machine, a long speculative generation
previously grew the runner past 90 GB and panicked the kernel; it now stays
flat at 30 GB.

* cli: add first-run onboarding shared with the desktop app (#18495)

* docs: clarify integrations overview and add assistant icons (#18511)

* x/transfer, server: tighten redirect handling for registry requests (#18512)

Redirects for registry and blob transfers now validate the target scheme
and resolved addresses before following, re-check DNS on each redirect,
and do not follow redirects that switch an https session to plain http.
The --insecure option continues to relax address checks for private
registries but not scheme checks.

* ci: harden release artifact uploads (#18516)

Serialize final release jobs and delete old assets before retagging to
avoid overlapping updates and mixed-version payloads.

Keep uploads parallel and retry failures twice with 15s/30s delays.
Retry cleanup using a fresh asset list and upload the checksum manifest
only after all payloads succeed.

* nemotron_h: add MLX vision support (#17714)

* nemotron_h: add MLX vision support

Implement the RADIO vision encoder and projector on the shared MLX media pipeline, including dynamic-resolution preprocessing, deterministic placeholder expansion, chunked feature scattering, and MTP offsets.

Expose source-advertised Nemotron vision while continuing to suppress unsupported audio, and preserve both modality towers at source precision during create.

Harden Nemotron streaming parser termination and add focused coverage for vision configuration, media placement, capability reporting, and tool-call parsing.

* review comments

* address comments

* tests: fix metadata deletion test flake (#18493)

Test both publication/deletion orderings directly instead of polling for a short-lived temporary file with a machine-dependent timeout.

* app: keep closed macOS windows from reopening on activation (#18518)

* api: expose model thinking levels and defaults (#18473)

* server: allow registry cross-host redirects among allowlisted hosts (#18533)

* server: fix getExistingName canonicalizing model name parts independently (#18438)

getExistingName canonicalizes the case of each model name part (host,
namespace, model, tag) by searching all manifests for a case-insensitive
match. The original implementation matched each part independently —
the tag from any manifest whose tag case-insensitively matched the
requested tag would overwrite the tag, regardless of whether the host,
namespace, or model matched.

A 'set' variable was intended to track which parts had already been
canonicalized and prevent overwrites, but it was never written to, so
it was always zero-valued and every match overwrote the corresponding
part unconditionally.

With 3000+ manifests, if another model had a tag that case-insensitively
matched (e.g. 'Q4_K_M' for a different model), the requested model's tag
could be canonicalized to that other model's tag casing. Go's map
iteration order is randomized, so the last match wins — producing
intermittent 'model not found' errors that succeed on retry.

Fix: when all four parts of an entry case-insensitively match the input,
return that entry's canonical name directly. Otherwise canonicalize each
part independently, with the 'set' variable now properly updated after
each part is set so it is only written once. This handles both exact
matches and new tags on existing models.

* parsers: report the strings that end a response's thinking

A format on a thinking model has to leave the thinking free and constrain
only the content after it, so whatever enforces the format needs to know
where the thinking ends. Today the server guesses whether a parser's
response starts inside thinking from the think value alone, which is wrong
for parsers whose default differs, and it has no way to learn the closing
string at all.

Each parser now answers ThinkingClose after Init: the strings any of which
ends the thinking its response begins with, or none when the response
starts in content because thinking is off, an assistant prefill continues
content, or the parser suppresses thinking for tools. Parsers whose models
open a new message before content end the thinking at that message's
header. Nothing consumes the answer yet.

* mlxrunner: constrain a format after the thinking in one generation

The MLX runner applies a format's grammar from the first sampled token,
so a thinking model asked for a format cannot think first, and the server
has to run two generations to get both the thinking and the formatted
content.

A completion request now carries the strings that end the thinking its
response begins with, and the MLX client builds from them a structural
tag: free text that cannot contain any of them, then one of them, then
the schema. The tail is optional so a response may still end inside its
thinking, as an unconstrained one can. Without a closing string the tag
is the plain schema, as before. The server does not send the strings yet.

* llm: apply a format after the thinking in one llama-server request

llama-server applies a schema from the first sampled token, so a thinking
model asked for a format cannot think first, and the server has to run two
generations to get both the thinking and the formatted content.

The client now sends one request whose grammar leaves the text before a
closing string unconstrained and requires the format after it.
llama-server converts the schema for us: an empty completion evaluates and
generates nothing but reports the GBNF it derived, which we wrap in rules
that recognize the closing strings and cache per schema for the life of
the process. On qwen3 0.6b at temperature 0 the thinking is byte-identical
with and without a format and the JSON follows the schema.

A response that ends before a closing string is delivered unchanged. The
conversion request briefly takes a llama-server slot on a cache miss. The
server does not send the strings yet.

* server: apply structured outputs in a single pass on thinking models

A format on a thinking model ran two generations: an unconstrained one,
cancelled once the parser reported content, then a re-rendered prompt with
the parsed thinking under the grammar. The restart cost a second prefill,
dropped the chunk that crossed the boundary, needed a harmony prompt hack,
stitched metrics across the two requests, and on MLX could leak a stray
first token into the JSON. The generate endpoint never deferred at all, so
its JSON was forced inside the thinking.

Both handlers now make one completion request that names the strings
ending the response's thinking, from the builtin parser or the generic
thinking parser, and the runner constrains only the content after them in
a single generation. The prompt is evaluated once and metrics pass straight
through. A raw generate prompt names no strings, since nothing says where
its response starts, and its format applies from the first token as
before. A format now applies to whatever follows the thinking, so a tool
call can no longer take the place of formatted content, which was already
the case with thinking off; harmony is the exception, since its tool calls
precede the final message.

The per-token metrics flag both runners carried for the cancelled first
pass has no caller left and goes with the two-pass code and its tests.

Fixes #18441
Fixes #17544
Fixes #14196
Fixes #10929

* app: avoid System Events for ChatGPT/Codex detection (#18601)

* llama.cpp: version update (#18577)

Refine memory allocation failure log substrings for upstream changes.

Remove the no longer needed Laguna metal patch - fixed upstream.

* MLX: version bump (#18576)

Plumbs fast::gated_delta_update through a temporary MLX-C patch for now.

* mlx: select Gemma 4 image resolution dynamically (#18603)

Replace the fixed checkpoint image budget with per-image selection across
the supported 70, 140, 280, 560, and 1120 budgets. Choose the publisher resize
grid closest to the input resolution, accounting for aspect ratio.

This preserves more detail in high-resolution documents while allowing
smaller images to use fewer tokens, without adding an API parameter.

Cover budget boundaries, extreme dimensions, position limits, and media
expansion for both vision architectures.

* mlx: speed up Qwen 3.8 prompt processing (#18550)

* mlx: speed up Qwen 3.8 prompt processing

Use MLX's gated-delta kernel for long scans and fold dense MLP global scales into SwiGLU.

* address comments

* docs: document thinking control discovery (#18501)

* xgrammar: add standalone CMake project for native library (#18611)

Move the ollama_xgrammar target into mlxrunner/xgrammar/native so it
can be configured on its own against an installed xgrammar. cmake/mlx
now adds it as a subdirectory and still uses the pinned xgrammar.

* launch: default Claude Code to client-side auto checks (#18596)

* mlxrunner: Update XGrammar to 0.2.7 for structured outputs

We pick up schema fixes for typed dictionary values and short arrays.

* app: sync macOS update menu and icon at startup (#18622)

* app: defer Settings model discovery (#18598)

* app: isolate cloud-setting tests from Windows user config (#18626)

Set USERPROFILE alongside HOME in both cloud-setting handler tests.
On Windows, os.UserHomeDir uses USERPROFILE, so the tests could write
to the developer's real server.json and leave cloud disabled.

* api: deprecate typical_p (#18627)

Switch from rejecting API requests to logging a warning.  Model creation still rejects the deprecated param.

Follow up from #18448 to remove the hard API failure.

* llama-server: prepare to remove compatibility patch

Add manifest-list storage so runner-specific manifests can coexist under one tag while preserving existing v1 tags as best-effort downgrade anchors. Show/list/copy/remove/pull/push now understand runner and digest selection and transfer referenced child manifests and layers.

Add lazy local compatibility migration for legacy Ollama GGUFs into llama.cpp-compatible children, covering the patched model families and preserving parser/renderer, templates, projectors, media metadata, split GGUFs, and MTP/draft tensors where applicable.

Extend create/import/conversion paths for the same compatibility rules, harden manifest-list combine validation, and add focused manifest, migration, transfer, and integration coverage for first-load conversion plus chat/tools/vision/audio/embedding behavior.

* bench: use HumanEval patch prompts (#17480)

* bench: use code prompts for prompt-token runs

Replace the synthetic word-list prompt with packed HumanEval Python prompts so speculative draft models see code-like continuations.

Keep the benchmark on the chat path, and calibrate -prompt-tokens with untimed chat probes that read PromptEvalCount instead of relying on a separate token-count API.

Each request still gets a nonce prefix to avoid prefix-cache hits while timed epochs measure the chat-rendered workload.

* review comments

* use different windows for each epoch

* add OpenAI API support

* address comments

* feat: add System One scoring API (#18606)

* mlx: bound pull stall retries and let the watchdog interrupt them (#18625)

* transfer: bound stall retries and let the watchdog interrupt them

A download that stalls could never recover. copy derived its own
cancellable context, but the request was built from the parent, so
cancelling on a stall never reached the in-flight body and the read
stayed parked. The stall watchdog could detect a stall it had no way
to stop.

Stall retries were also unbounded: they never incremented attempt, so
the retry loop had no limit, and because backoff was gated on
attempt > 0 they retried with no delay at all.

The request now owns the cancellable context and passes its cancel
down to copy, so a stall aborts the read. Stalls get their own retry
budget before counting against the limit, and backoff is keyed to
every retry rather than only the counted ones.

* move out of x/

* feat: allow ten web searches per response (#18602)

* MLX: version bump (#18651)

* llama.cpp: version bump b11232 (#18652)

* create: support explicit model capabilities (#18708)

Add CAPABILITY declarations to Modelfiles and an additive capabilities
field to create requests. Preserve declarations across GGUF and safetensors
creation, inheritance, and Modelfile export.

Require decision capability before scheduling System One requests instead
of matching Qwen architecture/renderer metadata. Retain main's GGUF-only
scoring restriction until the separate MLX runtime work lands.

Extracted from the capability foundation in 36d46a0c3 on system_one_mlx;
MLX scoring and manifest-list changes are intentionally separate.

* docs: document System One API (#18702)

* openai: keep tool message content parts in one message

FromChatRequest splits array content into one api.Message per part. That
is intended for user content, but a tool message is a single result: the
split also dropped its tool_call_id and tool name, since those were only
copied when the message had tool_calls. Renderers that resolve tool
results by ID then see extra, unnamed results; for example, Kimi K3 fails
with "tool message 2 has no resolvable tool name" on a tool result with
two text parts, which the OpenAI spec allows.

Merge the parts of a tool message into one message with the text joined,
the images kept, and ToolCallID and ToolName set, matching how
function_call_output items are converted for /v1/responses.

* openai: keep empty tool results sent as an empty content array

A tool message with "content": [] produced no message at all, so the
tool call it answers had no result in the rendered prompt. Emit an empty
tool message that keeps its ToolCallID and ToolName, and skip it only
when it has no parts, call id, or name.

* server: report only decision capability for decision models (#18737)

Show and list now return just "decision" for models declaring it, so clients don't offer them for general chat, tools, or thinking. The show response also omits the thinking field for these models. Scheduling and serving still check the full capability set.

* README: add oxi to community integrations

* models: add clef support (#18741)

* ci: fix missing build context (#18742)

* openai: keep image positions when merging tool result parts

Merging a tool result's parts collected its images separately from the
text, so renderers placed them all before the text: "Before: <A> After:
<B>" rendered as "<A><B>Before: After:". Write an [img] placeholder at
each image's position so renderContentWithImageTags and chatPrompt put
each image back where it was.

* docs: link to available decision models (#18758)

* docs: document image input for decision models (#18757)

* openai: split tool results with images instead of adding [img] markers

The [img] placeholders mixed internal markers into tool text: the native
llama-server path sends them as literal text, so an image-only result
gained a text part, and tool output containing [img] or [img-N] moved or
dropped image tags. api.Message cannot carry image positions without
in-band markers, so stop merging tool results that include images.

Text-only tool results, the only array form the Chat Completions spec
allows for tool messages, are still merged into one message (now with a
strings.Builder). Results with images keep the per-part split in order,
which preserves image positions, with the tool call id and name set on
every part.

* mlx: System one support (#18701)

* mlxrunner: restore System One scoring

Carry the MLX implementation and its tests from the original System One
commit. The API/compiler and llama-server implementation already exist on
the release branch, so retain those versions. Adapt the optional model test
to the renamed decision package and its explicit rendering/context setup.

(cherry picked from commit 26e546ddb3897b4564f03d3bdbdbefce9281edf8)

* Enable MLX System One and add regression coverage

* mlxrunner: add Laya support for System One

Import Laya checkpoints and implement bidirectional decision scoring.

* mlxrunner: release cached buffers after System One scoring

* decision: match Tev1 and Nimble publisher prompt formats

Select Tev1 prompts using renderer metadata and fix JSON formatting, with regression coverage for GGUF and MLX.

* mlx: support Clef and Clef Flash decision models

Add model import, quantization safeguards, and text/image scoring with the Clef joint decision head.

* support vision capabilities for decision models

* Make Clef scoring cancellable between prefill chunks

Preserve joint-head inputs and test cancellation, cleanup, and recovery.

* mlx: separate decision preparation and readout from forward

Let serial and batched scoring share model-owned preparation and readout
without duplicating architecture-specific logic in the runner.

* mlx: add Strands Decider support

* implement caching

---------

Co-authored-by: ParthSareen <[email protected]>

* mlx: Decision model improvements (#18776)

* reject instead of truncate on overflow

* tune route logic for faster warm runner lookup

* mlx: match publisher tokenizer semantics (#18779)

* mlx: match publisher tokenizer semantics

Honor pretokenizer stage order, split behavior, Unicode boundaries,
added-token normalization, and ranked BPE merges. Handle empty added
tokens and empty Metaspace input consistently.

Add shared Go/Python reference cases using published tokenizers, pulling
missing models directly and failing on errors, plus focused regressions
for configuration precedence, byte fallback, and parallel encoding.

* address comments

* pull: allow RCs to pull matching min_version (#18790)

Strip off pre-release from the version string so RCs can pull
models for the same release.

* test: split create integration tests out (#18470)

The create tests upload blobs which can cause problems when run in parallel on multiple systems.  This change splits them out with an explicit tag to make it easier to control when they are run.

* mlx: mitigate high latency after GPU idle (#18807)

Carry the MLX residency-refresh patch and enable it every second in the
runner, preserving explicit environment overrides.

Fixes #18744.

* Reduce model lookup and MLX decision request overhead (#18806)

* Reduce model lookup and MLX decision request overhead

Avoid decoding unrelated manifests when resolving existing model names.
Reuse small Metal scratch buffers between decision requests, releasing
larger working sets and clearing scratch after scoring errors.

* address comments

* llama.cpp: version update (#18761)

* MLX: version bump (#18720)

* MLX: version bump

* add scopes for unit tests to reduce memory usage

* mlx: fix patch for recent mlx update (#18812)

* docs: fix 6 dead links in README community integrations list

* model: add multimodal embeddings (#18820)

Implements the EmbeddingGemma2Model architecture on the MLX runner: 24-layer
bidirectional text encoder with PLE, shared gemma4 vision/audio towers,
mean-pool + L2 output. /api/embed accepts per-item media via input dicts.

* routes: fix embed 413 vs 400 routing (#18822)

* documentation re-structuring

* reorganizing the docs folder, adding error handling to the sample project, changing wording

* server: proxy cloud usage and balance APIs (#18829)

Forward GET /api/usage and GET /api/balance through the local server
using the signed-in account.

Add API documentation and tests for proxying, signing, and
disabled cloud access.

* llama: fix clef head reads past 2GiB on windows (#18777)

The Clef head read its weights with std::ifstream::seekg. The Windows
llama-server ships with libc++ 18.1.8, where that seek truncates the
offset to 32 bits. clef-flash stores the clef.* tensors at about 9.5GB,
so the head loaded backbone bytes as its weights and every
/v1/systemone request failed with "Clef: non-finite logit". clef:27b
keeps the head and output.weight below 2GB and was unaffected.

Read with ggml_fopen and an explicit 64-bit seek instead, as read_at
in llama/compat already does.

Fixes #18769

* keeping old urls, updating model retirement page

* cmd: remove account step from CLI onboarding (#18826)

* changing wording

* removing repetition, fixing a typo

* re-ordering top nav, splitting out sample project into new PR

* manifest: avoid symlinks on Windows (#18852)

Store named manifests as regular files on Windows, where symlinks can
be created successfully but fail when opened.

Repair existing symlinks lazily on read using the verified blob and
existing copy path. Keep locking consistent across platforms and avoid
reacquiring the store lock during pruning.

Fixes #18847

* mlx: drop carried metal residency patch now that it is upstream (#18854)

* Set CLAUDE_CODE_MAX_CONTEXT_TOKENS to whatever the models context window is

* server: hide duplicate and downgrade guards from list (#18874)

When a legacy GGUF which requires our llama.cpp patch set is loaded, we do a
lazy conversion on disk to make it llama.cpp compatible.  To support
downgrades, we temporarily hold both the new and old GGUFs and create a shadow
v1 manifest tag to prevent the downgraded server from deleting the new blobs.
Showing these in the list output is confusing to users and API consumers.  The
legacy copies will be removed in a future release to recover the disk space.

* respect CLAUDE_CODE_AUTO_COMPACT_WINDOW user setting

* launch: avoid inherited service-tier warnings in Codex (#18879)

* standardizing language referring to cloud services

* launch: suppress Claude Code connector warning for Ollama (#18878)

Co-authored-by: Parth Sareen <[email protected]>

* server: skip local model compatibility migration (#18908)

* decision: align request validation and option descriptions

* llama: update to b11521 and use native decision support

* llm: support multimodal embeddings through llama-server

* mlx: clip long laya states instead of rejecting them

* mlx: read candidate logits in float32 for quantized heads

* server: reuse verified manifests and loaded models in inference routes (#18947)

* server: reuse verified manifests and loaded models in inference routes

Resolve named manifests and runner selection in one verified cold lookup.
When a runner is loaded, reuse its model after checking that the v2 tag
still points to the same digest. Fully verify regular-file manifests,
including Windows copies.

Share the lookup across generate, chat, embed, and System One. Keep parser
selection request-local so reusing a model does not mutate its config.

Cover tag changes, runner selection, concurrent unloads, and existing
missing-model responses with regression tests and a lookup benchmark.

* address comments

* mlx: compact restored recurrent state after speculative rollback (#18955)

* mlx: compact restored recurrent state after speculative rollback

Per-token recurrent captures can leave a restored state pointing into a larger buffer. If a request ends before another model step, the live cache retains that buffer even though it accounts for only the selected state.

Track when a restored state may share that backing buffer. At request close, compact marked states in one batch before retaining them in the prefix cache. Clear the marker when a normal model step replaces the state, and cover restoration and buffer detachment in tests.

* address comments

* launch: populate Codex model picker with installed Ollama models (#18887)

* MLX, MLX-C: version bump (#18956)

* typo in docs

* docs: update README to include cloud and privacy language

* Revert "docs: restructuring" (#18960)

* docs: update SECURITY.md

- Directs users to Github advisories instead of hello email address

* Introduce clef and clef flash on cloud

* server: fix multimodal embedding load with small num_ctx (#18973)

* Add Kev decision scoring to MLX (#18976)

* Add Kev decision scoring to MLX

Load Kev models with their FP32 decision head and release metadata.
Support System One scoring with shared-state caching and Kev-specific limits.

* address comments

* mlx: preserve generation panics during cleanup (#18886)

A failure during decoding can trigger deferred drain and cache close, which may panic again and hide the original error. Skip stateful cleanup while a panic is unwinding so the runner reports the initial failure.

Add regression tests for the masked panic paths and normal cache saving.

* ci: harden download steps with retries (#18883)

Try a little harder instead of giving up on the first failure.

* gemma4: use MLX SDPA for CUDA prefill with wide head dims (#18809)

MLX's SDPA already handles head dims > 128 on CUDA, and is faster than our formerly required hand-rolled one.

* docs: changing model recs to Models page link, updating references to Ollamas cloud

* Add decision model integration tests and benchmarks (#18746)

* Add decision model integration tests and benchmarks

Support external JSONL corpora, quality scoring, concurrent requests, vision, and System One timing metrics.

* Refine decision tests and benchmarks with cache checks, external endpoints, and consistent response validation and timing

* cli: add decision model support to `ollama run` (#18962)

* decision: fix JSON state prompts for MLX decision models (#18974)

* renderers: add Python json.dumps serializer

* decision: render JSON states like the publishers' json.dumps

* Update README for improved privacy wording

* app: clarify cloud payment errors

* launch: allow usage credits without upgrading (#18985)

* mlx: port the Metal custom kernels to CUDA (#18657)

* mlx: port the Metal custom kernels to CUDA

mamba2_scan, depthwise_conv_silu and gated_delta (plus their _states/_bias
variants) had a Metal source only, so on CUDA each fell back to graph ops.

Deviations from the Metal sources:

- The scan returns early past D: Metal dispatches an exact thread count,
  CUDA rounds the grid up to whole blocks.
- T is dereferenced; CUDA passes inputs by address, Metal scalarizes
  zero-dimensional ones.
- simd_sum becomes a shfl butterfly, and the threadgroup q/k caches become
  per-warp registers: each warp normalizes the row its own lanes consume,
  costing a redundant norm but no shared memory and no barriers.
- The gates and SiLU call MLX's Sigmoid/LogAddExp/Exp instead of restating
  their formulas. Metal cannot: its custom-kernel preamble is metal::utils()
  alone, while CUDA embeds the op headers for nvrtc.

The parity tests now run on Metal and CUDA hosts.  The fused gated-delta
comparison takes a tolerance: the kernel and the graph path reduce in a
different order, so the bf16 output can land one ULP away.

* address comments

* openai: accept custom tool calls in Responses history (#18911)

Co-authored-by: Jeffrey Morgan <[email protected]>

* MLX: version bump (#18993)

* revert docs changes for now

* use cloudPassthroughMiddleware

* server: stop HTML-escaping cloud proxy request bodies (#19008)

* proxy: pass through ChatGPT upstream access errors (#19007)

* openai: clarify Responses authentication errors (#19004)

* New model... (#19030)

* ci: shorten Windows Vulkan build path

Keep the nested shader-generator compiler probes below Windows path limits in checkouts with longer repository names.

* mlx: fix Nemotron bugs and support global scales

Accept published Nemotron layer names while retaining legacy aliases, and
fix layer-count inference and detached MTP quantization. Stabilize Mamba
softplus, preserve FP32 vision normalization, and compile Mamba gate and
norm scaling.

Support per-expert F32 global scales and preserve activation-scale
companions in ModelOpt and compressed-tensors NVFP4 imports. Normalize
reciprocal globals and reject invalid scales. Keep activation scales
separate from weight-only inference.

* mlx: add Nemotron 3.5 Super

* minor adjustments

* llama.cpp: version bump b11669 (#19032)

* win: prevent orphaned runners (#18500)

* win: prevent orphaned runners

Assign runner processes to a singleton Windows Job Object configured with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE. This lets Windows terminate owned llama-server and MLX subprocesses when Ollama exits, including forced termination where graceful cleanup cannot run.

* address comments

* clef cloud launch

* be more precise with wording

* gguf: add the q2_0 tensor and file types (#18967)

* cleanup

* use identifiers for --ask mode question keys

* test

* transfer: support proxies on registry redirect targets (#19065)

Behind a proxy, defer redirect-target DNS to the proxy; without one, keep the resolve-and-pin path. Trust default-registry/CDN hostnames with no local DNS. Fix a nil CancelFunc crash in blobDownload.release.

* docs: add model grouping to cloud usage (#19069)

* docs: add model grouping to cloud usage

Document group_by=model in the cloud usage guide and OpenAPI schema.
Explain group selection and remainder, and show responses with multiple
models across time buckets.

* Update docs/api/cloud-usage.mdx

Co-authored-by: Bruce MacDonald <[email protected]>

---------

Co-authored-by: Bruce MacDonald <[email protected]>

* openai: allow Responses effort on non-thinking models (#19010)

* llama-server: let llama-server infer the draft speculative type (#19064)

llama-server can auto-detect most drafting models, so only pass the --spec-type
for drafting models it can't autodetect today: MTP sidecars detected by
Ollama's existing markers, and Eagle3.

* mlx: add PPLX Decider v1.2 support (#19072)

Implement the Qwen3.5-backed decision scorer with noncausal attention,
the publisher readout, image handling, and System One prompt encoding.

* api: populate show renderer/parser fields and add template_source (#19095)

ShowResponse's renderer and parser fields existed but the server never
set them; they now carry the effective values (renderer resolves the
gemma4 legacy alias by model size). A new template_source names what
actually renders chat prompts: the configured renderer/parser (leaving
any packaged template inert), a Go template layer, the GGUF's embedded
jinja, harmony, or none.

The CLI prints renderer/parser/template source rows only when set, so
ollama show output is unchanged for models without rendering config.

* openai: accept foreign compaction in Responses history (#19003)

* server: cancel remote inference when clients disconnect (#19144)

* avoid scary claude warning about auto compact window being too big

* openai: finish reasoning before client tool calls (#19146)

* llama.cpp: version bump b11738 (#19143)

* server: read loaded runner models without refMu (#19070)

* server: read loaded runner models without refMu

Concurrent lookups of a warm model failed TryLock against each other and
fell back to a manifest reload, defeating the cache and making
TestLoadedModelLookupConcurrent flaky. Make runnerRef.model an
atomic.Pointer so lookups never take refMu.

* address comments

* mlx: deduplicate CUDA runtime payloads (#17956)

* Deduplicate MLX CUDA runtime payloads

Move CUDA libraries shared by the GGML and MLX backends into the sibling CUDA payload, and teach in-process and subprocess MLX loading to resolve that packaged dependency directory.

Keep MLX-private libraries and JIT headers in the MLX overlay, include the full OpenBLAS Fortran runtime closure, and verify those dependencies in release packaging.

* address comments

* mlx: add Flint model support (#19181)

Preserve source tool JSON alongside decoded API values so Flint can retain
numeric types and schema order in prompts. Existing API marshaling is unchanged.

Assemble ModelOpt expert banks during safetensors import, and reject direct
Flint NVFP4 creation before conversion. Other models retain their existing
import and quantization paths.

Add optional learned sinks and device causal masks to shared MLX attention.
Existing callers retain the no-sink and host-mask paths; Flint opts into the
new behavior.

* ci: switch to released WoA CTK (#19185)

We were still using a pre-release, and the download site is flaky, so lets
get current on the latest CUDA Toolkit for WoA support.

* llama.cpp update (#19194)

* anthropic: surface errors after streaming starts (#19188)

* mlx: add d3 decision model support (#19196)

* mlx: add d3 decision model support

* bench: report loaded VRAM for decision runs

* build: update Go toolchain and dependencies (#19200)

* launch: use cloud model context in Claude Code (#19119)

* build: update jsonparser to v1.1.2 (#19220)

* mlxrunner: add Phonon text-to-speech support (#19166)

* mlxrunner: add Phonon text-to-speech support

Add Phonon text-to-speech through the existing MLX runner, with an
OpenAI-compatible speech endpoint and CLI playback.

Include model loading, text preprocessing, streaming audio, and
regression tests.

* docs: add speech models

* fix min version

---------

Co-authored-by: Daniel Hiltgen <[email protected]>

* flint: fix replies with thinking disabled (#19216)

* flint: fix replies with thinking disabled

Close the thinking section when think:false so Flint answers directly. Default and think:true prompts are unchanged.

* update template

* anthropic: reuse resolved thinking for web search (#19098)

* openai: preserve failures in Responses streams (#19225)

* Make sure all launchers know about cloud model metadata (#19223)

* Support GA Gradium Phonon checkpoints (#19227)

Replace the prerelease checkpoint path with Gradium's GA format, including default-voice import and speech conditioning. Set the 0.40.9 minimum, update the speech docs, and test import, inference setup, and rejection of the old checkpoint.

* Update gemma renderers (#19241)

* renderers: add gemma4-nemotron renderer

Add a Gemma 4 renderer variant that renders assistant content before
its tool calls rather than after the tool responses. Models opt in with
RENDERER gemma4-nemotron; gemma4 auto-detection is unchanged.

Adds the corresponding chat template as a test fixture for Jinja parity
checks.

* mlx: support Gemma 4 targets with DFlash drafts

Load a draft-owned output head when its config requires one, while preserving the target-head path used by existing DFlash models.

Expose Gemma 4 hidden-state taps and raw logits for speculative decoding. Report safetensors target precision independently of quantized draft weights.

* qwen3coder: preserve literal function closing tags in parameters (#19228)

* launch: use allocated context for OpenCode (#19193)

* decision: allow empty state for vllm-d3 (#19173)

* decision: allow empty state for vllm-d3

* server: reuse decoded state in System One tests

---------

Co-authored-by: Patrick Devine <[email protected]>

* llama.cpp: version bump b11845 (#19250)

* mlxrunner: spell out symbols, numbers and links for Phonon (#19234)

* mlxrunner: spell out symbols, numbers and links for Phonon

* docs: describe speech text normalization

* mlxrunner: fix Phonon misreadings inherited from xn-ptts

* mlxrunner: fix remaining Phonon misreadings

* mlxrunner: fold Phonon letters from the vocab, read #, _ and lists

* mlxrunner: add xn-ptts license notice for Phonon

* mlxrunner: move the xn-ptts license notice into normalize.go

* mlxrunner: fix remaining Phonon readings and port elongations

* docs: speech reads times and numeric dates

* mlxrunner: fix Phonon readings found in a listening pass

* docs: speech reads times and dates as written

* voice: add voice catalog for Phonon (#19242)

* mlxrunner: import and list Phonon catalog voices

* docs: document Phonon voices

* mlx: preserve small-image detail for compact Gemma 4 vision towers (#19247)

Dynamic sizing can floor the smallest image grid below its intended 70-token budget, losing detail in small images. Round that grid up for the compact tower, capped at the next supported budget.

Keep explicit budgets and the existing sizing for larger and unified towers. Update geometry and media-expansion tests.

* MLX, MLX-C: version bump - prompt speed up for gemma/flint/laguna (#19291)

* MLX, MLX-C: version bump

The MLX-C pin now provides its own bindings for gather_qmm global_scale
and fast::gated_delta_update, so those two carried patches drop out.
Carry 0001-mlx-c-sdpa-window-size instead: sliding-window attention
added a window_size argument to fast::scaled_dot_product_attention
(ml-explore/mlx#4734) that MLX-C has not bound yet, to be regenerated
from MLX-C once the upstream binding PR merges. The SDPA wrappers gain
a window size argument; all call sites default to the full context.

* mlxrunner: dispatch sliding-window prefills to the native SDPA window

Sliding layers no longer materialize a causal∩sliding mask for prefill
chunks past the window: resolve() dispatches {causal, window} natively
when the rotating cache's L>1 concat has linearized the ring and the
mask is otherwise pure causal, via a new MaskApplier.NativeWindow hint.
Vision relaxations, padding, model arrays, and decode keep the
materialized path. No model changes; sinks compose natively.

* dflash: add the DFlash2 draft model (#19149)

DFlash2 adds block-local dynamic convolutions and a candidate selector
to DFlash. The selector proposes each token conditioned on its
predecessor and returns each position's candidate distribution, which
verification uses to keep the output exact. Like the reference, the
draft samples with the request's temperature only.

A DFlash2 session drafts seven tokens every round on the existing
snapshot verify path instead of following the depth controller, whose
shallower picks lose more accepted tokens than they save in verify time.

qwen3.5-family targets now expose the layer taps, token embeddings and
raw logits a DFlash draft needs.

* llama.cpp: version bump b11901 (#19311)

* Fix kimi cli tool-only assistant turns (#19312)

* Fix kimi cli

* just interpret [] same as empty string actually

* dont gate on role

* cmd/launch: fix OpenCode v2 launch and config parsing (#19310)

Co-authored-by: 0d00ciallo0721 <[email protected]>

* mlx: add LFM3 and d1 models (#19333)

* llm: LFM3 GGUF fixes and llama-server speech (#19344)

Fixes for running LFM3 GGUFs on the llama-server runner, plus GGUF
text-to-speech that turns on once llama.cpp is bumped past b11901.

- BOS: honor an explicit tokenizer.ggml.add_bos_token. LFM3 GGUFs (and
  lfm2:24b) set it to false and expect the template's BOS, which the
  lfm2 default was stripping. The lfm2 default still applies when the
  key is absent. On lfm2:24b, WikiText PPL goes from 81.3 to 72.0.
- repeat_last_n -1 now maps to the context size; llama-server rejects
  negative values.
- Audio-only projectors (LFM3-Audio) no longer advertise vision, so
  clients don't send images the model can't take.
- /v1/audio/speech on GGUF models calls llama-server /tts chunk by
  chunk. Renderers opt in through a new SpeechPrompter (voices,
  voice parsing, chunking), so other speech models can add their own.
  The LFM3 voice and chunking helpers move from the MLX runner into
  model/renderers and are shared by both runners.

* llama.cpp: version bump b11963 (#19360)

* cmd: show help when running ollama without arguments (#19248)

* llama.cpp: workaround Metal unary crash (#19372)

This temporary patch works around a regression on older versions of MacOS
ggml_metal_library_compile_all: failed to build 'unary' library

* ci: pin buildx to workaround deadlock (#19373)

Recent buildx updates are causing frequent deadlocks in our CI builds.
Until this is resolved upstream, pin to an older version.

* openai: preserve readable Responses input content (#19192)

* mlx: sort long top-k rows in chunks (#19392)

MLX's argpartition sorts the whole row, and a row longer than one block
of the GPU sort takes a multi-pass merge sort. TopKIndices sorts each
2048-value chunk in a single block, then only the chunks' top k, and
returns the same indices in the same order.

The sampler's top_k and top_logprobs and the DFlash2 candidate selector
use it in place of a full-vocabulary argpartition.

* app: make ChatGPT disconnect failures retryable (#19336)

* feat(launch): use model output limits for Claude Code (#19410)

* openai: don't override model sampler defaults (#19432)

The OpenAI-compatible endpoints filled in sampler options the client
left out: temperature and top_p fell back to 1.0, and /v1/completions
always sent frequency_penalty and presence_penalty as 0. Request
options are applied last, so these values replaced the model's packaged
defaults. /api/chat honored those defaults; /v1 did not.

Omitted options are now left unset on /v1/chat/completions,
/v1/completions and /v1/responses, so the model's parameters apply, the
same as on /api/chat. Values the client sends still win, including an
explicit 0. On /v1/completions, top_p and the penalties are now
pointers so "omitted" and "0" can be told apart.

Clients that send no sampler options now get the model's defaults
instead of 1.0/1.0. A model with no sampler parameters gets Ollama's
defaults (temperature 0.8, top_p 0.9), as on /api/chat.

Fixes #17744
Fixes #18690

* launch: check ChatGPT routing before configuring (#19470)

* server: decode cloud web search responses (#19476)

* mlx: load bundled CUDA libraries in-process on Linux (#19433)

NVIDIA's libcusolver looks for its dependencies only in its own
directory, so libcublas and libnvJitLink resolved to the host's copies
and MLX failed to load when those didn't match the bundled ones. Preload
the bundled copies by full path before loading MLX.

* model: add MiMo V2.6 renderer for Qwen3.5 (#19400)

* launch: populate Pi models automatically (#19460)

* Add AutoTrust decision model to MLX (#19399)

* Add AutoTrust decision scoring to MLX

* address comments

* Support AutoTrust 35B decision models in MLX

* Resolve AutoTrust choice limits during config loading

Apply publisher-specific defaults and validate requests against the resolved limit.

* mlx: reject unsupported CUDA devices (#19521)

* mlx: bump for CUDA architecture metadata

* mlx: reject unsupported CUDA devices

* address comments

* mlx: support YaRN scaling in Qwen3 and Qwen3.5 (#19231)

* llama.cpp: version bump b12111 (#19530)

Drop 002-metal-unary-cast-constexpr.patch: superseded by upstream fix

* llama-server: allow parallel requests for recurrent and vision models (#19545)

These architectures were forced to num_parallel=1 because the older Go
engine's recurrent caches held one sequence. llama-server supports
multiple slots for all of them so we can allow parallelism now.

* cmd/launch: show gateway model names in Claude Desktop's model picker (#19533)

* cmd: restore the no-argument launcher (#19478)

Co-authored-by: Jeffrey Morgan <[email protected]>

* mlxrunner: close generation cache on shutdown (#19550)

* cmd/launch: add Kimi Code CLI support (#19506)

* openai: forward truncation option in responses requests (#19501)

Co-authored-by: Eva Ho <[email protected]>

* openai: return an empty array for /v1/models when no models are installed (#19539)

* llama.cpp: version bump b12177 (#19576)

* README: add Quock to Mobile community integrations (#19361)

* windows: add CUDA 13.5 and SM 103 for ARM64 (#19580)

Install the separate ARM64 cross package in CI and retain SM 121
support. Other platforms are unchanged.

* MLX: make Qwen3.8 Flash Next memory efficient (#18078)

* MLX: reduce Qwen3.8 Flash Next memory use

For NVFP4 creation, retain source precision for sensitive QSA projections
and non-expert MTP weights. Keep routed experts and PLE at NVFP4, and
promote other eligible weights to MXFP8.

Keep NVFP4 PLE tables host-backed, transferring only selected packed rows
and their scales to MLX. Honor scalar and per-expert NVFP4 global scales
in MoE, and per-shard global scales in host-backed PLE.

Use compressed QSA block selections in fused indexed Metal attention for
long prefill batches, retaining the graph fallback. Co-locate component
loading and forward methods, with explicit quantization and cache ownership.

* mlx: skip materializing host-backed tensors

Let models exclude tensors already owned by host storage from MLX loading.
Avoid allocating and discarding the full Qwen PLE tables at startup while
preserving the resident fallback.

* address comments

* launch: fix Claude Code routing and retired model errors (#19587)

* Add ripple preview support to the MLX runner (#19592)

Add the Ripple model, renderer, parser and import registration.
Support per-layer NoPE in DFlash drafts.
Fuse MLP activation, value blending and attention gating.
Add reference fixtures and model/runner regression tests.

---------

Co-authored-by: Daniel Hiltgen <[email protected]>
Co-authored-by: Jesse Gross <[email protected]>
Co-authored-by: Parth Sareen <[email protected]>
Co-authored-by: Eva H <[email protected]>
Co-authored-by: Patrick Devine <[email protected]>
Co-authored-by: Devon Rifkin <[email protected]>
Co-authored-by: Daniel Hiltgen <[email protected]>
Co-authored-by: Dong Chen <[email protected]>
Co-authored-by: manu <[email protected]>
Co-authored-by: Jeffrey Morgan <[email protected]>
Co-authored-by: Dongluo Chen <[email protected]>
Co-authored-by: Aniket Kumar <[email protected]>
Co-authored-by: Anna Rahn <[email protected]>
Co-authored-by: Gigrise <[email protected]>
Co-authored-by: Anna Rahn <[email protected]>
Co-authored-by: Jonathan Berg <[email protected]>
Co-authored-by: J Berg <[email protected]>
Co-authored-by: Anna Rahn <[email protected]>
Co-authored-by: Willie Tran <[email protected]>
Co-authored-by: Bruce MacDonald <[email protected]>
Co-authored-by: SynapShift <[email protected]>
Co-authored-by: 0d00ciallo0721 <[email protected]>
Co-authored-by: Marlon Ferreira <[email protected]>
Co-authored-by: Eva Ho <[email protected]>
Co-authored-by: liangliang205 <[email protected]>
Co-authored-by: Matteo Celani <[email protected]>
rick-github added a commit to rick-github/ollama that referenced this pull request Nov 8, 2026
* anthropic: reuse resolved thinking for web search (ollama#19098)

* openai: preserve failures in Responses streams (ollama#19225)

* Make sure all launchers know about cloud model metadata (ollama#19223)

* Support GA Gradium Phonon checkpoints (ollama#19227)

Replace the prerelease checkpoint path with Gradium's GA format, including default-voice import and speech conditioning. Set the 0.40.9 minimum, update the speech docs, and test import, inference setup, and rejection of the old checkpoint.

* Update gemma renderers (ollama#19241)

* renderers: add gemma4-nemotron renderer

Add a Gemma 4 renderer variant that renders assistant content before
its tool calls rather than after the tool responses. Models opt in with
RENDERER gemma4-nemotron; gemma4 auto-detection is unchanged.

Adds the corresponding chat template as a test fixture for Jinja parity
checks.

* mlx: support Gemma 4 targets with DFlash drafts

Load a draft-owned output head when its config requires one, while preserving the target-head path used by existing DFlash models.

Expose Gemma 4 hidden-state taps and raw logits for speculative decoding. Report safetensors target precision independently of quantized draft weights.

* qwen3coder: preserve literal function closing tags in parameters (ollama#19228)

* launch: use allocated context for OpenCode (ollama#19193)

* decision: allow empty state for vllm-d3 (ollama#19173)

* decision: allow empty state for vllm-d3

* server: reuse decoded state in System One tests

---------

Co-authored-by: Patrick Devine <[email protected]>

* llama.cpp: version bump b11845 (ollama#19250)

* mlxrunner: spell out symbols, numbers and links for Phonon (ollama#19234)

* mlxrunner: spell out symbols, numbers and links for Phonon

* docs: describe speech text normalization

* mlxrunner: fix Phonon misreadings inherited from xn-ptts

* mlxrunner: fix remaining Phonon misreadings

* mlxrunner: fold Phonon letters from the vocab, read #, _ and lists

* mlxrunner: add xn-ptts license notice for Phonon

* mlxrunner: move the xn-ptts license notice into normalize.go

* mlxrunner: fix remaining Phonon readings and port elongations

* docs: speech reads times and numeric dates

* mlxrunner: fix Phonon readings found in a listening pass

* docs: speech reads times and dates as written

* voice: add voice catalog for Phonon (ollama#19242)

* mlxrunner: import and list Phonon catalog voices

* docs: document Phonon voices

* mlx: preserve small-image detail for compact Gemma 4 vision towers (ollama#19247)

Dynamic sizing can floor the smallest image grid below its intended 70-token budget, losing detail in small images. Round that grid up for the compact tower, capped at the next supported budget.

Keep explicit budgets and the existing sizing for larger and unified towers. Update geometry and media-expansion tests.

* MLX, MLX-C: version bump - prompt speed up for gemma/flint/laguna (ollama#19291)

* MLX, MLX-C: version bump

The MLX-C pin now provides its own bindings for gather_qmm global_scale
and fast::gated_delta_update, so those two carried patches drop out.
Carry 0001-mlx-c-sdpa-window-size instead: sliding-window attention
added a window_size argument to fast::scaled_dot_product_attention
(ml-explore/mlx#4734) that MLX-C has not bound yet, to be regenerated
from MLX-C once the upstream binding PR merges. The SDPA wrappers gain
a window size argument; all call sites default to the full context.

* mlxrunner: dispatch sliding-window prefills to the native SDPA window

Sliding layers no longer materialize a causal∩sliding mask for prefill
chunks past the window: resolve() dispatches {causal, window} natively
when the rotating cache's L>1 concat has linearized the ring and the
mask is otherwise pure causal, via a new MaskApplier.NativeWindow hint.
Vision relaxations, padding, model arrays, and decode keep the
materialized path. No model changes; sinks compose natively.

* dflash: add the DFlash2 draft model (ollama#19149)

DFlash2 adds block-local dynamic convolutions and a candidate selector
to DFlash. The selector proposes each token conditioned on its
predecessor and returns each position's candidate distribution, which
verification uses to keep the output exact. Like the reference, the
draft samples with the request's temperature only.

A DFlash2 session drafts seven tokens every round on the existing
snapshot verify path instead of following the depth controller, whose
shallower picks lose more accepted tokens than they save in verify time.

qwen3.5-family targets now expose the layer taps, token embeddings and
raw logits a DFlash draft needs.

* llama.cpp: version bump b11901 (ollama#19311)

* Fix kimi cli tool-only assistant turns (ollama#19312)

* Fix kimi cli

* just interpret [] same as empty string actually

* dont gate on role

* cmd/launch: fix OpenCode v2 launch and config parsing (ollama#19310)

Co-authored-by: 0d00ciallo0721 <[email protected]>

* mlx: add LFM3 and d1 models (ollama#19333)

* llm: LFM3 GGUF fixes and llama-server speech (ollama#19344)

Fixes for running LFM3 GGUFs on the llama-server runner, plus GGUF
text-to-speech that turns on once llama.cpp is bumped past b11901.

- BOS: honor an explicit tokenizer.ggml.add_bos_token. LFM3 GGUFs (and
  lfm2:24b) set it to false and expect the template's BOS, which the
  lfm2 default was stripping. The lfm2 default still applies when the
  key is absent. On lfm2:24b, WikiText PPL goes from 81.3 to 72.0.
- repeat_last_n -1 now maps to the context size; llama-server rejects
  negative values.
- Audio-only projectors (LFM3-Audio) no longer advertise vision, so
  clients don't send images the model can't take.
- /v1/audio/speech on GGUF models calls llama-server /tts chunk by
  chunk. Renderers opt in through a new SpeechPrompter (voices,
  voice parsing, chunking), so other speech models can add their own.
  The LFM3 voice and chunking helpers move from the MLX runner into
  model/renderers and are shared by both runners.

* llama.cpp: version bump b11963 (ollama#19360)

* cmd: show help when running ollama without arguments (ollama#19248)

* llama.cpp: workaround Metal unary crash (ollama#19372)

This temporary patch works around a regression on older versions of MacOS
ggml_metal_library_compile_all: failed to build 'unary' library

* ci: pin buildx to workaround deadlock (ollama#19373)

Recent buildx updates are causing frequent deadlocks in our CI builds.
Until this is resolved upstream, pin to an older version.

* openai: preserve readable Responses input content (ollama#19192)

* mlx: sort long top-k rows in chunks (ollama#19392)

MLX's argpartition sorts the whole row, and a row longer than one block
of the GPU sort takes a multi-pass merge sort. TopKIndices sorts each
2048-value chunk in a single block, then only the chunks' top k, and
returns the same indices in the same order.

The sampler's top_k and top_logprobs and the DFlash2 candidate selector
use it in place of a full-vocabulary argpartition.

* app: make ChatGPT disconnect failures retryable (ollama#19336)

* feat(launch): use model output limits for Claude Code (ollama#19410)

* openai: don't override model sampler defaults (ollama#19432)

The OpenAI-compatible endpoints filled in sampler options the client
left out: temperature and top_p fell back to 1.0, and /v1/completions
always sent frequency_penalty and presence_penalty as 0. Request
options are applied last, so these values replaced the model's packaged
defaults. /api/chat honored those defaults; /v1 did not.

Omitted options are now left unset on /v1/chat/completions,
/v1/completions and /v1/responses, so the model's parameters apply, the
same as on /api/chat. Values the client sends still win, including an
explicit 0. On /v1/completions, top_p and the penalties are now
pointers so "omitted" and "0" can be told apart.

Clients that send no sampler options now get the model's defaults
instead of 1.0/1.0. A model with no sampler parameters gets Ollama's
defaults (temperature 0.8, top_p 0.9), as on /api/chat.

Fixes ollama#17744
Fixes ollama#18690

* launch: check ChatGPT routing before configuring (ollama#19470)

* server: decode cloud web search responses (ollama#19476)

* mlx: load bundled CUDA libraries in-process on Linux (ollama#19433)

NVIDIA's libcusolver looks for its dependencies only in its own
directory, so libcublas and libnvJitLink resolved to the host's copies
and MLX failed to load when those didn't match the bundled ones. Preload
the bundled copies by full path before loading MLX.

* model: add MiMo V2.6 renderer for Qwen3.5 (ollama#19400)

* launch: populate Pi models automatically (ollama#19460)

* Add AutoTrust decision model to MLX (ollama#19399)

* Add AutoTrust decision scoring to MLX

* address comments

* Support AutoTrust 35B decision models in MLX

* Resolve AutoTrust choice limits during config loading

Apply publisher-specific defaults and validate requests against the resolved limit.

* mlx: reject unsupported CUDA devices (ollama#19521)

* mlx: bump for CUDA architecture metadata

* mlx: reject unsupported CUDA devices

* address comments

* mlx: support YaRN scaling in Qwen3 and Qwen3.5 (ollama#19231)

* llama.cpp: version bump b12111 (ollama#19530)

Drop 002-metal-unary-cast-constexpr.patch: superseded by upstream fix

* llama-server: allow parallel requests for recurrent and vision models (ollama#19545)

These architectures were forced to num_parallel=1 because the older Go
engine's recurrent caches held one sequence. llama-server supports
multiple slots for all of them so we can allow parallelism now.

* cmd/launch: show gateway model names in Claude Desktop's model picker (ollama#19533)

* cmd: restore the no-argument launcher (ollama#19478)

Co-authored-by: Jeffrey Morgan <[email protected]>

* mlxrunner: close generation cache on shutdown (ollama#19550)

* cmd/launch: add Kimi Code CLI support (ollama#19506)

* openai: forward truncation option in responses requests (ollama#19501)

Co-authored-by: Eva Ho <[email protected]>

* openai: return an empty array for /v1/models when no models are installed (ollama#19539)

* llama.cpp: version bump b12177 (ollama#19576)

* README: add Quock to Mobile community integrations (ollama#19361)

* windows: add CUDA 13.5 and SM 103 for ARM64 (ollama#19580)

Install the separate ARM64 cross package in CI and retain SM 121
support. Other platforms are unchanged.

* MLX: make Qwen3.8 Flash Next memory efficient (ollama#18078)

* MLX: reduce Qwen3.8 Flash Next memory use

For NVFP4 creation, retain source precision for sensitive QSA projections
and non-expert MTP weights. Keep routed experts and PLE at NVFP4, and
promote other eligible weights to MXFP8.

Keep NVFP4 PLE tables host-backed, transferring only selected packed rows
and their scales to MLX. Honor scalar and per-expert NVFP4 global scales
in MoE, and per-shard global scales in host-backed PLE.

Use compressed QSA block selections in fused indexed Metal attention for
long prefill batches, retaining the graph fallback. Co-locate component
loading and forward methods, with explicit quantization and cache ownership.

* mlx: skip materializing host-backed tensors

Let models exclude tensors already owned by host storage from MLX loading.
Avoid allocating and discarding the full Qwen PLE tables at startup while
preserving the resident fallback.

* address comments

* launch: fix Claude Code routing and retired model errors (ollama#19587)

* Add ripple preview support to the MLX runner (ollama#19592)

Add the Ripple model, renderer, parser and import registration.
Support per-layer NoPE in DFlash drafts.
Fuse MLP activation, value blending and attention gating.
Add reference fixtures and model/runner regression tests.

---------

Co-authored-by: Eva H <[email protected]>
Co-authored-by: J Berg <[email protected]>
Co-authored-by: Daniel Hiltgen <[email protected]>
Co-authored-by: SynapShift <[email protected]>
Co-authored-by: Patrick Devine <[email protected]>
Co-authored-by: Jeffrey Morgan <[email protected]>
Co-authored-by: 0d00ciallo0721 <[email protected]>
Co-authored-by: Parth Sareen <[email protected]>
Co-authored-by: Marlon Ferreira <[email protected]>
Co-authored-by: Eva Ho <[email protected]>
Co-authored-by: liangliang205 <[email protected]>
Co-authored-by: Matteo Celani <[email protected]>
rcfa pushed a commit to cubiculum-ai/mlx that referenced this pull request Nov 26, 2026
osaurus-ai/mlx takes only the part of this commit that is independent of the window size: the
VJP fallback (gradients of the mask or the sinks, and the fallback's primals) and the gradient
test, without windows. The window size needs ml-explore#4734, which osaurus-ai/mlx does not take.

Ported: Apple's commit adds `|| other_grads` to an `if (outputs.size() != 2)` that came
upstream with ml-explore/mlx PR 4565, which the fork does not have. So this commit also adds
that check: without the logsumexp output, the VJP takes the fallback. The fused Metal backward
needs that output.

(cherry picked from commit 58d91ee)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants