mirror of
https://github.com/ollama/ollama.git
synced 2026-05-05 23:53:43 -05:00
* Update MLX and MLX-C * Run MLX CGO work on a locked OS thread 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. Also stop caching default MLX streams before the runner owns the thread and add worker/threaded MLX regression tests. * mlx: use common status writer * mlx: bundle missing libjaccl on arm64 Inspired by #15793 * review comments
33 lines
562 B
Go
33 lines
562 B
Go
//go:build darwin || linux
|
|
|
|
package mlxthread
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestDoUsesSameOSThread(t *testing.T) {
|
|
thread, err := Start("test", nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer thread.Stop(context.Background(), nil)
|
|
|
|
var first uint64
|
|
for range 32 {
|
|
if err := thread.Do(context.Background(), func() error {
|
|
id := currentThreadID()
|
|
if first == 0 {
|
|
first = id
|
|
} else if id != first {
|
|
return fmt.Errorf("job ran on OS thread %d, want %d", id, first)
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
}
|