mlx: additional gemma4 cache fixes (#15607)

Harden additional corner cases
This commit is contained in:
Daniel Hiltgen
2026-04-16 13:07:19 -07:00
committed by GitHub
parent b9cb535407
commit 55fa80d07a

View File

@@ -337,9 +337,10 @@ func (c *RotatingKVCache) State() []*mlx.Array {
if c.keys == nil || c.values == nil { if c.keys == nil || c.values == nil {
return nil return nil
} }
liveLen := min(c.offset, c.keys.Dim(2))
return []*mlx.Array{ return []*mlx.Array{
c.keys.Slice(mlx.Slice(), mlx.Slice(), mlx.Slice(0, c.offset), mlx.Slice()), c.keys.Slice(mlx.Slice(), mlx.Slice(), mlx.Slice(0, liveLen), mlx.Slice()),
c.values.Slice(mlx.Slice(), mlx.Slice(), mlx.Slice(0, c.offset), mlx.Slice()), c.values.Slice(mlx.Slice(), mlx.Slice(), mlx.Slice(0, liveLen), mlx.Slice()),
} }
} }