vllm.v1.attention.backends.mla.indexer ¶
DeepSeekV32IndexerDecodeMetadata dataclass
¶
Source code in vllm/v1/attention/backends/mla/indexer.py
DeepseekV32IndexerBackend ¶
Bases: AttentionBackend
Source code in vllm/v1/attention/backends/mla/indexer.py
get_builder_cls staticmethod
¶
get_builder_cls() -> type[
DeepseekV32IndexerMetadataBuilder
]
get_kv_cache_shape staticmethod
¶
get_kv_cache_shape(
num_blocks: int,
block_size: int,
num_kv_heads: int,
head_size: int,
cache_dtype_str: str = "auto",
) -> tuple[int, ...]
Source code in vllm/v1/attention/backends/mla/indexer.py
get_kv_cache_stride_order staticmethod
¶
get_metadata_cls staticmethod
¶
get_metadata_cls() -> type[AttentionMetadata]
DeepseekV32IndexerMetadata dataclass
¶
Source code in vllm/v1/attention/backends/mla/indexer.py
decode class-attribute
instance-attribute
¶
decode: Optional[DeepSeekV32IndexerDecodeMetadata] = None
prefill class-attribute
instance-attribute
¶
prefill: Optional[DeepseekV32IndexerPrefillMetadata] = None
__init__ ¶
__init__(
seq_lens: Tensor,
num_reqs: int,
max_query_len: int,
max_seq_len: int,
num_actual_tokens: int,
query_start_loc: Tensor,
slot_mapping: Tensor,
head_dim: int,
num_decodes: int,
num_decode_tokens: int,
num_prefills: int,
num_prefill_tokens: int,
decode: Optional[
DeepSeekV32IndexerDecodeMetadata
] = None,
prefill: Optional[
DeepseekV32IndexerPrefillMetadata
] = None,
) -> None
DeepseekV32IndexerMetadataBuilder ¶
Bases: AttentionMetadataBuilder
Source code in vllm/v1/attention/backends/mla/indexer.py
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 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 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
|
cudagraph_support class-attribute
¶
cudagraph_support: AttentionCGSupport = (
UNIFORM_SINGLE_TOKEN_DECODE
)
decode_lens_buffer instance-attribute
¶
decode_lens_buffer = empty(
(max_num_seqs,), dtype=int32, device=device
)
max_prefill_buffer_size instance-attribute
¶
max_prefill_buffer_size = get_max_prefill_buffer_size(
vllm_config
)
num_speculative_tokens instance-attribute
¶
scheduler_metadata_buffer instance-attribute
¶
scheduler_metadata_buffer = empty(
(num_sms + 1, 2), dtype=int32, device=device
)
__init__ ¶
Source code in vllm/v1/attention/backends/mla/indexer.py
build ¶
build(
common_prefix_len: int,
common_attn_metadata: CommonAttentionMetadata,
fast_build: bool = False,
) -> DeepseekV32IndexerMetadata
Source code in vllm/v1/attention/backends/mla/indexer.py
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 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
|
build_one_prefill_chunk ¶
Source code in vllm/v1/attention/backends/mla/indexer.py
DeepseekV32IndexerPrefillChunkMetadata dataclass
¶
Source code in vllm/v1/attention/backends/mla/indexer.py
DeepseekV32IndexerPrefillMetadata dataclass
¶
Source code in vllm/v1/attention/backends/mla/indexer.py
get_max_prefill_buffer_size ¶
get_max_prefill_buffer_size(vllm_config: VllmConfig)
Source code in vllm/v1/attention/backends/mla/indexer.py
kv_spans_from_batches ¶
kv_spans_from_batches(
start_seq_loc: Tensor,
seq_len_per_batch: Tensor,
device: device,
) -> tuple[Tensor, Tensor]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_seq_loc | Tensor | 1D long tensor [B+1], cumulative counts of selected tokens per batch. Example: [0, 2, 4, 7] -> batch sizes (selected) [2, 2, 3], N=7 tokens total. | required |
seq_len_per_batch | Tensor | 1D long tensor [B], full sequence length (KV length) of each batch. Example: [5, 9, 4]. | required |
Returns:
Name | Type | Description |
---|---|---|
start_tensor | Tensor | 1D long tensor [N], start offset in the concatenated KV cache for each token's batch. |
end_location | Tensor | 1D long tensor [N], exclusive end = start + token's local position. (So the attended KV slice is kv[start:end].) |
Assumes each batch contributes its full seq_len_per_batch[i]
keys to the KV cache, andthe selected tokens within a batch are the last counts[i]
positions of that sequence.
Source code in vllm/v1/attention/backends/mla/indexer.py
split_prefill_chunks ¶
split_prefill_chunks(
seq_lens_cpu: Tensor,
max_prefill_buffer_size: int,
reqs_start: int,
) -> list[tuple[int, int]]
Split the prefill chunks into a list of tuples of (reqs_start, reqs_end) such that the total sequence length of each chunk is less than the maximum prefill buffer size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seq_lens_cpu | Tensor | The sequence lengths of the prefill requests. | required |
max_prefill_buffer_size | int | The maximum prefill buffer size. | required |
reqs_start | int | The start index of the prefill requests. | required |
Returns:
Type | Description |
---|---|
list[tuple[int, int]] | A list of tuples of (reqs_start, reqs_end). |