Commit Graph
5757 Commits
Author SHA1 Message Date
Daniel Hiltgen a43fad18b0 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.
v0.34.2-rc0
2026-09-15 13:13:31 -07:00
Parth Sareen 38fdb5dd58 docs: refresh getting started guides (#18450) v0.34.1 2026-09-14 23:32:30 -07:00
Daniel Hiltgen 2c29c9f05e 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.
v0.34.1-rc2
2026-09-14 21:24:26 -07:00
Daniel Hiltgen 4ea3472496 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.
2026-09-14 20:53:05 -07:00
Daniel Hiltgen 98acec40ae 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
2026-09-14 20:32:36 -07:00
Daniel Hiltgen 891b086232 mlx: add mlx patch to docker build context (#18440) v0.34.1-rc1 2026-09-14 13:34:03 -07:00
Parth Sareen 2d26fafc42 docs: add ChatGPT Desktop integration (#18377) 2026-09-14 13:24:31 -07:00
Daniel Hiltgen f093c6e008 MLX: version bump (#18235)
* MLX: version bump

* mlx: support ModelOpt global scales in MoE models

* address comments

* address comments
v0.34.1-rc0
2026-09-14 09:49:46 -07:00
Eva H b17427b3ca app: refresh Apps layout and command copy feedback (#18372) 2026-09-14 08:54:46 -07:00
Daniel Hiltgen 53fed26112 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.
2026-09-11 13:25:08 -07:00
Parth Sareen c16bf9892a cmd: remove built-in agent (#18393) 2026-09-11 12:21:52 -07:00
Jesse Gross b68b112bd8 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.
2026-09-10 17:25:34 -07:00
Jesse Gross aeb8f71167 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.
2026-09-10 17:25:34 -07:00
Jesse Gross 13037ecb14 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.
2026-09-10 17:25:34 -07:00
frob 4512d2b76d llm: raise token repeat limit to 100 and return error instead of silently closing (#18374) 2026-09-10 15:46:58 -07:00
Jesse Gross f09d55d0e2 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.
2026-09-10 15:20:21 -07:00
Jesse Gross 1548f78c73 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.
2026-09-10 15:20:21 -07:00
Jesse Gross 6137793ac4 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
2026-09-10 15:20:11 -07:00
Jesse Gross b859a94509 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.
2026-09-10 15:20:11 -07:00
Jesse Gross 45a02807e2 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.
2026-09-10 15:20:11 -07:00
Jesse Gross 8d66f08355 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.
2026-09-10 15:20:11 -07:00
Daniel Hiltgen ea8d65004a 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.
2026-09-10 11:16:37 -07:00
Daniel Hiltgen c951dabec4 llama.cpp: version bump b10864 (#18317) 2026-09-10 08:09:59 -07:00
Eva H 159b1c3331 app: fix ChatGPT model selector spacing (#18347) 2026-09-09 15:02:42 -07:00
Parth Sareen d8ab4b4f0c openai: support standalone named function outputs (#18348) v0.34.0-rc5 v0.34.0 2026-09-09 14:51:50 -07:00
Parth Sareen 3738935d0c proxy: normalize namespaced commands in Full Access (#18331) v0.34.0-rc4 2026-09-09 10:20:48 -07:00
Parth Sareen 86f7292934 openai: accept plaintext-labeled Codex agent messages (#18329) v0.34.0-rc3 2026-09-08 17:09:48 -07:00
Parth Sareen cd1c5a145d openai: finalize responses at the web search limit (#18328) v0.34.0-rc2 2026-09-08 16:27:20 -07:00
Eva H 9160b3c0b8 app: add a first-use ChatGPT connection intro (#18321) 2026-09-08 15:44:21 -07:00
Eva H 3e02feac8d app: align ChatGPT connection status copy with Claude (#18325) 2026-09-08 15:22:56 -07:00
Parth Sareen 1b45aa19da server/openai: retry compaction after context overflow (#18324) 2026-09-08 14:42:03 -07:00
Eva H 34afa1a0c8 app: open Codex by default for Ollama launches (#18323) 2026-09-08 13:40:20 -07:00
Daniel Hiltgen b5d373f340 fix data races in progress and sched (#18319)
progress: join the render loop in stop and do the final writes after the
goroutine exits, so Stop/StopAndClear cannot race an in-flight render on
the shared bufio.Writer.

sched: read the unload-mutable fields in runnerRef.LogValue only under a
successful refMu.TryLock and omit them when contended, since slog resolves
it on goroutines that may already hold refMu.
2026-09-08 13:13:59 -07:00
Parth Sareen 9ef6c19341 app: preserve Codex configuration across host changes (#18247) 2026-09-08 12:42:37 -07:00
Jeffrey Morgan 3b5ab1fcfc openai: use tsc_ prefix for tool search call IDs (#18296) 2026-09-08 10:55:23 -07:00
Parth Sareen 83ed7d9965 app: harden Codex desktop proxy handling (#18244) v0.34.0-rc1 2026-09-04 17:48:55 -07:00
Parth Sareen b043d891c2 openai: preserve images through response compaction (#18245) 2026-09-04 17:48:45 -07:00
Parth Sareen 43e667004a app: route Codex auto review through selected model (#18246) 2026-09-04 17:48:37 -07:00
Daniel Hiltgen d3efc63263 ci: bound and cache the macOS MLX payload build (#18240)
Avoid unbounded parallel builds on small runners, and cache the payloads for repeated runs.
2026-09-04 14:38:05 -07:00
Eva H 87b9f9e95a app: add Ollama to ChatGPT Desktop (#18236) v0.34.0-rc0 2026-09-04 14:04:48 -07:00
Parth Sareen 3f77cb6dfb openai: add Codex compaction support (#18224) 2026-09-04 13:07:33 -07:00
Parth Sareen cf8b605b06 openai: add client tool search support (#18223) 2026-09-04 13:07:23 -07:00
Jesse Gross b68365a0a4 mlxrunner: compile structured output as xgrammar structural tags
The runner compiled a format as a JSON Schema, the one grammar kind its
xgrammar binding exposed. A structural tag holds a schema as one node of
a larger tree and also expresses what a schema cannot: free text around
constrained spans, a thinking region that closes before constrained
content, tool calls pinned to their schemas.

The runner now compiles structural tags only; its client wraps the API's
formats into one, which compiles to the same grammar as before. The JSON
token and vocabulary caps go with it: neither bounds compile cost, which
follows the grammar's state count. The byte and nesting caps stay.
2026-09-03 15:49:34 -07:00
Jesse Gross 4986e92379 mlxrunner: enable speculative decoding under structured output
A structured-output request could not use a model's draft head: it
decoded one token at a time, at roughly half the speculative throughput
on a dense 27B MTP model.

The grammar is enforced during verification instead: each draft
position's logits are masked before rejection sampling, so an invalid
draft is never accepted and every emitted token obeys the grammar.
Drafts stay unconstrained; constraining the draft chain would stall its
pipelined forwards.

Speculative steps also now dispatch the drafts before the host builds
the verification graph, worth 4-8% end to end at a fixed draft depth on
MTP models, with or without a grammar.
2026-09-03 15:49:34 -07:00
Daniel Hiltgen 59fe23d85c ci: rebuild MLX macOS test payloads the release can't supply (#18219)
* ci: rebuild MLX macOS test payloads the release can't supply

The MLX unit test dependency payload can go stale when a PR changes the
xgrammar wrapper (release dylib lacks the new symbols) or bumps MLX pins (no
matching release, so MLX tests silently skipped). Compare the matched tag's
build rules and wrapper sources against the checkout, rebuilding only
libollama_xgrammar.dylib on drift; with no matching release, build one Metal
variant at the platform default.

* address comments
2026-09-03 14:17:21 -07:00
Jesse Gross b79067b0db gemma4: image and audio input support
Safetensors gemma4 imports served by the MLX engine now answer image
and audio chats. Images run through both vision architectures: the
transformer tower (26B, 31B, e-series) and the 12B's encoder-free
unified embedder. Audio arrives through the same intake the ollama
API already accepts for gemma4 GGUFs — WAV bytes in the images field,
OpenAI input_audio parts, and /v1/audio/transcriptions uploads — with
the e2b/e4b checkpoints running clips through their conformer audio
encoder and the 12b unified checkpoint embedding the raw waveform
directly. Clips longer than 30 seconds are split evenly into chunks
of at most 30 seconds, cut at pauses, and encoded independently.

Each modality serves only checkpoints that carry it: 26B/31B have no
audio config and reject audio input, and checkpoints with an
unrecognized vision architecture still load as text-only models and
reject image requests.

The server previously hid the vision and audio capabilities for
gemma4 safetensors because the engine served neither. Both
suppressions are removed, and existing imports start advertising the
capabilities without re-importing since import already records them.
v0.33.3-rc2 v0.33.3
2026-09-02 15:07:28 -07:00
Jesse Gross 3ffc9a682a mlxrunner: shared audio decoding and chunking for audio models
Audio-capable models need mono PCM at their expected sample rate
before model-specific feature extraction. Like the image decoder set
in base, the supported audio containers are decided once here so
every model accepts the same formats: WAV, covering integer and float
PCM, extensible headers, and multi-channel downmix. Anything else is
rejected as unrecognized; supporting another container later means
one new decoder here, with no model or runner changes.

Input at other sample rates is resampled through a band-limiting
filter, so mismatched rates degrade gracefully instead of aliasing.
Decoded clips are capped at ten minutes: the declared rate comes from
an untrusted header, and the cap is what keeps a small file claiming
an absurdly low rate from resampling into an enormous allocation.

Models whose encoder takes clips only up to a fixed length split
longer clips with Split. Chunks are sized evenly, and each cut moves
to the quietest point within a few seconds of its even share, so a
boundary lands on a pause where the clip has one instead of severing
a word between two independently encoded chunks. The even sizing
bounds the search so no chunk can end up over the limit.
2026-09-02 15:07:28 -07:00
Jesse Gross ba064c3662 mlxrunner: check every mlx-c call in the MLX bindings
The bindings captured MLX error messages but checked almost no calls,
so a failure continued with a null output and surfaced later as zero
results, skipped evals, or an unrelated crash.

Wrap every call in mlxCheck. Paths that return an error or disable a
GPU kernel backend use mlxError instead, and the lookups where a
non-zero status means a miss read the buffer first and then treat the
status as data.

Also free the string handles behind Array.String and the log values
after the call that fills them; they were freed before it and leaked.
2026-09-02 15:05:54 -07:00
Jesse Gross c36adebc20 mlxrunner: capture MLX errors in a single buffer read after every call
MLX runs on one goroutine locked to its OS thread, so the thread-local
error buffers and closure-based check helpers defended against a
calling pattern that is already invalid.

Replace them with a single buffer that the handler fills and Go reads
after every call. mlxError returns the captured message; mlxCheck
panics on it and passes the call's result through, so a checked call
is one expression. Only an int status carries a failure signal, which
lets a message next to a zero status be reported as an earlier
unchecked call.

Fix two tests that relied on errors being dropped: the laguna
mixed-precision fixture used an unsupported quantization group size,
and the compile callback test expected the callback's own panic.
2026-09-02 15:05:54 -07:00
Daniel Hiltgen 882387a57b mlx: fix mtp_test unit test (#18203) 2026-09-02 11:17:16 -07:00