From 6a0ee480804d09c4d2aabddc71d4901f6e60b36c Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Tue, 15 Sep 2026 17:27:34 -0700 Subject: [PATCH] cmd: launch the MLX runner without the engine dispatcher The runner package used to pick an engine from the first argument of the runner subcommand. Only the MLX engine is left, so the dispatcher has a single arm, its README still describes the removed Go runner's flags and endpoints, and the standalone cmd/runner binary exists only to invoke it. We call mlxrunner.Execute directly from the hidden runner subcommand and drop the --mlx-engine argument from the command line the MLX client spawns. Both sides ship in the same binary, so nothing has to accept both forms. The runner package and cmd/runner are removed. The subcommand's help hook hands the runner a bare --help. cobra calls the hook with no arguments for `ollama help runner`, which used to index past the end of the slice. --- cmd/cmd.go | 6 +++--- cmd/runner/main.go | 15 --------------- runner/README.md | 21 --------------------- runner/runner.go | 21 --------------------- x/mlxrunner/client.go | 4 ++-- 5 files changed, 5 insertions(+), 62 deletions(-) delete mode 100644 cmd/runner/main.go delete mode 100644 runner/README.md delete mode 100644 runner/runner.go diff --git a/cmd/cmd.go b/cmd/cmd.go index b409e1955..bd529fc1d 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -51,13 +51,13 @@ import ( "github.com/ollama/ollama/parser" "github.com/ollama/ollama/progress" "github.com/ollama/ollama/readline" - "github.com/ollama/ollama/runner" "github.com/ollama/ollama/server" "github.com/ollama/ollama/types/model" "github.com/ollama/ollama/types/syncmap" "github.com/ollama/ollama/version" xcreate "github.com/ollama/ollama/x/create" xcreateclient "github.com/ollama/ollama/x/create/client" + "github.com/ollama/ollama/x/mlxrunner" ) func init() { @@ -2557,12 +2557,12 @@ func NewCLI() *cobra.Command { Use: "runner", Hidden: true, RunE: func(cmd *cobra.Command, args []string) error { - return runner.Execute(os.Args[1:]) + return mlxrunner.Execute(os.Args[2:]) }, FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true}, } runnerCmd.SetHelpFunc(func(cmd *cobra.Command, args []string) { - _ = runner.Execute(args[1:]) + _ = mlxrunner.Execute([]string{"--help"}) }) var gpuDiscoverLibDirs []string diff --git a/cmd/runner/main.go b/cmd/runner/main.go deleted file mode 100644 index fbfafc7ff..000000000 --- a/cmd/runner/main.go +++ /dev/null @@ -1,15 +0,0 @@ -package main - -import ( - "fmt" - "os" - - "github.com/ollama/ollama/runner" -) - -func main() { - if err := runner.Execute(os.Args[1:]); err != nil { - fmt.Fprintf(os.Stderr, "error: %s\n", err) - os.Exit(1) - } -} diff --git a/runner/README.md b/runner/README.md deleted file mode 100644 index 3ef37296f..000000000 --- a/runner/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# `runner` - -> Note: this is a work in progress - -A minimal runner for loading a model and running inference via a http web server. - -```shell -./runner -model -``` - -### Completion - -```shell -curl -X POST -H "Content-Type: application/json" -d '{"prompt": "hi"}' http://localhost:8080/completion -``` - -### Embeddings - -```shell -curl -X POST -H "Content-Type: application/json" -d '{"prompt": "turn me into an embedding"}' http://localhost:8080/embedding -``` diff --git a/runner/runner.go b/runner/runner.go deleted file mode 100644 index fec9e1633..000000000 --- a/runner/runner.go +++ /dev/null @@ -1,21 +0,0 @@ -package runner - -import ( - "fmt" - - "github.com/ollama/ollama/x/mlxrunner" -) - -func Execute(args []string) error { - if args[0] == "runner" { - args = args[1:] - } - - if len(args) > 0 { - switch args[0] { - case "--mlx-engine": - return mlxrunner.Execute(args[1:]) - } - } - return fmt.Errorf("unknown runner engine, expected --mlx-engine") -} diff --git a/x/mlxrunner/client.go b/x/mlxrunner/client.go index 4a6292ac1..081c2708b 100644 --- a/x/mlxrunner/client.go +++ b/x/mlxrunner/client.go @@ -340,8 +340,8 @@ func (c *Client) Load(ctx context.Context, systemInfo ml.SystemInfo, gpus []ml.D exe = eval } - // Spawn subprocess: ollama runner --mlx-engine --model --port - cmd := exec.Command(exe, "runner", "--mlx-engine", "--model", c.modelName, "--port", strconv.Itoa(port)) + // Spawn subprocess: ollama runner --model --port + cmd := exec.Command(exe, "runner", "--model", c.modelName, "--port", strconv.Itoa(port)) cmd.Env = os.Environ() // Set library path environment variable for MLX libraries