Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
bug: fix loading non-mlx models when ollama is built with mlx support (#14211)
Patrick Devine4a3741129d67
diff --git a/x/mlxrunner/mlx/dynamic.go b/x/mlxrunner/mlx/dynamic.goindex eb6427fb5..0c2306e46 100644--- a/x/mlxrunner/mlx/dynamic.go+++ b/x/mlxrunner/mlx/dynamic.go@@ -8,6 +8,7 @@ package mlximport "C"import (+ "fmt""io/fs""log/slog""os"@@ -16,6 +17,13 @@ import ("unsafe")+var initError error++// CheckInit returns any error that occurred during MLX dynamic library initialization.+func CheckInit() error {+ return initError+}+func init() {switch runtime.GOOS {case "darwin":@@ -34,7 +42,9 @@ func init() {for _, path := range filepath.SplitList(paths) {matches, err := fs.Glob(os.DirFS(path), "libmlxc.*")if err != nil {- panic(err)+ initError = fmt.Errorf("failed to glob for MLX libraries in %s: %w", path, err)+ slog.Warn("MLX dynamic library not available", "error", initError)+ return}for _, match := range matches {@@ -61,5 +71,6 @@ func init() {}}- panic("Failed to load any MLX dynamic library")+ initError = fmt.Errorf("failed to load any MLX dynamic library from OLLAMA_LIBRARY_PATH=%s", paths)+ slog.Warn("MLX dynamic library not available", "error", initError)}diff --git a/x/mlxrunner/server.go b/x/mlxrunner/server.goindex d8460b8d7..ef1e0dd1c 100644--- a/x/mlxrunner/server.go+++ b/x/mlxrunner/server.go@@ -7,6 +7,7 @@ import ("cmp""encoding/json""flag"+ "fmt""io""log/slog""net/http"@@ -16,12 +17,17 @@ import ("github.com/ollama/ollama/envconfig""github.com/ollama/ollama/logutil"+ "github.com/ollama/ollama/x/mlxrunner/mlx""github.com/ollama/ollama/x/mlxrunner/sample")func Execute(args []string) error {slog.SetDefault(logutil.NewLogger(os.Stderr, envconfig.LogLevel()))+ if err := mlx.CheckInit(); err != nil {+ return fmt.Errorf("MLX not available: %w", err)+ }+var (modelName stringport int