- Replace CacheView/ContiguousCache/PageCache with SGLang-inspired design: KVStorage (flat token-level NHD buffers [n_layers, size, H, D]), ReqToTokenPool (index table [req_idx, pos] -> token_slot), Allocator + PrefixCache (slot allocation with LRU and prefix sharing) - Add KVCache as pure dataclass passed to model: k_buffer, v_buffer, req_to_token, req_pool_indices, seq_lens, out_cache_loc - PagePool orchestrates all three layers, supports contiguous mode (pre-allocated per-request blocks, default) and paged mode (page_size=1 or >1 with dynamic allocation and prefix caching) - Attention layers now do raw buffer indexing instead of opaque write/gather method calls on CacheView objects - Update executor.bind_tasks signature: seq_lens list + start_pos - Rename paged_cache -> kv_cache throughout model/ and inference/
31 lines
652 B
Python
31 lines
652 B
Python
"""Inference core: cache, executor, scheduler, task management."""
|
|
|
|
from astrai.inference.core.cache import (
|
|
Allocator,
|
|
KVCache,
|
|
KVStorage,
|
|
PagePool,
|
|
PrefixCache,
|
|
ReqToTokenPool,
|
|
page_hash,
|
|
)
|
|
from astrai.inference.core.executor import Executor
|
|
from astrai.inference.core.scheduler import InferenceScheduler
|
|
from astrai.inference.core.task import STOP, Task, TaskManager, TaskStatus
|
|
|
|
__all__ = [
|
|
"Allocator",
|
|
"KVCache",
|
|
"KVStorage",
|
|
"PagePool",
|
|
"PrefixCache",
|
|
"ReqToTokenPool",
|
|
"page_hash",
|
|
"Executor",
|
|
"InferenceScheduler",
|
|
"STOP",
|
|
"Task",
|
|
"TaskManager",
|
|
"TaskStatus",
|
|
]
|