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.
Classes:
-
CacheOnlyAttentionBackend–Attention backend that only caches KV without computing attention.
-
CacheOnlyAttentionImpl–Attention implementation that only caches KV states.
-
CacheOnlyAttentionLayer–Attention layer that only caches key/value states without computing attention.
-
ExtractHiddenStatesModel–
Functions:
-
unified_kv_cache_update–Returns a dummy that is passed to unified_attention to signal a side effect and
CacheOnlyAttentionBackend
¶
CacheOnlyAttentionImpl
¶
CacheOnlyAttentionLayer
¶
Bases: Module, AttentionLayerBase
Attention layer that only caches key/value states without computing attention.
Methods:
-
forward–Cache hidden states as KV pairs without computing attention.
ExtractHiddenStatesModel
¶
Bases: Module
Methods:
-
forward–Process and cache hidden states.
-
load_weights–No weights to load for this dummy model.
unified_kv_cache_update(to_cache, layer_name)
¶
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.