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.
This commit is contained in:
Jesse Gross 2026-09-15 17:27:34 -07:00
parent a43fad18b0
commit 6a0ee48080
5 changed files with 5 additions and 62 deletions

View file

@ -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

View file

@ -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)
}
}

View file

@ -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 <model binary>
```
### 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
```

View file

@ -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")
}

View file

@ -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 <name> --port <port>
cmd := exec.Command(exe, "runner", "--mlx-engine", "--model", c.modelName, "--port", strconv.Itoa(port))
// Spawn subprocess: ollama runner --model <name> --port <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