From 8daf47fb3afec28de3e447d974c2bf911bcafc20 Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Mon, 23 Feb 2026 13:28:01 -0800 Subject: [PATCH] mlxrunner: Fix duplicate log prefixes and reduce log noise Pass subprocess stdout/stderr through to the parent's stderr directly instead of re-wrapping each line with slog. The subprocess already writes structured slog output, so the re-wrapping produced nested timestamps, levels, and message fields that were hard to read. Also downgrade verbose KV cache debug logs to trace level. --- x/mlxrunner/cache/cache.go | 7 +++---- x/mlxrunner/client.go | 7 ++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/x/mlxrunner/cache/cache.go b/x/mlxrunner/cache/cache.go index 274bdffe1..3c1ff6011 100644 --- a/x/mlxrunner/cache/cache.go +++ b/x/mlxrunner/cache/cache.go @@ -3,8 +3,7 @@ package cache import ( - "log/slog" - + "github.com/ollama/ollama/logutil" "github.com/ollama/ollama/x/mlxrunner/mlx" ) @@ -113,7 +112,7 @@ func (c *RotatingKVCache) Update(keys, values *mlx.Array) (*mlx.Array, *mlx.Arra } func (c *RotatingKVCache) concat(keys, values *mlx.Array) (newK *mlx.Array, newV *mlx.Array) { - slog.Debug("(*RotatingKVCache).concat", "keys_dim", keys.Dims(), "values_dim", values.Dims(), "offset", c.offset, "idx", c.idx, "max_size", c.maxSize) + logutil.Trace("(*RotatingKVCache).concat", "keys_dim", keys.Dims(), "values_dim", values.Dims(), "offset", c.offset, "idx", c.idx, "max_size", c.maxSize) if c.keys == nil { c.keys, c.values = keys.Clone(), values.Clone() mlx.Pin(c.keys, c.values) @@ -140,7 +139,7 @@ func (c *RotatingKVCache) concat(keys, values *mlx.Array) (newK *mlx.Array, newV } func (c *RotatingKVCache) update(keys, values *mlx.Array) (*mlx.Array, *mlx.Array) { - slog.Debug("(*RotatingKVCache).update", "keys_dim", keys.Dims(), "values_dim", values.Dims(), "offset", c.offset, "idx", c.idx, "max_size", c.maxSize) + logutil.Trace("(*RotatingKVCache).update", "keys_dim", keys.Dims(), "values_dim", values.Dims(), "offset", c.offset, "idx", c.idx, "max_size", c.maxSize) B, H, L, Dk, Dv := keys.Dim(0), keys.Dim(1), keys.Dim(2), keys.Dim(3), values.Dim(3) prev := c.offset diff --git a/x/mlxrunner/client.go b/x/mlxrunner/client.go index 19e987736..2152c382f 100644 --- a/x/mlxrunner/client.go +++ b/x/mlxrunner/client.go @@ -119,16 +119,13 @@ func NewClient(modelName string) (*Client, error) { stdout, _ := cmd.StdoutPipe() stderr, _ := cmd.StderrPipe() go func() { - scanner := bufio.NewScanner(stdout) - for scanner.Scan() { - slog.Info("mlx-runner", "msg", scanner.Text()) - } + io.Copy(os.Stderr, stdout) //nolint:errcheck }() go func() { scanner := bufio.NewScanner(stderr) for scanner.Scan() { line := scanner.Text() - slog.Warn("mlx-runner", "msg", line) + fmt.Fprintln(os.Stderr, line) c.lastErrLock.Lock() c.lastErr = line c.lastErrLock.Unlock()