Skip to main content

Python class

NestedIterableDataclass

NestedIterableDataclass

class max.nn.kv_cache.NestedIterableDataclass

source

Bases: Generic[T]

Base class for input symbols for KV cache managers.

The derived class is responsible for defining the input symbols for the specific KV cache manager. For example, here’s a derived class for a text KV cache manager:

@dataclass
class PagedCacheValues(NestedIterableDataclass[TensorType]):
    kv_blocks: TensorType
    cache_lengths: TensorType
    lookup_table: TensorType
    max_lengths: TensorType

flatten()

flatten()

source

Returns all leaf values as a flat list.

Returns:

A list containing every non-None leaf value yielded by iterating this dataclass.

Return type:

list[T]