vllm.v1.kv_offload.tiering.example ¶
ExampleSecondaryTier: A simple in-memory secondary tier for testing.
This implementation provides a minimal secondary tier that stores blocks in memory (using a dictionary) and simulates async transfers with immediate completion. It's useful for testing the TieringOffloadingManager without requiring actual storage or network backends.
ExampleSecondaryTier ¶
Bases: SecondaryTierManager
A simple in-memory secondary tier for testing.
This implementation: - Stores blocks in a dictionary (key -> True) - Simulates async transfers with immediate completion - Uses LRU eviction policy
Source code in vllm/v1/kv_offload/tiering/example/__init__.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
__init__ ¶
__init__(
vllm_config: VllmConfig,
primary_kv_view: memoryview,
max_blocks: int = 1000,
simulate_async: bool = False,
)
Initialize the example secondary tier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vllm_config | VllmConfig | Global vLLM configuration. | required |
primary_kv_view | memoryview | Memoryview of the primary tier's CPU KV cache. | required |
max_blocks | int | Maximum number of blocks this tier can store | 1000 |
simulate_async | bool | If True, jobs complete on next get_finished() call. If False, jobs complete immediately. | False |
Source code in vllm/v1/kv_offload/tiering/example/__init__.py
_complete_store_job ¶
_complete_store_job(job_metadata: _JobMetadata)
Complete a store job by adding blocks to storage.
Source code in vllm/v1/kv_offload/tiering/example/__init__.py
clear ¶
get_finished ¶
Poll for finished async jobs.
Returns:
| Type | Description |
|---|---|
Iterable[JobResult] | Iterable of JobResult objects for all jobs that have |
Iterable[JobResult] | finished since the last call. |
Source code in vllm/v1/kv_offload/tiering/example/__init__.py
lookup ¶
lookup(
key: OffloadKey, req_context: ReqContext
) -> bool | None
Check whether a block exists in this secondary tier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key | OffloadKey | Offload key to look up. | required |
req_context | ReqContext | Per-request context. | required |
Returns:
| Type | Description |
|---|---|
bool | None | True if the block is present, False if not found. |
Source code in vllm/v1/kv_offload/tiering/example/__init__.py
submit_load ¶
submit_load(job_metadata: JobMetadata) -> None
Submit an async job to load blocks from this tier to primary tier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_metadata | JobMetadata | Job metadata including job_id, keys, and spec for writing blocks into the primary tier. | required |
Source code in vllm/v1/kv_offload/tiering/example/__init__.py
submit_store ¶
submit_store(job_metadata: JobMetadata) -> None
Submit an async job to store blocks from primary tier to this tier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_metadata | JobMetadata | Job metadata including job_id, keys, and spec for reading blocks from the primary tier. | required |
Source code in vllm/v1/kv_offload/tiering/example/__init__.py
touch ¶
touch(
keys: Collection[OffloadKey], req_context: ReqContext
)
Mark blocks as recently used (move to end of LRU list).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys | Collection[OffloadKey] | Blocks to mark as recently used. | required |
req_context | ReqContext | Per-request context. | required |
Source code in vllm/v1/kv_offload/tiering/example/__init__.py
_JobMetadata dataclass ¶
Internal metadata for tracking job details.