[PR #15845] Update MLX and MLX-C with threading fixes #62022

Open
opened 2026-04-29 16:58:49 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15845
Author: @dhiltgen
Created: 4/27/2026
Status: 🔄 Open

Base: mainHead: mlx-bump-threading


📝 Commits (2)

  • 2a83966 Update MLX and MLX-C
  • 8166abe Run MLX CGO work on a locked OS thread

📊 Changes

21 files changed (+1752 additions, -188 deletions)

View changed files

📝 MLX_C_VERSION (+1 -1)
📝 MLX_VERSION (+1 -1)
📝 x/imagegen/mlx/mlx.c (+339 -49)
📝 x/imagegen/mlx/mlx.h (+146 -30)
x/internal/mlxthread/thread.go (+174 -0)
x/internal/mlxthread/thread_test.go (+128 -0)
📝 x/mlxrunner/mlx/array_test.go (+30 -39)
📝 x/mlxrunner/mlx/generated.c (+158 -5)
📝 x/mlxrunner/mlx/generated.h (+391 -25)
📝 x/mlxrunner/mlx/include/mlx/c/compile.h (+1 -0)
📝 x/mlxrunner/mlx/include/mlx/c/distributed_group.h (+23 -9)
📝 x/mlxrunner/mlx/include/mlx/c/fft.h (+20 -0)
x/mlxrunner/mlx/include/mlx/c/graph_utils.h (+61 -0)
📝 x/mlxrunner/mlx/include/mlx/c/io.h (+5 -0)
📝 x/mlxrunner/mlx/include/mlx/c/io_types.h (+46 -0)
📝 x/mlxrunner/mlx/include/mlx/c/mlx.h (+1 -0)
📝 x/mlxrunner/mlx/include/mlx/c/ops.h (+44 -0)
📝 x/mlxrunner/mlx/stream.go (+34 -14)
x/mlxrunner/mlx/thread_test.go (+97 -0)
📝 x/mlxrunner/runner.go (+14 -1)

...and 1 more files

📄 Description

MLX now relies on OS-thread-local execution state for streams, encoders, and caches. Add an mlxthread executor backed by runtime.LockOSThread and route runner initialization, model load, inference, status memory reads, and cleanup through the worker so Go goroutine migration cannot split MLX state across native threads.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/15845 **Author:** [@dhiltgen](https://github.com/dhiltgen) **Created:** 4/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `mlx-bump-threading` --- ### 📝 Commits (2) - [`2a83966`](https://github.com/ollama/ollama/commit/2a83966b7faec71774b3bc336e48ced4326b436b) Update MLX and MLX-C - [`8166abe`](https://github.com/ollama/ollama/commit/8166abef128a44704450686f65fdb85ec3a36fc7) Run MLX CGO work on a locked OS thread ### 📊 Changes **21 files changed** (+1752 additions, -188 deletions) <details> <summary>View changed files</summary> 📝 `MLX_C_VERSION` (+1 -1) 📝 `MLX_VERSION` (+1 -1) 📝 `x/imagegen/mlx/mlx.c` (+339 -49) 📝 `x/imagegen/mlx/mlx.h` (+146 -30) ➕ `x/internal/mlxthread/thread.go` (+174 -0) ➕ `x/internal/mlxthread/thread_test.go` (+128 -0) 📝 `x/mlxrunner/mlx/array_test.go` (+30 -39) 📝 `x/mlxrunner/mlx/generated.c` (+158 -5) 📝 `x/mlxrunner/mlx/generated.h` (+391 -25) 📝 `x/mlxrunner/mlx/include/mlx/c/compile.h` (+1 -0) 📝 `x/mlxrunner/mlx/include/mlx/c/distributed_group.h` (+23 -9) 📝 `x/mlxrunner/mlx/include/mlx/c/fft.h` (+20 -0) ➕ `x/mlxrunner/mlx/include/mlx/c/graph_utils.h` (+61 -0) 📝 `x/mlxrunner/mlx/include/mlx/c/io.h` (+5 -0) 📝 `x/mlxrunner/mlx/include/mlx/c/io_types.h` (+46 -0) 📝 `x/mlxrunner/mlx/include/mlx/c/mlx.h` (+1 -0) 📝 `x/mlxrunner/mlx/include/mlx/c/ops.h` (+44 -0) 📝 `x/mlxrunner/mlx/stream.go` (+34 -14) ➕ `x/mlxrunner/mlx/thread_test.go` (+97 -0) 📝 `x/mlxrunner/runner.go` (+14 -1) _...and 1 more files_ </details> ### 📄 Description MLX now relies on OS-thread-local execution state for streams, encoders, and caches. Add an mlxthread executor backed by runtime.LockOSThread and route runner initialization, model load, inference, status memory reads, and cleanup through the worker so Go goroutine migration cannot split MLX state across native threads. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-29 16:58:49 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#62022