Ollama has released a release candidate that processes short Inkling 2 conversation histories faster on Apple devices and frees memory unnecessarily retained by the MLX cache. For developers using local models, it reduces both short-request overhead and wasted history storage.
1. Reducing preparation work for short histories
Released on November 26, 0.40.19-rc0 includes improvements to short-history processing for Inkling 2 and the MLX runner's Engram history buffer. The speed and memory changes are covered in separate PRs.
Inkling 2 uses the Metal-accelerated path for long histories even when the history is shorter than 1024 keys. Previously, it converted the entire history to FP32 and built a dense mask for each query to mark which elements to compute. The developers say this preparation cost exceeded that of attention, which calculates relationships between inputs.
The new path splits the computation and combines the results. For short histories, it matches MLX's single-pass result within rounding error, the small differences that arise in numerical calculations. Short, unpadded blocks for a single request also use the merge and gate processing used for batched requests. Combining and passing through results this way reduces separate processing stages.
2. Removing unlikely candidates and unused computation
The draft model proposes next-token candidates, and the verification model checks them. This change excludes candidates whose probability is less than one-tenth that of the most likely candidate during proposal. According to the PR, verification follows the request's sampling settings, which select results based on probabilities, and corrects proposal probabilities, so the output remains unchanged.
The adaptive selector, which selects only necessary computation, converts only the rows actually used into vocabulary scores, values assigned to word candidates. Rather than scoring an entire block and using only part of it, it computes just the required portion. Draft models that do not use adaptive depth, which adjusts the scope of candidate review, retain their existing behavior.
The candidate filtering implementation is shown below. It excludes candidates whose probability at temperature 1 falls below the threshold relative to the most likely candidate.
// restrictScores drops candidates whose temperature-1 probability is below
// minP of the row's most likely one.
func restrictScores(scores *mlx.Array, minP float32) *mlx.Array {
floor := mlx.AddScalar(scores.MaxAxis(-1, true).AsType(mlx.DTypeFloat32), float32(math.Log(float64(minP))))
dropped := mlx.FromValue(float32(math.Inf(-1))).AsType(scores.DType())
return mlx.Where(scores.AsType(mlx.DTypeFloat32).Less(floor), dropped, scores)
}The same change also refines convolution snapshots, copies of intermediate states at specific points. When saving a state from an earlier point, it shares one required short segment instead of copying the entire input.
3. Reported throughput gains for chat and coding tasks
According to company-reported figures in PR 19881, throughput for a chat prompt, a set of inputs to the model, rose from 64.1 tokens per second in the old code to 78.5 in the changed code. The source lists the speedup as 1.20x.
For the coding task prompt, company-reported throughput increased from 89.0 to 114.5 tokens per second, with a speedup listed as 1.26x in the source. The prompts cover different tasks, so each compares the old and changed code for its respective task.
Both examples are results from the PR that updates short histories, candidate proposals, and snapshots together. For developers, the important point is that the combined reductions in preparation and unnecessary computation also improved actual request throughput.
4. The cache retains only the required final segment
PR 19913 changes the Engram cache in the MLX runner. It addresses a problem where a sliced array, a structure holding sequential data, could retain the entire original input chunk's storage even though only the history tail was needed.
The changed code slices out the required tail and copies it into a contiguous array. It is like switching from marking a needed section on a large sheet of paper and keeping the whole sheet to transferring just that section elsewhere.
The added tests check tail contents and retained memory for immediately saved, scheduled-to-save, and active states. They also check continued execution after restoring saved states and releasing multiple states in different orders.
5. A small copy in exchange for releasing memory
Short histories benefit from less unnecessary type conversion and mask creation, while the Engram cache releases large original storage allocations. The cache pays for this by copying the required tail into a separate contiguous array. Rather than simply eliminating computation, the memory improvement trades a small copy for avoiding retention of a large allocation.
The existing graph is retained for local windows smaller than 1024 keys or GPUs that do not support the split kernel. Other backends, the execution foundations that handle operations, are unchanged. The PRs do not provide the hardware or detailed model settings for the speed comparisons, or actual memory savings.
The key changes in this release candidate reduce preparation overhead for short requests and refine storage so the cache retains only the history it needs.
