vllm.v1.attention.backends.mamba_attn
Mamba2AttentionBackend ¶
Bases: AttentionBackend
Source code in vllm/v1/attention/backends/mamba_attn.py
Mamba2AttentionMetadata dataclass
¶
Source code in vllm/v1/attention/backends/mamba_attn.py
token_chunk_offset_ptr class-attribute
instance-attribute
¶
__init__ ¶
__init__(
num_prefills: int,
num_prefill_tokens: int,
num_decodes: int,
num_decode_tokens: int,
query_start_loc: Tensor,
seq_lens: Tensor,
has_initial_states: Tensor,
prep_initial_states: bool,
chunk_size: int,
seq_idx: Tensor,
chunk_indices: Tensor,
chunk_offsets: Tensor,
state_indices_tensor: Tensor,
nums_dict: Optional[dict] = None,
cu_seqlen: Optional[int] = None,
batch_ptr: Optional[tensor] = None,
token_chunk_offset_ptr: Optional[tensor] = None,
) -> None
Mamba2AttentionMetadataBuilder ¶
Bases: AttentionMetadataBuilder[Mamba2AttentionMetadata]
Source code in vllm/v1/attention/backends/mamba_attn.py
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 |
|
attn_cudagraph_support class-attribute
¶
attn_cudagraph_support: AttentionCGSupport = (
PURE_DECODE_ONLY
)
decode_cudagraph_max_bs instance-attribute
¶
decode_cudagraph_max_bs = min(
max_num_seqs, max_capture_size
)
state_indices_tensor instance-attribute
¶
state_indices_tensor = empty(
(decode_cudagraph_max_bs,), dtype=int32, device=device
)
__init__ ¶
__init__(
kv_cache_spec: AttentionSpec,
layer_names: list[str],
vllm_config: VllmConfig,
device: device,
)
Source code in vllm/v1/attention/backends/mamba_attn.py
build ¶
build(
common_prefix_len: int,
common_attn_metadata: CommonAttentionMetadata,
fast_build: bool = False,
) -> Mamba2AttentionMetadata
Source code in vllm/v1/attention/backends/mamba_attn.py
build_for_cudagraph_capture ¶
build_for_cudagraph_capture(
common_attn_metadata: CommonAttentionMetadata,
)
This method builds the metadata for full cudagraph capture. Currently, only decode is supported for full cudagraphs with Mamba.
Source code in vllm/v1/attention/backends/mamba_attn.py
can_run_in_cudagraph ¶
can_run_in_cudagraph(
common_attn_metadata: CommonAttentionMetadata,
) -> bool
_query_start_loc_to_chunk_indices_offsets ¶
_query_start_loc_to_chunk_indices_offsets(
query_start_loc: Tensor,
chunk_size: int,
total_seqlens: int,
)