|
| 1 | +# Configuration Documentation |
| 2 | + |
| 3 | +This document describes all configuration options available in the llm-d KV Cache Manager. |
| 4 | +All configurations are JSON-serializable and can be provided via configuration files or environment variables. |
| 5 | + |
| 6 | +## Main Configuration |
| 7 | + |
| 8 | +This package consists of two components: |
| 9 | +1. **KV Cache Indexer**: Manages the KV cache index, allowing efficient retrieval of cached blocks. |
| 10 | +2. **KV Event Processing**: Handles events from vLLM to update the cache index. |
| 11 | + |
| 12 | +The two components are configured separately, but share the index backend for storing KV block localities. |
| 13 | +The latter is configured via the `kvBlockIndexConfig` field in the KV Cache Indexer configuration. |
| 14 | + |
| 15 | +### Indexer Configuration (`Config`) |
| 16 | + |
| 17 | +The main configuration structure for the KV Cache Indexer module. |
| 18 | + |
| 19 | +```json |
| 20 | +{ |
| 21 | + "prefixStoreConfig": { ... }, |
| 22 | + "tokenProcessorConfig": { ... }, |
| 23 | + "kvBlockIndexConfig": { ... }, |
| 24 | + "tokenizersPoolConfig": { ... } |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +| Field | Type | Description | Default | |
| 29 | +|-------|------|-------------|---------| |
| 30 | +| `prefixStoreConfig` | [LRUStoreConfig](#lru-store-configuration-lrustoreconfig) | Configuration for the prefix store | See defaults | |
| 31 | +| `tokenProcessorConfig` | [TokenProcessorConfig](#token-processor-configuration-tokenprocessorconfig) | Configuration for token processing | See defaults | |
| 32 | +| `kvBlockIndexConfig` | [IndexConfig](#index-configuration-indexconfig) | Configuration for KV block indexing | See defaults | |
| 33 | +| `tokenizersPoolConfig` | [Config](#tokenization-pool-configuration-config) | Configuration for tokenization pool | See defaults | |
| 34 | + |
| 35 | + |
| 36 | +## Complete Example Configuration |
| 37 | + |
| 38 | +Here's a complete configuration example with all options: |
| 39 | + |
| 40 | +```json |
| 41 | +{ |
| 42 | + "prefixStoreConfig": { |
| 43 | + "cacheSize": 500000, |
| 44 | + "blockSize": 256 |
| 45 | + }, |
| 46 | + "tokenProcessorConfig": { |
| 47 | + "blockSize": 16, |
| 48 | + "hashSeed": "12345" |
| 49 | + }, |
| 50 | + "kvBlockIndexConfig": { |
| 51 | + "inMemoryConfig": { |
| 52 | + "size": 100000000, |
| 53 | + "podCacheSize": 10 |
| 54 | + }, |
| 55 | + "enableMetrics": true |
| 56 | + }, |
| 57 | + "tokenizersPoolConfig": { |
| 58 | + "workersCount": 8, |
| 59 | + "huggingFaceToken": "your_hf_token_here", |
| 60 | + "tokenizersCacheDir": "/tmp/tokenizers" |
| 61 | + } |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +## KV-Block Index Configuration |
| 66 | + |
| 67 | +### Index Configuration (`IndexConfig`) |
| 68 | + |
| 69 | +Configures the KV-block index backend. Multiple backends can be configured, but only the first available one will be used. |
| 70 | + |
| 71 | +```json |
| 72 | +{ |
| 73 | + "inMemoryConfig": { ... }, |
| 74 | + "redisConfig": { ... }, |
| 75 | + "enableMetrics": false |
| 76 | +} |
| 77 | +``` |
| 78 | + |
| 79 | +| Field | Type | Description | Default | |
| 80 | +|-------|-------------------------------------------------------|-------------|---------| |
| 81 | +| `inMemoryConfig` | [InMemoryIndexConfig](#in-memory-index-configuration) | In-memory index configuration | See defaults | |
| 82 | +| `redisConfig` | [RedisIndexConfig](#redis-index-configuration) | Redis index configuration | `null` | |
| 83 | +| `enableMetrics` | `boolean` | Enable admissions/evictions/hits/misses recording | `false` | |
| 84 | + |
| 85 | +### In-Memory Index Configuration (`InMemoryIndexConfig`) |
| 86 | + |
| 87 | +Configures the in-memory KV block index implementation. |
| 88 | + |
| 89 | +```json |
| 90 | +{ |
| 91 | + "size": 100000000, |
| 92 | + "podCacheSize": 10 |
| 93 | +} |
| 94 | +``` |
| 95 | + |
| 96 | +| Field | Type | Description | Default | |
| 97 | +|-------|------|-------------|---------| |
| 98 | +| `size` | `integer` | Maximum number of keys that can be stored | `100000000` | |
| 99 | +| `podCacheSize` | `integer` | Maximum number of pod entries per key | `10` | |
| 100 | + |
| 101 | +### Redis Index Configuration (`RedisIndexConfig`) |
| 102 | + |
| 103 | +Configures the Redis-backed KV block index implementation. |
| 104 | + |
| 105 | +```json |
| 106 | +{ |
| 107 | + "address": "redis://127.0.0.1:6379" |
| 108 | +} |
| 109 | +``` |
| 110 | + |
| 111 | +| Field | Type | Description | Default | |
| 112 | +|-------|------|-------------|---------| |
| 113 | +| `address` | `string` | Redis server address (can include auth: `redis://user:pass@host:port/db`) | `"redis://127.0.0.1:6379"` | |
| 114 | + |
| 115 | +## Token Processing Configuration |
| 116 | + |
| 117 | +### Token Processor Configuration (`TokenProcessorConfig`) |
| 118 | + |
| 119 | +Configures how tokens are converted to KV block keys. |
| 120 | + |
| 121 | +```json |
| 122 | +{ |
| 123 | + "blockSize": 16, |
| 124 | + "hashSeed": "" |
| 125 | +} |
| 126 | +``` |
| 127 | + |
| 128 | +| Field | Type | Description | Default | |
| 129 | +|-------|------|-------------|---------| |
| 130 | +| `blockSize` | `integer` | Number of tokens per block | `16` | |
| 131 | +| `hashSeed` | `string` | Seed for hash generation (should align with vLLM's PYTHONHASHSEED) | `""` | |
| 132 | + |
| 133 | +## Prefix Store Configuration |
| 134 | + |
| 135 | +### LRU Store Configuration (`LRUStoreConfig`) |
| 136 | + |
| 137 | +Configures the LRU-based prefix token store. |
| 138 | + |
| 139 | +```json |
| 140 | +{ |
| 141 | + "cacheSize": 500000, |
| 142 | + "blockSize": 256 |
| 143 | +} |
| 144 | +``` |
| 145 | + |
| 146 | +| Field | Type | Description | Default | |
| 147 | +|-------|------|-------------|---------| |
| 148 | +| `cacheSize` | `integer` | Maximum number of blocks the LRU cache can store | `500000` | |
| 149 | +| `blockSize` | `integer` | Number of tokens per block in the prefix cache | `256` | |
| 150 | + |
| 151 | +## Tokenization Configuration |
| 152 | + |
| 153 | +### Tokenization Pool Configuration (`Config`) |
| 154 | + |
| 155 | +Configures the tokenization worker pool. |
| 156 | + |
| 157 | +```json |
| 158 | +{ |
| 159 | + "workersCount": 5, |
| 160 | + "huggingFaceToken": "", |
| 161 | + "tokenizersCacheDir": "" |
| 162 | +} |
| 163 | +``` |
| 164 | + |
| 165 | +| Field | Type | Description | Default | |
| 166 | +|-------|------|-------------|--------| |
| 167 | +| `workersCount` | `integer` | Number of tokenization workers | `5` | |
| 168 | +| `huggingFaceToken` | `string` | HuggingFace authentication token | `""` | |
| 169 | +| `tokenizersCacheDir` | `string` | Directory for caching tokenizers | `""` | |
| 170 | + |
| 171 | +### HuggingFace Tokenizer Configuration (`HFTokenizerConfig`) |
| 172 | + |
| 173 | +Configures the HuggingFace tokenizer backend. |
| 174 | + |
| 175 | +```json |
| 176 | +{ |
| 177 | + "huggingFaceToken": "", |
| 178 | + "tokenizersCacheDir": "" |
| 179 | +} |
| 180 | +``` |
| 181 | + |
| 182 | +| Field | Type | Description | Default | |
| 183 | +|-------|------|-------------|---------| |
| 184 | +| `huggingFaceToken` | `string` | HuggingFace API token for accessing models | `""` | |
| 185 | +| `tokenizersCacheDir` | `string` | Local directory for caching downloaded tokenizers | `"./bin"` | |
| 186 | + |
| 187 | +## KV-Event Processing Configuration |
| 188 | + |
| 189 | +### KV-Event Pool Configuration (`Config`) |
| 190 | + |
| 191 | +Configures the ZMQ event processing pool for handling KV cache events. |
| 192 | + |
| 193 | +```json |
| 194 | +{ |
| 195 | + "zmqEndpoint": "tcp://*:5557", |
| 196 | + "topicFilter": "kv@", |
| 197 | + "concurrency": 4 |
| 198 | +} |
| 199 | +``` |
| 200 | + |
| 201 | +## Event Processing Configuration Example |
| 202 | + |
| 203 | +For the ZMQ event processing pool: |
| 204 | + |
| 205 | +```json |
| 206 | +{ |
| 207 | + "zmqEndpoint": "tcp://indexer:5557", |
| 208 | + "topicFilter": "kv@", |
| 209 | + "concurrency": 8 |
| 210 | +} |
| 211 | +``` |
| 212 | + |
| 213 | +| Field | Type | Description | Default | |
| 214 | +|-------|------|-------------|---------| |
| 215 | +| `zmqEndpoint` | `string` | ZMQ address to connect to | `"tcp://*:5557"` | |
| 216 | +| `topicFilter` | `string` | ZMQ subscription filter | `"kv@"` | |
| 217 | +| `concurrency` | `integer` | Number of parallel workers | `4` | |
| 218 | + |
| 219 | +--- |
| 220 | +## Notes |
| 221 | + |
| 222 | +1. **Hash Seed Alignment**: The `hash_seed` in `TokenProcessorConfig` should be aligned with vLLM's `PYTHONHASHSEED` environment variable to ensure consistent hashing across the system. |
| 223 | + |
| 224 | +2. **Memory Considerations**: The `size` parameter in `InMemoryIndexConfig` directly affects memory usage. Each key-value pair consumes memory proportional to the number of associated pods. |
| 225 | + |
| 226 | +3. **Performance Tuning**: |
| 227 | + - Increase `workers_count` in tokenization config for higher tokenization throughput |
| 228 | + - Adjust `concurrency` in event processing for better event handling performance |
| 229 | + - Tune cache sizes based on available memory and expected workload |
| 230 | + |
| 231 | +4. **Cache Directories**: Ensure the `tokenizers_cache_dir` has sufficient disk space and appropriate permissions for the application to read/write tokenizer files. |
| 232 | + |
| 233 | +5. **Redis Configuration**: When using Redis backend, ensure Redis server is accessible and has sufficient memory. The `address` field supports full Redis URLs including authentication: `redis://user:pass@host:port/db`. |
0 commit comments