mlx: avoid pulling MLX models when MLX is missing (#17710)

As we look to bring Linux and Windows MLX support online, instead of blocking
downloads at the registry to avoid users wasting time downloading a model they
can't run, shift the logic to the local side which knows if MLX is present or not.
This commit is contained in:
Daniel Hiltgen
2026-08-12 14:42:17 -07:00
committed by GitHub
parent 2b4a99376c
commit 88313499e0
+7
View File
@@ -31,6 +31,7 @@ import (
"github.com/ollama/ollama/thinking"
"github.com/ollama/ollama/types/model"
"github.com/ollama/ollama/version"
"github.com/ollama/ollama/x/mlxrunner/mlx"
"github.com/ollama/ollama/x/transfer"
)
@@ -1016,6 +1017,12 @@ func PullModel(ctx context.Context, name string, regOpts *registryOptions, fn fu
if err != nil {
return fmt.Errorf("pull model manifest: %s", err)
}
if hasTensorLayers(mf.Layers) {
if err := mlx.CheckInit(); err != nil {
slog.Debug("MLX is unavailable for safetensors model pull", "error", err)
return errors.New("this model requires MLX support, but the MLX runtime is not available")
}
}
var layers []manifest.Layer
layers = append(layers, mf.Layers...)