cache

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Update(keys, values *mlx.Array) (newKeys, newValues *mlx.Array)
	// State returns the cache-owned state roots that should be kept/evaluated.
	State() (keys, values *mlx.Array)
	CanTrim() bool
	Trim(int) int
	Clone() Cache
	Free()
	Offset() int
	Len() int
}

type KVCache

type KVCache struct {
	// contains filtered or unexported fields
}

func NewKVCache

func NewKVCache() *KVCache

func (*KVCache) CanTrim

func (c *KVCache) CanTrim() bool

func (*KVCache) Clone

func (c *KVCache) Clone() Cache

func (*KVCache) Free

func (c *KVCache) Free()

func (*KVCache) Len

func (c *KVCache) Len() int

func (*KVCache) Offset

func (c *KVCache) Offset() int

func (*KVCache) State

func (c *KVCache) State() (*mlx.Array, *mlx.Array)

func (*KVCache) Trim

func (c *KVCache) Trim(n int) int

func (*KVCache) Update

func (c *KVCache) Update(keys, values *mlx.Array) (*mlx.Array, *mlx.Array)

type RecurrentCache

type RecurrentCache struct {
	// contains filtered or unexported fields
}

RecurrentCache stores state for linear-recurrent layers.

Conv state shape: [B, convTail, convDim] Delta state shape: [B, numVHeads, headVDim, headKDim]

func NewRecurrentCache

func NewRecurrentCache(convTail, convDim, numVHeads, headVDim, headKDim int32) *RecurrentCache

func (*RecurrentCache) Advance

func (c *RecurrentCache) Advance(n int)

func (*RecurrentCache) CanTrim

func (c *RecurrentCache) CanTrim() bool

func (*RecurrentCache) Clone

func (c *RecurrentCache) Clone() Cache

func (*RecurrentCache) ConvState

func (c *RecurrentCache) ConvState(batch int, dtype mlx.DType) *mlx.Array

func (*RecurrentCache) DeltaState

func (c *RecurrentCache) DeltaState(batch int, dtype mlx.DType) *mlx.Array

func (*RecurrentCache) Free

func (c *RecurrentCache) Free()

func (*RecurrentCache) Len

func (c *RecurrentCache) Len() int

func (*RecurrentCache) Offset

func (c *RecurrentCache) Offset() int

func (*RecurrentCache) SetConvState

func (c *RecurrentCache) SetConvState(v *mlx.Array)

func (*RecurrentCache) SetDeltaState

func (c *RecurrentCache) SetDeltaState(v *mlx.Array)

func (*RecurrentCache) State

func (c *RecurrentCache) State() (*mlx.Array, *mlx.Array)

func (*RecurrentCache) Trim

func (c *RecurrentCache) Trim(n int) int

func (*RecurrentCache) Update

func (c *RecurrentCache) Update(keys, values *mlx.Array) (*mlx.Array, *mlx.Array)

type RotatingKVCache

type RotatingKVCache struct {
	*KVCache
	// contains filtered or unexported fields
}

RotatingKVCache implements sliding window attention with bounded memory

func NewRotatingKVCache

func NewRotatingKVCache(maxSize int) *RotatingKVCache

func (*RotatingKVCache) CanTrim

func (c *RotatingKVCache) CanTrim() bool

func (*RotatingKVCache) Clone

func (c *RotatingKVCache) Clone() Cache

func (*RotatingKVCache) Len

func (c *RotatingKVCache) Len() int

func (*RotatingKVCache) State

func (c *RotatingKVCache) State() (*mlx.Array, *mlx.Array)

func (*RotatingKVCache) Trim

func (c *RotatingKVCache) Trim(n int) int

func (*RotatingKVCache) Update

func (c *RotatingKVCache) Update(keys, values *mlx.Array) (*mlx.Array, *mlx.Array)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL