vllm.model_executor.models.extract_hidden_states ¶
Hidden States Extractor Model.
This model extracts and caches hidden states from the target model without performing actual token generation. It's used with the extract_hidden_states speculative decoding method.
CacheOnlyAttentionBackend ¶
Bases: AttentionBackend
Attention backend that only caches KV without computing attention.
Source code in vllm/model_executor/models/extract_hidden_states.py
CacheOnlyAttentionImpl ¶
Bases: AttentionImpl
Attention implementation that only caches KV states.
Source code in vllm/model_executor/models/extract_hidden_states.py
CacheOnlyAttentionLayer ¶
Bases: Module, AttentionLayerBase
Attention layer that only caches key/value states without computing attention.
Source code in vllm/model_executor/models/extract_hidden_states.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
forward ¶
Cache hidden states as KV pairs without computing attention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_cache | Tensor | The tensor to insert into the kv cache. shape [num_tokens, num_heads, head_size] | required |
Returns:
| Type | Description |
|---|---|
Tensor | Dummy output tensor (not used) |
Source code in vllm/model_executor/models/extract_hidden_states.py
ExtractHiddenStatesModel ¶
Bases: Module
Source code in vllm/model_executor/models/extract_hidden_states.py
forward ¶
forward(hidden_states: Tensor) -> None
Process and cache hidden states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hidden_states | Tensor | Hidden states from target model shape: [num_tokens, num_hidden_states, hidden_size] | required |
Returns:
| Type | Description |
|---|---|
None | Tuple of (dummy_output, dummy_output) - both unused |
Source code in vllm/model_executor/models/extract_hidden_states.py
load_weights ¶
unified_kv_cache_update ¶
Returns a dummy that is passed to unified_attention to signal a side effect and the data dependency between them to ensure torch.compile preserves ordering.