| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | |
| 4 | import torch |
| 5 | |
| 6 | from vllm.model_executor.layers.attention.attention import Attention |
| 7 | from vllm.model_executor.layers.attention.chunked_local_attention import ( |
| 8 | ChunkedLocalAttention, |
| 9 | ) |
| 10 | from vllm.model_executor.layers.attention.cross_attention import CrossAttention |
| 11 | from vllm.model_executor.layers.attention.encoder_only_attention import ( |
| 12 | EncoderOnlyAttention, |
| 13 | ) |
| 14 | from vllm.model_executor.layers.attention.mla_attention import MLAAttention |
| 15 | from vllm.model_executor.layers.attention.mm_encoder_attention import MMEncoderAttention |
| 16 | from vllm.model_executor.layers.attention.prefill_prefix_lm_attention import ( |
| 17 | PrefillPrefixLMAttention, |
| 18 | ) |
| 19 | from vllm.model_executor.layers.attention.rswa_attention import RSWAAttention |
| 20 | from vllm.model_executor.layers.attention.static_sink_attention import ( |
| 21 | StaticSinkAttention, |
| 22 | ) |
| 23 | from vllm.model_executor.layers.attention_layer_base import AttentionLayerBase |
| 24 | |
| 25 | |
| 26 | def is_deferred_attention_layer(layer: torch.nn.Module) -> bool: |
| 27 | """Whether an attention-like layer requires deferred post-load processing.""" |
| 28 | return isinstance(layer, (AttentionLayerBase, MMEncoderAttention)) and callable( |
| 29 | getattr(layer, "process_weights_after_loading", None) |
| 30 | ) |
| 31 | |
| 32 | |
| 33 | __all__ = [ |
| 34 | "Attention", |
| 35 | "ChunkedLocalAttention", |
| 36 | "CrossAttention", |
| 37 | "EncoderOnlyAttention", |
| 38 | "MLAAttention", |
| 39 | "MMEncoderAttention", |
| 40 | "PrefillPrefixLMAttention", |
| 41 | "RSWAAttention", |
| 42 | "StaticSinkAttention", |
| 43 | "is_deferred_attention_layer", |
| 44 | ] |