published fresh until

Ollama: fix MLX threadgroup limit crash on M1/M2

Summary If an Ollama MLX model on M1 or M2 fails with a 896-versus-1024 threadgroup limit, upgrade to v0.40.4 or use the maintainer's model-tag workaround with the llama.cpp runner.

Not for Ollama mlx runner failed: panic: cache: offset 5335 exceeds 5334 stored keys.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Upgrade Ollama to v0.40.4 or a later release containing the MLX fix.

Symptom

mlx runner failed: panic: mlx: Maximum threads per threadgroup is 896 but requested 1024 for kernel appears during generation. The reporter describes Ollama 0.40.0 on an M1 Max with MLX models. Reported by ejgroene; other users commented on the issue, including Vyaczeslav and ambouza-byte.

Cause

An MLX attention kernel could request a threadgroup larger than the device supported. The merged Ollama change updated MLX dependencies and carried the M1/M2 attention-kernel correction.

Fix

1. Upgrade to v0.40.4 or a later release containing the correction. 2. If you cannot upgrade, use the maintainer's alternate model tag, qwen3.6:35b-a3b-q4_K_M, for the documented example. The q4_K_M variant selects the llama.cpp-based runner instead of MLX.

Fixed in

First carrying stable release: v0.40.4 (released 2026-10-12), containing PR #18956, merged 2026-10-12.

As of November 2026, the stable release named in the source is v0.40.18. The MLX revision selected by this Ollama tag includes the M1/M2 kernel fallback when the requested threadgroup exceeds the kernel limit. Tagged source.

If it still fails

  • The workaround changes the model variant and runner; it does not repair MLX itself. This thread does not establish a fix for unrelated memory exhaustion or cache-offset failures.

Not for: Ollama mlx runner failed: panic: cache: offset 5335 exceeds 5334 stored keys.

Sources

Checked

2026-11-24; read the issue and linked comment API records, merged PR API record, release records, fix inclusion comparison, and tagged behavior source plus the selected MLX revision; no command was run.

Started from a post by @ejgroene, packaged by the editor. Original post

Subjects

More in local models

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Ollama: fix MLX threadgroup limit crash on M1/M2
Summary: If an Ollama MLX model on M1 or M2 fails with a 896-versus-1024 threadgroup limit, upgrade to `v0.40.4` or use the maintainer's model-tag workaround with the llama.cpp runner.
Copy for agent
get the whatworks thread ollama-mlx-896-1024-threadgroup-limit-m1-m2 and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread ollama-mlx-896-1024-threadgroup-limit-m1-m2
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp