Documentation
¶
Index ¶
- Constants
- type AllBlocksCleared
- type BlockRemoved
- type BlockStored
- type ContextData
- type EngineHashMapping
- type ModelContext
- type PodInfo
- type PrefixStore
- type SyncPrefixHashTable
- func (s *SyncPrefixHashTable) AddPrefix(modelName string, loraID int64, podName string, prefixHashes []uint64) error
- func (s *SyncPrefixHashTable) AddPrefixWithMedium(modelName string, loraID int64, podName, medium string, prefixHashes []uint64) error
- func (s *SyncPrefixHashTable) Close()
- func (s *SyncPrefixHashTable) GetPrefixHashes(tokens []byte) []uint64
- func (s *SyncPrefixHashTable) MatchPrefix(modelName string, loraID int64, tokens []byte, readyPods map[string]struct{}) (map[string]int, []uint64)
- func (s *SyncPrefixHashTable) ProcessAllBlocksCleared(event AllBlocksCleared) error
- func (s *SyncPrefixHashTable) ProcessBlockRemoved(event BlockRemoved) error
- func (s *SyncPrefixHashTable) ProcessBlockStored(event BlockStored) error
- func (s *SyncPrefixHashTable) RemovePrefix(modelName string, loraID int64, podName string) error
Constants ¶
const ( MediumGPU = "GPU" MediumCPU = "CPU" MediumStorage = "STORAGE" )
Storage tier constants mirroring vLLM's kv_events.py (MEDIUM_GPU/CPU/STORAGE). A prefix held only on a slower tier is a weaker routing signal than one on GPU, so match scores are weighted by tier (see mediumWeight).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllBlocksCleared ¶
type AllBlocksCleared struct {
}
AllBlocksCleared represents an event when all blocks are cleared This is currently not implemented as per requirements
type BlockRemoved ¶
type BlockRemoved struct {
// BlockHashes contains the engine block hashes that were removed
BlockHashes []int64
// Context information
ModelName string
LoraID int64 // -1 for no adapter
// Medium is the storage tier the blocks were removed from
// ("GPU"/"CPU"/"STORAGE"). Copies on other tiers stay indexed.
Medium string
// GroupIdx is the KV-cache group for hybrid-attention models (-1 when
// unspecified). Other groups holding the blocks stay indexed.
GroupIdx int64
// Source pod that removed these blocks (optional)
SourcePod string
}
BlockRemoved represents an event when blocks are removed
type BlockStored ¶
type BlockStored struct {
// BlockHashes contains the engine block hashes that were stored
BlockHashes []int64
// ParentBlockHash is the optional parent block hash
// nil means this is the first block in the sequence
ParentBlockHash *int64
// Tokens contains the token data for each block
// The length should match BlockHashes
Tokens [][]byte
// Context information
ModelName string
LoraID int64 // -1 for no adapter
// Medium is the storage tier the blocks live on: "GPU"/"CPU"/"STORAGE".
// Empty when the connected vLLM does not emit it. Used to score pods with
// non-GPU prefixes lower during routing (see issue #2285).
Medium string
// LoraName is the canonical adapter id ("" = base model). Reserved for
// per-adapter index isolation; not yet consumed by the index key.
LoraName string
// GroupIdx is the KV-cache group for hybrid-attention models (-1 when
// unspecified). The index tracks each group separately.
GroupIdx int64
// Source pod that stored these blocks
SourcePod string
}
BlockStored represents an event when blocks are stored
type ContextData ¶
type ContextData struct {
// contains filtered or unexported fields
}
ContextData holds all data for a specific context with separate locks
type EngineHashMapping ¶
type EngineHashMapping struct {
// contains filtered or unexported fields
}
EngineHashMapping maintains unidirectional mapping
type ModelContext ¶
ModelContext represents the first-level hash key
type PodInfo ¶
type PodInfo struct {
LastAccessTime atomic.Int64 // Unix timestamp (lock-free update)
SourcePod string
// contains filtered or unexported fields
}
PodInfo stores pod access information
type PrefixStore ¶
type PrefixStore struct {
// contains filtered or unexported fields
}
PrefixStore manages prefix hashes for a specific (model, lora_id) context
type SyncPrefixHashTable ¶
type SyncPrefixHashTable struct {
// contains filtered or unexported fields
}
SyncPrefixHashTable is the main structure
func GetSharedSyncPrefixHashTable ¶ added in v0.7.0
func GetSharedSyncPrefixHashTable() *SyncPrefixHashTable
GetSharedSyncPrefixHashTable returns the shared singleton instance of SyncPrefixHashTable. This ensures that all components (Store, kvSyncRouter, etc.) use the same indexer instance. This follows the same pattern as GetSharedPrefixHashTable for consistency.
func NewSyncPrefixHashTable ¶
func NewSyncPrefixHashTable() *SyncPrefixHashTable
NewSyncPrefixHashTable creates a new sync prefix hash table
func (*SyncPrefixHashTable) AddPrefix ¶
func (s *SyncPrefixHashTable) AddPrefix(modelName string, loraID int64, podName string, prefixHashes []uint64) error
AddPrefix adds prefix hashes for a specific model/lora context and pod. The medium is unknown here (callers without tier information), so entries are stored as unspecified, which scores as a full-strength GPU hit for backward compatibility.
func (*SyncPrefixHashTable) AddPrefixWithMedium ¶ added in v0.8.0
func (s *SyncPrefixHashTable) AddPrefixWithMedium(modelName string, loraID int64, podName, medium string, prefixHashes []uint64) error
AddPrefixWithMedium is AddPrefix with the storage tier the pod holds the prefixes on. The tier is added to the ones recorded per (prefix, pod) so MatchPrefix can score non-GPU prefixes lower.
func (*SyncPrefixHashTable) Close ¶
func (s *SyncPrefixHashTable) Close()
Close stops the eviction worker and cleans up resources
func (*SyncPrefixHashTable) GetPrefixHashes ¶
func (s *SyncPrefixHashTable) GetPrefixHashes(tokens []byte) []uint64
GetPrefixHashes computes prefix hashes for given tokens
func (*SyncPrefixHashTable) MatchPrefix ¶
func (s *SyncPrefixHashTable) MatchPrefix(modelName string, loraID int64, tokens []byte, readyPods map[string]struct{}) (map[string]int, []uint64)
MatchPrefix matches the input token prefix if already cached returns map[podname]%prefixmatch along with all prefix hashes
func (*SyncPrefixHashTable) ProcessAllBlocksCleared ¶
func (s *SyncPrefixHashTable) ProcessAllBlocksCleared(event AllBlocksCleared) error
ProcessAllBlocksCleared handles AllBlocksCleared events (placeholder implementation)
func (*SyncPrefixHashTable) ProcessBlockRemoved ¶
func (s *SyncPrefixHashTable) ProcessBlockRemoved(event BlockRemoved) error
ProcessBlockRemoved handles BlockRemoved events
func (*SyncPrefixHashTable) ProcessBlockStored ¶
func (s *SyncPrefixHashTable) ProcessBlockStored(event BlockStored) error
ProcessBlockStored handles BlockStored events
func (*SyncPrefixHashTable) RemovePrefix ¶
func (s *SyncPrefixHashTable) RemovePrefix(modelName string, loraID int64, podName string) error
RemovePrefix removes a specific pod from all prefix entries