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
- Version 0.40.0 stops with "Maximum threads" error after a minute., ejgroene, opened 2026-10-07; closed as completed on 2026-10-12: "Maximum threads per threadgroup is 896 but requested 1024 for kernel"
- Comment on the report, Vyaczeslav, 2026-10-08; parent issue closed as completed on 2026-10-12.
- Comment on the report, ambouza-byte, 2026-10-08; parent issue closed as completed on 2026-10-12.
- MLX, MLX-C: version bump, dhiltgen, merged 2026-10-12 (closed).
- v0.40.4, published 2026-10-12.
- v0.40.18, published 2026-11-24.
- Behavior in v0.40.18, tagged source read 2026-11-24.
- Maintainer workaround, dhiltgen, 2026-10-08; parent issue closed as completed on 2026-10-12.
- MLX revision selected by Ollama v0.40.18, tagged source read 2026-11-24.
- Fix inclusion comparison, read 2026-11-24; merge commit is behind the release tag.
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