Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

mlxrunner: use MaxAxis in the min-P sampler

Jesse Grossca01373b28e0
diff --git a/x/mlxrunner/mlx/ops.go b/x/mlxrunner/mlx/ops.go
index 209670d89..8bc0e47f9 100644
--- a/x/mlxrunner/mlx/ops.go
+++ b/x/mlxrunner/mlx/ops.go
@@ -139,6 +139,12 @@ func (t *Array) Less(other *Array) *Array {
return out
}
+func (t *Array) MaxAxis(axis int, keepDims bool) *Array {
+ out := New("MAX_AXIS")
+ C.mlx_max_axis(&out.ctx, t.ctx, C.int(axis), C.bool(keepDims), DefaultStream().ctx)
+ return out
+}
+
func (t *Array) Matmul(other *Array) *Array {
out := New("MATMUL")
C.mlx_matmul(&out.ctx, t.ctx, other.ctx, DefaultStream().ctx)
diff --git a/x/mlxrunner/sample/sample.go b/x/mlxrunner/sample/sample.go
index 1bf5b82c7..4139d0b6b 100644
--- a/x/mlxrunner/sample/sample.go
+++ b/x/mlxrunner/sample/sample.go
@@ -198,7 +198,7 @@ func minP(s *Sampler, scores *mlx.Array) *mlx.Array {
return scores
}
- maxScore := scores.TakeAlongAxis(scores.Argmax(-1, true), -1)
+ maxScore := scores.MaxAxis(-1, true)
threshold := mlx.AddScalar(maxScore, float32(math.Log(float64(s.MinP))))
return mlx.Where(