---
title: "KVLayerSpec"
sidebar_label: "KVLayerSpec"
description: "The clika_runtime.nn KVLayerSpec class."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

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`

```python
ConvStateOne short-conv rolling window: dim channels by width taps.
```

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

## `Kind`

```python
Kind(value, names=None, *, module=None, qualname=None, type=None, start=1)
```

WHAT a cache layer holds: token-indexed attention keys and values (AttentionKV, CrossAttentionKV) or a per-slot state slab (ConvState, RecurrentState, HybridState).

## `Layout`

```python
Layout(value, names=None, *, module=None, qualname=None, type=None, start=1)
```

HOW a token-indexed row is laid out (Auto follows the cache's mode); ignored by the state kinds, whose slabs are slot-resident either way.

## `RecurrentState`

```python
RecurrentStateThe recurrent slab geometry, per slot `[heads, k_dim, v_dim]`.
```

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

## `__init__`

```python
__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.
