Skip to main content

KVLayerSpec

One decoder layer's storage row: Kind says WHAT it stores, Layout says HOW a token-indexed row is laid out.

conv_states (property)

(self) -> list[clika_runtime._core.nn.KVLayerSpec.ConvState]

head_dim (property)

(self) -> int

k_scale (property)

(self) -> float | None

kind (property)

(self) -> clika_runtime._core.nn.KVLayerSpec.Kind

kv_heads (property)

(self) -> int

layout (property)

(self) -> clika_runtime._core.nn.KVLayerSpec.Layout

preallocate (property)

(self) -> bool

recurrent_state (property)

(self) -> clika_runtime._core.nn.KVLayerSpec.RecurrentState | None

v_head_dim (property)

(self) -> int

v_scale (property)

(self) -> float | None

window (property)

(self) -> int

ConvState

ConvState(*args, **kwargs)

One short-conv rolling window: dim channels by width taps.

Kind

Kind(*values)

Create a collection of name/value pairs.

Example enumeration:

class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3

Access them by:

  • attribute access:

    Color.RED <Color.RED: 1>

  • value lookup:

    Color(1) <Color.RED: 1>

  • name lookup:

    Color['RED'] <Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

len(Color) 3

list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.

Layout

Layout(*values)

Create a collection of name/value pairs.

Example enumeration:

class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3

Access them by:

  • attribute access:

    Color.RED <Color.RED: 1>

  • value lookup:

    Color(1) <Color.RED: 1>

  • name lookup:

    Color['RED'] <Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

len(Color) 3

list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.

RecurrentState

RecurrentState(*args, **kwargs)

The recurrent slab geometry, per slot [heads, k_dim, v_dim].

__init__

__init____init__(self, *, kind: clika_runtime._core.nn.KVLayerSpec.Kind = Kind.AttentionKV, layout: clika_runtime._core.nn.KVLayerSpec.Layout = Layout.Auto, kv_heads: int = 0, head_dim: int = 0, v_head_dim: int = 0, window: int = 0, preallocate: bool = False, k_scale: float | None = None, v_scale: float | None = None, conv_states: collections.abc.Sequence[clika_runtime._core.nn.KVLayerSpec.ConvState] = [], recurrent_state: clika_runtime._core.nn.KVLayerSpec.RecurrentState | None = None) -> None

init(self, *, kind: clika_runtime._core.nn.KVLayerSpec.Kind = Kind.AttentionKV, layout: clika_runtime._core.nn.KVLayerSpec.Layout = Layout.Auto, kv_heads: int = 0, head_dim: int = 0, v_head_dim: int = 0, window: int = 0, preallocate: bool = False, k_scale: float | None = None, v_scale: float | None = None, conv_states: collections.abc.Sequence[clika_runtime._core.nn.KVLayerSpec.ConvState] = [], recurrent_state: clika_runtime._core.nn.KVLayerSpec.RecurrentState | None = None) -> None

Zero geometry fields inherit the cache config's defaults; window > 0 makes a sliding row; the state fields serve the state kinds.